From 7998e0ec3bfa4b1a394888aa5ab416bc98c2f50d Mon Sep 17 00:00:00 2001 From: jsing Date: Sat, 17 Feb 2018 15:50:42 +0000 Subject: [PATCH] Provide X509_get0_extensions() and X509_get0_signature() --- lib/libcrypto/Symbols.list | 8 +++++--- lib/libcrypto/asn1/x_x509.c | 12 +++++++++++- lib/libcrypto/x509/x509.h | 6 ++++-- lib/libcrypto/x509/x509_set.c | 8 +++++++- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index d633575397f..85c65a8ca8c 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -1352,13 +1352,13 @@ EVP_PKEY_encrypt_init EVP_PKEY_encrypt_old EVP_PKEY_free EVP_PKEY_get0 -EVP_PKEY_get0_asn1 EVP_PKEY_get0_DH -EVP_PKEY_get1_DH EVP_PKEY_get0_DSA +EVP_PKEY_get0_RSA +EVP_PKEY_get0_asn1 +EVP_PKEY_get1_DH EVP_PKEY_get1_DSA EVP_PKEY_get1_EC_KEY -EVP_PKEY_get0_RSA EVP_PKEY_get1_RSA EVP_PKEY_get_attr EVP_PKEY_get_attr_by_NID @@ -2885,9 +2885,11 @@ X509_email_free X509_find_by_issuer_and_serial X509_find_by_subject X509_free +X509_get0_extensions X509_get0_notAfter X509_get0_notBefore X509_get0_pubkey_bitstr +X509_get0_signature X509_get1_email X509_get1_ocsp X509_get_default_cert_area diff --git a/lib/libcrypto/asn1/x_x509.c b/lib/libcrypto/asn1/x_x509.c index c82301a8917..6a56a795c0b 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.25 2018/02/14 16:18:10 jsing Exp $ */ +/* $OpenBSD: x_x509.c,v 1.26 2018/02/17 15:50:42 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -345,6 +345,16 @@ i2d_X509_AUX(X509 *a, unsigned char **pp) return length; } +void +X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, + const X509 *x) +{ + if (psig != NULL) + *psig = x->signature; + if (palg != NULL) + *palg = x->sig_alg; +} + int X509_get_signature_nid(const X509 *x) { diff --git a/lib/libcrypto/x509/x509.h b/lib/libcrypto/x509/x509.h index 0cb9e2826ab..6d6451171cf 100644 --- a/lib/libcrypto/x509/x509.h +++ b/lib/libcrypto/x509/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.28 2018/02/14 16:57:25 jsing Exp $ */ +/* $OpenBSD: x509.h,v 1.29 2018/02/17 15:50:42 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -887,7 +887,8 @@ 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); - +void X509_get0_signature(const ASN1_BIT_STRING **psig, + const X509_ALGOR **palg, const X509 *x); int X509_get_signature_nid(const X509 *x); int X509_alias_set1(X509 *x, unsigned char *name, int len); @@ -960,6 +961,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it, ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx); #endif +const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); int X509_set_version(X509 *x,long version); int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); ASN1_INTEGER * X509_get_serialNumber(X509 *x); diff --git a/lib/libcrypto/x509/x509_set.c b/lib/libcrypto/x509/x509_set.c index e60d6f967a7..a43f0099306 100644 --- a/lib/libcrypto/x509/x509_set.c +++ b/lib/libcrypto/x509/x509_set.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_set.c,v 1.13 2018/02/14 16:57:25 jsing Exp $ */ +/* $OpenBSD: x509_set.c,v 1.14 2018/02/17 15:50:42 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,6 +63,12 @@ #include #include +const STACK_OF(X509_EXTENSION) * +X509_get0_extensions(const X509 *x) +{ + return x->cert_info->extensions; +} + int X509_set_version(X509 *x, long version) { -- 2.20.1