How can I extract a signature from a pkcs7 envelope?

I want to extract the signature from the pkcs7 envelope. How can i do this?

+1
source share
1 answer

Use STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7) to extract the individual SignerInfos contained in your PKCS7. To get a real signature from a separate SignerInfo, you will need 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 (slightly misleading) enc_digest .

+2
source

Source: https://habr.com/ru/post/1216074/


All Articles