diff options
author | jsing <> | 2014-04-21 14:27:06 +0000 |
---|---|---|
committer | jsing <> | 2014-04-21 14:27:06 +0000 |
commit | ac499e34042be918cb0f1f53989f22ef20948783 (patch) | |
tree | f458806ca24206dc98c19495f9b9e3bb138d95ec /src/lib/libcrypto/x509v3/v3_bitst.c | |
parent | e4ed4425420c88ef04aa5413b94147204acfdfdd (diff) | |
download | openbsd-ac499e34042be918cb0f1f53989f22ef20948783.tar.gz openbsd-ac499e34042be918cb0f1f53989f22ef20948783.tar.bz2 openbsd-ac499e34042be918cb0f1f53989f22ef20948783.zip |
KNF.
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_bitst.c | 88 |
1 files changed, 46 insertions, 42 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_bitst.c b/src/lib/libcrypto/x509v3/v3_bitst.c index 058d0d4dce..31549cf003 100644 --- a/src/lib/libcrypto/x509v3/v3_bitst.c +++ b/src/lib/libcrypto/x509v3/v3_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 |
@@ -62,74 +62,80 @@ | |||
62 | #include <openssl/x509v3.h> | 62 | #include <openssl/x509v3.h> |
63 | 63 | ||
64 | static BIT_STRING_BITNAME ns_cert_type_table[] = { | 64 | static BIT_STRING_BITNAME ns_cert_type_table[] = { |
65 | {0, "SSL Client", "client"}, | 65 | {0, "SSL Client", "client"}, |
66 | {1, "SSL Server", "server"}, | 66 | {1, "SSL Server", "server"}, |
67 | {2, "S/MIME", "email"}, | 67 | {2, "S/MIME", "email"}, |
68 | {3, "Object Signing", "objsign"}, | 68 | {3, "Object Signing", "objsign"}, |
69 | {4, "Unused", "reserved"}, | 69 | {4, "Unused", "reserved"}, |
70 | {5, "SSL CA", "sslCA"}, | 70 | {5, "SSL CA", "sslCA"}, |
71 | {6, "S/MIME CA", "emailCA"}, | 71 | {6, "S/MIME CA", "emailCA"}, |
72 | {7, "Object Signing CA", "objCA"}, | 72 | {7, "Object Signing CA", "objCA"}, |
73 | {-1, NULL, NULL} | 73 | {-1, NULL, NULL} |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static BIT_STRING_BITNAME key_usage_type_table[] = { | 76 | static BIT_STRING_BITNAME key_usage_type_table[] = { |
77 | {0, "Digital Signature", "digitalSignature"}, | 77 | {0, "Digital Signature", "digitalSignature"}, |
78 | {1, "Non Repudiation", "nonRepudiation"}, | 78 | {1, "Non Repudiation", "nonRepudiation"}, |
79 | {2, "Key Encipherment", "keyEncipherment"}, | 79 | {2, "Key Encipherment", "keyEncipherment"}, |
80 | {3, "Data Encipherment", "dataEncipherment"}, | 80 | {3, "Data Encipherment", "dataEncipherment"}, |
81 | {4, "Key Agreement", "keyAgreement"}, | 81 | {4, "Key Agreement", "keyAgreement"}, |
82 | {5, "Certificate Sign", "keyCertSign"}, | 82 | {5, "Certificate Sign", "keyCertSign"}, |
83 | {6, "CRL Sign", "cRLSign"}, | 83 | {6, "CRL Sign", "cRLSign"}, |
84 | {7, "Encipher Only", "encipherOnly"}, | 84 | {7, "Encipher Only", "encipherOnly"}, |
85 | {8, "Decipher Only", "decipherOnly"}, | 85 | {8, "Decipher Only", "decipherOnly"}, |
86 | {-1, NULL, NULL} | 86 | {-1, NULL, NULL} |
87 | }; | 87 | }; |
88 | 88 | ||
89 | 89 | ||
90 | const X509V3_EXT_METHOD v3_nscert = | ||
91 | EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table); | ||
92 | const X509V3_EXT_METHOD v3_key_usage = | ||
93 | EXT_BITSTRING(NID_key_usage, key_usage_type_table); | ||
90 | 94 | ||
91 | const X509V3_EXT_METHOD v3_nscert = EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table); | 95 | STACK_OF(CONF_VALUE) * |
92 | const X509V3_EXT_METHOD v3_key_usage = EXT_BITSTRING(NID_key_usage, key_usage_type_table); | 96 | i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits, |
93 | 97 | STACK_OF(CONF_VALUE) *ret) | |
94 | STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, | ||
95 | ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) *ret) | ||
96 | { | 98 | { |
97 | BIT_STRING_BITNAME *bnam; | 99 | BIT_STRING_BITNAME *bnam; |
98 | for(bnam =method->usr_data; bnam->lname; bnam++) { | 100 | |
99 | if(ASN1_BIT_STRING_get_bit(bits, bnam->bitnum)) | 101 | for (bnam = method->usr_data; bnam->lname; bnam++) { |
102 | if (ASN1_BIT_STRING_get_bit(bits, bnam->bitnum)) | ||
100 | X509V3_add_value(bnam->lname, NULL, &ret); | 103 | X509V3_add_value(bnam->lname, NULL, &ret); |
101 | } | 104 | } |
102 | return ret; | 105 | return ret; |
103 | } | 106 | } |
104 | 107 | ||
105 | ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, | 108 | ASN1_BIT_STRING * |
106 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | 109 | v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
110 | STACK_OF(CONF_VALUE) *nval) | ||
107 | { | 111 | { |
108 | CONF_VALUE *val; | 112 | CONF_VALUE *val; |
109 | ASN1_BIT_STRING *bs; | 113 | ASN1_BIT_STRING *bs; |
110 | int i; | 114 | int i; |
111 | BIT_STRING_BITNAME *bnam; | 115 | BIT_STRING_BITNAME *bnam; |
112 | if(!(bs = M_ASN1_BIT_STRING_new())) { | 116 | |
113 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,ERR_R_MALLOC_FAILURE); | 117 | if (!(bs = M_ASN1_BIT_STRING_new())) { |
118 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, ERR_R_MALLOC_FAILURE); | ||
114 | return NULL; | 119 | return NULL; |
115 | } | 120 | } |
116 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | 121 | for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { |
117 | val = sk_CONF_VALUE_value(nval, i); | 122 | val = sk_CONF_VALUE_value(nval, i); |
118 | for(bnam = method->usr_data; bnam->lname; bnam++) { | 123 | for (bnam = method->usr_data; bnam->lname; bnam++) { |
119 | if(!strcmp(bnam->sname, val->name) || | 124 | if (!strcmp(bnam->sname, val->name) || |
120 | !strcmp(bnam->lname, val->name) ) { | 125 | !strcmp(bnam->lname, val->name) ) { |
121 | if(!ASN1_BIT_STRING_set_bit(bs, bnam->bitnum, 1)) { | 126 | if (!ASN1_BIT_STRING_set_bit(bs, |
127 | bnam->bitnum, 1)) { | ||
122 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, | 128 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, |
123 | ERR_R_MALLOC_FAILURE); | 129 | ERR_R_MALLOC_FAILURE); |
124 | M_ASN1_BIT_STRING_free(bs); | 130 | M_ASN1_BIT_STRING_free(bs); |
125 | return NULL; | 131 | return NULL; |
126 | } | 132 | } |
127 | break; | 133 | break; |
128 | } | 134 | } |
129 | } | 135 | } |
130 | if(!bnam->lname) { | 136 | if (!bnam->lname) { |
131 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, | 137 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, |
132 | X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); | 138 | X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); |
133 | X509V3_conf_err(val); | 139 | X509V3_conf_err(val); |
134 | M_ASN1_BIT_STRING_free(bs); | 140 | M_ASN1_BIT_STRING_free(bs); |
135 | return NULL; | 141 | return NULL; |
@@ -137,5 +143,3 @@ ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, | |||
137 | } | 143 | } |
138 | return bs; | 144 | return bs; |
139 | } | 145 | } |
140 | |||
141 | |||