summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2021-11-30 18:32:55 +0000
committertb <>2021-11-30 18:32:55 +0000
commit79ddefa4c7cf92070afb9d2eebdecf3c12e9c276 (patch)
tree0ce2149c08143a638c57b84d1969099066bd6560
parent0e600fe061e269a13ec50c5a2eae412ffc9339b7 (diff)
downloadopenbsd-79ddefa4c7cf92070afb9d2eebdecf3c12e9c276.tar.gz
openbsd-79ddefa4c7cf92070afb9d2eebdecf3c12e9c276.tar.bz2
openbsd-79ddefa4c7cf92070afb9d2eebdecf3c12e9c276.zip
last whitespace diff for now.
-rw-r--r--src/lib/libcrypto/asn1/asn1t.h119
1 files changed, 62 insertions, 57 deletions
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h
index d6168b65e1..3fdfc7b46f 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.15 2019/08/20 13:10:09 inoguchi Exp $ */ 1/* $OpenBSD: asn1t.h,v 1.16 2021/11/30 18:32:55 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 */
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -92,7 +92,7 @@ extern "C" {
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 ;\
@@ -120,29 +120,30 @@ extern "C" {
120 120
121 121
122/* This is a ASN1 type which just embeds a template */ 122/* This is a ASN1 type which just embeds a template */
123 123
124/* This pair helps declare a SEQUENCE. We can do: 124/*
125 * This pair helps declare a SEQUENCE. We can do:
125 * 126 *
126 * ASN1_SEQUENCE(stname) = { 127 * ASN1_SEQUENCE(stname) = {
127 * ... SEQUENCE components ... 128 * ... SEQUENCE components ...
128 * } ASN1_SEQUENCE_END(stname) 129 * } ASN1_SEQUENCE_END(stname)
129 * 130 *
130 * This will produce an ASN1_ITEM called stname_it 131 * This will produce an ASN1_ITEM called stname_it
131 * for a structure called stname. 132 * for a structure called stname.
132 * 133 *
133 * If you want the same structure but a different 134 * If you want the same structure but a different
134 * name then use: 135 * name then use:
135 * 136 *
136 * ASN1_SEQUENCE(itname) = { 137 * ASN1_SEQUENCE(itname) = {
137 * ... SEQUENCE components ... 138 * ... SEQUENCE components ...
138 * } ASN1_SEQUENCE_END_name(stname, itname) 139 * } ASN1_SEQUENCE_END_name(stname, itname)
139 * 140 *
140 * This will create an item called itname_it using 141 * This will create an item called itname_it using
141 * a structure called stname. 142 * a structure called stname.
142 */ 143 */
143 144
144#define ASN1_SEQUENCE(tname) \ 145#define ASN1_SEQUENCE(tname) \
145 static const ASN1_TEMPLATE tname##_seq_tt[] 146 static const ASN1_TEMPLATE tname##_seq_tt[]
146 147
147#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) 148#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
148 149
@@ -263,13 +264,14 @@ extern "C" {
263 ASN1_ITEM_end(tname) 264 ASN1_ITEM_end(tname)
264 265
265 266
266/* This pair helps declare a CHOICE type. We can do: 267/*
268 * This pair helps declare a CHOICE type. We can do:
267 * 269 *
268 * ASN1_CHOICE(chname) = { 270 * ASN1_CHOICE(chname) = {
269 * ... CHOICE options ... 271 * ... CHOICE options ...
270 * ASN1_CHOICE_END(chname) 272 * ASN1_CHOICE_END(chname)
271 * 273 *
272 * This will produce an ASN1_ITEM called chname_it 274 * This will produce an ASN1_ITEM called chname_it
273 * for a structure called chname. The structure 275 * for a structure called chname. The structure
274 * definition must look like this: 276 * definition must look like this:
275 * typedef struct { 277 * typedef struct {
@@ -279,14 +281,14 @@ extern "C" {
279 * ASN1_SOMEOTHER *opt2; 281 * ASN1_SOMEOTHER *opt2;
280 * } value; 282 * } value;
281 * } chname; 283 * } chname;
282 * 284 *
283 * the name of the selector must be 'type'. 285 * the name of the selector must be 'type'.
284 * to use an alternative selector name use the 286 * to use an alternative selector name use the
285 * ASN1_CHOICE_END_selector() version. 287 * ASN1_CHOICE_END_selector() version.
286 */ 288 */
287 289
288#define ASN1_CHOICE(tname) \ 290#define ASN1_CHOICE(tname) \
289 static const ASN1_TEMPLATE tname##_ch_tt[] 291 static const ASN1_TEMPLATE tname##_ch_tt[]
290 292
291#define ASN1_CHOICE_cb(tname, cb) \ 293#define ASN1_CHOICE_cb(tname, cb) \
292 static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ 294 static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
@@ -437,7 +439,7 @@ extern "C" {
437/* Macros for the ASN1_ADB structure */ 439/* Macros for the ASN1_ADB structure */
438 440
439#define ASN1_ADB(name) \ 441#define ASN1_ADB(name) \
440 static const ASN1_ADB_TABLE name##_adbtbl[] 442 static const ASN1_ADB_TABLE name##_adbtbl[]
441 443
442 444
443#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ 445#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
@@ -456,7 +458,7 @@ extern "C" {
456#define ADB_ENTRY(val, template) {val, template} 458#define ADB_ENTRY(val, template) {val, template}
457 459
458#define ASN1_ADB_TEMPLATE(name) \ 460#define ASN1_ADB_TEMPLATE(name) \
459 static const ASN1_TEMPLATE name##_tt 461 static const ASN1_TEMPLATE name##_tt
460 462
461#endif /* !LIBRESSL_INTERNAL */ 463#endif /* !LIBRESSL_INTERNAL */
462 464
@@ -467,13 +469,13 @@ extern "C" {
467 */ 469 */
468 470
469struct ASN1_TEMPLATE_st { 471struct ASN1_TEMPLATE_st {
470unsigned long flags; /* Various flags */ 472 unsigned long flags; /* Various flags */
471long tag; /* tag, not used if no tagging */ 473 long tag; /* tag, not used if no tagging */
472unsigned long offset; /* Offset of this field in structure */ 474 unsigned long offset; /* Offset of this field in structure */
473#ifndef NO_ASN1_FIELD_NAMES 475#ifndef NO_ASN1_FIELD_NAMES
474const char *field_name; /* Field name */ 476 const char *field_name; /* Field name */
475#endif 477#endif
476ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ 478 ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
477}; 479};
478 480
479/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ 481/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
@@ -540,24 +542,25 @@ struct ASN1_ADB_TABLE_st {
540/* context specific EXPLICIT */ 542/* context specific EXPLICIT */
541#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT 543#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT
542 544
543/* If tagging is in force these determine the 545/*
544 * type of tag to use. Otherwise the tag is 546 * If tagging is in force these determine the type of tag to use. Otherwiser
545 * determined by the underlying type. These 547 * the tag is determined by the underlying type. These values reflect the
546 * values reflect the actual octet format. 548 * actual octet format.
547 */ 549 */
548 550
549/* Universal tag */ 551/* Universal tag */
550#define ASN1_TFLG_UNIVERSAL (0x0<<6) 552#define ASN1_TFLG_UNIVERSAL (0x0<<6)
551/* Application tag */ 553/* Application tag */
552#define ASN1_TFLG_APPLICATION (0x1<<6) 554#define ASN1_TFLG_APPLICATION (0x1<<6)
553/* Context specific tag */ 555/* Context specific tag */
554#define ASN1_TFLG_CONTEXT (0x2<<6) 556#define ASN1_TFLG_CONTEXT (0x2<<6)
555/* Private tag */ 557/* Private tag */
556#define ASN1_TFLG_PRIVATE (0x3<<6) 558#define ASN1_TFLG_PRIVATE (0x3<<6)
557 559
558#define ASN1_TFLG_TAG_CLASS (0x3<<6) 560#define ASN1_TFLG_TAG_CLASS (0x3<<6)
559 561
560/* These are for ANY DEFINED BY type. In this case 562/*
563 * These are for ANY DEFINED BY type. In this case
561 * the 'item' field points to an ASN1_ADB structure 564 * the 'item' field points to an ASN1_ADB structure
562 * which contains a table of values to decode the 565 * which contains a table of values to decode the
563 * relevant type 566 * relevant type
@@ -569,7 +572,8 @@ struct ASN1_ADB_TABLE_st {
569 572
570#define ASN1_TFLG_ADB_INT (0x1<<9) 573#define ASN1_TFLG_ADB_INT (0x1<<9)
571 574
572/* This flag means a parent structure is passed 575/*
576 * This flag means a parent structure is passed
573 * instead of the field: this is useful is a 577 * instead of the field: this is useful is a
574 * SEQUENCE is being combined with a CHOICE for 578 * SEQUENCE is being combined with a CHOICE for
575 * example. Since this means the structure and 579 * example. Since this means the structure and
@@ -579,7 +583,8 @@ struct ASN1_ADB_TABLE_st {
579 583
580#define ASN1_TFLG_COMBINE (0x1<<10) 584#define ASN1_TFLG_COMBINE (0x1<<10)
581 585
582/* This flag when present in a SEQUENCE OF, SET OF 586/*
587 * This flag when present in a SEQUENCE OF, SET OF
583 * or EXPLICIT causes indefinite length constructed 588 * or EXPLICIT causes indefinite length constructed
584 * encoding to be used if required. 589 * encoding to be used if required.
585 */ 590 */
@@ -589,14 +594,14 @@ struct ASN1_ADB_TABLE_st {
589/* This is the actual ASN1 item itself */ 594/* This is the actual ASN1 item itself */
590 595
591struct ASN1_ITEM_st { 596struct ASN1_ITEM_st {
592char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ 597 char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */
593long utype; /* underlying type */ 598 long utype; /* underlying type */
594const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ 599 const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */
595long tcount; /* Number of templates if SEQUENCE or CHOICE */ 600 long tcount; /* Number of templates if SEQUENCE or CHOICE */
596const void *funcs; /* functions that handle this type */ 601 const void *funcs; /* functions that handle this type */
597long size; /* Structure size (usually)*/ 602 long size; /* Structure size (usually)*/
598#ifndef NO_ASN1_FIELD_NAMES 603#ifndef NO_ASN1_FIELD_NAMES
599const char *sname; /* Structure name */ 604 const char *sname; /* Structure name */
600#endif 605#endif
601}; 606};
602 607
@@ -606,7 +611,7 @@ const char *sname; /* Structure name */
606 * For PRIMITIVE types the underlying type 611 * For PRIMITIVE types the underlying type
607 * determines the behaviour if items is NULL. 612 * determines the behaviour if items is NULL.
608 * 613 *
609 * Otherwise templates must contain a single 614 * Otherwise templates must contain a single
610 * template and the type is treated in the 615 * template and the type is treated in the
611 * same way as the type specified in the template. 616 * same way as the type specified in the template.
612 * 617 *
@@ -620,7 +625,7 @@ const char *sname; /* Structure name */
620 * selector. 625 * selector.
621 * 626 *
622 * The 'funcs' field is used for application 627 * The 'funcs' field is used for application
623 * specific functions. 628 * specific functions.
624 * 629 *
625 * The EXTERN type uses a new style d2i/i2d. 630 * The EXTERN type uses a new style d2i/i2d.
626 * The new style should be used where possible 631 * The new style should be used where possible
@@ -657,7 +662,7 @@ const char *sname; /* Structure name */
657 * like CHOICE 662 * like CHOICE
658 */ 663 */
659 664
660struct ASN1_TLC_st{ 665struct ASN1_TLC_st {
661 char valid; /* Values below are valid */ 666 char valid; /* Values below are valid */
662 int ret; /* return value */ 667 int ret; /* return value */
663 long plen; /* length */ 668 long plen; /* length */
@@ -680,8 +685,8 @@ typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM
680typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); 685typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
681typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); 686typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
682 687
683typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, 688typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
684 int indent, const char *fname, 689 int indent, const char *fname,
685 const ASN1_PCTX *pctx); 690 const ASN1_PCTX *pctx);
686 691
687typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); 692typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
@@ -719,7 +724,7 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st {
719 * used. This is most useful where the supplied routines 724 * used. This is most useful where the supplied routines
720 * *almost* do the right thing but need some extra help 725 * *almost* do the right thing but need some extra help
721 * at a few points. If the callback returns zero then 726 * at a few points. If the callback returns zero then
722 * it is assumed a fatal error has occurred and the 727 * it is assumed a fatal error has occurred and the
723 * main operation should be abandoned. 728 * main operation should be abandoned.
724 * 729 *
725 * If major changes in the default behaviour are required 730 * If major changes in the default behaviour are required
@@ -853,13 +858,13 @@ typedef struct ASN1_STREAM_ARG_st {
853 int i2d_##fname(stname *a, unsigned char **out) \ 858 int i2d_##fname(stname *a, unsigned char **out) \
854 { \ 859 { \
855 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ 860 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
856 } 861 }
857 862
858#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ 863#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
859 int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ 864 int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
860 { \ 865 { \
861 return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ 866 return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
862 } 867 }
863 868
864/* This includes evil casts to remove const: they will go away when full 869/* This includes evil casts to remove const: they will go away when full
865 * ASN1 constification is done. 870 * ASN1 constification is done.
@@ -872,7 +877,7 @@ typedef struct ASN1_STREAM_ARG_st {
872 int i2d_##fname(const stname *a, unsigned char **out) \ 877 int i2d_##fname(const stname *a, unsigned char **out) \
873 { \ 878 { \
874 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ 879 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
875 } 880 }
876 881
877#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ 882#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
878 stname * stname##_dup(stname *x) \ 883 stname * stname##_dup(stname *x) \
@@ -889,7 +894,7 @@ typedef struct ASN1_STREAM_ARG_st {
889 { \ 894 { \
890 return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \ 895 return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
891 ASN1_ITEM_rptr(itname), pctx); \ 896 ASN1_ITEM_rptr(itname), pctx); \
892 } 897 }
893 898
894#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ 899#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
895 IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) 900 IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)