summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x509_ocsp.c
diff options
context:
space:
mode:
authortb <>2024-07-13 15:08:58 +0000
committertb <>2024-07-13 15:08:58 +0000
commitde05eb4f597b95fed408db9aa9e9474eb6daf5e6 (patch)
tree9bceb8f53165bf9b9a2232987ecac3565db027df /src/lib/libcrypto/x509/x509_ocsp.c
parentd694a3319273a6e59cc84d958713e0342bfc206d (diff)
downloadopenbsd-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.c58
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,
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{