Hello,
we created a couple of S/MIME messages using the PKCS7-functionalities
(PKCS7_encrypt, etc..). Everything seems to be working just fine right
now and we can decrypt the message using the private key. However, now
we're trying to decrypt the message using the symmetric key so we don't
have to pass around the private key anymore...
Since we used the AES256 cipher to encrypt the S/MIME message I figured
I'd try to extract the content from the S/MIME message and try to
AES256-decrypt it with the symmetric key.
This is a small part of the code we're using but it should be enough to
show you what exactly we're doing now:
BIO *bin = new BIO_new(BIO_s_mem());
BIO *bout = new BIO_new(BIO_s_mem());
BIO_set_mem_eof_return(bin, 0);
CMS_ContentInfo *cms = SMIME_read_CMS(bin, NULL);
if (!cms) {
...
}
ASN1_OCTET_STRING *content = *CMS_get0_content(cms);
if (!content) {
...
}
i2d_ASN1_bio_stream(bout, (ASN1_VALUE*) content, NULL, 0,
ASN1_ITEM_rptr(ASN1_OCTET_STRING));
char *r;
long len = BIO_get_mem_data(bout, &r);
std::string s(r, len);
Then I try to decrypt the string s with with symmetric key we have,
however each time we try this we get the following error-message:
"wrong final block length"
When I use the asn1parser on the "content" the output starts with
0:d=0 hl=4 l=6096 prim: OCTET STRING [HEX DUMP]: ....
I'm not quite sure what I'm doing wrong (probably alot though since I'm
still quite new to this), but the whole HEX DUMP-part alone seems kind
of strange to me. Could you possibly guide me into the right direction?
I'd really appreciate it!
If you need any other information, let me know.
Thanks in advance.
Best regards
B.A.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]