summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_attr.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c
index c43b0ae2f1..c35b153b84 100644
--- a/src/lib/libcrypto/pkcs7/pk7_attr.c
+++ b/src/lib/libcrypto/pkcs7/pk7_attr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pk7_attr.c,v 1.16 2025/05/10 05:54:38 tb Exp $ */ 1/* $OpenBSD: pk7_attr.c,v 1.17 2025/07/27 07:11:36 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -63,6 +63,7 @@
63#include <openssl/pkcs7.h> 63#include <openssl/pkcs7.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66#include "asn1_local.h"
66#include "err_local.h" 67#include "err_local.h"
67 68
68int 69int
@@ -148,12 +149,30 @@ LCRYPTO_ALIAS(PKCS7_add_attrib_content_type);
148int 149int
149PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t) 150PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t)
150{ 151{
151 if (!t && !(t = X509_gmtime_adj(NULL, 0))) { 152 ASN1_TIME *tm;
153 int ret = 0;
154
155 if ((tm = t) == NULL)
156 tm = X509_gmtime_adj(NULL, 0);
157 if (tm == NULL) {
152 PKCS7error(ERR_R_MALLOC_FAILURE); 158 PKCS7error(ERR_R_MALLOC_FAILURE);
153 return 0; 159 goto err;
154 } 160 }
155 return PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime, 161
156 V_ASN1_UTCTIME, t); 162 /* RFC 5652, section 11.3 - UTCTime for times between 1950 and 2050. */
163 if (ASN1_time_parse(tm->data, tm->length, NULL, tm->type) == -1)
164 goto err;
165 if (!PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime, tm->type, tm))
166 goto err;
167 tm = NULL;
168
169 ret = 1;
170
171 err:
172 if (tm != t)
173 ASN1_TIME_free(tm);
174
175 return ret;
157} 176}
158LCRYPTO_ALIAS(PKCS7_add0_attrib_signing_time); 177LCRYPTO_ALIAS(PKCS7_add0_attrib_signing_time);
159 178