Print the message digest algorithm from the signer info structure

This commit is contained in:
olszomal 2021-01-07 14:10:23 +01:00 committed by Michał Trojnara
parent 67e4edfe45
commit 6edd56bfac

View File

@ -208,6 +208,7 @@ typedef unsigned char u_char;
typedef struct SIGNATURE_st { typedef struct SIGNATURE_st {
PKCS7 *p7; PKCS7 *p7;
int md_nid;
ASN1_STRING *digest; ASN1_STRING *digest;
time_t signtime; time_t signtime;
char *url; char *url;
@ -2230,6 +2231,8 @@ static int print_attributes(SIGNATURE *signature, int verbose)
return 0; /* FAILED */ return 0; /* FAILED */
printf("\nAuthenticated attributes:\n"); printf("\nAuthenticated attributes:\n");
printf("\tMessage digest algorithm: %s\n",
(signature->md_nid == NID_undef) ? "UNKNOWN" : OBJ_nid2sn(signature->md_nid));
mdbuf = (unsigned char *)ASN1_STRING_get0_data(signature->digest); mdbuf = (unsigned char *)ASN1_STRING_get0_data(signature->digest);
len = ASN1_STRING_length(signature->digest); len = ASN1_STRING_length(signature->digest);
tohex(mdbuf, hexbuf, len); tohex(mdbuf, hexbuf, len);
@ -2429,6 +2432,7 @@ static int append_signature_list(STACK_OF(SIGNATURE) **signatures, PKCS7 *p7, in
signature = OPENSSL_malloc(sizeof(SIGNATURE)); signature = OPENSSL_malloc(sizeof(SIGNATURE));
signature->p7 = p7; signature->p7 = p7;
signature->md_nid = OBJ_obj2nid(si->digest_alg->algorithm);
signature->digest = NULL; signature->digest = NULL;
signature->signtime = INVALID_TIME; signature->signtime = INVALID_TIME;
signature->url = NULL; signature->url = NULL;