summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ct/ct_x509v3.c127
-rw-r--r--src/lib/libcrypto/x509/x509_addr.c10
-rw-r--r--src/lib/libcrypto/x509/x509_akey.c10
-rw-r--r--src/lib/libcrypto/x509/x509_alt.c118
-rw-r--r--src/lib/libcrypto/x509/x509_asid.c10
-rw-r--r--src/lib/libcrypto/x509/x509_bcons.c10
-rw-r--r--src/lib/libcrypto/x509/x509_bitst.c26
-rw-r--r--src/lib/libcrypto/x509/x509_cpols.c10
-rw-r--r--src/lib/libcrypto/x509/x509_crld.c48
-rw-r--r--src/lib/libcrypto/x509/x509_extku.c18
-rw-r--r--src/lib/libcrypto/x509/x509_ia5.c290
-rw-r--r--src/lib/libcrypto/x509/x509_info.c18
-rw-r--r--src/lib/libcrypto/x509/x509_int.c46
-rw-r--r--src/lib/libcrypto/x509/x509_lib.c173
-rw-r--r--src/lib/libcrypto/x509/x509_local.h45
-rw-r--r--src/lib/libcrypto/x509/x509_ncons.c10
-rw-r--r--src/lib/libcrypto/x509/x509_ocsp.c58
-rw-r--r--src/lib/libcrypto/x509/x509_pcons.c10
-rw-r--r--src/lib/libcrypto/x509/x509_pku.c10
-rw-r--r--src/lib/libcrypto/x509/x509_pmaps.c10
-rw-r--r--src/lib/libcrypto/x509/x509_skey.c10
21 files changed, 691 insertions, 376 deletions
diff --git a/src/lib/libcrypto/ct/ct_x509v3.c b/src/lib/libcrypto/ct/ct_x509v3.c
index 59f2975cd9..b14ffc9532 100644
--- a/src/lib/libcrypto/ct/ct_x509v3.c
+++ b/src/lib/libcrypto/ct/ct_x509v3.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_x509v3.c,v 1.6 2021/12/25 15:42:32 tb Exp $ */ 1/* $OpenBSD: ct_x509v3.c,v 1.7 2024/07/13 15:08:58 tb Exp $ */
2/* 2/*
3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson 3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson
4 * (steve@openssl.org) for the OpenSSL project 2014. 4 * (steve@openssl.org) for the OpenSSL project 2014.
@@ -128,59 +128,74 @@ ocsp_ext_d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, long len)
128 return s; 128 return s;
129} 129}
130 130
131/* Handlers for X509v3/OCSP Certificate Transparency extensions */ 131/* X509v3 extension in certificates that contains SCTs */
132const X509V3_EXT_METHOD v3_ct_scts[3] = { 132static const X509V3_EXT_METHOD x509v3_ext_ct_precert_scts = {
133 /* X509v3 extension in certificates that contains SCTs */ 133 .ext_nid = NID_ct_precert_scts,
134 [0] = { 134 .ext_flags = 0,
135 .ext_nid = NID_ct_precert_scts, 135 .it = NULL,
136 .ext_flags = 0, 136 .ext_new = NULL,
137 .it = NULL, 137 .ext_free = (X509V3_EXT_FREE)SCT_LIST_free,
138 .ext_new = NULL, 138 .d2i = (X509V3_EXT_D2I)x509_ext_d2i_SCT_LIST,
139 .ext_free = (X509V3_EXT_FREE)SCT_LIST_free, 139 .i2d = (X509V3_EXT_I2D)i2d_SCT_LIST,
140 .d2i = (X509V3_EXT_D2I)x509_ext_d2i_SCT_LIST, 140 .i2s = NULL,
141 .i2d = (X509V3_EXT_I2D)i2d_SCT_LIST, 141 .s2i = NULL,
142 .i2s = NULL, 142 .i2v = NULL,
143 .s2i = NULL, 143 .v2i = NULL,
144 .i2v = NULL, 144 .i2r = (X509V3_EXT_I2R)i2r_SCT_LIST,
145 .v2i = NULL, 145 .r2i = NULL,
146 .i2r = (X509V3_EXT_I2R)i2r_SCT_LIST, 146 .usr_data = NULL,
147 .r2i = NULL,
148 .usr_data = NULL,
149 },
150
151 /* X509v3 extension to mark a certificate as a pre-certificate */
152 [1] = {
153 .ext_nid = NID_ct_precert_poison,
154 .ext_flags = 0,
155 .it = &ASN1_NULL_it,
156 .ext_new = NULL,
157 .ext_free = NULL,
158 .d2i = NULL,
159 .i2d = NULL,
160 .i2s = i2s_poison,
161 .s2i = s2i_poison,
162 .i2v = NULL,
163 .v2i = NULL,
164 .i2r = NULL,
165 .r2i = NULL,
166 .usr_data = NULL,
167 },
168
169 /* OCSP extension that contains SCTs */
170 [2] = {
171 .ext_nid = NID_ct_cert_scts,
172 .ext_flags = 0,
173 .it = NULL,
174 .ext_new = NULL,
175 .ext_free = (X509V3_EXT_FREE)SCT_LIST_free,
176 .d2i = (X509V3_EXT_D2I)ocsp_ext_d2i_SCT_LIST,
177 .i2d = (X509V3_EXT_I2D)i2d_SCT_LIST,
178 .i2s = NULL,
179 .s2i = NULL,
180 .i2v = NULL,
181 .v2i = NULL,
182 .i2r = (X509V3_EXT_I2R)i2r_SCT_LIST,
183 .r2i = NULL,
184 .usr_data = NULL,
185 },
186}; 147};
148
149const X509V3_EXT_METHOD *
150x509v3_ext_method_ct_precert_scts(void)
151{
152 return &x509v3_ext_ct_precert_scts;
153}
154
155/* X509v3 extension to mark a certificate as a pre-certificate */
156static const X509V3_EXT_METHOD x509v3_ext_ct_precert_poison = {
157 .ext_nid = NID_ct_precert_poison,
158 .ext_flags = 0,
159 .it = &ASN1_NULL_it,
160 .ext_new = NULL,
161 .ext_free = NULL,
162 .d2i = NULL,
163 .i2d = NULL,
164 .i2s = i2s_poison,
165 .s2i = s2i_poison,
166 .i2v = NULL,
167 .v2i = NULL,
168 .i2r = NULL,
169 .r2i = NULL,
170 .usr_data = NULL,
171};
172
173const X509V3_EXT_METHOD *
174x509v3_ext_method_ct_precert_poison(void)
175{
176 return &x509v3_ext_ct_precert_poison;
177}
178
179/* OCSP extension that contains SCTs */
180static const X509V3_EXT_METHOD x509v3_ext_ct_cert_scts = {
181 .ext_nid = NID_ct_cert_scts,
182 .ext_flags = 0,
183 .it = NULL,
184 .ext_new = NULL,
185 .ext_free = (X509V3_EXT_FREE)SCT_LIST_free,
186 .d2i = (X509V3_EXT_D2I)ocsp_ext_d2i_SCT_LIST,
187 .i2d = (X509V3_EXT_I2D)i2d_SCT_LIST,
188 .i2s = NULL,
189 .s2i = NULL,
190 .i2v = NULL,
191 .v2i = NULL,
192 .i2r = (X509V3_EXT_I2R)i2r_SCT_LIST,
193 .r2i = NULL,
194 .usr_data = NULL,
195};
196
197const X509V3_EXT_METHOD *
198x509v3_ext_method_ct_cert_scts(void)
199{
200 return &x509v3_ext_ct_cert_scts;
201}
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c
index 864b7bbf3d..2208cc434e 100644
--- a/src/lib/libcrypto/x509/x509_addr.c
+++ b/src/lib/libcrypto/x509/x509_addr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_addr.c,v 1.92 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_addr.c,v 1.93 2024/07/13 15:08:58 tb Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -1714,7 +1714,7 @@ v2i_IPAddrBlocks(const struct v3_ext_method *method, struct v3_ext_ctx *ctx,
1714/* 1714/*
1715 * OpenSSL dispatch 1715 * OpenSSL dispatch
1716 */ 1716 */
1717const X509V3_EXT_METHOD v3_addr = { 1717static const X509V3_EXT_METHOD x509v3_ext_sbgp_ipAddrBlock = {
1718 .ext_nid = NID_sbgp_ipAddrBlock, 1718 .ext_nid = NID_sbgp_ipAddrBlock,
1719 .ext_flags = 0, 1719 .ext_flags = 0,
1720 .it = &IPAddrBlocks_it, 1720 .it = &IPAddrBlocks_it,
@@ -1731,6 +1731,12 @@ const X509V3_EXT_METHOD v3_addr = {
1731 .usr_data = NULL, 1731 .usr_data = NULL,
1732}; 1732};
1733 1733
1734const X509V3_EXT_METHOD *
1735x509v3_ext_method_sbgp_ipAddrBlock(void)
1736{
1737 return &x509v3_ext_sbgp_ipAddrBlock;
1738}
1739
1734/* 1740/*
1735 * Figure out whether extension uses inheritance. 1741 * Figure out whether extension uses inheritance.
1736 */ 1742 */
diff --git a/src/lib/libcrypto/x509/x509_akey.c b/src/lib/libcrypto/x509/x509_akey.c
index f8c7113350..b052d95984 100644
--- a/src/lib/libcrypto/x509/x509_akey.c
+++ b/src/lib/libcrypto/x509/x509_akey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_akey.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ 1/* $OpenBSD: x509_akey.c,v 1.2 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -70,7 +70,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
70static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, 70static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
71 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); 71 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
72 72
73const X509V3_EXT_METHOD v3_akey_id = { 73static const X509V3_EXT_METHOD x509v3_ext_authority_key_identifier = {
74 .ext_nid = NID_authority_key_identifier, 74 .ext_nid = NID_authority_key_identifier,
75 .ext_flags = X509V3_EXT_MULTILINE, 75 .ext_flags = X509V3_EXT_MULTILINE,
76 .it = &AUTHORITY_KEYID_it, 76 .it = &AUTHORITY_KEYID_it,
@@ -87,6 +87,12 @@ const X509V3_EXT_METHOD v3_akey_id = {
87 .usr_data = NULL, 87 .usr_data = NULL,
88}; 88};
89 89
90const X509V3_EXT_METHOD *
91x509v3_ext_method_authority_key_identifier(void)
92{
93 return &x509v3_ext_authority_key_identifier;
94}
95
90static STACK_OF(CONF_VALUE) * 96static STACK_OF(CONF_VALUE) *
91i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, AUTHORITY_KEYID *akeyid, 97i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, AUTHORITY_KEYID *akeyid,
92 STACK_OF(CONF_VALUE) *extlist) 98 STACK_OF(CONF_VALUE) *extlist)
diff --git a/src/lib/libcrypto/x509/x509_alt.c b/src/lib/libcrypto/x509/x509_alt.c
index 59fa39fa6b..8981e4c4fb 100644
--- a/src/lib/libcrypto/x509/x509_alt.c
+++ b/src/lib/libcrypto/x509/x509_alt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_alt.c,v 1.16 2023/08/30 00:49:32 tb Exp $ */ 1/* $OpenBSD: x509_alt.c,v 1.17 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -74,57 +74,75 @@ static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens);
74static int do_othername(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx); 74static int do_othername(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx);
75static int do_dirname(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx); 75static int do_dirname(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx);
76 76
77const X509V3_EXT_METHOD v3_alt[] = { 77static const X509V3_EXT_METHOD x509v3_ext_subject_alt_name = {
78 { 78 .ext_nid = NID_subject_alt_name,
79 .ext_nid = NID_subject_alt_name, 79 .ext_flags = 0,
80 .ext_flags = 0, 80 .it = &GENERAL_NAMES_it,
81 .it = &GENERAL_NAMES_it, 81 .ext_new = NULL,
82 .ext_new = NULL, 82 .ext_free = NULL,
83 .ext_free = NULL, 83 .d2i = NULL,
84 .d2i = NULL, 84 .i2d = NULL,
85 .i2d = NULL, 85 .i2s = NULL,
86 .i2s = NULL, 86 .s2i = NULL,
87 .s2i = NULL, 87 .i2v = (X509V3_EXT_I2V)i2v_GENERAL_NAMES,
88 .i2v = (X509V3_EXT_I2V)i2v_GENERAL_NAMES, 88 .v2i = (X509V3_EXT_V2I)v2i_subject_alt,
89 .v2i = (X509V3_EXT_V2I)v2i_subject_alt, 89 .i2r = NULL,
90 .i2r = NULL, 90 .r2i = NULL,
91 .r2i = NULL, 91 .usr_data = NULL,
92 .usr_data = NULL,
93 },
94 {
95 .ext_nid = NID_issuer_alt_name,
96 .ext_flags = 0,
97 .it = &GENERAL_NAMES_it,
98 .ext_new = NULL,
99 .ext_free = NULL,
100 .d2i = NULL,
101 .i2d = NULL,
102 .i2s = NULL,
103 .s2i = NULL,
104 .i2v = (X509V3_EXT_I2V)i2v_GENERAL_NAMES,
105 .v2i = (X509V3_EXT_V2I)v2i_issuer_alt,
106 .i2r = NULL,
107 .r2i = NULL,
108 .usr_data = NULL,
109 },
110 {
111 .ext_nid = NID_certificate_issuer,
112 .ext_flags = 0,
113 .it = &GENERAL_NAMES_it,
114 .ext_new = NULL,
115 .ext_free = NULL,
116 .d2i = NULL,
117 .i2d = NULL,
118 .i2s = NULL,
119 .s2i = NULL,
120 .i2v = (X509V3_EXT_I2V)i2v_GENERAL_NAMES,
121 .v2i = NULL,
122 .i2r = NULL,
123 .r2i = NULL,
124 .usr_data = NULL,
125 },
126}; 92};
127 93
94const X509V3_EXT_METHOD *
95x509v3_ext_method_subject_alt_name(void)
96{
97 return &x509v3_ext_subject_alt_name;
98}
99
100static const X509V3_EXT_METHOD x509v3_ext_issuer_alt_name = {
101 .ext_nid = NID_issuer_alt_name,
102 .ext_flags = 0,
103 .it = &GENERAL_NAMES_it,
104 .ext_new = NULL,
105 .ext_free = NULL,
106 .d2i = NULL,
107 .i2d = NULL,
108 .i2s = NULL,
109 .s2i = NULL,
110 .i2v = (X509V3_EXT_I2V)i2v_GENERAL_NAMES,
111 .v2i = (X509V3_EXT_V2I)v2i_issuer_alt,
112 .i2r = NULL,
113 .r2i = NULL,
114 .usr_data = NULL,
115};
116
117const X509V3_EXT_METHOD *
118x509v3_ext_method_issuer_alt_name(void)
119{
120 return &x509v3_ext_issuer_alt_name;
121}
122
123static const X509V3_EXT_METHOD x509v3_ext_certificate_issuer = {
124 .ext_nid = NID_certificate_issuer,
125 .ext_flags = 0,
126 .it = &GENERAL_NAMES_it,
127 .ext_new = NULL,
128 .ext_free = NULL,
129 .d2i = NULL,
130 .i2d = NULL,
131 .i2s = NULL,
132 .s2i = NULL,
133 .i2v = (X509V3_EXT_I2V)i2v_GENERAL_NAMES,
134 .v2i = NULL,
135 .i2r = NULL,
136 .r2i = NULL,
137 .usr_data = NULL,
138};
139
140const X509V3_EXT_METHOD *
141x509v3_ext_method_certificate_issuer(void)
142{
143 return &x509v3_ext_certificate_issuer;
144}
145
128STACK_OF(CONF_VALUE) * 146STACK_OF(CONF_VALUE) *
129i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, GENERAL_NAMES *gens, 147i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, GENERAL_NAMES *gens,
130 STACK_OF(CONF_VALUE) *ret) 148 STACK_OF(CONF_VALUE) *ret)
diff --git a/src/lib/libcrypto/x509/x509_asid.c b/src/lib/libcrypto/x509/x509_asid.c
index e3af673202..40ee201a9f 100644
--- a/src/lib/libcrypto/x509/x509_asid.c
+++ b/src/lib/libcrypto/x509/x509_asid.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_asid.c,v 1.44 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_asid.c,v 1.45 2024/07/13 15:08:58 tb Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -946,7 +946,7 @@ v2i_ASIdentifiers(const struct v3_ext_method *method, struct v3_ext_ctx *ctx,
946/* 946/*
947 * OpenSSL dispatch. 947 * OpenSSL dispatch.
948 */ 948 */
949const X509V3_EXT_METHOD v3_asid = { 949static const X509V3_EXT_METHOD x509v3_ext_sbgp_autonomousSysNum = {
950 .ext_nid = NID_sbgp_autonomousSysNum, 950 .ext_nid = NID_sbgp_autonomousSysNum,
951 .ext_flags = 0, 951 .ext_flags = 0,
952 .it = &ASIdentifiers_it, 952 .it = &ASIdentifiers_it,
@@ -963,6 +963,12 @@ const X509V3_EXT_METHOD v3_asid = {
963 .usr_data = NULL, 963 .usr_data = NULL,
964}; 964};
965 965
966const X509V3_EXT_METHOD *
967x509v3_ext_method_sbgp_autonomousSysNum(void)
968{
969 return &x509v3_ext_sbgp_autonomousSysNum;
970}
971
966/* 972/*
967 * Figure out whether extension uses inheritance. 973 * Figure out whether extension uses inheritance.
968 */ 974 */
diff --git a/src/lib/libcrypto/x509/x509_bcons.c b/src/lib/libcrypto/x509/x509_bcons.c
index 7ad65231ec..e44ff4d1cb 100644
--- a/src/lib/libcrypto/x509/x509_bcons.c
+++ b/src/lib/libcrypto/x509/x509_bcons.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_bcons.c,v 1.4 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_bcons.c,v 1.5 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -70,7 +70,7 @@ static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
70static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, 70static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
71 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); 71 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
72 72
73const X509V3_EXT_METHOD v3_bcons = { 73static const X509V3_EXT_METHOD x509v3_ext_basic_constraints = {
74 .ext_nid = NID_basic_constraints, 74 .ext_nid = NID_basic_constraints,
75 .ext_flags = 0, 75 .ext_flags = 0,
76 .it = &BASIC_CONSTRAINTS_it, 76 .it = &BASIC_CONSTRAINTS_it,
@@ -87,6 +87,12 @@ const X509V3_EXT_METHOD v3_bcons = {
87 .usr_data = NULL, 87 .usr_data = NULL,
88}; 88};
89 89
90const X509V3_EXT_METHOD *
91x509v3_ext_method_basic_constraints(void)
92{
93 return &x509v3_ext_basic_constraints;
94}
95
90static const ASN1_TEMPLATE BASIC_CONSTRAINTS_seq_tt[] = { 96static const ASN1_TEMPLATE BASIC_CONSTRAINTS_seq_tt[] = {
91 { 97 {
92 .flags = ASN1_TFLG_OPTIONAL, 98 .flags = ASN1_TFLG_OPTIONAL,
diff --git a/src/lib/libcrypto/x509/x509_bitst.c b/src/lib/libcrypto/x509/x509_bitst.c
index 4c36d31b03..0328310f08 100644
--- a/src/lib/libcrypto/x509/x509_bitst.c
+++ b/src/lib/libcrypto/x509/x509_bitst.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_bitst.c,v 1.5 2024/06/18 08:29:40 tb Exp $ */ 1/* $OpenBSD: x509_bitst.c,v 1.6 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -102,7 +102,7 @@ static BIT_STRING_BITNAME crl_reasons[] = {
102 {-1, NULL, NULL} 102 {-1, NULL, NULL}
103}; 103};
104 104
105const X509V3_EXT_METHOD v3_nscert = { 105static const X509V3_EXT_METHOD x509v3_ext_netscape_cert_type = {
106 .ext_nid = NID_netscape_cert_type, 106 .ext_nid = NID_netscape_cert_type,
107 .ext_flags = 0, 107 .ext_flags = 0,
108 .it = &ASN1_BIT_STRING_it, 108 .it = &ASN1_BIT_STRING_it,
@@ -119,7 +119,13 @@ const X509V3_EXT_METHOD v3_nscert = {
119 .usr_data = ns_cert_type_table, 119 .usr_data = ns_cert_type_table,
120}; 120};
121 121
122const X509V3_EXT_METHOD v3_key_usage = { 122const X509V3_EXT_METHOD *
123x509v3_ext_method_netscape_cert_type(void)
124{
125 return &x509v3_ext_netscape_cert_type;
126}
127
128static const X509V3_EXT_METHOD x509v3_ext_key_usage = {
123 .ext_nid = NID_key_usage, 129 .ext_nid = NID_key_usage,
124 .ext_flags = 0, 130 .ext_flags = 0,
125 .it = &ASN1_BIT_STRING_it, 131 .it = &ASN1_BIT_STRING_it,
@@ -136,7 +142,13 @@ const X509V3_EXT_METHOD v3_key_usage = {
136 .usr_data = key_usage_type_table, 142 .usr_data = key_usage_type_table,
137}; 143};
138 144
139const X509V3_EXT_METHOD v3_crl_reason = { 145const X509V3_EXT_METHOD *
146x509v3_ext_method_key_usage(void)
147{
148 return &x509v3_ext_key_usage;
149}
150
151static const X509V3_EXT_METHOD x509v3_ext_crl_reason = {
140 .ext_nid = NID_crl_reason, 152 .ext_nid = NID_crl_reason,
141 .ext_flags = 0, 153 .ext_flags = 0,
142 .it = &ASN1_ENUMERATED_it, 154 .it = &ASN1_ENUMERATED_it,
@@ -153,6 +165,12 @@ const X509V3_EXT_METHOD v3_crl_reason = {
153 .usr_data = crl_reasons, 165 .usr_data = crl_reasons,
154}; 166};
155 167
168const X509V3_EXT_METHOD *
169x509v3_ext_method_crl_reason(void)
170{
171 return &x509v3_ext_crl_reason;
172}
173
156STACK_OF(CONF_VALUE) * 174STACK_OF(CONF_VALUE) *
157i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits, 175i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits,
158 STACK_OF(CONF_VALUE) *ret) 176 STACK_OF(CONF_VALUE) *ret)
diff --git a/src/lib/libcrypto/x509/x509_cpols.c b/src/lib/libcrypto/x509/x509_cpols.c
index 34c9345a4f..7a701ea659 100644
--- a/src/lib/libcrypto/x509/x509_cpols.c
+++ b/src/lib/libcrypto/x509/x509_cpols.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_cpols.c,v 1.12 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_cpols.c,v 1.13 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -82,7 +82,7 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
82 STACK_OF(CONF_VALUE) *unot, int ia5org); 82 STACK_OF(CONF_VALUE) *unot, int ia5org);
83static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos); 83static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos);
84 84
85const X509V3_EXT_METHOD v3_cpols = { 85static const X509V3_EXT_METHOD x509v3_ext_certificate_policies = {
86 .ext_nid = NID_certificate_policies, 86 .ext_nid = NID_certificate_policies,
87 .ext_flags = 0, 87 .ext_flags = 0,
88 .it = &CERTIFICATEPOLICIES_it, 88 .it = &CERTIFICATEPOLICIES_it,
@@ -99,6 +99,12 @@ const X509V3_EXT_METHOD v3_cpols = {
99 .usr_data = NULL, 99 .usr_data = NULL,
100}; 100};
101 101
102const X509V3_EXT_METHOD *
103x509v3_ext_method_certificate_policies(void)
104{
105 return &x509v3_ext_certificate_policies;
106}
107
102static const ASN1_TEMPLATE CERTIFICATEPOLICIES_item_tt = { 108static const ASN1_TEMPLATE CERTIFICATEPOLICIES_item_tt = {
103 .flags = ASN1_TFLG_SEQUENCE_OF, 109 .flags = ASN1_TFLG_SEQUENCE_OF,
104 .tag = 0, 110 .tag = 0,
diff --git a/src/lib/libcrypto/x509/x509_crld.c b/src/lib/libcrypto/x509/x509_crld.c
index dfb5d27f65..e9252a247a 100644
--- a/src/lib/libcrypto/x509/x509_crld.c
+++ b/src/lib/libcrypto/x509/x509_crld.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_crld.c,v 1.6 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_crld.c,v 1.7 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -72,7 +72,7 @@ static void *v2i_crld(const X509V3_EXT_METHOD *method,
72static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out, 72static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out,
73 int indent); 73 int indent);
74 74
75const X509V3_EXT_METHOD v3_crld = { 75static const X509V3_EXT_METHOD x509v3_ext_crl_distribution_points = {
76 .ext_nid = NID_crl_distribution_points, 76 .ext_nid = NID_crl_distribution_points,
77 .ext_flags = 0, 77 .ext_flags = 0,
78 .it = &CRL_DIST_POINTS_it, 78 .it = &CRL_DIST_POINTS_it,
@@ -89,7 +89,13 @@ const X509V3_EXT_METHOD v3_crld = {
89 .usr_data = NULL, 89 .usr_data = NULL,
90}; 90};
91 91
92const X509V3_EXT_METHOD v3_freshest_crl = { 92const X509V3_EXT_METHOD *
93x509v3_ext_method_crl_distribution_points(void)
94{
95 return &x509v3_ext_crl_distribution_points;
96}
97
98static const X509V3_EXT_METHOD x509v3_ext_freshest_crl = {
93 .ext_nid = NID_freshest_crl, 99 .ext_nid = NID_freshest_crl,
94 .ext_flags = 0, 100 .ext_flags = 0,
95 .it = &CRL_DIST_POINTS_it, 101 .it = &CRL_DIST_POINTS_it,
@@ -106,6 +112,12 @@ const X509V3_EXT_METHOD v3_freshest_crl = {
106 .usr_data = NULL, 112 .usr_data = NULL,
107}; 113};
108 114
115const X509V3_EXT_METHOD *
116x509v3_ext_method_freshest_crl(void)
117{
118 return &x509v3_ext_freshest_crl;
119}
120
109static STACK_OF(GENERAL_NAME) * 121static STACK_OF(GENERAL_NAME) *
110gnames_from_sectname(X509V3_CTX *ctx, char *sect) 122gnames_from_sectname(X509V3_CTX *ctx, char *sect)
111{ 123{
@@ -655,17 +667,29 @@ static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out,
655static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, 667static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
656 STACK_OF(CONF_VALUE) *nval); 668 STACK_OF(CONF_VALUE) *nval);
657 669
658const X509V3_EXT_METHOD v3_idp = { 670static const X509V3_EXT_METHOD x509v3_ext_issuing_distribution_point = {
659 NID_issuing_distribution_point, X509V3_EXT_MULTILINE, 671 .ext_nid = NID_issuing_distribution_point,
660 &ISSUING_DIST_POINT_it, 672 .ext_flags = X509V3_EXT_MULTILINE,
661 0, 0, 0, 0, 673 .it = &ISSUING_DIST_POINT_it,
662 0, 0, 674 .ext_new = NULL,
663 0, 675 .ext_free = NULL,
664 v2i_idp, 676 .d2i = NULL,
665 i2r_idp, 0, 677 .i2d = NULL,
666 NULL 678 .i2s = NULL,
679 .s2i = NULL,
680 .i2v = NULL,
681 .v2i = v2i_idp,
682 .i2r = i2r_idp,
683 .r2i = NULL,
684 .usr_data = NULL,
667}; 685};
668 686
687const X509V3_EXT_METHOD *
688x509v3_ext_method_issuing_distribution_point(void)
689{
690 return &x509v3_ext_issuing_distribution_point;
691}
692
669static void * 693static void *
670v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, 694v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
671 STACK_OF(CONF_VALUE) *nval) 695 STACK_OF(CONF_VALUE) *nval)
diff --git a/src/lib/libcrypto/x509/x509_extku.c b/src/lib/libcrypto/x509/x509_extku.c
index f0f8d44aa6..6a69adabc6 100644
--- a/src/lib/libcrypto/x509/x509_extku.c
+++ b/src/lib/libcrypto/x509/x509_extku.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_extku.c,v 1.4 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_extku.c,v 1.5 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -68,7 +68,7 @@ static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
68static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE( 68static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(
69 const X509V3_EXT_METHOD *method, void *eku, STACK_OF(CONF_VALUE) *extlist); 69 const X509V3_EXT_METHOD *method, void *eku, STACK_OF(CONF_VALUE) *extlist);
70 70
71const X509V3_EXT_METHOD v3_ext_ku = { 71static const X509V3_EXT_METHOD x509v3_ext_ext_key_usage = {
72 .ext_nid = NID_ext_key_usage, 72 .ext_nid = NID_ext_key_usage,
73 .ext_flags = 0, 73 .ext_flags = 0,
74 .it = &EXTENDED_KEY_USAGE_it, 74 .it = &EXTENDED_KEY_USAGE_it,
@@ -85,8 +85,14 @@ const X509V3_EXT_METHOD v3_ext_ku = {
85 .usr_data = NULL, 85 .usr_data = NULL,
86}; 86};
87 87
88const X509V3_EXT_METHOD *
89x509v3_ext_method_ext_key_usage(void)
90{
91 return &x509v3_ext_ext_key_usage;
92}
93
88/* NB OCSP acceptable responses also is a SEQUENCE OF OBJECT */ 94/* NB OCSP acceptable responses also is a SEQUENCE OF OBJECT */
89const X509V3_EXT_METHOD v3_ocsp_accresp = { 95static const X509V3_EXT_METHOD x509v3_ext_id_pkix_OCSP_acceptableResponses = {
90 .ext_nid = NID_id_pkix_OCSP_acceptableResponses, 96 .ext_nid = NID_id_pkix_OCSP_acceptableResponses,
91 .ext_flags = 0, 97 .ext_flags = 0,
92 .it = &EXTENDED_KEY_USAGE_it, 98 .it = &EXTENDED_KEY_USAGE_it,
@@ -103,6 +109,12 @@ const X509V3_EXT_METHOD v3_ocsp_accresp = {
103 .usr_data = NULL, 109 .usr_data = NULL,
104}; 110};
105 111
112const X509V3_EXT_METHOD *
113x509v3_ext_method_id_pkix_OCSP_acceptableResponses(void)
114{
115 return &x509v3_ext_id_pkix_OCSP_acceptableResponses;
116}
117
106static const ASN1_TEMPLATE EXTENDED_KEY_USAGE_item_tt = { 118static const ASN1_TEMPLATE EXTENDED_KEY_USAGE_item_tt = {
107 .flags = ASN1_TFLG_SEQUENCE_OF, 119 .flags = ASN1_TFLG_SEQUENCE_OF,
108 .tag = 0, 120 .tag = 0,
diff --git a/src/lib/libcrypto/x509/x509_ia5.c b/src/lib/libcrypto/x509/x509_ia5.c
index 4113c3d3b3..4f62a9134c 100644
--- a/src/lib/libcrypto/x509/x509_ia5.c
+++ b/src/lib/libcrypto/x509/x509_ia5.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_ia5.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ 1/* $OpenBSD: x509_ia5.c,v 1.2 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -68,137 +68,167 @@ static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);
68static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, 68static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
69 X509V3_CTX *ctx, char *str); 69 X509V3_CTX *ctx, char *str);
70 70
71const X509V3_EXT_METHOD v3_ns_ia5_list[] = { 71static const X509V3_EXT_METHOD x509v3_ext_netscape_base_url = {
72 { 72 .ext_nid = NID_netscape_base_url,
73 .ext_nid = NID_netscape_base_url, 73 .ext_flags = 0,
74 .ext_flags = 0, 74 .it = &ASN1_IA5STRING_it,
75 .it = &ASN1_IA5STRING_it, 75 .ext_new = NULL,
76 .ext_new = NULL, 76 .ext_free = NULL,
77 .ext_free = NULL, 77 .d2i = NULL,
78 .d2i = NULL, 78 .i2d = NULL,
79 .i2d = NULL, 79 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
80 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, 80 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
81 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, 81 .i2v = NULL,
82 .i2v = NULL, 82 .v2i = NULL,
83 .v2i = NULL, 83 .i2r = NULL,
84 .i2r = NULL, 84 .r2i = NULL,
85 .r2i = NULL, 85 .usr_data = NULL,
86 .usr_data = NULL,
87 },
88 {
89 .ext_nid = NID_netscape_revocation_url,
90 .ext_flags = 0,
91 .it = &ASN1_IA5STRING_it,
92 .ext_new = NULL,
93 .ext_free = NULL,
94 .d2i = NULL,
95 .i2d = NULL,
96 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
97 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
98 .i2v = NULL,
99 .v2i = NULL,
100 .i2r = NULL,
101 .r2i = NULL,
102 .usr_data = NULL,
103 },
104 {
105 .ext_nid = NID_netscape_ca_revocation_url,
106 .ext_flags = 0,
107 .it = &ASN1_IA5STRING_it,
108 .ext_new = NULL,
109 .ext_free = NULL,
110 .d2i = NULL,
111 .i2d = NULL,
112 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
113 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
114 .i2v = NULL,
115 .v2i = NULL,
116 .i2r = NULL,
117 .r2i = NULL,
118 .usr_data = NULL,
119 },
120 {
121 .ext_nid = NID_netscape_renewal_url,
122 .ext_flags = 0,
123 .it = &ASN1_IA5STRING_it,
124 .ext_new = NULL,
125 .ext_free = NULL,
126 .d2i = NULL,
127 .i2d = NULL,
128 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
129 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
130 .i2v = NULL,
131 .v2i = NULL,
132 .i2r = NULL,
133 .r2i = NULL,
134 .usr_data = NULL,
135 },
136 {
137 .ext_nid = NID_netscape_ca_policy_url,
138 .ext_flags = 0,
139 .it = &ASN1_IA5STRING_it,
140 .ext_new = NULL,
141 .ext_free = NULL,
142 .d2i = NULL,
143 .i2d = NULL,
144 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
145 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
146 .i2v = NULL,
147 .v2i = NULL,
148 .i2r = NULL,
149 .r2i = NULL,
150 .usr_data = NULL,
151 },
152 {
153 .ext_nid = NID_netscape_ssl_server_name,
154 .ext_flags = 0,
155 .it = &ASN1_IA5STRING_it,
156 .ext_new = NULL,
157 .ext_free = NULL,
158 .d2i = NULL,
159 .i2d = NULL,
160 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
161 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
162 .i2v = NULL,
163 .v2i = NULL,
164 .i2r = NULL,
165 .r2i = NULL,
166 .usr_data = NULL,
167 },
168 {
169 .ext_nid = NID_netscape_comment,
170 .ext_flags = 0,
171 .it = &ASN1_IA5STRING_it,
172 .ext_new = NULL,
173 .ext_free = NULL,
174 .d2i = NULL,
175 .i2d = NULL,
176 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
177 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
178 .i2v = NULL,
179 .v2i = NULL,
180 .i2r = NULL,
181 .r2i = NULL,
182 .usr_data = NULL,
183 },
184 {
185 .ext_nid = -1,
186 .ext_flags = 0,
187 .it = NULL,
188 .ext_new = NULL,
189 .ext_free = NULL,
190 .d2i = NULL,
191 .i2d = NULL,
192 .i2s = NULL,
193 .s2i = NULL,
194 .i2v = NULL,
195 .v2i = NULL,
196 .i2r = NULL,
197 .r2i = NULL,
198 .usr_data = NULL,
199 },
200}; 86};
201 87
88const X509V3_EXT_METHOD *
89x509v3_ext_method_netscape_base_url(void)
90{
91 return &x509v3_ext_netscape_base_url;
92}
93
94static const X509V3_EXT_METHOD x509v3_ext_netscape_revocation_url = {
95 .ext_nid = NID_netscape_revocation_url,
96 .ext_flags = 0,
97 .it = &ASN1_IA5STRING_it,
98 .ext_new = NULL,
99 .ext_free = NULL,
100 .d2i = NULL,
101 .i2d = NULL,
102 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
103 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
104 .i2v = NULL,
105 .v2i = NULL,
106 .i2r = NULL,
107 .r2i = NULL,
108 .usr_data = NULL,
109};
110
111const X509V3_EXT_METHOD *
112x509v3_ext_method_netscape_revocation_url(void)
113{
114 return &x509v3_ext_netscape_revocation_url;
115}
116
117static const X509V3_EXT_METHOD x509v3_ext_netscape_ca_revocation_url = {
118 .ext_nid = NID_netscape_ca_revocation_url,
119 .ext_flags = 0,
120 .it = &ASN1_IA5STRING_it,
121 .ext_new = NULL,
122 .ext_free = NULL,
123 .d2i = NULL,
124 .i2d = NULL,
125 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
126 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
127 .i2v = NULL,
128 .v2i = NULL,
129 .i2r = NULL,
130 .r2i = NULL,
131 .usr_data = NULL,
132};
133
134const X509V3_EXT_METHOD *
135x509v3_ext_method_netscape_ca_revocation_url(void)
136{
137 return &x509v3_ext_netscape_ca_revocation_url;
138}
139
140static const X509V3_EXT_METHOD x509v3_ext_netscape_renewal_url = {
141 .ext_nid = NID_netscape_renewal_url,
142 .ext_flags = 0,
143 .it = &ASN1_IA5STRING_it,
144 .ext_new = NULL,
145 .ext_free = NULL,
146 .d2i = NULL,
147 .i2d = NULL,
148 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
149 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
150 .i2v = NULL,
151 .v2i = NULL,
152 .i2r = NULL,
153 .r2i = NULL,
154 .usr_data = NULL,
155};
156
157const X509V3_EXT_METHOD *
158x509v3_ext_method_netscape_renewal_url(void)
159{
160 return &x509v3_ext_netscape_renewal_url;
161}
162
163static const X509V3_EXT_METHOD x509v3_ext_netscape_ca_policy_url = {
164 .ext_nid = NID_netscape_ca_policy_url,
165 .ext_flags = 0,
166 .it = &ASN1_IA5STRING_it,
167 .ext_new = NULL,
168 .ext_free = NULL,
169 .d2i = NULL,
170 .i2d = NULL,
171 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
172 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
173 .i2v = NULL,
174 .v2i = NULL,
175 .i2r = NULL,
176 .r2i = NULL,
177 .usr_data = NULL,
178};
179
180const X509V3_EXT_METHOD *
181x509v3_ext_method_netscape_ca_policy_url(void)
182{
183 return &x509v3_ext_netscape_ca_policy_url;
184}
185
186static const X509V3_EXT_METHOD x509v3_ext_netscape_ssl_server_name = {
187 .ext_nid = NID_netscape_ssl_server_name,
188 .ext_flags = 0,
189 .it = &ASN1_IA5STRING_it,
190 .ext_new = NULL,
191 .ext_free = NULL,
192 .d2i = NULL,
193 .i2d = NULL,
194 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
195 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
196 .i2v = NULL,
197 .v2i = NULL,
198 .i2r = NULL,
199 .r2i = NULL,
200 .usr_data = NULL,
201};
202
203const X509V3_EXT_METHOD *
204x509v3_ext_method_netscape_ssl_server_name(void)
205{
206 return &x509v3_ext_netscape_ssl_server_name;
207}
208
209static const X509V3_EXT_METHOD x509v3_ext_netscape_comment = {
210 .ext_nid = NID_netscape_comment,
211 .ext_flags = 0,
212 .it = &ASN1_IA5STRING_it,
213 .ext_new = NULL,
214 .ext_free = NULL,
215 .d2i = NULL,
216 .i2d = NULL,
217 .i2s = (X509V3_EXT_I2S)i2s_ASN1_IA5STRING,
218 .s2i = (X509V3_EXT_S2I)s2i_ASN1_IA5STRING,
219 .i2v = NULL,
220 .v2i = NULL,
221 .i2r = NULL,
222 .r2i = NULL,
223 .usr_data = NULL,
224};
225
226const X509V3_EXT_METHOD *
227x509v3_ext_method_netscape_comment(void)
228{
229 return &x509v3_ext_netscape_comment;
230}
231
202static char * 232static char *
203i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5) 233i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5)
204{ 234{
diff --git a/src/lib/libcrypto/x509/x509_info.c b/src/lib/libcrypto/x509/x509_info.c
index 9372b066ae..d1de346ee6 100644
--- a/src/lib/libcrypto/x509/x509_info.c
+++ b/src/lib/libcrypto/x509/x509_info.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_info.c,v 1.4 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_info.c,v 1.5 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -71,7 +71,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(
71static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS( 71static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(
72 X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 72 X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
73 73
74const X509V3_EXT_METHOD v3_info = { 74static const X509V3_EXT_METHOD x509v3_ext_info_access = {
75 .ext_nid = NID_info_access, 75 .ext_nid = NID_info_access,
76 .ext_flags = X509V3_EXT_MULTILINE, 76 .ext_flags = X509V3_EXT_MULTILINE,
77 .it = &AUTHORITY_INFO_ACCESS_it, 77 .it = &AUTHORITY_INFO_ACCESS_it,
@@ -88,7 +88,13 @@ const X509V3_EXT_METHOD v3_info = {
88 .usr_data = NULL, 88 .usr_data = NULL,
89}; 89};
90 90
91const X509V3_EXT_METHOD v3_sinfo = { 91const X509V3_EXT_METHOD *
92x509v3_ext_method_info_access(void)
93{
94 return &x509v3_ext_info_access;
95}
96
97static const X509V3_EXT_METHOD x509v3_ext_sinfo_access = {
92 .ext_nid = NID_sinfo_access, 98 .ext_nid = NID_sinfo_access,
93 .ext_flags = X509V3_EXT_MULTILINE, 99 .ext_flags = X509V3_EXT_MULTILINE,
94 .it = &AUTHORITY_INFO_ACCESS_it, 100 .it = &AUTHORITY_INFO_ACCESS_it,
@@ -105,6 +111,12 @@ const X509V3_EXT_METHOD v3_sinfo = {
105 .usr_data = NULL, 111 .usr_data = NULL,
106}; 112};
107 113
114const X509V3_EXT_METHOD *
115x509v3_ext_method_sinfo_access(void)
116{
117 return &x509v3_ext_sinfo_access;
118}
119
108static const ASN1_TEMPLATE ACCESS_DESCRIPTION_seq_tt[] = { 120static const ASN1_TEMPLATE ACCESS_DESCRIPTION_seq_tt[] = {
109 { 121 {
110 .flags = 0, 122 .flags = 0,
diff --git a/src/lib/libcrypto/x509/x509_int.c b/src/lib/libcrypto/x509/x509_int.c
index 35c8853c13..2236bfe4c4 100644
--- a/src/lib/libcrypto/x509/x509_int.c
+++ b/src/lib/libcrypto/x509/x509_int.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_int.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ 1/* $OpenBSD: x509_int.c,v 1.2 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,7 +60,7 @@
60 60
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63const X509V3_EXT_METHOD v3_crl_num = { 63static const X509V3_EXT_METHOD x509v3_ext_crl_number = {
64 .ext_nid = NID_crl_number, 64 .ext_nid = NID_crl_number,
65 .ext_flags = 0, 65 .ext_flags = 0,
66 .it = &ASN1_INTEGER_it, 66 .it = &ASN1_INTEGER_it,
@@ -77,7 +77,13 @@ const X509V3_EXT_METHOD v3_crl_num = {
77 .usr_data = NULL, 77 .usr_data = NULL,
78}; 78};
79 79
80const X509V3_EXT_METHOD v3_delta_crl = { 80const X509V3_EXT_METHOD *
81x509v3_ext_method_crl_number(void)
82{
83 return &x509v3_ext_crl_number;
84}
85
86static const X509V3_EXT_METHOD x509v3_ext_delta_crl = {
81 .ext_nid = NID_delta_crl, 87 .ext_nid = NID_delta_crl,
82 .ext_flags = 0, 88 .ext_flags = 0,
83 .it = &ASN1_INTEGER_it, 89 .it = &ASN1_INTEGER_it,
@@ -94,17 +100,37 @@ const X509V3_EXT_METHOD v3_delta_crl = {
94 .usr_data = NULL, 100 .usr_data = NULL,
95}; 101};
96 102
103const X509V3_EXT_METHOD *
104x509v3_ext_method_delta_crl(void)
105{
106 return &x509v3_ext_delta_crl;
107}
108
97static void * 109static void *
98s2i_asn1_int(X509V3_EXT_METHOD *meth, X509V3_CTX *ctx, char *value) 110s2i_asn1_int(X509V3_EXT_METHOD *meth, X509V3_CTX *ctx, char *value)
99{ 111{
100 return s2i_ASN1_INTEGER(meth, value); 112 return s2i_ASN1_INTEGER(meth, value);
101} 113}
102 114
103const X509V3_EXT_METHOD v3_inhibit_anyp = { 115static const X509V3_EXT_METHOD x509v3_ext_inhibit_any_policy = {
104 NID_inhibit_any_policy, 0, &ASN1_INTEGER_it, 116 .ext_nid = NID_inhibit_any_policy,
105 0, 0, 0, 0, 117 .ext_flags = 0,
106 (X509V3_EXT_I2S)i2s_ASN1_INTEGER, 118 .it = &ASN1_INTEGER_it,
107 (X509V3_EXT_S2I)s2i_asn1_int, 119 .ext_new = NULL,
108 0, 0, 0, 0, 120 .ext_free = NULL,
109 NULL 121 .d2i = NULL,
122 .i2d = NULL,
123 .i2s = (X509V3_EXT_I2S)i2s_ASN1_INTEGER,
124 .s2i = (X509V3_EXT_S2I)s2i_asn1_int,
125 .i2v = NULL,
126 .v2i = NULL,
127 .i2r = NULL,
128 .r2i = NULL,
129 .usr_data = NULL,
110}; 130};
131
132const X509V3_EXT_METHOD *
133x509v3_ext_method_inhibit_any_policy(void)
134{
135 return &x509v3_ext_inhibit_any_policy;
136}
diff --git a/src/lib/libcrypto/x509/x509_lib.c b/src/lib/libcrypto/x509/x509_lib.c
index 8382babbdf..6fa66ab88e 100644
--- a/src/lib/libcrypto/x509/x509_lib.c
+++ b/src/lib/libcrypto/x509/x509_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_lib.c,v 1.23 2024/06/17 05:38:08 tb Exp $ */ 1/* $OpenBSD: x509_lib.c,v 1.24 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -65,89 +65,104 @@
65 65
66#include "x509_local.h" 66#include "x509_local.h"
67 67
68extern const X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku; 68const X509V3_EXT_METHOD *
69extern const X509V3_EXT_METHOD v3_pkey_usage_period, v3_info, v3_sinfo; 69X509V3_EXT_get_nid(int nid)
70extern const X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id; 70{
71extern const X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate; 71 switch (nid) {
72extern const X509V3_EXT_METHOD v3_delta_crl, v3_cpols, v3_crld, v3_freshest_crl; 72 case NID_authority_key_identifier:
73extern const X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, v3_ocsp_acutoff; 73 return x509v3_ext_method_authority_key_identifier();
74extern const X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, v3_ocsp_serviceloc; 74 case NID_basic_constraints:
75extern const X509V3_EXT_METHOD v3_crl_hold; 75 return x509v3_ext_method_basic_constraints();
76extern const X509V3_EXT_METHOD v3_policy_mappings, v3_policy_constraints; 76 case NID_certificate_issuer:
77extern const X509V3_EXT_METHOD v3_name_constraints, v3_inhibit_anyp, v3_idp; 77 return x509v3_ext_method_certificate_issuer();
78extern const X509V3_EXT_METHOD v3_addr, v3_asid; 78 case NID_certificate_policies:
79extern const X509V3_EXT_METHOD v3_ct_scts[3]; 79 return x509v3_ext_method_certificate_policies();
80 80 case NID_crl_distribution_points:
81static const X509V3_EXT_METHOD *standard_exts[] = { 81 return x509v3_ext_method_crl_distribution_points();
82 &v3_nscert, 82 case NID_crl_number:
83 &v3_ns_ia5_list[0], 83 return x509v3_ext_method_crl_number();
84 &v3_ns_ia5_list[1], 84 case NID_crl_reason:
85 &v3_ns_ia5_list[2], 85 return x509v3_ext_method_crl_reason();
86 &v3_ns_ia5_list[3], 86#ifndef OPENSSL_NO_CT
87 &v3_ns_ia5_list[4], 87 case NID_ct_cert_scts:
88 &v3_ns_ia5_list[5], 88 return x509v3_ext_method_ct_cert_scts();
89 &v3_ns_ia5_list[6], 89 case NID_ct_precert_poison:
90 &v3_skey_id, 90 return x509v3_ext_method_ct_precert_poison();
91 &v3_key_usage, 91 case NID_ct_precert_scts:
92 &v3_pkey_usage_period, 92 return x509v3_ext_method_ct_precert_scts();
93 &v3_alt[0],
94 &v3_alt[1],
95 &v3_bcons,
96 &v3_crl_num,
97 &v3_cpols,
98 &v3_akey_id,
99 &v3_crld,
100 &v3_ext_ku,
101 &v3_delta_crl,
102 &v3_crl_reason,
103#ifndef OPENSSL_NO_OCSP
104 &v3_crl_invdate,
105#endif
106 &v3_info,
107#ifndef OPENSSL_NO_RFC3779
108 &v3_addr,
109 &v3_asid,
110#endif
111#ifndef OPENSSL_NO_OCSP
112 &v3_ocsp_nonce,
113 &v3_ocsp_crlid,
114 &v3_ocsp_accresp,
115 &v3_ocsp_nocheck,
116 &v3_ocsp_acutoff,
117 &v3_ocsp_serviceloc,
118#endif 93#endif
119 &v3_sinfo, 94 case NID_delta_crl:
120 &v3_policy_constraints, 95 return x509v3_ext_method_delta_crl();
96 case NID_ext_key_usage:
97 return x509v3_ext_method_ext_key_usage();
98 case NID_freshest_crl:
99 return x509v3_ext_method_freshest_crl();
121#ifndef OPENSSL_NO_OCSP 100#ifndef OPENSSL_NO_OCSP
122 &v3_crl_hold, 101 case NID_hold_instruction_code:
102 return x509v3_ext_method_hold_instruction_code();
103 case NID_id_pkix_OCSP_CrlID:
104 return x509v3_ext_method_id_pkix_OCSP_CrlID();
105 case NID_id_pkix_OCSP_Nonce:
106 return x509v3_ext_method_id_pkix_OCSP_Nonce();
107 case NID_id_pkix_OCSP_acceptableResponses:
108 return x509v3_ext_method_id_pkix_OCSP_acceptableResponses();
109 case NID_id_pkix_OCSP_archiveCutoff:
110 return x509v3_ext_method_id_pkix_OCSP_archiveCutoff();
111 case NID_id_pkix_OCSP_serviceLocator:
112 return x509v3_ext_method_id_pkix_OCSP_serviceLocator();
123#endif 113#endif
124 &v3_name_constraints, 114 case NID_info_access:
125 &v3_policy_mappings, 115 return x509v3_ext_method_info_access();
126 &v3_inhibit_anyp, 116 case NID_inhibit_any_policy:
127 &v3_idp, 117 return x509v3_ext_method_inhibit_any_policy();
128 &v3_alt[2], 118 case NID_invalidity_date:
129 &v3_freshest_crl, 119 return x509v3_ext_method_invalidity_date();
130#ifndef OPENSSL_NO_CT 120 case NID_issuer_alt_name:
131 &v3_ct_scts[0], 121 return x509v3_ext_method_issuer_alt_name();
132 &v3_ct_scts[1], 122 case NID_issuing_distribution_point:
133 &v3_ct_scts[2], 123 return x509v3_ext_method_issuing_distribution_point();
124 case NID_key_usage:
125 return x509v3_ext_method_key_usage();
126 case NID_name_constraints:
127 return x509v3_ext_method_name_constraints();
128 case NID_netscape_base_url:
129 return x509v3_ext_method_netscape_base_url();
130 case NID_netscape_ca_policy_url:
131 return x509v3_ext_method_netscape_ca_policy_url();
132 case NID_netscape_ca_revocation_url:
133 return x509v3_ext_method_netscape_ca_revocation_url();
134 case NID_netscape_cert_type:
135 return x509v3_ext_method_netscape_cert_type();
136 case NID_netscape_comment:
137 return x509v3_ext_method_netscape_comment();
138 case NID_netscape_renewal_url:
139 return x509v3_ext_method_netscape_renewal_url();
140 case NID_netscape_revocation_url:
141 return x509v3_ext_method_netscape_revocation_url();
142 case NID_netscape_ssl_server_name:
143 return x509v3_ext_method_netscape_ssl_server_name();
144 case NID_policy_constraints:
145 return x509v3_ext_method_policy_constraints();
146 case NID_policy_mappings:
147 return x509v3_ext_method_policy_mappings();
148 case NID_private_key_usage_period:
149 return x509v3_ext_method_private_key_usage_period();
150#ifndef OPENSSL_NO_RFC3779
151 case NID_sbgp_ipAddrBlock:
152 return x509v3_ext_method_sbgp_ipAddrBlock();
153 case NID_sbgp_autonomousSysNum:
154 return x509v3_ext_method_sbgp_autonomousSysNum();
134#endif 155#endif
135}; 156 case NID_sinfo_access:
136 157 return x509v3_ext_method_sinfo_access();
137#define STANDARD_EXTENSION_COUNT (sizeof(standard_exts) / sizeof(standard_exts[0])) 158 case NID_subject_alt_name:
138 159 return x509v3_ext_method_subject_alt_name();
139const X509V3_EXT_METHOD * 160 case NID_subject_key_identifier:
140X509V3_EXT_get_nid(int nid) 161 return x509v3_ext_method_subject_key_identifier();
141{ 162 default:
142 size_t i; 163 return NULL;
143
144 for (i = 0; i < STANDARD_EXTENSION_COUNT; i++) {
145 if (standard_exts[i]->ext_nid == nid)
146 return standard_exts[i];
147 } 164 }
148 165};
149 return NULL;
150}
151LCRYPTO_ALIAS(X509V3_EXT_get_nid); 166LCRYPTO_ALIAS(X509V3_EXT_get_nid);
152 167
153const X509V3_EXT_METHOD * 168const X509V3_EXT_METHOD *
diff --git a/src/lib/libcrypto/x509/x509_local.h b/src/lib/libcrypto/x509/x509_local.h
index 6b72678e7a..81a237d860 100644
--- a/src/lib/libcrypto/x509/x509_local.h
+++ b/src/lib/libcrypto/x509/x509_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_local.h,v 1.25 2024/07/12 18:15:10 beck Exp $ */ 1/* $OpenBSD: x509_local.h,v 1.26 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2013. 3 * project 2013.
4 */ 4 */
@@ -418,6 +418,49 @@ X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
418int X509_PURPOSE_get_by_id(int id); 418int X509_PURPOSE_get_by_id(int id);
419int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); 419int X509_PURPOSE_get_trust(const X509_PURPOSE *xp);
420 420
421const X509V3_EXT_METHOD *x509v3_ext_method_authority_key_identifier(void);
422const X509V3_EXT_METHOD *x509v3_ext_method_basic_constraints(void);
423const X509V3_EXT_METHOD *x509v3_ext_method_certificate_issuer(void);
424const X509V3_EXT_METHOD *x509v3_ext_method_certificate_policies(void);
425const X509V3_EXT_METHOD *x509v3_ext_method_crl_distribution_points(void);
426const X509V3_EXT_METHOD *x509v3_ext_method_crl_number(void);
427const X509V3_EXT_METHOD *x509v3_ext_method_crl_reason(void);
428const X509V3_EXT_METHOD *x509v3_ext_method_ct_cert_scts(void);
429const X509V3_EXT_METHOD *x509v3_ext_method_ct_precert_poison(void);
430const X509V3_EXT_METHOD *x509v3_ext_method_ct_precert_scts(void);
431const X509V3_EXT_METHOD *x509v3_ext_method_delta_crl(void);
432const X509V3_EXT_METHOD *x509v3_ext_method_ext_key_usage(void);
433const X509V3_EXT_METHOD *x509v3_ext_method_freshest_crl(void);
434const X509V3_EXT_METHOD *x509v3_ext_method_hold_instruction_code(void);
435const X509V3_EXT_METHOD *x509v3_ext_method_id_pkix_OCSP_CrlID(void);
436const X509V3_EXT_METHOD *x509v3_ext_method_id_pkix_OCSP_Nonce(void);
437const X509V3_EXT_METHOD *x509v3_ext_method_id_pkix_OCSP_acceptableResponses(void);
438const X509V3_EXT_METHOD *x509v3_ext_method_id_pkix_OCSP_archiveCutoff(void);
439const X509V3_EXT_METHOD *x509v3_ext_method_id_pkix_OCSP_serviceLocator(void);
440const X509V3_EXT_METHOD *x509v3_ext_method_info_access(void);
441const X509V3_EXT_METHOD *x509v3_ext_method_inhibit_any_policy(void);
442const X509V3_EXT_METHOD *x509v3_ext_method_invalidity_date(void);
443const X509V3_EXT_METHOD *x509v3_ext_method_issuer_alt_name(void);
444const X509V3_EXT_METHOD *x509v3_ext_method_issuing_distribution_point(void);
445const X509V3_EXT_METHOD *x509v3_ext_method_key_usage(void);
446const X509V3_EXT_METHOD *x509v3_ext_method_name_constraints(void);
447const X509V3_EXT_METHOD *x509v3_ext_method_netscape_base_url(void);
448const X509V3_EXT_METHOD *x509v3_ext_method_netscape_ca_policy_url(void);
449const X509V3_EXT_METHOD *x509v3_ext_method_netscape_ca_revocation_url(void);
450const X509V3_EXT_METHOD *x509v3_ext_method_netscape_cert_type(void);
451const X509V3_EXT_METHOD *x509v3_ext_method_netscape_comment(void);
452const X509V3_EXT_METHOD *x509v3_ext_method_netscape_renewal_url(void);
453const X509V3_EXT_METHOD *x509v3_ext_method_netscape_revocation_url(void);
454const X509V3_EXT_METHOD *x509v3_ext_method_netscape_ssl_server_name(void);
455const X509V3_EXT_METHOD *x509v3_ext_method_policy_constraints(void);
456const X509V3_EXT_METHOD *x509v3_ext_method_policy_mappings(void);
457const X509V3_EXT_METHOD *x509v3_ext_method_private_key_usage_period(void);
458const X509V3_EXT_METHOD *x509v3_ext_method_sbgp_ipAddrBlock(void);
459const X509V3_EXT_METHOD *x509v3_ext_method_sbgp_autonomousSysNum(void);
460const X509V3_EXT_METHOD *x509v3_ext_method_sinfo_access(void);
461const X509V3_EXT_METHOD *x509v3_ext_method_subject_alt_name(void);
462const X509V3_EXT_METHOD *x509v3_ext_method_subject_key_identifier(void);
463
421__END_HIDDEN_DECLS 464__END_HIDDEN_DECLS
422 465
423#endif /* !HEADER_X509_LOCAL_H */ 466#endif /* !HEADER_X509_LOCAL_H */
diff --git a/src/lib/libcrypto/x509/x509_ncons.c b/src/lib/libcrypto/x509/x509_ncons.c
index f8c63886a4..148a66e887 100644
--- a/src/lib/libcrypto/x509/x509_ncons.c
+++ b/src/lib/libcrypto/x509/x509_ncons.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_ncons.c,v 1.10 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_ncons.c,v 1.11 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -81,7 +81,7 @@ static int nc_dns(ASN1_IA5STRING *sub, ASN1_IA5STRING *dns);
81static int nc_email(ASN1_IA5STRING *sub, ASN1_IA5STRING *eml); 81static int nc_email(ASN1_IA5STRING *sub, ASN1_IA5STRING *eml);
82static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base); 82static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base);
83 83
84const X509V3_EXT_METHOD v3_name_constraints = { 84static const X509V3_EXT_METHOD x509v3_ext_name_constraints = {
85 .ext_nid = NID_name_constraints, 85 .ext_nid = NID_name_constraints,
86 .ext_flags = 0, 86 .ext_flags = 0,
87 .it = &NAME_CONSTRAINTS_it, 87 .it = &NAME_CONSTRAINTS_it,
@@ -98,6 +98,12 @@ const X509V3_EXT_METHOD v3_name_constraints = {
98 .usr_data = NULL, 98 .usr_data = NULL,
99}; 99};
100 100
101const X509V3_EXT_METHOD *
102x509v3_ext_method_name_constraints(void)
103{
104 return &x509v3_ext_name_constraints;
105}
106
101static const ASN1_TEMPLATE GENERAL_SUBTREE_seq_tt[] = { 107static const ASN1_TEMPLATE GENERAL_SUBTREE_seq_tt[] = {
102 { 108 {
103 .flags = 0, 109 .flags = 0,
diff --git a/src/lib/libcrypto/x509/x509_ocsp.c b/src/lib/libcrypto/x509/x509_ocsp.c
index cc55d9390d..11d1a1c9c3 100644
--- a/src/lib/libcrypto/x509/x509_ocsp.c
+++ b/src/lib/libcrypto/x509/x509_ocsp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_ocsp.c,v 1.2 2022/01/07 09:45:52 tb Exp $ */ 1/* $OpenBSD: x509_ocsp.c,v 1.3 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -95,7 +95,7 @@ static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
95static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, 95static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in,
96 BIO *bp, int ind); 96 BIO *bp, int ind);
97 97
98const X509V3_EXT_METHOD v3_ocsp_crlid = { 98static const X509V3_EXT_METHOD x509v3_ext_id_pkix_OCSP_CrlID = {
99 .ext_nid = NID_id_pkix_OCSP_CrlID, 99 .ext_nid = NID_id_pkix_OCSP_CrlID,
100 .ext_flags = 0, 100 .ext_flags = 0,
101 .it = &OCSP_CRLID_it, 101 .it = &OCSP_CRLID_it,
@@ -112,7 +112,13 @@ const X509V3_EXT_METHOD v3_ocsp_crlid = {
112 .usr_data = NULL, 112 .usr_data = NULL,
113}; 113};
114 114
115const X509V3_EXT_METHOD v3_ocsp_acutoff = { 115const X509V3_EXT_METHOD *
116x509v3_ext_method_id_pkix_OCSP_CrlID(void)
117{
118 return &x509v3_ext_id_pkix_OCSP_CrlID;
119}
120
121const X509V3_EXT_METHOD x509v3_ext_id_pkix_OCSP_archiveCutoff = {
116 .ext_nid = NID_id_pkix_OCSP_archiveCutoff, 122 .ext_nid = NID_id_pkix_OCSP_archiveCutoff,
117 .ext_flags = 0, 123 .ext_flags = 0,
118 .it = &ASN1_GENERALIZEDTIME_it, 124 .it = &ASN1_GENERALIZEDTIME_it,
@@ -129,7 +135,13 @@ const X509V3_EXT_METHOD v3_ocsp_acutoff = {
129 .usr_data = NULL, 135 .usr_data = NULL,
130}; 136};
131 137
132const X509V3_EXT_METHOD v3_crl_invdate = { 138const X509V3_EXT_METHOD *
139x509v3_ext_method_id_pkix_OCSP_archiveCutoff(void)
140{
141 return &x509v3_ext_id_pkix_OCSP_archiveCutoff;
142}
143
144static const X509V3_EXT_METHOD x509v3_ext_invalidity_date = {
133 .ext_nid = NID_invalidity_date, 145 .ext_nid = NID_invalidity_date,
134 .ext_flags = 0, 146 .ext_flags = 0,
135 .it = &ASN1_GENERALIZEDTIME_it, 147 .it = &ASN1_GENERALIZEDTIME_it,
@@ -146,7 +158,13 @@ const X509V3_EXT_METHOD v3_crl_invdate = {
146 .usr_data = NULL, 158 .usr_data = NULL,
147}; 159};
148 160
149const X509V3_EXT_METHOD v3_crl_hold = { 161const X509V3_EXT_METHOD *
162x509v3_ext_method_invalidity_date(void)
163{
164 return &x509v3_ext_invalidity_date;
165}
166
167static const X509V3_EXT_METHOD x509v3_ext_hold_instruction_code = {
150 .ext_nid = NID_hold_instruction_code, 168 .ext_nid = NID_hold_instruction_code,
151 .ext_flags = 0, 169 .ext_flags = 0,
152 .it = &ASN1_OBJECT_it, 170 .it = &ASN1_OBJECT_it,
@@ -163,7 +181,13 @@ const X509V3_EXT_METHOD v3_crl_hold = {
163 .usr_data = NULL, 181 .usr_data = NULL,
164}; 182};
165 183
166const X509V3_EXT_METHOD v3_ocsp_nonce = { 184const X509V3_EXT_METHOD *
185x509v3_ext_method_hold_instruction_code(void)
186{
187 return &x509v3_ext_hold_instruction_code;
188}
189
190static const X509V3_EXT_METHOD x509v3_ext_id_pkix_OCSP_Nonce = {
167 .ext_nid = NID_id_pkix_OCSP_Nonce, 191 .ext_nid = NID_id_pkix_OCSP_Nonce,
168 .ext_flags = 0, 192 .ext_flags = 0,
169 .it = NULL, 193 .it = NULL,
@@ -180,7 +204,13 @@ const X509V3_EXT_METHOD v3_ocsp_nonce = {
180 .usr_data = NULL, 204 .usr_data = NULL,
181}; 205};
182 206
183const X509V3_EXT_METHOD v3_ocsp_nocheck = { 207const X509V3_EXT_METHOD *
208x509v3_ext_method_id_pkix_OCSP_Nonce(void)
209{
210 return &x509v3_ext_id_pkix_OCSP_Nonce;
211}
212
213static const X509V3_EXT_METHOD x509v3_ext_id_pkix_OCSP_noCheck = {
184 .ext_nid = NID_id_pkix_OCSP_noCheck, 214 .ext_nid = NID_id_pkix_OCSP_noCheck,
185 .ext_flags = 0, 215 .ext_flags = 0,
186 .it = &ASN1_NULL_it, 216 .it = &ASN1_NULL_it,
@@ -197,7 +227,13 @@ const X509V3_EXT_METHOD v3_ocsp_nocheck = {
197 .usr_data = NULL, 227 .usr_data = NULL,
198}; 228};
199 229
200const X509V3_EXT_METHOD v3_ocsp_serviceloc = { 230const X509V3_EXT_METHOD *
231x509v3_ext_method_id_pkix_OCSP_noCheck(void)
232{
233 return &x509v3_ext_id_pkix_OCSP_noCheck;
234}
235
236static const X509V3_EXT_METHOD x509v3_ext_id_pkix_OCSP_serviceLocator = {
201 .ext_nid = NID_id_pkix_OCSP_serviceLocator, 237 .ext_nid = NID_id_pkix_OCSP_serviceLocator,
202 .ext_flags = 0, 238 .ext_flags = 0,
203 .it = &OCSP_SERVICELOC_it, 239 .it = &OCSP_SERVICELOC_it,
@@ -214,6 +250,12 @@ const X509V3_EXT_METHOD v3_ocsp_serviceloc = {
214 .usr_data = NULL, 250 .usr_data = NULL,
215}; 251};
216 252
253const X509V3_EXT_METHOD *
254x509v3_ext_method_id_pkix_OCSP_serviceLocator(void)
255{
256 return &x509v3_ext_id_pkix_OCSP_serviceLocator;
257}
258
217static int 259static int
218i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) 260i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind)
219{ 261{
diff --git a/src/lib/libcrypto/x509/x509_pcons.c b/src/lib/libcrypto/x509/x509_pcons.c
index 8f2109eaad..d6ee9d7e2c 100644
--- a/src/lib/libcrypto/x509/x509_pcons.c
+++ b/src/lib/libcrypto/x509/x509_pcons.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_pcons.c,v 1.4 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_pcons.c,v 1.5 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -71,7 +71,7 @@ i2v_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, void *bcons,
71static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, 71static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method,
72 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); 72 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
73 73
74const X509V3_EXT_METHOD v3_policy_constraints = { 74static const X509V3_EXT_METHOD x509v3_ext_policy_constraints = {
75 .ext_nid = NID_policy_constraints, 75 .ext_nid = NID_policy_constraints,
76 .ext_flags = 0, 76 .ext_flags = 0,
77 .it = &POLICY_CONSTRAINTS_it, 77 .it = &POLICY_CONSTRAINTS_it,
@@ -88,6 +88,12 @@ const X509V3_EXT_METHOD v3_policy_constraints = {
88 .usr_data = NULL, 88 .usr_data = NULL,
89}; 89};
90 90
91const X509V3_EXT_METHOD *
92x509v3_ext_method_policy_constraints(void)
93{
94 return &x509v3_ext_policy_constraints;
95}
96
91static const ASN1_TEMPLATE POLICY_CONSTRAINTS_seq_tt[] = { 97static const ASN1_TEMPLATE POLICY_CONSTRAINTS_seq_tt[] = {
92 { 98 {
93 .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, 99 .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL,
diff --git a/src/lib/libcrypto/x509/x509_pku.c b/src/lib/libcrypto/x509/x509_pku.c
index 05c9ff2431..6753f0f733 100644
--- a/src/lib/libcrypto/x509/x509_pku.c
+++ b/src/lib/libcrypto/x509/x509_pku.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_pku.c,v 1.4 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_pku.c,v 1.5 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -65,7 +65,7 @@
65static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, 65static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
66 PKEY_USAGE_PERIOD *usage, BIO *out, int indent); 66 PKEY_USAGE_PERIOD *usage, BIO *out, int indent);
67 67
68const X509V3_EXT_METHOD v3_pkey_usage_period = { 68static const X509V3_EXT_METHOD x509v3_ext_private_key_usage_period = {
69 .ext_nid = NID_private_key_usage_period, 69 .ext_nid = NID_private_key_usage_period,
70 .ext_flags = 0, 70 .ext_flags = 0,
71 .it = &PKEY_USAGE_PERIOD_it, 71 .it = &PKEY_USAGE_PERIOD_it,
@@ -82,6 +82,12 @@ const X509V3_EXT_METHOD v3_pkey_usage_period = {
82 .usr_data = NULL, 82 .usr_data = NULL,
83}; 83};
84 84
85const X509V3_EXT_METHOD *
86x509v3_ext_method_private_key_usage_period(void)
87{
88 return &x509v3_ext_private_key_usage_period;
89}
90
85static const ASN1_TEMPLATE PKEY_USAGE_PERIOD_seq_tt[] = { 91static const ASN1_TEMPLATE PKEY_USAGE_PERIOD_seq_tt[] = {
86 { 92 {
87 .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, 93 .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL,
diff --git a/src/lib/libcrypto/x509/x509_pmaps.c b/src/lib/libcrypto/x509/x509_pmaps.c
index b2d74dce1d..7a91917f65 100644
--- a/src/lib/libcrypto/x509/x509_pmaps.c
+++ b/src/lib/libcrypto/x509/x509_pmaps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_pmaps.c,v 1.4 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_pmaps.c,v 1.5 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -69,7 +69,7 @@ static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method,
69static STACK_OF(CONF_VALUE) *i2v_POLICY_MAPPINGS( 69static STACK_OF(CONF_VALUE) *i2v_POLICY_MAPPINGS(
70 const X509V3_EXT_METHOD *method, void *pmps, STACK_OF(CONF_VALUE) *extlist); 70 const X509V3_EXT_METHOD *method, void *pmps, STACK_OF(CONF_VALUE) *extlist);
71 71
72const X509V3_EXT_METHOD v3_policy_mappings = { 72static const X509V3_EXT_METHOD x509v3_ext_policy_mappings = {
73 .ext_nid = NID_policy_mappings, 73 .ext_nid = NID_policy_mappings,
74 .ext_flags = 0, 74 .ext_flags = 0,
75 .it = &POLICY_MAPPINGS_it, 75 .it = &POLICY_MAPPINGS_it,
@@ -86,6 +86,12 @@ const X509V3_EXT_METHOD v3_policy_mappings = {
86 .usr_data = NULL, 86 .usr_data = NULL,
87}; 87};
88 88
89const X509V3_EXT_METHOD *
90x509v3_ext_method_policy_mappings(void)
91{
92 return &x509v3_ext_policy_mappings;
93}
94
89static const ASN1_TEMPLATE POLICY_MAPPING_seq_tt[] = { 95static const ASN1_TEMPLATE POLICY_MAPPING_seq_tt[] = {
90 { 96 {
91 .flags = 0, 97 .flags = 0,
diff --git a/src/lib/libcrypto/x509/x509_skey.c b/src/lib/libcrypto/x509/x509_skey.c
index 245ba51586..d2c90b6f1c 100644
--- a/src/lib/libcrypto/x509/x509_skey.c
+++ b/src/lib/libcrypto/x509/x509_skey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_skey.c,v 1.5 2023/02/16 08:38:17 tb Exp $ */ 1/* $OpenBSD: x509_skey.c,v 1.6 2024/07/13 15:08:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -67,7 +67,7 @@
67static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, 67static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
68 X509V3_CTX *ctx, char *str); 68 X509V3_CTX *ctx, char *str);
69 69
70const X509V3_EXT_METHOD v3_skey_id = { 70static const X509V3_EXT_METHOD x509v3_ext_subject_key_identifier = {
71 .ext_nid = NID_subject_key_identifier, 71 .ext_nid = NID_subject_key_identifier,
72 .ext_flags = 0, 72 .ext_flags = 0,
73 .it = &ASN1_OCTET_STRING_it, 73 .it = &ASN1_OCTET_STRING_it,
@@ -84,6 +84,12 @@ const X509V3_EXT_METHOD v3_skey_id = {
84 .usr_data = NULL, 84 .usr_data = NULL,
85}; 85};
86 86
87const X509V3_EXT_METHOD *
88x509v3_ext_method_subject_key_identifier(void)
89{
90 return &x509v3_ext_subject_key_identifier;
91}
92
87char * 93char *
88i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, const ASN1_OCTET_STRING *oct) 94i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, const ASN1_OCTET_STRING *oct)
89{ 95{