OK, found it on my own.

I was in need of automatic type checking of the built in multistring types at 
parsing
time, i.e. when doing d2i_X509_TEMPLATE_TYPE(...) an templates for new 
structures.

Just in case someone might be interested, i found a solution that works for me.

With some digging the code, i found the template type missing for ASN1 
multistring types,
namely ASN1_PRINTABLE, DISPLAYTEXT and DIRECTORYSTRING.

I thing that can be obtained by adding:

#define DEFINE_ASN1_ITEM_TEMPLATE(tname) \
        ASN1_ITEM_TEMPLATE(tname##) = ASN1_EX_TEMPLATE_TYPE(0, 0, tname##, 
tname##)

DEFINE_ASN1_ITEM_TEMPLATE(DIRECTORYSTRING);
DEFINE_ASN1_ITEM_TEMPLATE(ASN1_PRINTABLE);
DEFINE_ASN1_ITEM_TEMPLATE(DISPLAYTEXT);

in my c source. So the correct types are being checked at parsing time.
The underlying types are all of ASN1_STRING. For use within the program, i 
added:

typedef ASN1_STRING DIRECTORYSTRING;
typedef ASN1_STRING ASN1_PRINTABLE;
typedef ASN1_STRING DISPLAYTEXT;

in the headerfile. Together with the mentioned patch, concerning template 
parsing,
functionality is a good bit enhaced.

Maybe some OM could review these little changes whether they are ok or should 
be revised.
If the former, i would appreciate to see them in the mainstream.

Christian Weber wrote on 10.03.2011 at 18:40:
...
--- C:/wrk/openssl-1.0.0d/crypto/asn1/tasn_dec.c Tue Jun 15 18:25:06 2010 +++ S:/Build/SAK-2.1/openssl-1.0.0d/crypto/asn1/tasn_dec.c Thu Mar 10 01:26:40 2011
@@ -188,6 +188,8 @@
              */
             if ((tag != -1) || opt)
                 {
+                /* If OPTIONAL, assume this is OK Patch 5.2.2010 ChWe */
+                if (opt) return -1;
                 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I,
                 ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE);
                 goto err;
We wonder if this critical in any aspect? With the patch the lib still seems to work for us.

TIA
--
Christian Weber
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to