summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/cms/cms_sd.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/src/lib/libcrypto/cms/cms_sd.c b/src/lib/libcrypto/cms/cms_sd.c
index f79d740482..3f454435de 100644
--- a/src/lib/libcrypto/cms/cms_sd.c
+++ b/src/lib/libcrypto/cms/cms_sd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_sd.c,v 1.34 2025/05/10 05:54:38 tb Exp $ */ 1/* $OpenBSD: cms_sd.c,v 1.35 2025/07/27 07:16:20 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -484,35 +484,6 @@ CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, EVP_PKEY *pk,
484} 484}
485LCRYPTO_ALIAS(CMS_add1_signer); 485LCRYPTO_ALIAS(CMS_add1_signer);
486 486
487static int
488cms_add1_signingTime(CMS_SignerInfo *si, ASN1_TIME *t)
489{
490 ASN1_TIME *tt;
491 int r = 0;
492
493 if (t)
494 tt = t;
495 else
496 tt = X509_gmtime_adj(NULL, 0);
497
498 if (!tt)
499 goto merr;
500
501 if (CMS_signed_add1_attr_by_NID(si, NID_pkcs9_signingTime,
502 tt->type, tt, -1) <= 0)
503 goto merr;
504
505 r = 1;
506
507 merr:
508 if (!t)
509 ASN1_TIME_free(tt);
510 if (!r)
511 CMSerror(ERR_R_MALLOC_FAILURE);
512
513 return r;
514}
515
516EVP_PKEY_CTX * 487EVP_PKEY_CTX *
517CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si) 488CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si)
518{ 489{
@@ -778,6 +749,7 @@ cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain)
778int 749int
779CMS_SignerInfo_sign(CMS_SignerInfo *si) 750CMS_SignerInfo_sign(CMS_SignerInfo *si)
780{ 751{
752 ASN1_TIME *at = NULL;
781 const EVP_MD *md; 753 const EVP_MD *md;
782 unsigned char *buf = NULL, *sig = NULL; 754 unsigned char *buf = NULL, *sig = NULL;
783 int buf_len = 0; 755 int buf_len = 0;
@@ -788,7 +760,12 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si)
788 goto err; 760 goto err;
789 761
790 if (CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1) < 0) { 762 if (CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1) < 0) {
791 if (!cms_add1_signingTime(si, NULL)) 763 if ((at = X509_gmtime_adj(NULL, 0)) == NULL) {
764 CMSerror(ERR_R_MALLOC_FAILURE);
765 goto err;
766 }
767 if (!CMS_signed_add1_attr_by_NID(si, NID_pkcs9_signingTime,
768 at->type, at, -1))
792 goto err; 769 goto err;
793 } 770 }
794 771
@@ -828,6 +805,7 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si)
828 ret = 1; 805 ret = 1;
829 806
830 err: 807 err:
808 ASN1_TIME_free(at);
831 (void)EVP_MD_CTX_reset(si->mctx); 809 (void)EVP_MD_CTX_reset(si->mctx);
832 freezero(buf, buf_len); 810 freezero(buf, buf_len);
833 freezero(sig, sig_len); 811 freezero(sig, sig_len);