diff options
author | tb <> | 2024-07-13 15:08:58 +0000 |
---|---|---|
committer | tb <> | 2024-07-13 15:08:58 +0000 |
commit | de05eb4f597b95fed408db9aa9e9474eb6daf5e6 (patch) | |
tree | 9bceb8f53165bf9b9a2232987ecac3565db027df /src/lib/libcrypto/x509/x509_ocsp.c | |
parent | d694a3319273a6e59cc84d958713e0342bfc206d (diff) | |
download | openbsd-de05eb4f597b95fed408db9aa9e9474eb6daf5e6.tar.gz openbsd-de05eb4f597b95fed408db9aa9e9474eb6daf5e6.tar.bz2 openbsd-de05eb4f597b95fed408db9aa9e9474eb6daf5e6.zip |
Unify X.509v3 extension methods
Use C99 initializers for all structs (some were forgotten).
Make all the structs static, call them x509v3_ext_* matching NID_*.
Add accessors called x509v3_ext_method_* and use these to implement
X509V3_EXT_get_nid().
This adds consistency and avoids a few contortions like grouping
a few extensions in arrays to save a couple externs.
ok beck jsing
Diffstat (limited to 'src/lib/libcrypto/x509/x509_ocsp.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_ocsp.c | 58 |
1 files changed, 50 insertions, 8 deletions
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, | |||
95 | static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, | 95 | static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, |
96 | BIO *bp, int ind); | 96 | BIO *bp, int ind); |
97 | 97 | ||
98 | const X509V3_EXT_METHOD v3_ocsp_crlid = { | 98 | static 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 | ||
115 | const X509V3_EXT_METHOD v3_ocsp_acutoff = { | 115 | const X509V3_EXT_METHOD * |
116 | x509v3_ext_method_id_pkix_OCSP_CrlID(void) | ||
117 | { | ||
118 | return &x509v3_ext_id_pkix_OCSP_CrlID; | ||
119 | } | ||
120 | |||
121 | const 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 | ||
132 | const X509V3_EXT_METHOD v3_crl_invdate = { | 138 | const X509V3_EXT_METHOD * |
139 | x509v3_ext_method_id_pkix_OCSP_archiveCutoff(void) | ||
140 | { | ||
141 | return &x509v3_ext_id_pkix_OCSP_archiveCutoff; | ||
142 | } | ||
143 | |||
144 | static 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 | ||
149 | const X509V3_EXT_METHOD v3_crl_hold = { | 161 | const X509V3_EXT_METHOD * |
162 | x509v3_ext_method_invalidity_date(void) | ||
163 | { | ||
164 | return &x509v3_ext_invalidity_date; | ||
165 | } | ||
166 | |||
167 | static 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 | ||
166 | const X509V3_EXT_METHOD v3_ocsp_nonce = { | 184 | const X509V3_EXT_METHOD * |
185 | x509v3_ext_method_hold_instruction_code(void) | ||
186 | { | ||
187 | return &x509v3_ext_hold_instruction_code; | ||
188 | } | ||
189 | |||
190 | static 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 | ||
183 | const X509V3_EXT_METHOD v3_ocsp_nocheck = { | 207 | const X509V3_EXT_METHOD * |
208 | x509v3_ext_method_id_pkix_OCSP_Nonce(void) | ||
209 | { | ||
210 | return &x509v3_ext_id_pkix_OCSP_Nonce; | ||
211 | } | ||
212 | |||
213 | static 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 | ||
200 | const X509V3_EXT_METHOD v3_ocsp_serviceloc = { | 230 | const X509V3_EXT_METHOD * |
231 | x509v3_ext_method_id_pkix_OCSP_noCheck(void) | ||
232 | { | ||
233 | return &x509v3_ext_id_pkix_OCSP_noCheck; | ||
234 | } | ||
235 | |||
236 | static 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 | ||
253 | const X509V3_EXT_METHOD * | ||
254 | x509v3_ext_method_id_pkix_OCSP_serviceLocator(void) | ||
255 | { | ||
256 | return &x509v3_ext_id_pkix_OCSP_serviceLocator; | ||
257 | } | ||
258 | |||
217 | static int | 259 | static int |
218 | i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) | 260 | i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) |
219 | { | 261 | { |