diff options
| author | tb <> | 2026-01-16 09:25:15 +0000 |
|---|---|---|
| committer | tb <> | 2026-01-16 09:25:15 +0000 |
| commit | fe899f24bfb43e00efb15a72fbbd28ff635a8caa (patch) | |
| tree | 8b76a9a3a45802d255f53281cab82620a72c5d5d /src/lib/libcrypto | |
| parent | e62eb532814715d8684398ad800f331610cfd8d0 (diff) | |
| download | openbsd-fe899f24bfb43e00efb15a72fbbd28ff635a8caa.tar.gz openbsd-fe899f24bfb43e00efb15a72fbbd28ff635a8caa.tar.bz2 openbsd-fe899f24bfb43e00efb15a72fbbd28ff635a8caa.zip | |
Add missing space after commas, shorten a couple comments in structs,
reflow weirdly wrapped long comments and improve the random line
breaks in typedefs and prototypes.
Diffstat (limited to 'src/lib/libcrypto')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn1t.h | 155 |
1 files changed, 74 insertions, 81 deletions
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h index 1cf0652373..b3fb1cf838 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.30 2026/01/16 09:21:48 tb Exp $ */ | 1 | /* $OpenBSD: asn1t.h,v 1.31 2026/01/16 09:25:15 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 | */ |
| @@ -336,7 +336,7 @@ extern "C" { | |||
| 336 | ; \ | 336 | ; \ |
| 337 | ASN1_ITEM_start(tname) \ | 337 | ASN1_ITEM_start(tname) \ |
| 338 | .itype = ASN1_ITYPE_CHOICE, \ | 338 | .itype = ASN1_ITYPE_CHOICE, \ |
| 339 | .utype = offsetof(stname,selname), \ | 339 | .utype = offsetof(stname, selname), \ |
| 340 | .templates = tname##_ch_tt, \ | 340 | .templates = tname##_ch_tt, \ |
| 341 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ | 341 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
| 342 | .funcs = NULL, \ | 342 | .funcs = NULL, \ |
| @@ -348,7 +348,7 @@ extern "C" { | |||
| 348 | ; \ | 348 | ; \ |
| 349 | static_ASN1_ITEM_start(tname) \ | 349 | static_ASN1_ITEM_start(tname) \ |
| 350 | .itype = ASN1_ITYPE_CHOICE, \ | 350 | .itype = ASN1_ITYPE_CHOICE, \ |
| 351 | .utype = offsetof(stname,selname), \ | 351 | .utype = offsetof(stname, selname), \ |
| 352 | .templates = tname##_ch_tt, \ | 352 | .templates = tname##_ch_tt, \ |
| 353 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ | 353 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
| 354 | .funcs = NULL, \ | 354 | .funcs = NULL, \ |
| @@ -360,7 +360,7 @@ extern "C" { | |||
| 360 | ; \ | 360 | ; \ |
| 361 | ASN1_ITEM_start(tname) \ | 361 | ASN1_ITEM_start(tname) \ |
| 362 | .itype = ASN1_ITYPE_CHOICE, \ | 362 | .itype = ASN1_ITYPE_CHOICE, \ |
| 363 | .utype = offsetof(stname,selname), \ | 363 | .utype = offsetof(stname, selname), \ |
| 364 | .templates = tname##_ch_tt, \ | 364 | .templates = tname##_ch_tt, \ |
| 365 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ | 365 | .tcount = sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ |
| 366 | .funcs = &tname##_aux, \ | 366 | .funcs = &tname##_aux, \ |
| @@ -543,16 +543,16 @@ typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; | |||
| 543 | typedef struct ASN1_ADB_st ASN1_ADB; | 543 | typedef struct ASN1_ADB_st ASN1_ADB; |
| 544 | 544 | ||
| 545 | struct ASN1_ADB_st { | 545 | struct ASN1_ADB_st { |
| 546 | unsigned long flags; /* Various flags */ | 546 | unsigned long flags; /* Various flags */ |
| 547 | unsigned long offset; /* Offset of selector field */ | 547 | unsigned long offset; /* Offset of selector field */ |
| 548 | const ASN1_ADB_TABLE *tbl; /* Table of possible types */ | 548 | const ASN1_ADB_TABLE *tbl; /* Table of possible types */ |
| 549 | long tblcount; /* Number of entries in tbl */ | 549 | long tblcount; /* Number of entries in tbl */ |
| 550 | const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ | 550 | const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ |
| 551 | const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ | 551 | const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ |
| 552 | }; | 552 | }; |
| 553 | 553 | ||
| 554 | struct ASN1_ADB_TABLE_st { | 554 | struct ASN1_ADB_TABLE_st { |
| 555 | long value; /* NID for an object or value for an int */ | 555 | long value; /* NID for an object or value for an int */ |
| 556 | const ASN1_TEMPLATE tt; /* item for this value */ | 556 | const ASN1_TEMPLATE tt; /* item for this value */ |
| 557 | }; | 557 | }; |
| 558 | 558 | ||
| @@ -567,9 +567,9 @@ struct ASN1_ADB_TABLE_st { | |||
| 567 | /* Field is a SEQUENCE OF */ | 567 | /* Field is a SEQUENCE OF */ |
| 568 | #define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) | 568 | #define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) |
| 569 | 569 | ||
| 570 | /* Special case: this refers to a SET OF that | 570 | /* |
| 571 | * will be sorted into DER order when encoded *and* | 571 | * Special case: this refers to a SET OF that will be sorted into DER order |
| 572 | * the corresponding STACK will be modified to match | 572 | * when encoded *and* the corresponding STACK will be modified to match |
| 573 | * the new order. | 573 | * the new order. |
| 574 | */ | 574 | */ |
| 575 | #define ASN1_TFLG_SET_ORDER (0x3 << 1) | 575 | #define ASN1_TFLG_SET_ORDER (0x3 << 1) |
| @@ -577,9 +577,9 @@ struct ASN1_ADB_TABLE_st { | |||
| 577 | /* Mask for SET OF or SEQUENCE OF */ | 577 | /* Mask for SET OF or SEQUENCE OF */ |
| 578 | #define ASN1_TFLG_SK_MASK (0x3 << 1) | 578 | #define ASN1_TFLG_SK_MASK (0x3 << 1) |
| 579 | 579 | ||
| 580 | /* These flags mean the tag should be taken from the | 580 | /* |
| 581 | * tag field. If EXPLICIT then the underlying type | 581 | * These flags mean the tag should be taken from the tag field. If EXPLICIT |
| 582 | * is used for the inner tag. | 582 | * then the underlying type is used for the inner tag. |
| 583 | */ | 583 | */ |
| 584 | 584 | ||
| 585 | /* IMPLICIT tagging */ | 585 | /* IMPLICIT tagging */ |
| @@ -615,10 +615,9 @@ struct ASN1_ADB_TABLE_st { | |||
| 615 | #define ASN1_TFLG_TAG_CLASS (0x3<<6) | 615 | #define ASN1_TFLG_TAG_CLASS (0x3<<6) |
| 616 | 616 | ||
| 617 | /* | 617 | /* |
| 618 | * These are for ANY DEFINED BY type. In this case | 618 | * These are for ANY DEFINED BY type. In this case the 'item' field points |
| 619 | * the 'item' field points to an ASN1_ADB structure | 619 | * to an ASN1_ADB structure which contains a table of values to decode the |
| 620 | * which contains a table of values to decode the | 620 | * relevant type. |
| 621 | * relevant type | ||
| 622 | */ | 621 | */ |
| 623 | 622 | ||
| 624 | #define ASN1_TFLG_ADB_MASK (0x3<<8) | 623 | #define ASN1_TFLG_ADB_MASK (0x3<<8) |
| @@ -628,9 +627,8 @@ struct ASN1_ADB_TABLE_st { | |||
| 628 | #define ASN1_TFLG_ADB_INT (0x1<<9) | 627 | #define ASN1_TFLG_ADB_INT (0x1<<9) |
| 629 | 628 | ||
| 630 | /* | 629 | /* |
| 631 | * This flag when present in a SEQUENCE OF, SET OF | 630 | * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes |
| 632 | * or EXPLICIT causes indefinite length constructed | 631 | * indefinite length constructed encoding to be used if required. |
| 633 | * encoding to be used if required. | ||
| 634 | */ | 632 | */ |
| 635 | 633 | ||
| 636 | #define ASN1_TFLG_NDEF (0x1<<11) | 634 | #define ASN1_TFLG_NDEF (0x1<<11) |
| @@ -638,52 +636,43 @@ struct ASN1_ADB_TABLE_st { | |||
| 638 | /* This is the actual ASN1 item itself */ | 636 | /* This is the actual ASN1 item itself */ |
| 639 | 637 | ||
| 640 | struct ASN1_ITEM_st { | 638 | struct ASN1_ITEM_st { |
| 641 | char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ | 639 | char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ |
| 642 | long utype; /* underlying type */ | 640 | long utype; /* underlying type */ |
| 643 | const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ | 641 | const ASN1_TEMPLATE *templates; /* contents for SEQUENCE or CHOICE */ |
| 644 | long tcount; /* Number of templates if SEQUENCE or CHOICE */ | 642 | long tcount; /* Number of templates if SEQUENCE or CHOICE */ |
| 645 | const void *funcs; /* functions that handle this type */ | 643 | const void *funcs; /* functions that handle this type */ |
| 646 | long size; /* Structure size (usually) */ | 644 | long size; /* Structure size (usually) */ |
| 647 | const char *sname; /* Structure name */ | 645 | const char *sname; /* Structure name */ |
| 648 | }; | 646 | }; |
| 649 | 647 | ||
| 650 | /* These are values for the itype field and | 648 | /* |
| 651 | * determine how the type is interpreted. | 649 | * These are values for the itype field and determine how the type is |
| 650 | * interpreted. | ||
| 652 | * | 651 | * |
| 653 | * For PRIMITIVE types the underlying type | 652 | * For PRIMITIVE types the underlying type determines the behaviour if |
| 654 | * determines the behaviour if items is NULL. | 653 | * items is NULL. |
| 655 | * | 654 | * |
| 656 | * Otherwise templates must contain a single | 655 | * Otherwise templates must contain a single template and the type is |
| 657 | * template and the type is treated in the | 656 | * treated in the same way as the type specified in the template. |
| 658 | * same way as the type specified in the template. | ||
| 659 | * | 657 | * |
| 660 | * For SEQUENCE types the templates field points | 658 | * For SEQUENCE types the templates field points to the members, the |
| 661 | * to the members, the size field is the | 659 | * size field is the structure size. |
| 662 | * structure size. | ||
| 663 | * | 660 | * |
| 664 | * For CHOICE types the templates field points | 661 | * For CHOICE types the templates field points to each possible member |
| 665 | * to each possible member (typically a union) | 662 | * (typically a union) and the 'size' field is the offset of the selector. |
| 666 | * and the 'size' field is the offset of the | ||
| 667 | * selector. | ||
| 668 | * | 663 | * |
| 669 | * The 'funcs' field is used for application | 664 | * The 'funcs' field is used for application specific functions. |
| 670 | * specific functions. | ||
| 671 | * | 665 | * |
| 672 | * The EXTERN type uses a new style d2i/i2d. | 666 | * The EXTERN type uses a new style d2i/i2d. The new style should be used |
| 673 | * The new style should be used where possible | 667 | * where possible because it avoids things like the d2i IMPLICIT hack. |
| 674 | * because it avoids things like the d2i IMPLICIT | ||
| 675 | * hack. | ||
| 676 | * | 668 | * |
| 677 | * MSTRING is a multiple string type, it is used | 669 | * MSTRING is a multiple string type, it is used for a CHOICE of character |
| 678 | * for a CHOICE of character strings where the | 670 | * strings where the actual strings all occupy an ASN1_STRING structure. |
| 679 | * actual strings all occupy an ASN1_STRING | 671 | * In this case the 'utype' field has a special meaning, it is used as a |
| 680 | * structure. In this case the 'utype' field | 672 | * mask of acceptable types using the B_ASN1 constants. |
| 681 | * has a special meaning, it is used as a mask | ||
| 682 | * of acceptable types using the B_ASN1 constants. | ||
| 683 | * | 673 | * |
| 684 | * NDEF_SEQUENCE is the same as SEQUENCE except | 674 | * NDEF_SEQUENCE is the same as SEQUENCE except that it will use |
| 685 | * that it will use indefinite length constructed | 675 | * indefinite length constructed encoding if requested. |
| 686 | * encoding if requested. | ||
| 687 | * | 676 | * |
| 688 | */ | 677 | */ |
| 689 | 678 | ||
| @@ -717,23 +706,27 @@ struct ASN1_TLC_st { | |||
| 717 | 706 | ||
| 718 | typedef ASN1_VALUE * ASN1_new_func(void); | 707 | typedef ASN1_VALUE * ASN1_new_func(void); |
| 719 | typedef void ASN1_free_func(ASN1_VALUE *a); | 708 | typedef void ASN1_free_func(ASN1_VALUE *a); |
| 720 | typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length); | 709 | typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, |
| 710 | long length); | ||
| 721 | typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); | 711 | typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); |
| 722 | 712 | ||
| 723 | typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, | 713 | typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, |
| 724 | int tag, int aclass, char opt, ASN1_TLC *ctx); | 714 | const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx); |
| 725 | 715 | ||
| 726 | typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); | 716 | typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, |
| 717 | const ASN1_ITEM *it, int tag, int aclass); | ||
| 727 | typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); | 718 | typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 728 | typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); | 719 | typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 729 | 720 | ||
| 730 | typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, | 721 | typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, int indent, |
| 731 | int indent, const char *fname, | 722 | const char *fname, const ASN1_PCTX *pctx); |
| 732 | const ASN1_PCTX *pctx); | ||
| 733 | 723 | ||
| 734 | typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); | 724 | typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, |
| 735 | typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); | 725 | int *putype, const ASN1_ITEM *it); |
| 736 | typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); | 726 | typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, |
| 727 | int len, int utype, char *free_cont, const ASN1_ITEM *it); | ||
| 728 | typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, | ||
| 729 | const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); | ||
| 737 | 730 | ||
| 738 | typedef struct ASN1_EXTERN_FUNCS_st { | 731 | typedef struct ASN1_EXTERN_FUNCS_st { |
| 739 | void *app_data; | 732 | void *app_data; |
| @@ -756,25 +749,25 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st { | |||
| 756 | ASN1_primitive_print *prim_print; | 749 | ASN1_primitive_print *prim_print; |
| 757 | } ASN1_PRIMITIVE_FUNCS; | 750 | } ASN1_PRIMITIVE_FUNCS; |
| 758 | 751 | ||
| 759 | /* This is the ASN1_AUX structure: it handles various | 752 | /* |
| 760 | * miscellaneous requirements. For example the use of | 753 | * This is the ASN1_AUX structure: it handles various miscellaneous |
| 761 | * reference counts and an informational callback. | 754 | * requirements. For example the use of reference counts and an |
| 755 | * informational callback. | ||
| 762 | * | 756 | * |
| 763 | * The "informational callback" is called at various | 757 | * The "informational callback" is called at various points during |
| 764 | * points during the ASN1 encoding and decoding. It can | 758 | * the ASN1 encoding and decoding. It can be used to provide minor |
| 765 | * be used to provide minor customisation of the structures | 759 | * customisation of the structures used. This is most useful where |
| 766 | * used. This is most useful where the supplied routines | 760 | * the supplied routines *almost* do the right thing but need some |
| 767 | * *almost* do the right thing but need some extra help | 761 | * extra help at a few points. If the callback returns zero then it |
| 768 | * at a few points. If the callback returns zero then | 762 | * is assumed a fatal error has occurred and the main operation |
| 769 | * it is assumed a fatal error has occurred and the | 763 | * should be abandoned. |
| 770 | * main operation should be abandoned. | ||
| 771 | * | 764 | * |
| 772 | * If major changes in the default behaviour are required | 765 | * If major changes in the default behaviour are required then an |
| 773 | * then an external type is more appropriate. | 766 | * external type is more appropriate. |
| 774 | */ | 767 | */ |
| 775 | 768 | ||
| 776 | typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, | 769 | typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, |
| 777 | void *exarg); | 770 | void *exarg); |
| 778 | 771 | ||
| 779 | typedef struct ASN1_AUX_st { | 772 | typedef struct ASN1_AUX_st { |
| 780 | void *app_data; | 773 | void *app_data; |
| @@ -992,10 +985,10 @@ DECLARE_STACK_OF(ASN1_VALUE) | |||
| 992 | 985 | ||
| 993 | int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | 986 | int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 994 | void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); | 987 | void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 995 | int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, | 988 | int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, |
| 996 | int tag, int aclass, char opt, ASN1_TLC *ctx); | 989 | const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx); |
| 997 | 990 | int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |
| 998 | int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); | 991 | const ASN1_ITEM *it, int tag, int aclass); |
| 999 | 992 | ||
| 1000 | #ifdef __cplusplus | 993 | #ifdef __cplusplus |
| 1001 | } | 994 | } |
