diff options
| author | tb <> | 2026-01-16 09:19:20 +0000 |
|---|---|---|
| committer | tb <> | 2026-01-16 09:19:20 +0000 |
| commit | 24d198d8053cb927535d8b46fd5525f1c6eabafa (patch) | |
| tree | 25b09d31c2fd3f05456d6a3970f7229845e99784 /src/lib/libcrypto | |
| parent | f3b7e1f8d7abce09c15e715e5f167b6f10d127de (diff) | |
| download | openbsd-24d198d8053cb927535d8b46fd5525f1c6eabafa.tar.gz openbsd-24d198d8053cb927535d8b46fd5525f1c6eabafa.tar.bz2 openbsd-24d198d8053cb927535d8b46fd5525f1c6eabafa.zip | |
asn1t.h: more macro cleanup, add missing C99 initializers for ADB_ENTRY()
ok kenjiro
Diffstat (limited to 'src/lib/libcrypto')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn1t.h | 168 |
1 files changed, 99 insertions, 69 deletions
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h index 5ed7cb97f5..0a0a709e73 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.28 2026/01/11 07:52:34 tb Exp $ */ | 1 | /* $OpenBSD: asn1t.h,v 1.29 2026/01/16 09:19:20 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 | */ |
| @@ -88,7 +88,6 @@ extern "C" { | |||
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | |||
| 92 | /* Macros to aid ASN1 template writing */ | 91 | /* Macros to aid ASN1 template writing */ |
| 93 | 92 | ||
| 94 | #define ASN1_ITEM_TEMPLATE(tname) \ | 93 | #define ASN1_ITEM_TEMPLATE(tname) \ |
| @@ -145,9 +144,11 @@ extern "C" { | |||
| 145 | #define ASN1_SEQUENCE(tname) \ | 144 | #define ASN1_SEQUENCE(tname) \ |
| 146 | static const ASN1_TEMPLATE tname##_seq_tt[] | 145 | static const ASN1_TEMPLATE tname##_seq_tt[] |
| 147 | 146 | ||
| 148 | #define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) | 147 | #define ASN1_SEQUENCE_END(stname) \ |
| 148 | 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) \ |
| 151 | static_ASN1_SEQUENCE_END_name(stname, stname) | ||
| 151 | 152 | ||
| 152 | #define ASN1_SEQUENCE_END_name(stname, tname) \ | 153 | #define ASN1_SEQUENCE_END_name(stname, tname) \ |
| 153 | ; \ | 154 | ; \ |
| @@ -236,11 +237,14 @@ extern "C" { | |||
| 236 | .sname = #tname, \ | 237 | .sname = #tname, \ |
| 237 | ASN1_ITEM_end(tname) | 238 | ASN1_ITEM_end(tname) |
| 238 | 239 | ||
| 239 | #define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) | 240 | #define ASN1_SEQUENCE_END_enc(stname, tname) \ |
| 241 | ASN1_SEQUENCE_END_ref(stname, tname) | ||
| 240 | 242 | ||
| 241 | #define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) | 243 | #define ASN1_SEQUENCE_END_cb(stname, tname) \ |
| 244 | ASN1_SEQUENCE_END_ref(stname, tname) | ||
| 242 | 245 | ||
| 243 | #define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname) | 246 | #define static_ASN1_SEQUENCE_END_cb(stname, tname) \ |
| 247 | static_ASN1_SEQUENCE_END_ref(stname, tname) | ||
| 244 | 248 | ||
| 245 | #define ASN1_SEQUENCE_END_ref(stname, tname) \ | 249 | #define ASN1_SEQUENCE_END_ref(stname, tname) \ |
| 246 | ; \ | 250 | ; \ |
| @@ -316,13 +320,17 @@ extern "C" { | |||
| 316 | }; \ | 320 | }; \ |
| 317 | ASN1_CHOICE(tname) | 321 | ASN1_CHOICE(tname) |
| 318 | 322 | ||
| 319 | #define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) | 323 | #define ASN1_CHOICE_END(stname) \ |
| 324 | ASN1_CHOICE_END_name(stname, stname) | ||
| 320 | 325 | ||
| 321 | #define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname) | 326 | #define static_ASN1_CHOICE_END(stname) \ |
| 327 | static_ASN1_CHOICE_END_name(stname, stname) | ||
| 322 | 328 | ||
| 323 | #define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) | 329 | #define ASN1_CHOICE_END_name(stname, tname) \ |
| 330 | ASN1_CHOICE_END_selector(stname, tname, type) | ||
| 324 | 331 | ||
| 325 | #define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type) | 332 | #define static_ASN1_CHOICE_END_name(stname, tname) \ |
| 333 | static_ASN1_CHOICE_END_selector(stname, tname, type) | ||
| 326 | 334 | ||
| 327 | #define ASN1_CHOICE_END_selector(stname, tname, selname) \ | 335 | #define ASN1_CHOICE_END_selector(stname, tname, selname) \ |
| 328 | ; \ | 336 | ; \ |
| @@ -501,7 +509,11 @@ extern "C" { | |||
| 501 | .null_tt = none, \ | 509 | .null_tt = none, \ |
| 502 | } | 510 | } |
| 503 | 511 | ||
| 504 | #define ADB_ENTRY(val, template) {val, template} | 512 | #define ADB_ENTRY(val, template) \ |
| 513 | { \ | ||
| 514 | .value = val, \ | ||
| 515 | .tt = template, \ | ||
| 516 | } | ||
| 505 | 517 | ||
| 506 | #define ASN1_ADB_TEMPLATE(name) \ | 518 | #define ASN1_ADB_TEMPLATE(name) \ |
| 507 | static const ASN1_TEMPLATE name##_tt | 519 | static const ASN1_TEMPLATE name##_tt |
| @@ -853,93 +865,111 @@ typedef struct ASN1_STREAM_ARG_st { | |||
| 853 | 865 | ||
| 854 | /* Macro to implement standard functions in terms of ASN1_ITEM structures */ | 866 | /* Macro to implement standard functions in terms of ASN1_ITEM structures */ |
| 855 | 867 | ||
| 856 | #define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) | 868 | #define IMPLEMENT_ASN1_FUNCTIONS(stname) \ |
| 869 | IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) | ||
| 857 | 870 | ||
| 858 | #define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) | 871 | #define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) \ |
| 872 | IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) | ||
| 859 | 873 | ||
| 860 | #define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ | 874 | #define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ |
| 861 | IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) | 875 | IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) |
| 862 | 876 | ||
| 863 | #define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ | 877 | #define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ |
| 864 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) | 878 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) |
| 865 | 879 | ||
| 866 | #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ | 880 | #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ |
| 867 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) | 881 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) |
| 868 | 882 | ||
| 869 | #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ | 883 | #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ |
| 870 | pre stname *fname##_new(void) \ | 884 | pre stname * \ |
| 871 | { \ | 885 | fname##_new(void) \ |
| 872 | return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ | 886 | { \ |
| 873 | } \ | 887 | return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ |
| 874 | pre void fname##_free(stname *a) \ | 888 | } \ |
| 875 | { \ | 889 | pre void \ |
| 890 | fname##_free(stname *a) \ | ||
| 891 | { \ | ||
| 876 | ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ | 892 | ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ |
| 877 | } | 893 | } |
| 878 | 894 | ||
| 879 | #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ | 895 | #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ |
| 880 | stname *fname##_new(void) \ | 896 | stname * \ |
| 881 | { \ | 897 | fname##_new(void) \ |
| 882 | return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ | 898 | { \ |
| 883 | } \ | 899 | return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ |
| 884 | void fname##_free(stname *a) \ | 900 | } \ |
| 885 | { \ | 901 | void \ |
| 902 | fname##_free(stname *a) \ | ||
| 903 | { \ | ||
| 886 | ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ | 904 | ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ |
| 887 | } | 905 | } |
| 888 | 906 | ||
| 889 | #define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ | 907 | #define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ |
| 890 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ | 908 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ |
| 891 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) | 909 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) |
| 892 | 910 | ||
| 893 | #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ | 911 | #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ |
| 894 | stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ | 912 | stname * \ |
| 895 | { \ | 913 | d2i_##fname(stname **a, const unsigned char **in, long len) \ |
| 896 | return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ | 914 | { \ |
| 897 | } \ | 915 | return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, \ |
| 898 | int i2d_##fname(stname *a, unsigned char **out) \ | 916 | len, ASN1_ITEM_rptr(itname)); \ |
| 899 | { \ | 917 | } \ |
| 900 | return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ | 918 | int \ |
| 919 | i2d_##fname(stname *a, unsigned char **out) \ | ||
| 920 | { \ | ||
| 921 | return ASN1_item_i2d((ASN1_VALUE *)a, out, \ | ||
| 922 | ASN1_ITEM_rptr(itname)); \ | ||
| 901 | } | 923 | } |
| 902 | 924 | ||
| 903 | #define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ | 925 | #define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ |
| 904 | int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ | 926 | int \ |
| 905 | { \ | 927 | i2d_##stname##_NDEF(stname *a, unsigned char **out) \ |
| 906 | return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ | 928 | { \ |
| 929 | return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, \ | ||
| 930 | ASN1_ITEM_rptr(stname)); \ | ||
| 907 | } | 931 | } |
| 908 | 932 | ||
| 909 | /* This includes evil casts to remove const: they will go away when full | 933 | /* This includes evil casts to remove const: they will go away when full |
| 910 | * ASN1 constification is done. | 934 | * ASN1 constification is done. |
| 911 | */ | 935 | */ |
| 912 | #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ | 936 | #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ |
| 913 | stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ | 937 | stname * \ |
| 914 | { \ | 938 | d2i_##fname(stname **a, const unsigned char **in, long len) \ |
| 915 | return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ | 939 | { \ |
| 916 | } \ | 940 | return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, \ |
| 917 | int i2d_##fname(const stname *a, unsigned char **out) \ | 941 | len, ASN1_ITEM_rptr(itname)); \ |
| 918 | { \ | 942 | } \ |
| 919 | return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ | 943 | int \ |
| 944 | i2d_##fname(const stname *a, unsigned char **out) \ | ||
| 945 | { \ | ||
| 946 | return ASN1_item_i2d((ASN1_VALUE *)a, out, \ | ||
| 947 | ASN1_ITEM_rptr(itname)); \ | ||
| 920 | } | 948 | } |
| 921 | 949 | ||
| 922 | #define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ | 950 | #define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ |
| 923 | stname * stname##_dup(stname *x) \ | 951 | stname * \ |
| 924 | { \ | 952 | stname##_dup(stname *x) \ |
| 925 | return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ | 953 | { \ |
| 926 | } | 954 | return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ |
| 955 | } | ||
| 927 | 956 | ||
| 928 | #define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ | 957 | #define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ |
| 929 | IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) | 958 | IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) |
| 930 | 959 | ||
| 931 | #define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ | 960 | #define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ |
| 932 | int fname##_print_ctx(BIO *out, stname *x, int indent, \ | 961 | int \ |
| 933 | const ASN1_PCTX *pctx) \ | 962 | fname##_print_ctx(BIO *out, stname *x, int indent, \ |
| 934 | { \ | 963 | const ASN1_PCTX *pctx) \ |
| 935 | return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \ | 964 | { \ |
| 936 | ASN1_ITEM_rptr(itname), pctx); \ | 965 | return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \ |
| 966 | ASN1_ITEM_rptr(itname), pctx); \ | ||
| 937 | } | 967 | } |
| 938 | 968 | ||
| 939 | #define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ | 969 | #define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ |
| 940 | IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) | 970 | IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) |
| 941 | 971 | ||
| 942 | #define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ | 972 | #define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ |
| 943 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ | 973 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ |
| 944 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) | 974 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) |
| 945 | 975 | ||
