CMS sign digest

CLI changes: New parameter -digest to CLI command openssl cms, to
provide pre-computed digest for use with -sign.

API changes: New function CMS_final_digest(), like CMS_final() but
uses a pre-computed digest instead of computing it from the data.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/15348)
This commit is contained in:
Viktor Söderqvist 2021-04-28 10:54:57 +02:00 committed by Todd Short
parent e4cdcb8bc4
commit 07342bad1b
14 changed files with 191 additions and 30 deletions

View file

@ -207,6 +207,13 @@ err:
/* unfortunately cannot constify SMIME_write_ASN1() due to this function */
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio)
{
return ossl_cms_DataFinal(cms, cmsbio, NULL, 0);
}
int ossl_cms_DataFinal(CMS_ContentInfo *cms, BIO *cmsbio,
const unsigned char *precomp_md,
unsigned int precomp_mdlen)
{
ASN1_OCTET_STRING **pos = CMS_get0_content(cms);
@ -245,7 +252,7 @@ int CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio)
return ossl_cms_AuthEnvelopedData_final(cms, cmsbio);
case NID_pkcs7_signed:
return ossl_cms_SignedData_final(cms, cmsbio);
return ossl_cms_SignedData_final(cms, cmsbio, precomp_md, precomp_mdlen);
case NID_pkcs7_digest:
return ossl_cms_DigestedData_do_final(cms, cmsbio, 0);