Discussion:
Extracting RecipientInfos/DER from S/MIME message
Benjamin Amling
2010-04-14 10:01:57 UTC
Permalink
Hello,

is it possible to extract the DER blob from the RecipientInfos-part of a
S/MIME message? I tried the following steps already but couldn't manage
to get what I want:

*********************************************************************
BIO *bin = BIO_new(BIO_s_mem());
BIO_write(bin, mimeMessage.c_str(), mimeMessage.size()); // no errors

CMS_ContentInfo *cms = SMIME_read_CMS(bin, NULL); // no errors

STACK_OF(CMS_RecipientInfo) * ris = CMS_get0_RecipientInfos(cms); // no
errors

CMS_RecipientInfo *ri;
for (int i = 0; i < sk_CMS_RecipientInfo_num(ris); ++i) {
ri = sk_CMS_RecipientInfo_value(ris, i);
// sk_CMS_RecipientInfo_num(ris) returns 1, so it shouldn't be empty
// CMS_RecipientInfo_type(ri) returns 0
}
**********************************************************************

This is as far as I got. I have no idea on how to proceed and what I can
do with the CMS_RecipientInfos I managed to extract so far.

I'm still quite new to using the OpenSSL API in C/C++ so I'd appreciate
any kind of help. :-)


Thanks in advance!

Benjamin


______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Dr. Stephen Henson
2010-04-14 11:23:43 UTC
Permalink
Post by Benjamin Amling
Hello,
is it possible to extract the DER blob from the RecipientInfos-part of a
S/MIME message? I tried the following steps already but couldn't manage
*********************************************************************
BIO *bin = BIO_new(BIO_s_mem());
BIO_write(bin, mimeMessage.c_str(), mimeMessage.size()); // no errors
CMS_ContentInfo *cms = SMIME_read_CMS(bin, NULL); // no errors
STACK_OF(CMS_RecipientInfo) * ris = CMS_get0_RecipientInfos(cms); // no
errors
CMS_RecipientInfo *ri;
for (int i = 0; i < sk_CMS_RecipientInfo_num(ris); ++i) {
ri = sk_CMS_RecipientInfo_value(ris, i);
// sk_CMS_RecipientInfo_num(ris) returns 1, so it shouldn't be empty
// CMS_RecipientInfo_type(ri) returns 0
}
**********************************************************************
This is as far as I got. I have no idea on how to proceed and what I can
do with the CMS_RecipientInfos I managed to extract so far.
I'm still quite new to using the OpenSSL API in C/C++ so I'd appreciate
any kind of help. :-)
The return value of CMS_RecipientInfo_type() is a constant indictaing tha type
and will almost always be CMS_RECIPINFO_TRANS (see cms.h). Once you have the
type you can use the appropriate function to retrieve its contents. For example
CMS_RecipientInfo_ktri_get0_signer_id().

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Loading...