Topic: Decoding ASN1

I would like to decode ASN1 from a binary encoded file (not a certificate) using wolfCrypt to do the heavy lifting for me. Based off of this post - https://www.wolfssl.com/better-asn-1-su … templates/ - it sounds like this can be done using templates.

Using an X509 cert as the example, it seems like this involves creating an array of type "ASNItem" ("x509CertASN" in asn.c) and using functions such as GetASN_Items()/GetASN_OID(). The issue is these functions are local for internal ASN processing.

Looking into asn_public.h, there are structs for "Asn1Item" and "Asn1" but no obvious functions to handle decoding. My best guess is that the wc_Asn1_PrintAll()/wc_Asn1_Print() functions could be used in some way as they facilitate parsing and save results in an "Asn1" object.

Is there a way to specify a template for how the ASN1 should look and have wolfCrypt parse it? Or parse the data and save it into an object so it could be compared after?

Thanks

Share

Re: Decoding ASN1

Hi confused_squirrel,

Thanks for your interest in wolfSSL.  You are on the right track with our getter functions such as GetASN_Items and GetASN_OID, these are the functions we use to parse ASN and the functions you should call for this case.  These are internal static functions, we do not have a public interface for this.  You will need to find a way to call static wolfSSL functions from your application, or patch our source to make these functions non static.
We don't currently have a complete example on how to use these functions as again, they are internal functions.

Are you willing to share some information about your project?  Are you working on a commercial or personal project?  You are welcome to email us at support [AT] wolfssl [DOT] com if this information is confidential.

Thanks,
Kareem

Share