From 93736f7c6b1378abd082ca6029ca3f7439c6fa0f Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 23 Oct 2021 11:56:10 +0000 Subject: [PATCH] Prepare to provide X509_re_X509*_tbs() ok beck jsing --- lib/libcrypto/asn1/x_x509.c | 9 ++++++++- lib/libcrypto/x509/x509.h | 12 +++++++++++- lib/libcrypto/x509/x509_req.c | 9 ++++++++- lib/libcrypto/x509/x509cset.c | 9 ++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/asn1/x_x509.c b/lib/libcrypto/asn1/x_x509.c index 422f6256f72..ebe09a6099f 100644 --- a/lib/libcrypto/asn1/x_x509.c +++ b/lib/libcrypto/asn1/x_x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_x509.c,v 1.27 2021/09/02 12:41:44 job Exp $ */ +/* $OpenBSD: x_x509.c,v 1.28 2021/10/23 11:56:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -353,6 +353,13 @@ i2d_X509_AUX(X509 *a, unsigned char **pp) return length; } +int +i2d_re_X509_tbs(X509 *x, unsigned char **pp) +{ + x->cert_info->enc.modified = 1; + return i2d_X509_CINF(x->cert_info, pp); +} + void X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, const X509 *x) diff --git a/lib/libcrypto/x509/x509.h b/lib/libcrypto/x509/x509.h index e8383d717c0..84288de5de6 100644 --- a/lib/libcrypto/x509/x509.h +++ b/lib/libcrypto/x509/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.80 2021/10/23 11:41:50 tb Exp $ */ +/* $OpenBSD: x509.h,v 1.81 2021/10/23 11:56:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -596,6 +596,10 @@ extern "C" { int X509_CRL_up_ref(X509_CRL *x); int X509_CRL_get_signature_nid(const X509_CRL *crl); +#if defined(LIBRESSL_NEW_API) +int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp); +#endif + const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl); long X509_CRL_get_version(const X509_CRL *crl); const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl); @@ -906,6 +910,11 @@ int X509_set_ex_data(X509 *r, int idx, void *arg); void *X509_get_ex_data(X509 *r, int idx); int i2d_X509_AUX(X509 *a,unsigned char **pp); X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length); + +#if defined(LIBRESSL_NEW_API) +int i2d_re_X509_tbs(X509 *x, unsigned char **pp); +#endif + void X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, const X509 *x); int X509_get_signature_nid(const X509 *x); @@ -1019,6 +1028,7 @@ 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) +int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp); EVP_PKEY * X509_REQ_get0_pubkey(X509_REQ *req); #endif int X509_REQ_extension_nid(int nid); diff --git a/lib/libcrypto/x509/x509_req.c b/lib/libcrypto/x509/x509_req.c index fe20b1c70d2..c81fe4a3a9c 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.22 2021/10/22 16:42:13 tb Exp $ */ +/* $OpenBSD: x509_req.c,v 1.23 2021/10/23 11:56:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -349,3 +349,10 @@ X509_REQ_add1_attr_by_txt(X509_REQ *req, const char *attrname, int type, return 1; return 0; } + +int +i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp) +{ + req->req_info->enc.modified = 1; + return i2d_X509_REQ_INFO(req->req_info, pp); +} diff --git a/lib/libcrypto/x509/x509cset.c b/lib/libcrypto/x509/x509cset.c index 182dd8a9542..98fbdc2025c 100644 --- a/lib/libcrypto/x509/x509cset.c +++ b/lib/libcrypto/x509/x509cset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509cset.c,v 1.14 2018/02/22 17:01:44 jsing Exp $ */ +/* $OpenBSD: x509cset.c,v 1.15 2021/10/23 11:56:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -208,3 +208,10 @@ X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) } return (in != NULL); } + +int +i2d_re_X509_CRL_tbs(X509_CRL *crl, unsigned char **pp) +{ + crl->crl->enc.modified = 1; + return i2d_X509_CRL_INFO(crl->crl, pp); +} -- 2.20.1