From 538b2a6cf0497cf8bb61ae726a484a3d7a34e54e Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 18 Dec 2023 13:33:36 -0500 Subject: [PATCH] Restore the X509_EXTENSION ASN1_ITEM too wpa_supplicant also depends on that one. Change-Id: I6abb505d076eb258e6b8d68be42e624f4aedc725 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/64947 Auto-Submit: David Benjamin Commit-Queue: Bob Beck Reviewed-by: Bob Beck --- crypto/asn1/asn1_test.cc | 22 ++++++++++++++++++++++ include/openssl/x509.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/crypto/asn1/asn1_test.cc b/crypto/asn1/asn1_test.cc index 196d7b7e5..c2e5f5b4d 100644 --- a/crypto/asn1/asn1_test.cc +++ b/crypto/asn1/asn1_test.cc @@ -2828,6 +2828,12 @@ struct EMBED_X509_ALGOR { STACK_OF(X509_ALGOR) *seq; }; +struct EMBED_X509_EXTENSION { + X509_EXTENSION *simple; + X509_EXTENSION *opt; + STACK_OF(X509_EXTENSION) *seq; +}; + struct EMBED_X509_NAME { X509_NAME *simple; X509_NAME *opt; @@ -2856,6 +2862,14 @@ ASN1_SEQUENCE(EMBED_X509_NAME) = { } ASN1_SEQUENCE_END(EMBED_X509_NAME) IMPLEMENT_ASN1_FUNCTIONS(EMBED_X509_NAME) +DECLARE_ASN1_FUNCTIONS(EMBED_X509_EXTENSION) +ASN1_SEQUENCE(EMBED_X509_EXTENSION) = { + ASN1_SIMPLE(EMBED_X509_EXTENSION, simple, X509_EXTENSION), + ASN1_EXP_OPT(EMBED_X509_EXTENSION, opt, X509_EXTENSION, 0), + ASN1_IMP_SEQUENCE_OF_OPT(EMBED_X509_EXTENSION, seq, X509_EXTENSION, 1), +} ASN1_SEQUENCE_END(EMBED_X509_EXTENSION) +IMPLEMENT_ASN1_FUNCTIONS(EMBED_X509_EXTENSION) + DECLARE_ASN1_FUNCTIONS(EMBED_X509) ASN1_SEQUENCE(EMBED_X509) = { ASN1_SIMPLE(EMBED_X509, simple, X509), @@ -2940,6 +2954,14 @@ TEST(ASN1Test, EmbedTypes) { EMBED_X509_NAME_free, d2i_EMBED_X509_NAME, i2d_EMBED_X509_NAME, sk_X509_NAME_num, sk_X509_NAME_value); + static const uint8_t kTestExtension[] = {0x30, 0x0c, 0x06, 0x03, 0x55, + 0x1d, 0x13, 0x04, 0x05, 0x30, + 0x03, 0x01, 0x01, 0xf}; + TestEmbedType(kTestExtension, i2d_X509_EXTENSION, EMBED_X509_EXTENSION_new, + EMBED_X509_EXTENSION_free, d2i_EMBED_X509_EXTENSION, + i2d_EMBED_X509_EXTENSION, sk_X509_EXTENSION_num, + sk_X509_EXTENSION_value); + static const uint8_t kTestCert[] = { 0x30, 0x82, 0x01, 0xcf, 0x30, 0x82, 0x01, 0x76, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xd9, 0x4c, 0x04, 0xda, 0x49, 0x7d, 0xbf, 0xeb, diff --git a/include/openssl/x509.h b/include/openssl/x509.h index 6fb07aa62..b3a988b1c 100644 --- a/include/openssl/x509.h +++ b/include/openssl/x509.h @@ -1630,6 +1630,10 @@ OPENSSL_EXPORT const ASN1_BIT_STRING *X509_PUBKEY_get0_public_key( // determined by the extension type. This library represents extensions with the // |X509_EXTENSION| type. +// X509_EXTENSION is an |ASN1_ITEM| whose ASN.1 type is X.509 Extension (RFC +// 5280) and C type is |X509_EXTENSION*|. +DECLARE_ASN1_ITEM(X509_EXTENSION) + // X509_EXTENSION_new returns a newly-allocated, empty |X509_EXTENSION| object // or NULL on error. OPENSSL_EXPORT X509_EXTENSION *X509_EXTENSION_new(void);