summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/asn1/asn1t.h146
1 files changed, 88 insertions, 58 deletions
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h
index da66858a1f..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.27 2026/01/09 03:46:44 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 */
@@ -362,115 +362,145 @@ extern "C" {
362 362
363/* This helps with the template wrapper form of ASN1_ITEM */ 363/* This helps with the template wrapper form of ASN1_ITEM */
364 364
365#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ 365#define ASN1_EX_TEMPLATE_TYPE(flagsval, tagval, name, type) \
366 (flags), (tag), 0,\ 366 { \
367 #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 }
368 373
369/* These help with SEQUENCE or CHOICE components */ 374/* These help with SEQUENCE or CHOICE components */
370 375
371/* used to declare other types */ 376/* used to declare other types */
372 377
373#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ 378#define ASN1_EX_TYPE(flagsval, tagval, stname, field, type) \
374 (flags), (tag), offsetof(stname, field),\ 379 { \
375 #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 }
376 386
377/* implicit and explicit helper macros */ 387/* implicit and explicit helper macros */
378 388
379#define ASN1_IMP_EX(stname, field, type, tag, ex) \ 389#define ASN1_IMP_EX(stname, field, type, tag, ex) \
380 ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) 390 ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)
381 391
382#define ASN1_EXP_EX(stname, field, type, tag, ex) \ 392#define ASN1_EXP_EX(stname, field, type, tag, ex) \
383 ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) 393 ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)
384 394
385/* 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 */
386 396
387#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } 397#define ASN1_ADB_OBJECT(tblname) \
388#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
389/* Plain simple type */ 414/* Plain simple type */
390#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)
391 417
392/* OPTIONAL simple type */ 418/* OPTIONAL simple type */
393#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)
394 421
395/* IMPLICIT tagged simple type */ 422/* IMPLICIT tagged simple type */
396#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)
397 425
398/* IMPLICIT tagged OPTIONAL simple type */ 426/* IMPLICIT tagged OPTIONAL simple type */
399#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)
400 429
401/* Same as above but EXPLICIT */ 430/* Same as above but EXPLICIT */
402 431
403#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) 432#define ASN1_EXP(stname, field, type, tag) \
404#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)
405 436
406/* SEQUENCE OF type */ 437/* SEQUENCE OF type */
407#define ASN1_SEQUENCE_OF(stname, field, type) \ 438#define ASN1_SEQUENCE_OF(stname, field, type) \
408 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) 439 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
409 440
410/* OPTIONAL SEQUENCE OF */ 441/* OPTIONAL SEQUENCE OF */
411#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ 442#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
412 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)
413 444
414/* Same as above but for SET OF */ 445/* Same as above but for SET OF */
415 446
416#define ASN1_SET_OF(stname, field, type) \ 447#define ASN1_SET_OF(stname, field, type) \
417 ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) 448 ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
418 449
419#define ASN1_SET_OF_OPT(stname, field, type) \ 450#define ASN1_SET_OF_OPT(stname, field, type) \
420 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)
421 452
422/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ 453/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
423 454
424#define ASN1_IMP_SET_OF(stname, field, type, tag) \ 455#define ASN1_IMP_SET_OF(stname, field, type, tag) \
425 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) 456 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
426 457
427#define ASN1_EXP_SET_OF(stname, field, type, tag) \ 458#define ASN1_EXP_SET_OF(stname, field, type, tag) \
428 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) 459 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
429 460
430#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ 461#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
431 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)
432 463
433#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ 464#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
434 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)
435 466
436#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ 467#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
437 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) 468 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
438 469
439#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ 470#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
440 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)
441 472
442#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ 473#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
443 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) 474 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
444 475
445#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ 476#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
446 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)
447 478
448/* EXPLICIT using indefinite length constructed form */ 479/* EXPLICIT using indefinite length constructed form */
449#define ASN1_NDEF_EXP(stname, field, type, tag) \ 480#define ASN1_NDEF_EXP(stname, field, type, tag) \
450 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) 481 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
451 482
452/* EXPLICIT OPTIONAL using indefinite length constructed form */ 483/* EXPLICIT OPTIONAL using indefinite length constructed form */
453#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ 484#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
454 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)
455 486
456/* Macros for the ASN1_ADB structure */ 487/* Macros for the ASN1_ADB structure */
457 488
458#define ASN1_ADB(name) \ 489#define ASN1_ADB(name) \
459 static const ASN1_ADB_TABLE name##_adbtbl[] 490 static const ASN1_ADB_TABLE name##_adbtbl[]
460 491
461/* In 5b70372d OpenSSL added adb_cb. Ignore this until someone complains. */ 492/* In 5b70372d OpenSSL added adb_cb. Ignore this until someone complains. */
462#define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ 493#define ASN1_ADB_END(name, flagsval, field, adb_cb, def, none) \
463 ;\ 494 ; \
464 static const ASN1_ADB name##_adb = {\ 495 static const ASN1_ADB name##_adb = { \
465 flags,\ 496 .flags = flagsval, \
466 offsetof(name, field),\ 497 .offset = offsetof(name, field), \
467 name##_adbtbl,\ 498 .tbl = name##_adbtbl, \
468 sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ 499 .tblcount = sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
469 def,\ 500 .default_tt = def, \
470 none\ 501 .null_tt = none, \
471 } 502 }
472 503
473
474#define ADB_ENTRY(val, template) {val, template} 504#define ADB_ENTRY(val, template) {val, template}
475 505
476#define ASN1_ADB_TEMPLATE(name) \ 506#define ASN1_ADB_TEMPLATE(name) \