@@ -2167,3 +2167,148 @@ int wc_SetUnknownExtCallback(DecodedCert* cert,
21672167int wc_CheckCertSigPubKey (const byte * cert , word32 certSz ,
21682168 void * heap , const byte * pubKey ,
21692169 word32 pubKeySz , int pubKeyOID );
2170+
2171+ /*!
2172+ \ingroup ASN
2173+
2174+ \brief This function initializes the ASN.1 print options.
2175+
2176+ \return 0 on success.
2177+ \return BAD_FUNC_ARG when asn1 is NULL.
2178+
2179+ \param opts The ASN.1 options for printing.
2180+
2181+ _Example_
2182+ \code
2183+ Asn1PrintOptions opt;
2184+
2185+ // Initialize ASN.1 print options before use.
2186+ wc_Asn1PrintOptions_Init(&opt);
2187+ \endcode
2188+
2189+ \sa wc_Asn1PrintOptions_Set
2190+ \sa wc_Asn1_PrintAll
2191+ */
2192+ int wc_Asn1PrintOptions_Init (Asn1PrintOptions * opts );
2193+
2194+ /*!
2195+ \ingroup ASN
2196+
2197+ \brief This function sets a print option into an ASN.1 print options object.
2198+
2199+ \return 0 on success.
2200+ \return BAD_FUNC_ARG when asn1 is NULL.
2201+ \return BAD_FUNC_ARG when val is out of range for option.
2202+
2203+ \param opts The ASN.1 options for printing.
2204+ \param opt An option to set value for.
2205+ \param val The value to set.
2206+
2207+ _Example_
2208+ \code
2209+ Asn1PrintOptions opt;
2210+
2211+ // Initialize ASN.1 print options before use.
2212+ wc_Asn1PrintOptions_Init(&opt);
2213+ // Set the number of indents when printing tag name to be 1.
2214+ wc_Asn1PrintOptions_Set(&opt, ASN1_PRINT_OPT_INDENT, 1);
2215+ \endcode
2216+
2217+ \sa wc_Asn1PrintOptions_Init
2218+ \sa wc_Asn1_PrintAll
2219+ */
2220+ int wc_Asn1PrintOptions_Set (Asn1PrintOptions * opts , enum Asn1PrintOpt opt ,
2221+ word32 val );
2222+
2223+ /*!
2224+ \ingroup ASN
2225+
2226+ \brief This function initializes an ASN.1 parsing object.
2227+
2228+ \return 0 on success.
2229+ \return BAD_FUNC_ARG when asn1 is NULL.
2230+
2231+ \param asn1 ASN.1 parse object.
2232+
2233+ _Example_
2234+ \code
2235+ Asn1 asn1;
2236+
2237+ // Initialize ASN.1 parse object before use.
2238+ wc_Asn1_Init(&asn1);
2239+ \endcode
2240+
2241+ \sa wc_Asn1_SetFile
2242+ \sa wc_Asn1_PrintAll
2243+ */
2244+ int wc_Asn1_Init (Asn1 * asn1 );
2245+
2246+ /*!
2247+ \ingroup ASN
2248+
2249+ \brief This function sets the file to use when printing into an ASN.1
2250+ parsing object.
2251+
2252+ \return 0 on success.
2253+ \return BAD_FUNC_ARG when asn1 is NULL.
2254+ \return BAD_FUNC_ARG when file is XBADFILE.
2255+
2256+ \param asn1 The ASN.1 parse object.
2257+ \param file File to print to.
2258+
2259+ _Example_
2260+ \code
2261+ Asn1 asn1;
2262+
2263+ // Initialize ASN.1 parse object before use.
2264+ wc_Asn1_Init(&asn1);
2265+ // Set standard out to be the file descriptor to write to.
2266+ wc_Asn1_SetFile(&asn1, stdout);
2267+ \endcode
2268+
2269+ \sa wc_Asn1_Init
2270+ \sa wc_Asn1_PrintAll
2271+ */
2272+ int wc_Asn1_SetFile (Asn1 * asn1 , XFILE file );
2273+
2274+ /*!
2275+ \ingroup ASN
2276+
2277+ \brief Print all ASN.1 items.
2278+
2279+ \return 0 on success.
2280+ \return BAD_FUNC_ARG when asn1 or opts is NULL.
2281+ \return ASN_LEN_E when ASN.1 item's length too long.
2282+ \return ASN_DEPTH_E when end offset invalid.
2283+ \return ASN_PARSE_E when not all of an ASN.1 item parsed.
2284+
2285+ \param asn1 The ASN.1 parse object.
2286+ \param opts The ASN.1 print options.
2287+ \param data Buffer containing BER/DER data to print.
2288+ \param len Length of data to print in bytes.
2289+
2290+ \code
2291+ Asn1PrintOptions opts;
2292+ Asn1 asn1;
2293+ unsigned char data[] = { Initialize with DER/BER data };
2294+ word32 len = sizeof(data);
2295+
2296+ // Initialize ASN.1 print options before use.
2297+ wc_Asn1PrintOptions_Init(&opt);
2298+ // Set the number of indents when printing tag name to be 1.
2299+ wc_Asn1PrintOptions_Set(&opt, ASN1_PRINT_OPT_INDENT, 1);
2300+
2301+ // Initialize ASN.1 parse object before use.
2302+ wc_Asn1_Init(&asn1);
2303+ // Set standard out to be the file descriptor to write to.
2304+ wc_Asn1_SetFile(&asn1, stdout);
2305+ // Print all ASN.1 items in buffer with the specified print options.
2306+ wc_Asn1_PrintAll(&asn1, &opts, data, len);
2307+ \endcode
2308+
2309+ \sa wc_Asn1_Init
2310+ \sa wc_Asn1_SetFile
2311+ */
2312+ int wc_Asn1_PrintAll (Asn1 * asn1 , Asn1PrintOptions * opts , unsigned char * data ,
2313+ word32 len );
2314+
0 commit comments