Hi all,
I have following piece of program, it just encrypts some data with
SEC_DerSignData, and then
decode it. It appears that function SEC_DerSignData succeeds, but
SEC_ASN1DecodeItem
always returns DER_BAD error code. What's wrong with my code? Please assume
that all
variables are initialized correctly.
Thank you very much!
----------------------------------------------------------------------------
-------------------------------------------------
SECItem dataDER;
char *data = "test data";
CERTSignedData signedData;
if (SEC_DerSignData(pArena, dataDER, (unsigned char *)data, strlen(data) +
1, pPrivateKey,
SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION) != SECSuccess)
printf("DerSignData error");
PORT_Memset(&signedData, 0, sizeof(signedData));
if (SEC_ASN1DecodeItem(pArena, &signedData,
SEC_ASN1_GET(CERT_SignedDataTemplate), &dataDER) != SECSuccess)
printf("DecodeItem error");