title: Does the OpenSSL ASN.1 API support extensible types?
body: <p>I'm trying to use the OpenSSL ASN.1 API to implement my own custom types.  I expect to extend these types in the future, and the ASN.1 standard itself supports this via the concept of extensible types (see <a href="http://lionet.info/asn1c/blog/2010/09/21/question-extensibility-removing-fields/" rel="nofollow noreferrer">here</a> for an overview of what I want).  However, I can't figure out if the OpenSSL ASN.1 API supports this concept and if so how to implement it.  I've got the following structures defined using the macros supplied by OpenSSL:</p>
  
  <pre><code>typedef struct _TEST_STRUCT_V1 {
      ASN1_INTEGER* Field1;
  } TEST_STRUCT_V1;
  
  typedef struct _TEST_STRUCT_V2 {
      ASN1_INTEGER* Field1;
      ASN1_INTEGER* Field2;
  } TEST_STRUCT_V2;
  
  ASN1_SEQUENCE(TEST_STRUCT_V1) = {
      ASN1_SIMPLE(TEST_STRUCT_V1, Field1, ASN1_INTEGER),
  } ASN1_SEQUENCE_END(TEST_STRUCT_V1);
  
  IMPLEMENT_ASN1_FUNCTIONS(TEST_STRUCT_V1);
  
  ASN1_SEQUENCE(TEST_STRUCT_V2) = {
      ASN1_SIMPLE(TEST_STRUCT_V2, Field1, ASN1_INTEGER),
      ASN1_SIMPLE(TEST_STRUCT_V2, Field2, ASN1_INTEGER),
  } ASN1_SEQUENCE_END(TEST_STRUCT_V2);
  
  IMPLEMENT_ASN1_FUNCTIONS(TEST_STRUCT_V2);
  </code></pre>
  
  <p>These macros generate encoding and decoding functions.  However, neither pair of functions works with the other version of the struct.</p>
  
  <p>Perhaps I'm barking up the wrong tree?  I'm only trying to use OpenSSL's implementation of ASN.1 since I'm already using the library for crypto, but maybe a proper ASN.1 compiler would be the way to go?</p>