Thanks Kareem, I contacted support.

Hi Kareem,

Thanks for your response.
I already found the callback you stated.

I want to do the following steps marked with -1-, -2-, -3-, - 

static int myCustomExtCallback(const word16* oid, word32 oidSz, int crit, const unsigned char* der, word32 derSz)
{
   -1- Check the OID matches my custom OID
   -2- Take the char* der and parse this with my custom defined ASN template into --> myParsedAsn
   -3- Loop over myParsedASN and apply our custom settings in the code.

}

Question: My question is how do I use the ASN_TEMPLATE code to execute step -2- above?
Note: The parsing at step 2 should be able to parse the ASN definition specified in my original post.

Regards Rob

p.s. 1: I searched for examples but WOLFSSL_ASN1_TEMPLATE is not mentioned.
https://github.com/search?q=repo%3Awolf … ;type=code
p.s. 2: I searched the code and only got two hits, but this did not provide a hint on how to use ASN1 parsing with a template.
https://github.com/search?q=repo%3Awolf … ;type=code
p.s. 3: asn1.h looks to contain the API interface I need, but not sure on how to use it with my ASN specification (in the original post) and nested sequences, and how to then parse the DER encoded char* der provided by the callback.
https://github.com/wolfSSL/wolfssl/blob … ssl/asn1.h

Goal:
We have a custom extension that contains some config settings DER encoded.
I would like to use wolfssl to parse this content in an ASN structure using the ASN templating available in wolfssl.

What I'm looking for:
how do I parse the ASN data received via the custom extension callback

What I found:
I found an example on how to add a custom extension callback.

I found some ASN template definitions but not sure how to combine these into valid code that can parse the below ASN.
https://github.com/wolfSSL/wolfssl/blob … /src/asn.c
I assume using a combination of these definitions  ASN_SEQUENCE, ASN_CONSTRUCTED, ASN_OCTET_STRING?

Question: Does an ASN templating and parsing example exist? I could not find it in the available examples.

ASN format i want to parse

TOTALCONFIG ::= SEQUENCE {
  version OCTET STRING (SIZE(4)),
  myconfigs SEQUENCE (SIZE(0..MAX)) OF single-config
}

single-config ::= SEQUENCE {
  config-id INTEGER(0..MAX),
  config-settings-a [0] SEQUENCE (SIZE(1...MAX)) OF OCTET STRING (SIZE(2..MAX)) OPTIONAL,
  config-settings-b [1] SEQUENCE (SIZE(1...MAX)) OF OCTET STRING (SIZE(2..MAX)) OPTIONAL,
  config-settings-c [2] SEQUENCE (SIZE(1...MAX)) OF OCTET STRING (SIZE(3)) OPTIONAL
}


other things I searched for
Of course I also used chatgpt but not sure if this code is valid

typedef struct {
    int myInteger;
    char myString[50]; // Adjust size as needed
} MyCustomData;

static const WOLFSSL_ASN1_TEMPLATE MyCustomTemplate[] = {
    { 0, 0, ASN1_INTEGER, offsetof(MyCustomData, myInteger), 0 },
    { 1, 0, ASN1_UTF8STRING, offsetof(MyCustomData, myString), sizeof(((MyCustomData*)0)->myString) },
    { 0, 0, 0, 0, 0 } // End of template
};