Hi, Thanks for the all the help.
I see the same error when I am trying to create a x509 certificate using the DSA parameters g, p, q and public key y. These parameters are generated by the GetPublicKey API in C#. All the above parameters are BYTE arrays. Find the DSA parameters attached. ...... // BN_bin2bn((const unsigned char *)uLicenseCheckG, sizeof(uLicenseCheckG), dsaParams->g); BN_bin2bn((const unsigned char *)uLicenseCheckP, sizeof(uLicenseCheckP), dsaParams->p); BN_bin2bn((const unsigned char *)uLicenseCheckQ, sizeof(uLicenseCheckQ), dsaParams->q); BN_bin2bn((const unsigned char *)uLicenseCheckY, sizeof(uLicenseCheckY), dsaParams->pub_key); unsigned char *buff; int nLength; nLength = i2d_DSA_PUBKEY(dsaParams, &buff); X509 *x509Cert = X509_new(); const unsigned char *p; p = buff; x509Cert = d2i_X509(NULL, &p, nLength); // Problem occurs here, x509Cert is NULL and the error is the same as before <-- STACK_OF(X509) *st=sk_X509_new_null(); // I want to use this stack of x509 in CMS_verify sk_X509_push(st, x509Cert); -Ujwal From: Ujwal Chinthala Sent: Wednesday, January 20, 2010 1:39 PM To: 'st...@openssl.org' Cc: 'openssl-users@openssl.org' Subject: Re: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag Hi Dr, I already tried using : openssl pkcs7 -inform DER -in pkcs7.p7 It gives me the same error, which are as follows net\chint...@symdev1:~/Symphony/Dev/system/dl/sym-licensemanager$ openssl pkcs7 -inform DER -in pkcs7.p7 unable to load PKCS7 object 11381:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1306: 11381:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:380:Type=PKCS7_ISSUER_AND_SERIAL 11381:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:749:Field=issuer_and_serial, Type=PKCS7_SIGNER_INFO 11381:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:710:Field=signer_info, Type=PKCS7_SIGNED 11381:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:749: 11381:error:0D08403A:asn1 encoding routines:ASN1_TEMPLATE_EX_D2I:nested asn1 error:tasn_dec.c:578:Field=d.sign, Type=PKCS7 Please find the binary file you requested attached. Thanks, -Ujwal From: Ujwal Chinthala Sent: Tuesday, January 19, 2010 4:41 PM To: 'openssl-users@openssl.org' Subject: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag Hi, I am new to OpenSSL. I am trying to verify the compressed XML data, signed using PKCS#7. Then a four byte crc is appended to it and the whole data is now base64 encoded. All the above is done using windows libraries. The verification works fine in windows. Now I am trying to verify the above data(signed using windows libs) using OpenSSL. The data is decoded from base64 to bytes, crc is verified. Then I try to use the command d2i_pkcs7 to create the PKCS7 structure which results in the following error , error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag. The code I am using to do this is as follows: const unsigned char *q; q = (const unsigned char*)nBytes; PKCS7 *p7 = NULL; // I want to use this p7 structure in PKCS7_verify p7 = d2i_PKCS7(NULL, &q, nCountOfBytes);// error occurs here where nBytes is a BYTE array storing the data. I don't have a clue what this error means, am I missing something here? -Ujwal
const BYTE uLicenseCheckG[] = {0x18, 0x12, 0x67, 0x75, 0x17, 0x25, 0x6A, 0x8F, 0x99, 0x2E, 0x89, 0x98, 0x09, 0x58, 0x0B, 0x9F, 0x1C, 0xE1, 0xAB, 0x80, 0x27, 0xDD, 0xAF, 0x62, 0x3C, 0xD8, 0x51, 0x11, 0xC2, 0x9B, 0x3F, 0x05, 0x29, 0x9D, 0x8F, 0x71, 0x47, 0xEC, 0x89, 0xBB, 0xBD, 0x21, 0x01, 0x96, 0xF2, 0x91, 0x7A, 0x77, 0x65, 0x53, 0x8B, 0x0E, 0x8A, 0x59, 0x92, 0x5B, 0x46, 0x7F, 0x20, 0x52, 0xC3, 0x10, 0x3A, 0xEC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