Reputation: 8529
I want to extract signature from pkcs7 envelop. How can i do it ?
Upvotes: 2
Views: 2224
Reputation: 39620
Use STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7)
to retrieve the individual SignerInfos contained in your PKCS7.
To get the actual signature from an individual SignerInfo, you will have to access the corresponding pointer manually. PKCS7_SIGNER_INFO is defined as:
typedef struct pkcs7_signer_info_st
{
ASN1_INTEGER *version; /* version 1 */
PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
X509_ALGOR *digest_alg;
STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */
X509_ALGOR *digest_enc_alg;
ASN1_OCTET_STRING *enc_digest;
STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */
/* The private key to sign with */
EVP_PKEY *pkey;
} PKCS7_SIGNER_INFO;
The correct field is (slightly misleading) enc_digest
.
Upvotes: 4