summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2018-02-14 16:57:25 +0000
committerjsing <>2018-02-14 16:57:25 +0000
commitc46ba7482ab6670501b4e03ceadbf235aa22b0e7 (patch)
tree070ba1732882d2bb8be5ba4acdfa2f1ef543f094
parentc865544aa0c94bd5b8fa9f689148c1ee561270f0 (diff)
downloadopenbsd-c46ba7482ab6670501b4e03ceadbf235aa22b0e7.tar.gz
openbsd-c46ba7482ab6670501b4e03ceadbf235aa22b0e7.tar.bz2
openbsd-c46ba7482ab6670501b4e03ceadbf235aa22b0e7.zip
Provide X509_get{0,m}_not{Before,After}().
-rw-r--r--src/lib/libcrypto/Symbols.list4
-rw-r--r--src/lib/libcrypto/x509/x509.h6
-rw-r--r--src/lib/libcrypto/x509/x509_set.c36
3 files changed, 41 insertions, 5 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index 276c61b3a4..540213232b 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -2857,6 +2857,8 @@ X509_email_free
2857X509_find_by_issuer_and_serial 2857X509_find_by_issuer_and_serial
2858X509_find_by_subject 2858X509_find_by_subject
2859X509_free 2859X509_free
2860X509_get0_notAfter
2861X509_get0_notBefore
2860X509_get0_pubkey_bitstr 2862X509_get0_pubkey_bitstr
2861X509_get1_email 2863X509_get1_email
2862X509_get1_ocsp 2864X509_get1_ocsp
@@ -2880,6 +2882,8 @@ X509_get_pubkey_parameters
2880X509_get_serialNumber 2882X509_get_serialNumber
2881X509_get_signature_nid 2883X509_get_signature_nid
2882X509_get_subject_name 2884X509_get_subject_name
2885X509_getm_notAfter
2886X509_getm_notBefore
2883X509_gmtime_adj 2887X509_gmtime_adj
2884X509_issuer_and_serial_cmp 2888X509_issuer_and_serial_cmp
2885X509_issuer_and_serial_hash 2889X509_issuer_and_serial_hash
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index cda89ac5af..0cb9e2826a 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509.h,v 1.27 2018/02/14 16:18:10 jsing Exp $ */ 1/* $OpenBSD: x509.h,v 1.28 2018/02/14 16:57:25 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -969,6 +969,10 @@ int X509_set_subject_name(X509 *x, X509_NAME *name);
969X509_NAME * X509_get_subject_name(X509 *a); 969X509_NAME * X509_get_subject_name(X509 *a);
970int X509_set_notBefore(X509 *x, const ASN1_TIME *tm); 970int X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
971int X509_set_notAfter(X509 *x, const ASN1_TIME *tm); 971int X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
972const ASN1_TIME *X509_get0_notBefore(const X509 *x);
973ASN1_TIME *X509_getm_notBefore(const X509 *x);
974const ASN1_TIME *X509_get0_notAfter(const X509 *x);
975ASN1_TIME *X509_getm_notAfter(const X509 *x);
972int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); 976int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
973EVP_PKEY * X509_get_pubkey(X509 *x); 977EVP_PKEY * X509_get_pubkey(X509 *x);
974ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); 978ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
diff --git a/src/lib/libcrypto/x509/x509_set.c b/src/lib/libcrypto/x509/x509_set.c
index aeaf161024..e60d6f967a 100644
--- a/src/lib/libcrypto/x509/x509_set.c
+++ b/src/lib/libcrypto/x509/x509_set.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_set.c,v 1.12 2015/09/30 17:49:59 jsing Exp $ */ 1/* $OpenBSD: x509_set.c,v 1.13 2018/02/14 16:57:25 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -104,17 +104,31 @@ X509_set_issuer_name(X509 *x, X509_NAME *name)
104int 104int
105X509_set_subject_name(X509 *x, X509_NAME *name) 105X509_set_subject_name(X509 *x, X509_NAME *name)
106{ 106{
107 if ((x == NULL) || (x->cert_info == NULL)) 107 if (x == NULL || x->cert_info == NULL)
108 return (0); 108 return (0);
109 return (X509_NAME_set(&x->cert_info->subject, name)); 109 return (X509_NAME_set(&x->cert_info->subject, name));
110} 110}
111 111
112const ASN1_TIME *
113X509_get0_notBefore(const X509 *x)
114{
115 return X509_getm_notBefore(x);
116}
117
118ASN1_TIME *
119X509_getm_notBefore(const X509 *x)
120{
121 if (x == NULL || x->cert_info == NULL || x->cert_info->validity == NULL)
122 return (NULL);
123 return x->cert_info->validity->notBefore;
124}
125
112int 126int
113X509_set_notBefore(X509 *x, const ASN1_TIME *tm) 127X509_set_notBefore(X509 *x, const ASN1_TIME *tm)
114{ 128{
115 ASN1_TIME *in; 129 ASN1_TIME *in;
116 130
117 if ((x == NULL) || (x->cert_info->validity == NULL)) 131 if (x == NULL || x->cert_info->validity == NULL)
118 return (0); 132 return (0);
119 in = x->cert_info->validity->notBefore; 133 in = x->cert_info->validity->notBefore;
120 if (in != tm) { 134 if (in != tm) {
@@ -127,12 +141,26 @@ X509_set_notBefore(X509 *x, const ASN1_TIME *tm)
127 return (in != NULL); 141 return (in != NULL);
128} 142}
129 143
144const ASN1_TIME *
145X509_get0_notAfter(const X509 *x)
146{
147 return X509_getm_notAfter(x);
148}
149
150ASN1_TIME *
151X509_getm_notAfter(const X509 *x)
152{
153 if (x == NULL || x->cert_info == NULL || x->cert_info->validity == NULL)
154 return (NULL);
155 return x->cert_info->validity->notAfter;
156}
157
130int 158int
131X509_set_notAfter(X509 *x, const ASN1_TIME *tm) 159X509_set_notAfter(X509 *x, const ASN1_TIME *tm)
132{ 160{
133 ASN1_TIME *in; 161 ASN1_TIME *in;
134 162
135 if ((x == NULL) || (x->cert_info->validity == NULL)) 163 if (x == NULL || x->cert_info->validity == NULL)
136 return (0); 164 return (0);
137 in = x->cert_info->validity->notAfter; 165 in = x->cert_info->validity->notAfter;
138 if (in != tm) { 166 if (in != tm) {