vlm / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
1.04k stars 558 forks source link

Failed X.509 example #47

Open DesmondHayes opened 10 years ago

DesmondHayes commented 10 years ago

Tried examples/sample.source.PKIX1, but failed. Compiled just fine with usual 'make'. Then tried to use 'x509dump' executable with 'sample-Certificate-1.der' as argument, which gave me an error 'sample-Certificate-1.der: Decode failed past byte 4: Input processing error'. Also tried other certificates, self-signed and real (from the cache of Firefox). Examples from 'http://csrc.nist.gov/groups/ST/crypto_apps_infra/documents/pkixtools/' worked OK. 'Microsoft Internet Authority' certificate from the cache of Firefox forked wine, but several others failed. Self-signed certificates generated with OpenSSL and with IIS7 failed.

cberge commented 9 years ago

Hi, I got the same error... running x509dump with -dd option I discovered it stopped while analyzing serialNumber of the certificate: 0x020000000001454393fb2718779f serialNumber is coded as an Integer (that is OK) but asn1c seem to store and manage native Integer as long values... not sufficient to store 0x020000000001454393fb2718779f So it exit about line 114 in nativeInteger.c just comment the following and the certificate is parsed (But integer values ar bad!!!!)

    if((specs&&specs->field_unsigned)
        ? asn_INTEGER2ulong(&tmp, (unsigned long *)&l) 
        : asn_INTEGER2long(&tmp, &l)) {
        rval.code = RC_FAIL;
        rval.consumed = 0;
        return rval;
    }

Any idea how to solve this? Do you think it's possible to use integer.c instead of nativeInteger.?

daa commented 8 years ago

adding -fwide-types to asn1c command solves this problem for me