From e3cc8252a21e905e698c32011a48afb6bb8a5295 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 22 Feb 2018 17:05:35 +0000 Subject: [PATCH] Provide X509_get0_pubkey(). --- lib/libcrypto/Symbols.list | 1 + lib/libcrypto/x509/x509.h | 5 +++-- lib/libcrypto/x509/x509_cmp.c | 10 ++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index bd821d71803..15cc4710be3 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -2955,6 +2955,7 @@ X509_free X509_get0_extensions X509_get0_notAfter X509_get0_notBefore +X509_get0_pubkey X509_get0_pubkey_bitstr X509_get0_signature X509_get1_email diff --git a/lib/libcrypto/x509/x509.h b/lib/libcrypto/x509/x509.h index 906cadaea39..1dafabe971b 100644 --- a/lib/libcrypto/x509/x509.h +++ b/lib/libcrypto/x509/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.37 2018/02/22 17:01:44 jsing Exp $ */ +/* $OpenBSD: x509.h,v 1.38 2018/02/22 17:05:35 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -994,7 +994,8 @@ const ASN1_TIME *X509_get0_notAfter(const X509 *x); ASN1_TIME *X509_getm_notAfter(const X509 *x); int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); EVP_PKEY * X509_get_pubkey(X509 *x); -ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); +EVP_PKEY * X509_get0_pubkey(X509 *x); +ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x); int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); int X509_REQ_set_version(X509_REQ *x,long version); diff --git a/lib/libcrypto/x509/x509_cmp.c b/lib/libcrypto/x509/x509_cmp.c index 72fbef15446..440467521b9 100644 --- a/lib/libcrypto/x509/x509_cmp.c +++ b/lib/libcrypto/x509/x509_cmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_cmp.c,v 1.27 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: x509_cmp.c,v 1.28 2018/02/22 17:05:35 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -321,11 +321,17 @@ X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name) EVP_PKEY * X509_get_pubkey(X509 *x) { - if ((x == NULL) || (x->cert_info == NULL)) + if (x == NULL || x->cert_info == NULL) return (NULL); return (X509_PUBKEY_get(x->cert_info->key)); } +EVP_PKEY * +X509_get0_pubkey(X509 *x) +{ + return X509_get_pubkey(x); +} + ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x) { -- 2.20.1