Hello All, I
used following C code to sign the data and encode in DER format. But
JAVA Crypto code is failed to parse the DER encoded PKCS#7 data. Following is
the “C” code to sign the data. Is
there any problem in my code? The
certificate I used is self signed certificate. Char*
PKI_Sign (char* inputData, char* pcCertName) { int
flags = PKCS7_DETACHED | PKCS7_NOCERTS; X509
*pSignerCert = NULL; EVP_PKEY
*pkey = NULL; BIO
*InputData = NULL; Char
TempAuthData[2048]; pSignerCert
= GetCertifcateByCertName (pcCertName); if(!pSignerCert) { g_pkiReasonCode
= CMS_NO_CERTIFICATE; return
0; } /*
It searches key store and gets private key by its filename.*/ pkey
= GetRSAPrivateKeyByCertName(pcCertName); if(!pkey) { g_pkiReasonCode
= CMS_NO_CERTIFICATE; return
0; } InputData
= BIO_new_file(tempFilename, "r"); EVP_add_digest
(EVP_sha1 ()); EVP_add_digest_alias
(SN_sha1,"ssl3-sha1"); EVP_add_digest_alias
(SN_sha1WithRSAEncryption, SN_sha1WithRSA); EVP_add_digest
(EVP_dss1 ()); EVP_add_digest_alias
(SN_dsaWithSHA1, SN_dsaWithSHA1_2); EVP_add_digest_alias
(SN_dsaWithSHA1,"DSS1"); EVP_add_digest_alias
(SN_dsaWithSHA1,"dss1"); pkcs7
= PKCS7_sign (pSignerCert, pkey, NULL, InputData, flags); usDataLength
= ASN1_item_i2d(pkcs7, &TempAuthData,ASN1_ITEM_rptr(PKCS7)); return
TempAuthData; } Thanks in advance…… Madhu ##################################################################### This Email Message is for the sole use of the intended recipient(s) and May contain CONFIDENTIAL and PRIVILEGED information. LG Soft India will not be responisible for any viruses or defects or any forwarded attachements emanating either from within LG Soft India or outside. Any unauthorised review , use, disclosure or distribution is prohibited. If you are not intentded recipient, please contact the sender by reply email and destroy all copies of the original message. ##################################################################### |
- Any problem with this "C" code Madhu Sudhan Reddy
- Re: Any problem with this "C" code Dr. Stephen Henson