diff options
author | jsing <> | 2014-04-21 16:49:02 +0000 |
---|---|---|
committer | jsing <> | 2014-04-21 16:49:02 +0000 |
commit | 1d74853fd0a51591b1a5915391aee920ef15e5eb (patch) | |
tree | 5bd805c4799b19613d3cf314de0a3004d86aa88e /src/lib/libcrypto/x509v3/v3_genn.c | |
parent | fd7ee4f098b5b70e38ec12a3ba7875821d79748f (diff) | |
download | openbsd-1d74853fd0a51591b1a5915391aee920ef15e5eb.tar.gz openbsd-1d74853fd0a51591b1a5915391aee920ef15e5eb.tar.bz2 openbsd-1d74853fd0a51591b1a5915391aee920ef15e5eb.zip |
KNF.
Diffstat (limited to 'src/lib/libcrypto/x509v3/v3_genn.c')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_genn.c | 91 |
1 files changed, 48 insertions, 43 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_genn.c b/src/lib/libcrypto/x509v3/v3_genn.c index b628357301..b47098e5a7 100644 --- a/src/lib/libcrypto/x509v3/v3_genn.c +++ b/src/lib/libcrypto/x509v3/v3_genn.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 |
@@ -94,27 +94,28 @@ ASN1_CHOICE(GENERAL_NAME) = { | |||
94 | 94 | ||
95 | IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAME) | 95 | IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAME) |
96 | 96 | ||
97 | ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = | 97 | ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = |
98 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) | 98 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) |
99 | ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES) | 99 | ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES) |
100 | 100 | ||
101 | IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES) | 101 | IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES) |
102 | 102 | ||
103 | GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a) | 103 | GENERAL_NAME * |
104 | { | 104 | GENERAL_NAME_dup(GENERAL_NAME *a) |
105 | return (GENERAL_NAME *) ASN1_dup((i2d_of_void *) i2d_GENERAL_NAME, | 105 | { |
106 | (d2i_of_void *) d2i_GENERAL_NAME, | 106 | return (GENERAL_NAME *)ASN1_dup((i2d_of_void *)i2d_GENERAL_NAME, |
107 | (char *) a); | 107 | (d2i_of_void *)d2i_GENERAL_NAME, (char *)a); |
108 | } | 108 | } |
109 | 109 | ||
110 | /* Returns 0 if they are equal, != 0 otherwise. */ | 110 | /* Returns 0 if they are equal, != 0 otherwise. */ |
111 | int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) | 111 | int |
112 | { | 112 | GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) |
113 | { | ||
113 | int result = -1; | 114 | int result = -1; |
114 | 115 | ||
115 | if (!a || !b || a->type != b->type) return -1; | 116 | if (!a || !b || a->type != b->type) |
116 | switch(a->type) | 117 | return -1; |
117 | { | 118 | switch (a->type) { |
118 | case GEN_X400: | 119 | case GEN_X400: |
119 | case GEN_EDIPARTY: | 120 | case GEN_EDIPARTY: |
120 | result = ASN1_TYPE_cmp(a->d.other, b->d.other); | 121 | result = ASN1_TYPE_cmp(a->d.other, b->d.other); |
@@ -137,32 +138,34 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) | |||
137 | case GEN_IPADD: | 138 | case GEN_IPADD: |
138 | result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip); | 139 | result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip); |
139 | break; | 140 | break; |
140 | 141 | ||
141 | case GEN_RID: | 142 | case GEN_RID: |
142 | result = OBJ_cmp(a->d.rid, b->d.rid); | 143 | result = OBJ_cmp(a->d.rid, b->d.rid); |
143 | break; | 144 | break; |
144 | } | ||
145 | return result; | ||
146 | } | 145 | } |
146 | return result; | ||
147 | } | ||
147 | 148 | ||
148 | /* Returns 0 if they are equal, != 0 otherwise. */ | 149 | /* Returns 0 if they are equal, != 0 otherwise. */ |
149 | int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) | 150 | int |
150 | { | 151 | OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) |
152 | { | ||
151 | int result = -1; | 153 | int result = -1; |
152 | 154 | ||
153 | if (!a || !b) return -1; | 155 | if (!a || !b) |
156 | return -1; | ||
154 | /* Check their type first. */ | 157 | /* Check their type first. */ |
155 | if ((result = OBJ_cmp(a->type_id, b->type_id)) != 0) | 158 | if ((result = OBJ_cmp(a->type_id, b->type_id)) != 0) |
156 | return result; | 159 | return result; |
157 | /* Check the value. */ | 160 | /* Check the value. */ |
158 | result = ASN1_TYPE_cmp(a->value, b->value); | 161 | result = ASN1_TYPE_cmp(a->value, b->value); |
159 | return result; | 162 | return result; |
160 | } | 163 | } |
161 | 164 | ||
162 | void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) | 165 | void |
163 | { | 166 | GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) |
164 | switch(type) | 167 | { |
165 | { | 168 | switch (type) { |
166 | case GEN_X400: | 169 | case GEN_X400: |
167 | case GEN_EDIPARTY: | 170 | case GEN_EDIPARTY: |
168 | a->d.other = value; | 171 | a->d.other = value; |
@@ -185,20 +188,20 @@ void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) | |||
185 | case GEN_IPADD: | 188 | case GEN_IPADD: |
186 | a->d.ip = value; | 189 | a->d.ip = value; |
187 | break; | 190 | break; |
188 | 191 | ||
189 | case GEN_RID: | 192 | case GEN_RID: |
190 | a->d.rid = value; | 193 | a->d.rid = value; |
191 | break; | 194 | break; |
192 | } | ||
193 | a->type = type; | ||
194 | } | 195 | } |
196 | a->type = type; | ||
197 | } | ||
195 | 198 | ||
196 | void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) | 199 | void * |
197 | { | 200 | GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) |
201 | { | ||
198 | if (ptype) | 202 | if (ptype) |
199 | *ptype = a->type; | 203 | *ptype = a->type; |
200 | switch(a->type) | 204 | switch (a->type) { |
201 | { | ||
202 | case GEN_X400: | 205 | case GEN_X400: |
203 | case GEN_EDIPARTY: | 206 | case GEN_EDIPARTY: |
204 | return a->d.other; | 207 | return a->d.other; |
@@ -216,19 +219,21 @@ void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) | |||
216 | 219 | ||
217 | case GEN_IPADD: | 220 | case GEN_IPADD: |
218 | return a->d.ip; | 221 | return a->d.ip; |
219 | 222 | ||
220 | case GEN_RID: | 223 | case GEN_RID: |
221 | return a->d.rid; | 224 | return a->d.rid; |
222 | 225 | ||
223 | default: | 226 | default: |
224 | return NULL; | 227 | return NULL; |
225 | } | ||
226 | } | 228 | } |
229 | } | ||
227 | 230 | ||
228 | int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, | 231 | int |
229 | ASN1_OBJECT *oid, ASN1_TYPE *value) | 232 | GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, |
230 | { | 233 | ASN1_TYPE *value) |
234 | { | ||
231 | OTHERNAME *oth; | 235 | OTHERNAME *oth; |
236 | |||
232 | oth = OTHERNAME_new(); | 237 | oth = OTHERNAME_new(); |
233 | if (!oth) | 238 | if (!oth) |
234 | return 0; | 239 | return 0; |
@@ -236,11 +241,12 @@ int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, | |||
236 | oth->value = value; | 241 | oth->value = value; |
237 | GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth); | 242 | GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth); |
238 | return 1; | 243 | return 1; |
239 | } | 244 | } |
240 | 245 | ||
241 | int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, | 246 | int |
242 | ASN1_OBJECT **poid, ASN1_TYPE **pvalue) | 247 | GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, |
243 | { | 248 | ASN1_TYPE **pvalue) |
249 | { | ||
244 | if (gen->type != GEN_OTHERNAME) | 250 | if (gen->type != GEN_OTHERNAME) |
245 | return 0; | 251 | return 0; |
246 | if (poid) | 252 | if (poid) |
@@ -248,5 +254,4 @@ int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, | |||
248 | if (pvalue) | 254 | if (pvalue) |
249 | *pvalue = gen->d.otherName->value; | 255 | *pvalue = gen->d.otherName->value; |
250 | return 1; | 256 | return 1; |
251 | } | 257 | } |
252 | |||