diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn1t.h | 494 | ||||
| -rw-r--r-- | src/lib/libcrypto/stack/stack.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/x509/x509_utl.c | 6 |
3 files changed, 285 insertions, 219 deletions
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h index 655e01ab6a..5ed7cb97f5 100644 --- a/src/lib/libcrypto/asn1/asn1t.h +++ b/src/lib/libcrypto/asn1/asn1t.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: asn1t.h,v 1.26 2026/01/09 03:34:30 tb Exp $ */ | 1 | /* $OpenBSD: asn1t.h,v 1.28 2026/01/11 07:52:34 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 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -78,44 +78,44 @@ extern "C" { | |||
| 78 | 78 | ||
| 79 | /* Macros for start and end of ASN1_ITEM definition */ | 79 | /* Macros for start and end of ASN1_ITEM definition */ |
| 80 | 80 | ||
| 81 | #define ASN1_ITEM_start(itname) \ | 81 | #define ASN1_ITEM_start(itname) \ |
| 82 | const ASN1_ITEM itname##_it = { | 82 | const ASN1_ITEM itname##_it = { |
| 83 | 83 | ||
| 84 | #define static_ASN1_ITEM_start(itname) \ | 84 | #define static_ASN1_ITEM_start(itname) \ |
| 85 | static const ASN1_ITEM itname##_it = { | 85 | static const ASN1_ITEM itname##_it = { |
| 86 | 86 | ||
| 87 | #define ASN1_ITEM_end(itname) \ | 87 | #define ASN1_ITEM_end(itname) \ |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | 91 | ||
| 92 | /* Macros to aid ASN1 template writing */ | 92 | /* Macros to aid ASN1 template writing */ |
| 93 | 93 | ||
| 94 | #define ASN1_ITEM_TEMPLATE(tname) \ | 94 | #define ASN1_ITEM_TEMPLATE(tname) \ |
| 95 | static const ASN1_TEMPLATE tname##_item_tt | 95 | static const ASN1_TEMPLATE tname##_item_tt |
| 96 | 96 | ||
| 97 | #define ASN1_ITEM_TEMPLATE_END(tname) \ | 97 | #define ASN1_ITEM_TEMPLATE_END(tname) \ |
| 98 | ;\ | 98 | ; \ |
| 99 | ASN1_ITEM_start(tname) \ | 99 | ASN1_ITEM_start(tname) \ |
| 100 | ASN1_ITYPE_PRIMITIVE,\ | 100 | .itype = ASN1_ITYPE_PRIMITIVE, \ |
| 101 | -1,\ | 101 | .utype = -1, \ |
| 102 | &tname##_item_tt,\ | 102 | .templates = &tname##_item_tt, \ |
| 103 | 0,\ | 103 | .tcount = 0, \ |
| 104 | NULL,\ | 104 | .funcs = NULL, \ |
| 105 | 0,\ | 105 | .size = 0, \ |
| 106 | #tname \ | 106 | .sname = #tname, \ |
| 107 | ASN1_ITEM_end(tname) | 107 | ASN1_ITEM_end(tname) |
| 108 | 108 | ||
| 109 | #define static_ASN1_ITEM_TEMPLATE_END(tname) \ | 109 | #define static_ASN1_ITEM_TEMPLATE_END(tname) \ |
| 110 | ;\ | 110 | ; \ |
| 111 | static_ASN1_ITEM_start(tname) \ | 111 | static_ASN1_ITEM_start(tname) \ |
| 112 | ASN1_ITYPE_PRIMITIVE,\ | 112 | .itype = ASN1_ITYPE_PRIMITIVE, \ |
| 113 | -1,\ | 113 | .utype = -1, \ |
| 114 | &tname##_item_tt,\ | 114 | .templates = &tname##_item_tt, \ |
| 115 | 0,\ | 115 | .tcount = 0, \ |
| 116 | NULL,\ | 116 | .funcs = NULL, \ |
| 117 | 0,\ | 117 | .size = 0, \ |
| 118 | #tname \ | 118 | .sname = #tname, \ |
| 119 | ASN1_ITEM_end(tname) | 119 | ASN1_ITEM_end(tname) |
| 120 | 120 | ||
| 121 | 121 | ||
| @@ -142,77 +142,98 @@ extern "C" { | |||
| 142 | * a structure called stname. | 142 | * a structure called stname. |
| 143 | */ | 143 | */ |
| 144 | 144 | ||
| 145 | #define ASN1_SEQUENCE(tname) \ | 145 | #define ASN1_SEQUENCE(tname) \ |
| 146 | static const ASN1_TEMPLATE tname##_seq_tt[] | 146 | static const ASN1_TEMPLATE tname##_seq_tt[] |
| 147 | 147 | ||
| 148 | #define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) | 148 | #define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) |
| 149 | 149 | ||
| 150 | #define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname) | 150 | #define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname) |
| 151 | 151 | ||
| 152 | #define ASN1_SEQUENCE_END_name(stname, tname) \ | 152 | #define ASN1_SEQUENCE_END_name(stname, tname) \ |
| 153 | ;\ | 153 | ; \ |
| 154 | ASN1_ITEM_start(tname) \ | 154 | ASN1_ITEM_start(tname) \ |
| 155 | ASN1_ITYPE_SEQUENCE,\ | 155 | .itype = ASN1_ITYPE_SEQUENCE, \ |
| 156 | V_ASN1_SEQUENCE,\ | 156 | .utype = V_ASN1_SEQUENCE, \ |
| 157 | tname##_seq_tt,\ | 157 | .templates = tname##_seq_tt, \ |
| 158 | sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ | 158 | .tcount = sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
| 159 | NULL,\ | 159 | .funcs = NULL, \ |
| 160 | sizeof(stname),\ | 160 | .size = sizeof(stname), \ |
| 161 | #stname \ | 161 | .sname = #stname, \ |
| 162 | ASN1_ITEM_end(tname) | 162 | ASN1_ITEM_end(tname) |
| 163 | 163 | ||
| 164 | #define static_ASN1_SEQUENCE_END_name(stname, tname) \ | 164 | #define static_ASN1_SEQUENCE_END_name(stname, tname) \ |
| 165 | ;\ | 165 | ; \ |
| 166 | static_ASN1_ITEM_start(tname) \ | 166 | static_ASN1_ITEM_start(tname) \ |
| 167 | ASN1_ITYPE_SEQUENCE,\ | 167 | .itype = ASN1_ITYPE_SEQUENCE, \ |
| 168 | V_ASN1_SEQUENCE,\ | 168 | .utype = V_ASN1_SEQUENCE, \ |
| 169 | tname##_seq_tt,\ | 169 | .templates = tname##_seq_tt, \ |
| 170 | sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ | 170 | .tcount = sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
| 171 | NULL,\ | 171 | .funcs = NULL, \ |
| 172 | sizeof(stname),\ | 172 | .size = sizeof(stname), \ |
| 173 | #stname \ | 173 | .sname = #stname, \ |
| 174 | ASN1_ITEM_end(tname) | 174 | ASN1_ITEM_end(tname) |
| 175 | 175 | ||
| 176 | #define ASN1_NDEF_SEQUENCE(tname) \ | 176 | #define ASN1_NDEF_SEQUENCE(tname) \ |
| 177 | ASN1_SEQUENCE(tname) | 177 | ASN1_SEQUENCE(tname) |
| 178 | 178 | ||
| 179 | #define ASN1_NDEF_SEQUENCE_cb(tname, cb) \ | 179 | #define ASN1_NDEF_SEQUENCE_cb(tname, cb) \ |
| 180 | ASN1_SEQUENCE_cb(tname, cb) | 180 | ASN1_SEQUENCE_cb(tname, cb) |
| 181 | 181 | ||
| 182 | #define ASN1_SEQUENCE_cb(tname, cb) \ | 182 | #define ASN1_SEQUENCE_cb(tname, cb) \ |
| 183 | static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ | 183 | static const ASN1_AUX tname##_aux = { \ |
| 184 | .app_data = NULL, \ | ||
| 185 | .flags = 0, \ | ||
| 186 | .ref_offset = 0, \ | ||
| 187 | .ref_lock = 0, \ | ||
| 188 | .asn1_cb = cb, \ | ||
| 189 | .enc_offset = 0, \ | ||
| 190 | }; \ | ||
| 184 | ASN1_SEQUENCE(tname) | 191 | ASN1_SEQUENCE(tname) |
| 185 | 192 | ||
| 186 | #define ASN1_SEQUENCE_ref(tname, cb, lck) \ | 193 | #define ASN1_SEQUENCE_ref(tname, cb, lck) \ |
| 187 | static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \ | 194 | static const ASN1_AUX tname##_aux = { \ |
| 195 | .app_data = NULL, \ | ||
| 196 | .flags = ASN1_AFLG_REFCOUNT, \ | ||
| 197 | .ref_offset = offsetof(tname, references), \ | ||
| 198 | .ref_lock = lck, \ | ||
| 199 | .asn1_cb = cb, \ | ||
| 200 | .enc_offset = 0, \ | ||
| 201 | }; \ | ||
| 188 | ASN1_SEQUENCE(tname) | 202 | ASN1_SEQUENCE(tname) |
| 189 | 203 | ||
| 190 | #define ASN1_SEQUENCE_enc(tname, enc, cb) \ | 204 | #define ASN1_SEQUENCE_enc(tname, enc, cb) \ |
| 191 | static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ | 205 | static const ASN1_AUX tname##_aux = { \ |
| 206 | .app_data = NULL, \ | ||
| 207 | .flags = ASN1_AFLG_ENCODING, \ | ||
| 208 | .ref_offset = 0, \ | ||
| 209 | .ref_lock = 0, \ | ||
| 210 | .asn1_cb = cb, \ | ||
| 211 | .enc_offset = offsetof(tname, enc), \ | ||
| 212 | }; \ | ||
| 192 | ASN1_SEQUENCE(tname) | 213 | ASN1_SEQUENCE(tname) |
| 193 | 214 | ||
| 194 | #define ASN1_NDEF_SEQUENCE_END(tname) \ | 215 | #define ASN1_NDEF_SEQUENCE_END(tname) \ |
| 195 | ;\ | 216 | ; \ |
| 196 | ASN1_ITEM_start(tname) \ | 217 | ASN1_ITEM_start(tname) \ |
| 197 | ASN1_ITYPE_NDEF_SEQUENCE,\ | 218 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, \ |
| 198 | V_ASN1_SEQUENCE,\ | 219 | .utype = V_ASN1_SEQUENCE, \ |
| 199 | tname##_seq_tt,\ | 220 | .templates = tname##_seq_tt, \ |
| 200 | sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ | 221 | .tcount = sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
| 201 | NULL,\ | 222 | .funcs = NULL, \ |
| 202 | sizeof(tname),\ | 223 | .size = sizeof(tname), \ |
| 203 | #tname \ | 224 | .sname = #tname, \ |
| 204 | ASN1_ITEM_end(tname) | 225 | ASN1_ITEM_end(tname) |
| 205 | 226 | ||
| 206 | #define static_ASN1_NDEF_SEQUENCE_END(tname) \ | 227 | #define static_ASN1_NDEF_SEQUENCE_END(tname) \ |
| 207 | ;\ | 228 | ; \ |
| 208 | static_ASN1_ITEM_start(tname) \ | 229 | static_ASN1_ITEM_start(tname) \ |
| 209 | ASN1_ITYPE_NDEF_SEQUENCE,\ | 230 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, \ |
| 210 | V_ASN1_SEQUENCE,\ | 231 | .utype = V_ASN1_SEQUENCE, \ |
| 211 | tname##_seq_tt,\ | 232 | .templates = tname##_seq_tt, \ |
| 212 | sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ | 233 | .tcount = sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
| 213 | NULL,\ | 234 | .funcs = NULL, \ |
| 214 | sizeof(tname),\ | 235 | .size = sizeof(tname), \ |
| 215 | #tname \ | 236 | .sname = #tname, \ |
| 216 | ASN1_ITEM_end(tname) | 237 | ASN1_ITEM_end(tname) |
| 217 | 238 | ||
| 218 | #define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) | 239 | #define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) |
| @@ -221,40 +242,40 @@ extern "C" { | |||
| 221 | 242 | ||
| 222 | #define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname) | 243 | #define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname) |
| 223 | 244 | ||
| 224 | #define ASN1_SEQUENCE_END_ref(stname, tname) \ | 245 | #define ASN1_SEQUENCE_END_ref(stname, tname) \ |
| 225 | ;\ | 246 | ; \ |
| 226 | ASN1_ITEM_start(tname) \ | 247 | ASN1_ITEM_start(tname) \ |
| 227 | ASN1_ITYPE_SEQUENCE,\ | 248 | .itype = ASN1_ITYPE_SEQUENCE, \ |
| 228 | V_ASN1_SEQUENCE,\ | 249 | .utype = V_ASN1_SEQUENCE, \ |
| 229 | tname##_seq_tt,\ | 250 | .templates = tname##_seq_tt, \ |
| 230 | sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ | 251 | .tcount = sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
| 231 | &tname##_aux,\ | 252 | .funcs = &tname##_aux, \ |
| 232 | sizeof(stname),\ | 253 | .size = sizeof(stname), \ |
| 233 | #stname \ | 254 | .sname = #stname, \ |
| 234 | ASN1_ITEM_end(tname) | 255 | ASN1_ITEM_end(tname) |
| 235 | 256 | ||
| 236 | #define static_ASN1_SEQUENCE_END_ref(stname, tname) \ | 257 | #define static_ASN1_SEQUENCE_END_ref(stname, tname) \ |
| 237 | ;\ | 258 | ; \ |
| 238 | static_ASN1_ITEM_start(tname) \ | 259 | static_ASN1_ITEM_start(tname) \ |
| 239 | ASN1_ITYPE_SEQUENCE,\ | 260 | .itype = ASN1_ITYPE_SEQUENCE, \ |
| 240 | V_ASN1_SEQUENCE,\ | 261 | .utype = V_ASN1_SEQUENCE, \ |
| 241 | tname##_seq_tt,\ | 262 | .templates = tname##_seq_tt, \ |
| 242 | sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ | 263 | .tcount = sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
| 243 | &tname##_aux,\ | 264 | .funcs = &tname##_aux, \ |
| 244 | sizeof(stname),\ | 265 | .size = sizeof(stname), \ |
| 245 | #stname \ | 266 | .sname = #stname, \ |
| 246 | ASN1_ITEM_end(tname) | 267 | ASN1_ITEM_end(tname) |
| 247 | 268 | ||
| 248 | #define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ | 269 | #define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ |
| 249 | ;\ | 270 | ; \ |
| 250 | ASN1_ITEM_start(tname) \ | 271 | ASN1_ITEM_start(tname) \ |
| 251 | ASN1_ITYPE_NDEF_SEQUENCE,\ | 272 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, \ |
| 252 | V_ASN1_SEQUENCE,\ | 273 | .utype = V_ASN1_SEQUENCE, \ |
| 253 | tname##_seq_tt,\ | 274 | .templates = tname##_seq_tt, \ |
| 254 | sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ | 275 | .tcount = sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ |
| 255 | &tname##_aux,\ | 276 | .funcs = &tname##_aux, \ |
| 256 | sizeof(stname),\ | 277 | .size = sizeof(stname), \ |
| 257 | #stname \ | 278 | .sname = #stname, \ |
| 258 | ASN1_ITEM_end(tname) | 279 | ASN1_ITEM_end(tname) |
| 259 | 280 | ||
| 260 | 281 | ||
| @@ -281,11 +302,18 @@ extern "C" { | |||
| 281 | * ASN1_CHOICE_END_selector() version. | 302 | * ASN1_CHOICE_END_selector() version. |
| 282 | */ | 303 | */ |
| 283 | 304 | ||
| 284 | #define ASN1_CHOICE(tname) \ | 305 | #define ASN1_CHOICE(tname) \ |
| 285 | static const ASN1_TEMPLATE tname##_ch_tt[] | 306 | static const ASN1_TEMPLATE tname##_ch_tt[] |
| 286 | 307 | ||
| 287 | #define ASN1_CHOICE_cb(tname, cb) \ | 308 | #define ASN1_CHOICE_cb(tname, cb) \ |
| 288 | static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ | 309 | static const ASN1_AUX tname##_aux = { \ |
| 310 | .app_data = NULL, \ | ||
| 311 | .flags = 0, \ | ||
| 312 | .ref_offset = 0, \ | ||
| 313 | .ref_lock = 0, \ | ||
| 314 | .asn1_cb = cb, \ | ||
| 315 | .enc_offset = 0, \ | ||
| 316 | }; \ | ||
| 289 | ASN1_CHOICE(tname) | 317 | ASN1_CHOICE(tname) |
| 290 | 318 | ||
| 291 | #define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) | 319 | #define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) |
| @@ -296,153 +324,183 @@ extern "C" { | |||
| 296 | 324 | ||
| 297 | #define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type) | 325 | #define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type) |
| 298 | 326 | ||
| 299 | #define ASN1_CHOICE_END_selector(stname, tname, selname) \ | 327 | #define ASN1_CHOICE_END_selector(stname, tname, selname) \ |
| 300 | ;\ | 328 | ; \ |
| 301 | ASN1_ITEM_start(tname) \ | 329 | ASN1_ITEM_start(tname) \ |
| 302 | ASN1_ITYPE_CHOICE,\ | 330 | .itype = ASN1_ITYPE_CHOICE, \ |
| 303 | offsetof(stname,selname) ,\ | 331 | .utype = offsetof(stname,selname), \ |
| 304 | tname##_ch_tt,\ | 332 | .templates = tname##_ch_tt, \ |
| 305 | sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ | 333 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
| 306 | NULL,\ | 334 | .funcs = NULL, \ |
| 307 | sizeof(stname),\ | 335 | .size = sizeof(stname), \ |
| 308 | #stname \ | 336 | .sname = #stname, \ |
| 309 | ASN1_ITEM_end(tname) | 337 | ASN1_ITEM_end(tname) |
| 310 | 338 | ||
| 311 | #define static_ASN1_CHOICE_END_selector(stname, tname, selname) \ | 339 | #define static_ASN1_CHOICE_END_selector(stname, tname, selname) \ |
| 312 | ;\ | 340 | ; \ |
| 313 | static_ASN1_ITEM_start(tname) \ | 341 | static_ASN1_ITEM_start(tname) \ |
| 314 | ASN1_ITYPE_CHOICE,\ | 342 | .itype = ASN1_ITYPE_CHOICE, \ |
| 315 | offsetof(stname,selname) ,\ | 343 | .utype = offsetof(stname,selname), \ |
| 316 | tname##_ch_tt,\ | 344 | .templates = tname##_ch_tt, \ |
| 317 | sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ | 345 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
| 318 | NULL,\ | 346 | .funcs = NULL, \ |
| 319 | sizeof(stname),\ | 347 | .size = sizeof(stname), \ |
| 320 | #stname \ | 348 | .sname = #stname, \ |
| 321 | ASN1_ITEM_end(tname) | 349 | ASN1_ITEM_end(tname) |
| 322 | 350 | ||
| 323 | #define ASN1_CHOICE_END_cb(stname, tname, selname) \ | 351 | #define ASN1_CHOICE_END_cb(stname, tname, selname) \ |
| 324 | ;\ | 352 | ; \ |
| 325 | ASN1_ITEM_start(tname) \ | 353 | ASN1_ITEM_start(tname) \ |
| 326 | ASN1_ITYPE_CHOICE,\ | 354 | .itype = ASN1_ITYPE_CHOICE, \ |
| 327 | offsetof(stname,selname) ,\ | 355 | .utype = offsetof(stname,selname), \ |
| 328 | tname##_ch_tt,\ | 356 | .templates = tname##_ch_tt, \ |
| 329 | sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ | 357 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
| 330 | &tname##_aux,\ | 358 | .funcs = &tname##_aux, \ |
| 331 | sizeof(stname),\ | 359 | .size = sizeof(stname), \ |
| 332 | #stname \ | 360 | .sname = #stname, \ |
| 333 | ASN1_ITEM_end(tname) | 361 | ASN1_ITEM_end(tname) |
| 334 | 362 | ||
| 335 | /* This helps with the template wrapper form of ASN1_ITEM */ | 363 | /* This helps with the template wrapper form of ASN1_ITEM */ |
| 336 | 364 | ||
| 337 | #define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ | 365 | #define ASN1_EX_TEMPLATE_TYPE(flagsval, tagval, name, type) \ |
| 338 | (flags), (tag), 0,\ | 366 | { \ |
| 339 | #name, ASN1_ITEM_ref(type) } | 367 | .flags = (flagsval), \ |
| 368 | .tag = (tagval), \ | ||
| 369 | .offset = 0, \ | ||
| 370 | .field_name = #name, \ | ||
| 371 | .item = ASN1_ITEM_ref(type), \ | ||
| 372 | } | ||
| 340 | 373 | ||
| 341 | /* These help with SEQUENCE or CHOICE components */ | 374 | /* These help with SEQUENCE or CHOICE components */ |
| 342 | 375 | ||
| 343 | /* used to declare other types */ | 376 | /* used to declare other types */ |
| 344 | 377 | ||
| 345 | #define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ | 378 | #define ASN1_EX_TYPE(flagsval, tagval, stname, field, type) \ |
| 346 | (flags), (tag), offsetof(stname, field),\ | 379 | { \ |
| 347 | #field, ASN1_ITEM_ref(type) } | 380 | .flags = (flagsval), \ |
| 381 | .tag = (tagval), \ | ||
| 382 | .offset = offsetof(stname, field), \ | ||
| 383 | .field_name = #field, \ | ||
| 384 | .item = ASN1_ITEM_ref(type), \ | ||
| 385 | } | ||
| 348 | 386 | ||
| 349 | /* implicit and explicit helper macros */ | 387 | /* implicit and explicit helper macros */ |
| 350 | 388 | ||
| 351 | #define ASN1_IMP_EX(stname, field, type, tag, ex) \ | 389 | #define ASN1_IMP_EX(stname, field, type, tag, ex) \ |
| 352 | ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) | 390 | ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) |
| 353 | 391 | ||
| 354 | #define ASN1_EXP_EX(stname, field, type, tag, ex) \ | 392 | #define ASN1_EXP_EX(stname, field, type, tag, ex) \ |
| 355 | ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) | 393 | ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) |
| 356 | 394 | ||
| 357 | /* Any defined by macros: the field used is in the table itself */ | 395 | /* Any defined by macros: the field used is in the table itself */ |
| 358 | 396 | ||
| 359 | #define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } | 397 | #define ASN1_ADB_OBJECT(tblname) \ |
| 360 | #define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } | 398 | { \ |
| 399 | .flags = ASN1_TFLG_ADB_OID, \ | ||
| 400 | .tag = -1, \ | ||
| 401 | .offset = 0, \ | ||
| 402 | .field_name = #tblname, \ | ||
| 403 | .item = (const ASN1_ITEM *)&(tblname##_adb), \ | ||
| 404 | } | ||
| 405 | #define ASN1_ADB_INTEGER(tblname) \ | ||
| 406 | { \ | ||
| 407 | .flags = ASN1_TFLG_ADB_INT, \ | ||
| 408 | .tag = -1, \ | ||
| 409 | .offset = 0, \ | ||
| 410 | .field_name = #tblname, \ | ||
| 411 | .item = (const ASN1_ITEM *)&(tblname##_adb), \ | ||
| 412 | } | ||
| 413 | |||
| 361 | /* Plain simple type */ | 414 | /* Plain simple type */ |
| 362 | #define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) | 415 | #define ASN1_SIMPLE(stname, field, type) \ |
| 416 | ASN1_EX_TYPE(0, 0, stname, field, type) | ||
| 363 | 417 | ||
| 364 | /* OPTIONAL simple type */ | 418 | /* OPTIONAL simple type */ |
| 365 | #define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) | 419 | #define ASN1_OPT(stname, field, type) \ |
| 420 | ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) | ||
| 366 | 421 | ||
| 367 | /* IMPLICIT tagged simple type */ | 422 | /* IMPLICIT tagged simple type */ |
| 368 | #define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) | 423 | #define ASN1_IMP(stname, field, type, tag) \ |
| 424 | ASN1_IMP_EX(stname, field, type, tag, 0) | ||
| 369 | 425 | ||
| 370 | /* IMPLICIT tagged OPTIONAL simple type */ | 426 | /* IMPLICIT tagged OPTIONAL simple type */ |
| 371 | #define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) | 427 | #define ASN1_IMP_OPT(stname, field, type, tag) \ |
| 428 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) | ||
| 372 | 429 | ||
| 373 | /* Same as above but EXPLICIT */ | 430 | /* Same as above but EXPLICIT */ |
| 374 | 431 | ||
| 375 | #define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) | 432 | #define ASN1_EXP(stname, field, type, tag) \ |
| 376 | #define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) | 433 | ASN1_EXP_EX(stname, field, type, tag, 0) |
| 434 | #define ASN1_EXP_OPT(stname, field, type, tag) \ | ||
| 435 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) | ||
| 377 | 436 | ||
| 378 | /* SEQUENCE OF type */ | 437 | /* SEQUENCE OF type */ |
| 379 | #define ASN1_SEQUENCE_OF(stname, field, type) \ | 438 | #define ASN1_SEQUENCE_OF(stname, field, type) \ |
| 380 | ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) | 439 | ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) |
| 381 | 440 | ||
| 382 | /* OPTIONAL SEQUENCE OF */ | 441 | /* OPTIONAL SEQUENCE OF */ |
| 383 | #define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ | 442 | #define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ |
| 384 | ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) | 443 | ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) |
| 385 | 444 | ||
| 386 | /* Same as above but for SET OF */ | 445 | /* Same as above but for SET OF */ |
| 387 | 446 | ||
| 388 | #define ASN1_SET_OF(stname, field, type) \ | 447 | #define ASN1_SET_OF(stname, field, type) \ |
| 389 | ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) | 448 | ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) |
| 390 | 449 | ||
| 391 | #define ASN1_SET_OF_OPT(stname, field, type) \ | 450 | #define ASN1_SET_OF_OPT(stname, field, type) \ |
| 392 | ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) | 451 | ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) |
| 393 | 452 | ||
| 394 | /* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ | 453 | /* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ |
| 395 | 454 | ||
| 396 | #define ASN1_IMP_SET_OF(stname, field, type, tag) \ | 455 | #define ASN1_IMP_SET_OF(stname, field, type, tag) \ |
| 397 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) | 456 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) |
| 398 | 457 | ||
| 399 | #define ASN1_EXP_SET_OF(stname, field, type, tag) \ | 458 | #define ASN1_EXP_SET_OF(stname, field, type, tag) \ |
| 400 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) | 459 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) |
| 401 | 460 | ||
| 402 | #define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ | 461 | #define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ |
| 403 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) | 462 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) |
| 404 | 463 | ||
| 405 | #define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ | 464 | #define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ |
| 406 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) | 465 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) |
| 407 | 466 | ||
| 408 | #define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ | 467 | #define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ |
| 409 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) | 468 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) |
| 410 | 469 | ||
| 411 | #define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ | 470 | #define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ |
| 412 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) | 471 | ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) |
| 413 | 472 | ||
| 414 | #define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ | 473 | #define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ |
| 415 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) | 474 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) |
| 416 | 475 | ||
| 417 | #define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ | 476 | #define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ |
| 418 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) | 477 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) |
| 419 | 478 | ||
| 420 | /* EXPLICIT using indefinite length constructed form */ | 479 | /* EXPLICIT using indefinite length constructed form */ |
| 421 | #define ASN1_NDEF_EXP(stname, field, type, tag) \ | 480 | #define ASN1_NDEF_EXP(stname, field, type, tag) \ |
| 422 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) | 481 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) |
| 423 | 482 | ||
| 424 | /* EXPLICIT OPTIONAL using indefinite length constructed form */ | 483 | /* EXPLICIT OPTIONAL using indefinite length constructed form */ |
| 425 | #define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ | 484 | #define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ |
| 426 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) | 485 | ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) |
| 427 | 486 | ||
| 428 | /* Macros for the ASN1_ADB structure */ | 487 | /* Macros for the ASN1_ADB structure */ |
| 429 | 488 | ||
| 430 | #define ASN1_ADB(name) \ | 489 | #define ASN1_ADB(name) \ |
| 431 | static const ASN1_ADB_TABLE name##_adbtbl[] | 490 | static const ASN1_ADB_TABLE name##_adbtbl[] |
| 432 | 491 | ||
| 433 | /* In 5b70372d OpenSSL added adb_cb. Ignore this until someone complains. */ | 492 | /* In 5b70372d OpenSSL added adb_cb. Ignore this until someone complains. */ |
| 434 | #define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ | 493 | #define ASN1_ADB_END(name, flagsval, field, adb_cb, def, none) \ |
| 435 | ;\ | 494 | ; \ |
| 436 | static const ASN1_ADB name##_adb = {\ | 495 | static const ASN1_ADB name##_adb = { \ |
| 437 | flags,\ | 496 | .flags = flagsval, \ |
| 438 | offsetof(name, field),\ | 497 | .offset = offsetof(name, field), \ |
| 439 | name##_adbtbl,\ | 498 | .tbl = name##_adbtbl, \ |
| 440 | sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ | 499 | .tblcount = sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ |
| 441 | def,\ | 500 | .default_tt = def, \ |
| 442 | none\ | 501 | .null_tt = none, \ |
| 443 | } | 502 | } |
| 444 | 503 | ||
| 445 | |||
| 446 | #define ADB_ENTRY(val, template) {val, template} | 504 | #define ADB_ENTRY(val, template) {val, template} |
| 447 | 505 | ||
| 448 | #define ASN1_ADB_TEMPLATE(name) \ | 506 | #define ASN1_ADB_TEMPLATE(name) \ |
| @@ -760,25 +818,37 @@ typedef struct ASN1_STREAM_ARG_st { | |||
| 760 | 818 | ||
| 761 | /* Macro to implement a primitive type */ | 819 | /* Macro to implement a primitive type */ |
| 762 | #define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) | 820 | #define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) |
| 763 | #define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ | 821 | #define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ |
| 764 | ASN1_ITEM_start(itname) \ | 822 | ASN1_ITEM_start(itname) \ |
| 765 | ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ | 823 | .itype = ASN1_ITYPE_PRIMITIVE, \ |
| 766 | ASN1_ITEM_end(itname) | 824 | .utype = V_##vname, \ |
| 825 | .templates = NULL, \ | ||
| 826 | .tcount = 0, \ | ||
| 827 | .funcs = NULL, \ | ||
| 828 | .size = ex, \ | ||
| 829 | .sname = #itname, \ | ||
| 830 | ASN1_ITEM_end(itname) | ||
| 767 | 831 | ||
| 768 | /* Macro to implement a multi string type */ | 832 | /* Macro to implement a multi string type */ |
| 769 | #define IMPLEMENT_ASN1_MSTRING(itname, mask) \ | 833 | #define IMPLEMENT_ASN1_MSTRING(itname, mask) \ |
| 770 | ASN1_ITEM_start(itname) \ | 834 | ASN1_ITEM_start(itname) \ |
| 771 | ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ | 835 | .itype = ASN1_ITYPE_MSTRING, \ |
| 772 | ASN1_ITEM_end(itname) | 836 | .utype = mask, \ |
| 773 | #define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ | 837 | .templates = NULL, \ |
| 774 | ASN1_ITEM_start(sname) \ | 838 | .tcount = 0, \ |
| 775 | ASN1_ITYPE_EXTERN, \ | 839 | .funcs = NULL, \ |
| 776 | tag, \ | 840 | .size = sizeof(ASN1_STRING), \ |
| 777 | NULL, \ | 841 | .sname = #itname, \ |
| 778 | 0, \ | 842 | ASN1_ITEM_end(itname) |
| 779 | &fptrs, \ | 843 | #define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ |
| 780 | 0, \ | 844 | ASN1_ITEM_start(sname) \ |
| 781 | #sname \ | 845 | .itype = ASN1_ITYPE_EXTERN, \ |
| 846 | .utype = tag, \ | ||
| 847 | .templates = NULL, \ | ||
| 848 | .tcount = 0, \ | ||
| 849 | .funcs = &fptrs, \ | ||
| 850 | .size = 0, \ | ||
| 851 | .sname = #sname, \ | ||
| 782 | ASN1_ITEM_end(sname) | 852 | ASN1_ITEM_end(sname) |
| 783 | 853 | ||
| 784 | /* Macro to implement standard functions in terms of ASN1_ITEM structures */ | 854 | /* Macro to implement standard functions in terms of ASN1_ITEM structures */ |
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c index ed18688a31..dd9d8b8395 100644 --- a/src/lib/libcrypto/stack/stack.c +++ b/src/lib/libcrypto/stack/stack.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: stack.c,v 1.34 2025/12/21 07:35:11 tb Exp $ */ | 1 | /* $OpenBSD: stack.c,v 1.35 2026/01/14 17:43:49 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -201,7 +201,7 @@ static const void * | |||
| 201 | obj_bsearch_ex(const void *key, const void *base_, int num, int size, | 201 | obj_bsearch_ex(const void *key, const void *base_, int num, int size, |
| 202 | int (*cmp)(const void *, const void *)) | 202 | int (*cmp)(const void *, const void *)) |
| 203 | { | 203 | { |
| 204 | const void *base = base_; | 204 | const char *base = base_; |
| 205 | int l, h, i, c; | 205 | int l, h, i, c; |
| 206 | 206 | ||
| 207 | l = 0; | 207 | l = 0; |
diff --git a/src/lib/libcrypto/x509/x509_utl.c b/src/lib/libcrypto/x509/x509_utl.c index 4be8630d89..2e60834edf 100644 --- a/src/lib/libcrypto/x509/x509_utl.c +++ b/src/lib/libcrypto/x509/x509_utl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_utl.c,v 1.27 2025/05/10 05:54:39 tb Exp $ */ | 1 | /* $OpenBSD: x509_utl.c,v 1.28 2026/01/12 22:08:34 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 | */ |
| @@ -148,8 +148,6 @@ X509V3_add_value_uchar(const char *name, const unsigned char *value, | |||
| 148 | return X509V3_add_value(name, (const char *)value, extlist); | 148 | return X509V3_add_value(name, (const char *)value, extlist); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | /* Free function for STACK_OF(CONF_VALUE) */ | ||
| 152 | |||
| 153 | void | 151 | void |
| 154 | X509V3_conf_free(CONF_VALUE *conf) | 152 | X509V3_conf_free(CONF_VALUE *conf) |
| 155 | { | 153 | { |
| @@ -354,8 +352,6 @@ X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint) | |||
| 354 | #define HDR_NAME 1 | 352 | #define HDR_NAME 1 |
| 355 | #define HDR_VALUE 2 | 353 | #define HDR_VALUE 2 |
| 356 | 354 | ||
| 357 | /*#define DEBUG*/ | ||
| 358 | |||
| 359 | STACK_OF(CONF_VALUE) * | 355 | STACK_OF(CONF_VALUE) * |
| 360 | X509V3_parse_list(const char *line) | 356 | X509V3_parse_list(const char *line) |
| 361 | { | 357 | { |
