1

Is it possible to detect S/MIME content types (enveloped or signed) using OpenSSL CMS API? I would prefer to avoid pre-parsing S/MIME headers and let OpenSSL to detect whether message is signed or encrypted.

I'm looking for a method that would extract smime-type from CMS_ContentInfo.

1 Answers1

1

After formulating a question, I've noticed solution myself. In case this might be useful for someone else:

CMS_get0_type - converts CMS_ContentInfo into ASN1_object pointer

OBJ_obj2nid - gets one of the following NID values from ASN1_object pointer:

NID_pkcs7_data

NID_pkcs7_signed

NID_pkcs7_digest

NID_id_smime_ct_compressedData:

NID_pkcs7_encrypted

NID_pkcs7_enveloped

For details see: http://wiki.openssl.org/index.php/Manual:CMS_get0_type(3)