diff options
author | jsing <> | 2022-06-25 17:43:56 +0000 |
---|---|---|
committer | jsing <> | 2022-06-25 17:43:56 +0000 |
commit | 45d168a6140632da2ca76c8437622ccf56118001 (patch) | |
tree | f0b14e663b4474365cedaa6a7dbcf9103dc8218f | |
parent | 1d19a6a87bdf14afc50458119a6f47ca1a457aca (diff) | |
download | openbsd-45d168a6140632da2ca76c8437622ccf56118001.tar.gz openbsd-45d168a6140632da2ca76c8437622ccf56118001.tar.bz2 openbsd-45d168a6140632da2ca76c8437622ccf56118001.zip |
Use ints for boolean values.
Switch to using ints for boolean values and use 0 or 1 for constructed,
rather than using 0 the ASN.1 tag encoded value (1 << 5).
ok tb@
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index 80e185563e..375425a9f2 100644 --- a/src/lib/libcrypto/asn1/tasn_dec.c +++ b/src/lib/libcrypto/asn1/tasn_dec.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tasn_dec.c,v 1.76 2022/05/21 13:21:42 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.77 2022/06/25 17:43:56 jsing 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 | */ |
@@ -86,7 +86,7 @@ | |||
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | static int asn1_template_d2i(ASN1_VALUE **pval, CBS *cbs, | 88 | static int asn1_template_d2i(ASN1_VALUE **pval, CBS *cbs, |
89 | const ASN1_TEMPLATE *at, char optional, int depth); | 89 | const ASN1_TEMPLATE *at, int optional, int depth); |
90 | 90 | ||
91 | static int | 91 | static int |
92 | asn1_check_eoc(CBS *cbs) | 92 | asn1_check_eoc(CBS *cbs) |
@@ -103,8 +103,8 @@ asn1_check_eoc(CBS *cbs) | |||
103 | 103 | ||
104 | static int | 104 | static int |
105 | asn1_check_tag(CBS *cbs, size_t *out_len, int *out_tag, uint8_t *out_class, | 105 | asn1_check_tag(CBS *cbs, size_t *out_len, int *out_tag, uint8_t *out_class, |
106 | char *out_indefinite, char *out_constructed, int expected_tag, | 106 | int *out_indefinite, int *out_constructed, int expected_tag, |
107 | int expected_class, char optional) | 107 | int expected_class, int optional) |
108 | { | 108 | { |
109 | int constructed, indefinite; | 109 | int constructed, indefinite; |
110 | uint32_t tag_number; | 110 | uint32_t tag_number; |
@@ -168,20 +168,20 @@ asn1_check_tag(CBS *cbs, size_t *out_len, int *out_tag, uint8_t *out_class, | |||
168 | *out_tag = tag_number; | 168 | *out_tag = tag_number; |
169 | if (out_class != NULL) | 169 | if (out_class != NULL) |
170 | *out_class = tag_class << 6; | 170 | *out_class = tag_class << 6; |
171 | if (out_indefinite != NULL && indefinite) | 171 | if (out_indefinite != NULL) |
172 | *out_indefinite = 1 << 0; | 172 | *out_indefinite = indefinite; |
173 | if (out_constructed != NULL && constructed) | 173 | if (out_constructed != NULL) |
174 | *out_constructed = 1 << 5; | 174 | *out_constructed = constructed; |
175 | 175 | ||
176 | return 1; | 176 | return 1; |
177 | } | 177 | } |
178 | 178 | ||
179 | /* Collect the contents from a constructed ASN.1 object. */ | 179 | /* Collect the contents from a constructed ASN.1 object. */ |
180 | static int | 180 | static int |
181 | asn1_collect(CBB *cbb, CBS *cbs, char indefinite, int expected_tag, | 181 | asn1_collect(CBB *cbb, CBS *cbs, int indefinite, int expected_tag, |
182 | int expected_class, int depth) | 182 | int expected_class, int depth) |
183 | { | 183 | { |
184 | char constructed; | 184 | int constructed; |
185 | size_t length; | 185 | size_t length; |
186 | CBS content; | 186 | CBS content; |
187 | int need_eoc; | 187 | int need_eoc; |
@@ -232,7 +232,7 @@ asn1_collect(CBB *cbb, CBS *cbs, char indefinite, int expected_tag, | |||
232 | 232 | ||
233 | /* Find the end of an ASN.1 object. */ | 233 | /* Find the end of an ASN.1 object. */ |
234 | static int | 234 | static int |
235 | asn1_find_end(CBS *cbs, size_t length, char indefinite) | 235 | asn1_find_end(CBS *cbs, size_t length, int indefinite) |
236 | { | 236 | { |
237 | size_t eoc_count; | 237 | size_t eoc_count; |
238 | 238 | ||
@@ -446,7 +446,7 @@ asn1_c2i(ASN1_VALUE **pval, CBS *content, int utype, const ASN1_ITEM *it) | |||
446 | */ | 446 | */ |
447 | static int | 447 | static int |
448 | asn1_d2i_primitive_content(ASN1_VALUE **pval, CBS *cbs, CBS *cbs_object, | 448 | asn1_d2i_primitive_content(ASN1_VALUE **pval, CBS *cbs, CBS *cbs_object, |
449 | int utype, char constructed, char indefinite, size_t length, | 449 | int utype, int constructed, int indefinite, size_t length, |
450 | const ASN1_ITEM *it) | 450 | const ASN1_ITEM *it) |
451 | { | 451 | { |
452 | CBS cbs_content, cbs_initial; | 452 | CBS cbs_content, cbs_initial; |
@@ -515,10 +515,10 @@ asn1_d2i_primitive_content(ASN1_VALUE **pval, CBS *cbs, CBS *cbs_object, | |||
515 | 515 | ||
516 | static int | 516 | static int |
517 | asn1_d2i_any(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 517 | asn1_d2i_any(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
518 | int tag_number, int tag_class, char optional) | 518 | int tag_number, int tag_class, int optional) |
519 | { | 519 | { |
520 | char constructed, indefinite; | 520 | int constructed, indefinite; |
521 | unsigned char object_class; | 521 | uint8_t object_class; |
522 | int object_type; | 522 | int object_type; |
523 | CBS cbs_object; | 523 | CBS cbs_object; |
524 | size_t length; | 524 | size_t length; |
@@ -552,10 +552,10 @@ asn1_d2i_any(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
552 | 552 | ||
553 | static int | 553 | static int |
554 | asn1_d2i_mstring(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 554 | asn1_d2i_mstring(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
555 | int tag_number, int tag_class, char optional) | 555 | int tag_number, int tag_class, int optional) |
556 | { | 556 | { |
557 | char constructed, indefinite; | 557 | int constructed, indefinite; |
558 | unsigned char object_class; | 558 | uint8_t object_class; |
559 | int object_tag; | 559 | int object_tag; |
560 | CBS cbs_object; | 560 | CBS cbs_object; |
561 | size_t length; | 561 | size_t length; |
@@ -598,10 +598,10 @@ asn1_d2i_mstring(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
598 | 598 | ||
599 | static int | 599 | static int |
600 | asn1_d2i_primitive(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 600 | asn1_d2i_primitive(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
601 | int tag_number, int tag_class, char optional) | 601 | int tag_number, int tag_class, int optional) |
602 | { | 602 | { |
603 | CBS cbs_object; | 603 | CBS cbs_object; |
604 | char constructed, indefinite; | 604 | int constructed, indefinite; |
605 | int utype = it->utype; | 605 | int utype = it->utype; |
606 | size_t length; | 606 | size_t length; |
607 | int ret; | 607 | int ret; |
@@ -634,7 +634,7 @@ asn1_d2i_primitive(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
634 | 634 | ||
635 | static int | 635 | static int |
636 | asn1_item_d2i_choice(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 636 | asn1_item_d2i_choice(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
637 | int tag_number, int tag_class, char optional, int depth) | 637 | int tag_number, int tag_class, int optional, int depth) |
638 | { | 638 | { |
639 | const ASN1_TEMPLATE *at, *errat = NULL; | 639 | const ASN1_TEMPLATE *at, *errat = NULL; |
640 | const ASN1_AUX *aux; | 640 | const ASN1_AUX *aux; |
@@ -728,10 +728,10 @@ asn1_item_d2i_choice(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
728 | 728 | ||
729 | static int | 729 | static int |
730 | asn1_item_d2i_sequence(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 730 | asn1_item_d2i_sequence(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
731 | int tag_number, int tag_class, char optional, int depth) | 731 | int tag_number, int tag_class, int optional, int depth) |
732 | { | 732 | { |
733 | CBS cbs_seq, cbs_seq_content, cbs_object; | 733 | CBS cbs_seq, cbs_seq_content, cbs_object; |
734 | char constructed, indefinite, optional_field; | 734 | int constructed, indefinite, optional_field; |
735 | const ASN1_TEMPLATE *errat = NULL; | 735 | const ASN1_TEMPLATE *errat = NULL; |
736 | const ASN1_TEMPLATE *seqat, *at; | 736 | const ASN1_TEMPLATE *seqat, *at; |
737 | ASN1_aux_cb *asn1_cb = NULL; | 737 | ASN1_aux_cb *asn1_cb = NULL; |
@@ -904,7 +904,7 @@ asn1_item_d2i_sequence(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
904 | 904 | ||
905 | static int | 905 | static int |
906 | asn1_item_d2i_extern(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 906 | asn1_item_d2i_extern(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
907 | int tag_number, int tag_class, char optional) | 907 | int tag_number, int tag_class, int optional) |
908 | { | 908 | { |
909 | const ASN1_EXTERN_FUNCS *ef = it->funcs; | 909 | const ASN1_EXTERN_FUNCS *ef = it->funcs; |
910 | const unsigned char *p = NULL; | 910 | const unsigned char *p = NULL; |
@@ -933,7 +933,7 @@ asn1_item_d2i_extern(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
933 | 933 | ||
934 | static int | 934 | static int |
935 | asn1_item_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 935 | asn1_item_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
936 | int tag_number, int tag_class, char optional, int depth) | 936 | int tag_number, int tag_class, int optional, int depth) |
937 | { | 937 | { |
938 | if (pval == NULL) | 938 | if (pval == NULL) |
939 | return 0; | 939 | return 0; |
@@ -1008,14 +1008,14 @@ asn1_template_stack_of_free(STACK_OF(ASN1_VALUE) *avals, const ASN1_TEMPLATE *at | |||
1008 | 1008 | ||
1009 | static int | 1009 | static int |
1010 | asn1_template_stack_of_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, | 1010 | asn1_template_stack_of_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, |
1011 | char optional, int depth) | 1011 | int optional, int depth) |
1012 | { | 1012 | { |
1013 | CBS cbs_object, cbs_object_content; | 1013 | CBS cbs_object, cbs_object_content; |
1014 | STACK_OF(ASN1_VALUE) *avals = NULL; | 1014 | STACK_OF(ASN1_VALUE) *avals = NULL; |
1015 | ASN1_VALUE *aval = NULL; | 1015 | ASN1_VALUE *aval = NULL; |
1016 | int tag_number, tag_class; | 1016 | int tag_number, tag_class; |
1017 | int eoc_needed; | 1017 | int eoc_needed; |
1018 | char indefinite; | 1018 | int indefinite; |
1019 | size_t length; | 1019 | size_t length; |
1020 | int ret; | 1020 | int ret; |
1021 | 1021 | ||
@@ -1111,7 +1111,7 @@ asn1_template_stack_of_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, | |||
1111 | 1111 | ||
1112 | static int | 1112 | static int |
1113 | asn1_template_noexp_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, | 1113 | asn1_template_noexp_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, |
1114 | char optional, int depth) | 1114 | int optional, int depth) |
1115 | { | 1115 | { |
1116 | int tag_number, tag_class; | 1116 | int tag_number, tag_class; |
1117 | int ret; | 1117 | int ret; |
@@ -1150,10 +1150,10 @@ asn1_template_noexp_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, | |||
1150 | 1150 | ||
1151 | static int | 1151 | static int |
1152 | asn1_template_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, | 1152 | asn1_template_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_TEMPLATE *at, |
1153 | char optional, int depth) | 1153 | int optional, int depth) |
1154 | { | 1154 | { |
1155 | CBS cbs_exp, cbs_exp_content; | 1155 | CBS cbs_exp, cbs_exp_content; |
1156 | char constructed, indefinite; | 1156 | int constructed, indefinite; |
1157 | size_t length; | 1157 | size_t length; |
1158 | int ret; | 1158 | int ret; |
1159 | 1159 | ||
@@ -1243,7 +1243,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long inlen, | |||
1243 | 1243 | ||
1244 | CBS_init(&cbs, *in, inlen); | 1244 | CBS_init(&cbs, *in, inlen); |
1245 | if ((ret = asn1_item_d2i(pval, &cbs, it, tag_number, tag_class, | 1245 | if ((ret = asn1_item_d2i(pval, &cbs, it, tag_number, tag_class, |
1246 | optional, 0)) == 1) | 1246 | (int)optional, 0)) == 1) |
1247 | *in = CBS_data(&cbs); | 1247 | *in = CBS_data(&cbs); |
1248 | 1248 | ||
1249 | return ret; | 1249 | return ret; |