diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/t_bitst.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/t_bitst.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/t_bitst.c b/src/lib/libcrypto/asn1/t_bitst.c index 2e59a25fa1..1dc04beabf 100644 --- a/src/lib/libcrypto/asn1/t_bitst.c +++ b/src/lib/libcrypto/asn1/t_bitst.c | |||
| @@ -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 |
| @@ -61,15 +61,18 @@ | |||
| 61 | #include <openssl/conf.h> | 61 | #include <openssl/conf.h> |
| 62 | #include <openssl/x509v3.h> | 62 | #include <openssl/x509v3.h> |
| 63 | 63 | ||
| 64 | int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, | 64 | int |
| 65 | BIT_STRING_BITNAME *tbl, int indent) | 65 | ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, |
| 66 | BIT_STRING_BITNAME *tbl, int indent) | ||
| 66 | { | 67 | { |
| 67 | BIT_STRING_BITNAME *bnam; | 68 | BIT_STRING_BITNAME *bnam; |
| 68 | char first = 1; | 69 | char first = 1; |
| 70 | |||
| 69 | BIO_printf(out, "%*s", indent, ""); | 71 | BIO_printf(out, "%*s", indent, ""); |
| 70 | for(bnam = tbl; bnam->lname; bnam++) { | 72 | for (bnam = tbl; bnam->lname; bnam++) { |
| 71 | if(ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { | 73 | if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { |
| 72 | if(!first) BIO_puts(out, ", "); | 74 | if (!first) |
| 75 | BIO_puts(out, ", "); | ||
| 73 | BIO_puts(out, bnam->lname); | 76 | BIO_puts(out, bnam->lname); |
| 74 | first = 0; | 77 | first = 0; |
| 75 | } | 78 | } |
| @@ -78,25 +81,31 @@ int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, | |||
| 78 | return 1; | 81 | return 1; |
| 79 | } | 82 | } |
| 80 | 83 | ||
| 81 | int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, | 84 | int |
| 82 | BIT_STRING_BITNAME *tbl) | 85 | ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, |
| 86 | BIT_STRING_BITNAME *tbl) | ||
| 83 | { | 87 | { |
| 84 | int bitnum; | 88 | int bitnum; |
| 89 | |||
| 85 | bitnum = ASN1_BIT_STRING_num_asc(name, tbl); | 90 | bitnum = ASN1_BIT_STRING_num_asc(name, tbl); |
| 86 | if(bitnum < 0) return 0; | 91 | if (bitnum < 0) |
| 87 | if(bs) { | 92 | return 0; |
| 88 | if(!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) | 93 | if (bs) { |
| 94 | if (!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) | ||
| 89 | return 0; | 95 | return 0; |
| 90 | } | 96 | } |
| 91 | return 1; | 97 | return 1; |
| 92 | } | 98 | } |
| 93 | 99 | ||
| 94 | int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) | 100 | int |
| 101 | ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) | ||
| 95 | { | 102 | { |
| 96 | BIT_STRING_BITNAME *bnam; | 103 | BIT_STRING_BITNAME *bnam; |
| 97 | for(bnam = tbl; bnam->lname; bnam++) { | 104 | |
| 98 | if(!strcmp(bnam->sname, name) || | 105 | for (bnam = tbl; bnam->lname; bnam++) { |
| 99 | !strcmp(bnam->lname, name) ) return bnam->bitnum; | 106 | if (!strcmp(bnam->sname, name) || |
| 107 | !strcmp(bnam->lname, name)) | ||
| 108 | return bnam->bitnum; | ||
| 100 | } | 109 | } |
| 101 | return -1; | 110 | return -1; |
| 102 | } | 111 | } |
