0

I not found documentation on the page of openssl about how to work with ASN1_ENUMERATED.

Using BERViewer to visualize the structure:
enter image description here

So I used:

ASN1_SEQUENCE_ANY *asn1SequenceAny = sk_ASN1_TYPE_new_null();
asn1SequenceAny = d2i_ASN1_SEQUENCE_ANY(&asn1SequenceAny, (const unsigned char**)&data,len);

ASN1_TYPE *asn1Type = NULL;
asn1Type = sk_ASN1_TYPE_pop(asn1SequenceAny);
if(asn1Type->type == V_ASN1_ENUMERATED)
{
    asn1Type->value.enumerated->data; // How to get sequence inside [0] ?
}

Enumerated data on the disk "asn1Type->value.enumerated->data" looks like:
enter image description here

How to get the ASN1_SEQUENCE_ANY from [0]:

SEQUENCE
     |__SEQUENCE
     |__SEQUENCE

I tried: ASN1_ENUMERATED_get, return -1. Why not zero?

Articles are very welcome.

Cobaia
  • 1,503
  • 3
  • 22
  • 41

1 Answers1

0

OpenSSL provides a number of functions to decode these messages. You have to know what was the corresponding function that encoded it was, because the decode routines also parse the output to make sure the decoded message matches the expected type implied by the decode method you called. You seem to want:

d2i_ASN1_OBJECT (3ssl) - ASN1 OBJECT IDENTIFIER functions

But if that is not right, you can search the OpenSSL documentation for d2i, you will find many functions to try.

If you download the OpenSSL source code, after unpacking it, look inside the apps subdirectory, and read through the asn1pars.c file. Or, you can follow this link to view it online. Hope this helps!

jxh
  • 69,070
  • 8
  • 110
  • 193