From c46ba7482ab6670501b4e03ceadbf235aa22b0e7 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 14 Feb 2018 16:57:25 +0000 Subject: Provide X509_get{0,m}_not{Before,After}(). --- src/lib/libcrypto/x509/x509_set.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/lib/libcrypto/x509/x509_set.c') 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 @@ -/* $OpenBSD: x509_set.c,v 1.12 2015/09/30 17:49:59 jsing Exp $ */ +/* $OpenBSD: x509_set.c,v 1.13 2018/02/14 16:57:25 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -104,17 +104,31 @@ X509_set_issuer_name(X509 *x, X509_NAME *name) int X509_set_subject_name(X509 *x, X509_NAME *name) { - if ((x == NULL) || (x->cert_info == NULL)) + if (x == NULL || x->cert_info == NULL) return (0); return (X509_NAME_set(&x->cert_info->subject, name)); } +const ASN1_TIME * +X509_get0_notBefore(const X509 *x) +{ + return X509_getm_notBefore(x); +} + +ASN1_TIME * +X509_getm_notBefore(const X509 *x) +{ + if (x == NULL || x->cert_info == NULL || x->cert_info->validity == NULL) + return (NULL); + return x->cert_info->validity->notBefore; +} + int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) { ASN1_TIME *in; - if ((x == NULL) || (x->cert_info->validity == NULL)) + if (x == NULL || x->cert_info->validity == NULL) return (0); in = x->cert_info->validity->notBefore; if (in != tm) { @@ -127,12 +141,26 @@ X509_set_notBefore(X509 *x, const ASN1_TIME *tm) return (in != NULL); } +const ASN1_TIME * +X509_get0_notAfter(const X509 *x) +{ + return X509_getm_notAfter(x); +} + +ASN1_TIME * +X509_getm_notAfter(const X509 *x) +{ + if (x == NULL || x->cert_info == NULL || x->cert_info->validity == NULL) + return (NULL); + return x->cert_info->validity->notAfter; +} + int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) { ASN1_TIME *in; - if ((x == NULL) || (x->cert_info->validity == NULL)) + if (x == NULL || x->cert_info->validity == NULL) return (0); in = x->cert_info->validity->notAfter; if (in != tm) { -- cgit v1.2.3-55-g6feb