Dear all,
I have an encrypted char *, to be decrypted using the private key read from
the PKCS12 protection file (which is done!!). Now the problem lies into the
BIO_s_mem and BIO_s_file (the encrypted char * is Base64 encoded)
I have run the two tests:
1. Store the char * into a file called "temp.tmp", and write the following
code:
/************* START ******************/
b64 = BIO_new(BIO_f_base64());
bio2 = BIO_new_file("temp.tmp", "rb");
bio2 = BIO_push(b64, bio2);
if ((inlen2 = BIO_read(bio2, ecryptedData, 128)) <= 0) {
printf("error 1<<<<<<<<");
exit(-1);
}
encryptedData[128] = '\0';
// decryption with the private key
if (EVP_PKEY_decrypt(decryptedData, encryptedData, 128, privKey) == -1) {
printf("error 2<<<<<<<<");
exit(-1);
}
/************ END *****************/
IT WORKS FINE!
2. Then I test the following code, by reading in the char * directly into a
BIO_s_mem:
/************* START ******************/
b64 = BIO_new(BIO_f_base64());
bio2 = BIO_new(BIO_s_mem());
BIO_write(bio2, data, 128);
bio2 = BIO_push(b64, bio2);
if ((inlen2 = BIO_read(b64, encryptedData, 128)) <= 0) {
printf("error 1<<<<<<<<<<<<");
exit(-1);
}
encryptedData[128] = '\0';
// decryption with the private key
if (EVP_PKEY_decrypt(decryptedData, encryptedData, 128, privKey) == -1) {
printf("error 2<<<<<<<<");
exit(-1);
}
/************ END *****************/
THE MESSAGE "error 2<<<<<<<<<" is printed.
What is the difference (of course there must be a difference, but I wish you
could help me)? Is there something wrong with the code 2? When I printed out
the encryptedData array as a string (printf("%s\n", encryptedData)), they
look the same. Please help. Thousand thanks.
Best regards,
--------------------------------------------
Jordan Cheun Ngen, Chong
INF-4067 Universiteit Twente
Postbus 217
7500 AE Enschede
The Netherlands
Distributed and Embedded Systems (DIES)
--------------------------------------------
Office Phone: +31 53 4894655
Web site: http://www.cs.utwente.nl/~chong
Email Add.: [EMAIL PROTECTED]
============================================
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]