From 14c3aa5d70f71218ab683c4b8163aab13bfb0d05 Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 22 Oct 2021 16:42:13 +0000 Subject: [PATCH] Prepare to provide X509_REQ_pubkey_get0() ok jsing --- lib/libcrypto/x509/x509.h | 5 ++++- lib/libcrypto/x509/x509_req.c | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/x509/x509.h b/lib/libcrypto/x509/x509.h index d3b43679242..0d3b3abebc7 100644 --- a/lib/libcrypto/x509/x509.h +++ b/lib/libcrypto/x509/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.78 2021/10/21 15:52:02 tb Exp $ */ +/* $OpenBSD: x509.h,v 1.79 2021/10/22 16:42:13 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1011,6 +1011,9 @@ int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name); X509_NAME *X509_REQ_get_subject_name(const X509_REQ *x); int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); +#if defined(LIBRESSL_NEW_API) +EVP_PKEY * X509_REQ_get0_pubkey(X509_REQ *req); +#endif int X509_REQ_extension_nid(int nid); int * X509_REQ_get_extension_nids(void); void X509_REQ_set_extension_nids(int *nids); diff --git a/lib/libcrypto/x509/x509_req.c b/lib/libcrypto/x509/x509_req.c index b44306b00dd..fe20b1c70d2 100644 --- a/lib/libcrypto/x509/x509_req.c +++ b/lib/libcrypto/x509/x509_req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_req.c,v 1.21 2018/05/13 06:48:00 tb Exp $ */ +/* $OpenBSD: x509_req.c,v 1.22 2021/10/22 16:42:13 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -121,6 +121,14 @@ X509_REQ_get_pubkey(X509_REQ *req) return (X509_PUBKEY_get(req->req_info->pubkey)); } +EVP_PKEY * +X509_REQ_get0_pubkey(X509_REQ *req) +{ + if (req == NULL || req->req_info == NULL) + return NULL; + return X509_PUBKEY_get0(req->req_info->pubkey); +} + int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k) { -- 2.20.1