diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_cpols.c | 311 |
1 files changed, 172 insertions, 139 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_cpols.c b/src/lib/libcrypto/x509v3/v3_cpols.c index 1a337fa07e..e00190242b 100644 --- a/src/lib/libcrypto/x509v3/v3_cpols.c +++ b/src/lib/libcrypto/x509v3/v3_cpols.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 |
@@ -67,28 +67,32 @@ | |||
67 | 67 | ||
68 | /* Certificate policies extension support: this one is a bit complex... */ | 68 | /* Certificate policies extension support: this one is a bit complex... */ |
69 | 69 | ||
70 | static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, BIO *out, int indent); | 70 | static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, |
71 | static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *value); | 71 | BIO *out, int indent); |
72 | static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, int indent); | 72 | static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, |
73 | X509V3_CTX *ctx, char *value); | ||
74 | static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, | ||
75 | int indent); | ||
73 | static void print_notice(BIO *out, USERNOTICE *notice, int indent); | 76 | static void print_notice(BIO *out, USERNOTICE *notice, int indent); |
74 | static POLICYINFO *policy_section(X509V3_CTX *ctx, | 77 | static POLICYINFO *policy_section(X509V3_CTX *ctx, |
75 | STACK_OF(CONF_VALUE) *polstrs, int ia5org); | 78 | STACK_OF(CONF_VALUE) *polstrs, int ia5org); |
76 | static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, | 79 | static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, |
77 | STACK_OF(CONF_VALUE) *unot, int ia5org); | 80 | STACK_OF(CONF_VALUE) *unot, int ia5org); |
78 | static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos); | 81 | static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos); |
79 | 82 | ||
80 | const X509V3_EXT_METHOD v3_cpols = { | 83 | const X509V3_EXT_METHOD v3_cpols = { |
81 | NID_certificate_policies, 0,ASN1_ITEM_ref(CERTIFICATEPOLICIES), | 84 | NID_certificate_policies, 0, ASN1_ITEM_ref(CERTIFICATEPOLICIES), |
82 | 0,0,0,0, | 85 | 0, 0, 0, 0, |
83 | 0,0, | 86 | 0, 0, |
84 | 0,0, | 87 | 0, 0, |
85 | (X509V3_EXT_I2R)i2r_certpol, | 88 | (X509V3_EXT_I2R)i2r_certpol, |
86 | (X509V3_EXT_R2I)r2i_certpol, | 89 | (X509V3_EXT_R2I)r2i_certpol, |
87 | NULL | 90 | NULL |
88 | }; | 91 | }; |
89 | 92 | ||
90 | ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES) = | 93 | ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES) = |
91 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CERTIFICATEPOLICIES, POLICYINFO) | 94 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CERTIFICATEPOLICIES, |
95 | POLICYINFO) | ||
92 | ASN1_ITEM_TEMPLATE_END(CERTIFICATEPOLICIES) | 96 | ASN1_ITEM_TEMPLATE_END(CERTIFICATEPOLICIES) |
93 | 97 | ||
94 | IMPLEMENT_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) | 98 | IMPLEMENT_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) |
@@ -100,7 +104,8 @@ ASN1_SEQUENCE(POLICYINFO) = { | |||
100 | 104 | ||
101 | IMPLEMENT_ASN1_FUNCTIONS(POLICYINFO) | 105 | IMPLEMENT_ASN1_FUNCTIONS(POLICYINFO) |
102 | 106 | ||
103 | ASN1_ADB_TEMPLATE(policydefault) = ASN1_SIMPLE(POLICYQUALINFO, d.other, ASN1_ANY); | 107 | ASN1_ADB_TEMPLATE(policydefault) = |
108 | ASN1_SIMPLE(POLICYQUALINFO, d.other, ASN1_ANY); | ||
104 | 109 | ||
105 | ASN1_ADB(POLICYQUALINFO) = { | 110 | ASN1_ADB(POLICYQUALINFO) = { |
106 | ADB_ENTRY(NID_id_qt_cps, ASN1_SIMPLE(POLICYQUALINFO, d.cpsuri, ASN1_IA5STRING)), | 111 | ADB_ENTRY(NID_id_qt_cps, ASN1_SIMPLE(POLICYQUALINFO, d.cpsuri, ASN1_IA5STRING)), |
@@ -128,8 +133,9 @@ ASN1_SEQUENCE(NOTICEREF) = { | |||
128 | 133 | ||
129 | IMPLEMENT_ASN1_FUNCTIONS(NOTICEREF) | 134 | IMPLEMENT_ASN1_FUNCTIONS(NOTICEREF) |
130 | 135 | ||
131 | static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, | 136 | static |
132 | X509V3_CTX *ctx, char *value) | 137 | STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
138 | char *value) | ||
133 | { | 139 | { |
134 | STACK_OF(POLICYINFO) *pols = NULL; | 140 | STACK_OF(POLICYINFO) *pols = NULL; |
135 | char *pstr; | 141 | char *pstr; |
@@ -138,43 +144,47 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, | |||
138 | STACK_OF(CONF_VALUE) *vals; | 144 | STACK_OF(CONF_VALUE) *vals; |
139 | CONF_VALUE *cnf; | 145 | CONF_VALUE *cnf; |
140 | int i, ia5org; | 146 | int i, ia5org; |
147 | |||
141 | pols = sk_POLICYINFO_new_null(); | 148 | pols = sk_POLICYINFO_new_null(); |
142 | if (pols == NULL) { | 149 | if (pols == NULL) { |
143 | X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_MALLOC_FAILURE); | 150 | X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_MALLOC_FAILURE); |
144 | return NULL; | 151 | return NULL; |
145 | } | 152 | } |
146 | vals = X509V3_parse_list(value); | 153 | vals = X509V3_parse_list(value); |
147 | if (vals == NULL) { | 154 | if (vals == NULL) { |
148 | X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_X509V3_LIB); | 155 | X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_X509V3_LIB); |
149 | goto err; | 156 | goto err; |
150 | } | 157 | } |
151 | ia5org = 0; | 158 | ia5org = 0; |
152 | for(i = 0; i < sk_CONF_VALUE_num(vals); i++) { | 159 | for (i = 0; i < sk_CONF_VALUE_num(vals); i++) { |
153 | cnf = sk_CONF_VALUE_value(vals, i); | 160 | cnf = sk_CONF_VALUE_value(vals, i); |
154 | if(cnf->value || !cnf->name ) { | 161 | if (cnf->value || !cnf->name ) { |
155 | X509V3err(X509V3_F_R2I_CERTPOL,X509V3_R_INVALID_POLICY_IDENTIFIER); | 162 | X509V3err(X509V3_F_R2I_CERTPOL, |
163 | X509V3_R_INVALID_POLICY_IDENTIFIER); | ||
156 | X509V3_conf_err(cnf); | 164 | X509V3_conf_err(cnf); |
157 | goto err; | 165 | goto err; |
158 | } | 166 | } |
159 | pstr = cnf->name; | 167 | pstr = cnf->name; |
160 | if(!strcmp(pstr,"ia5org")) { | 168 | if (!strcmp(pstr, "ia5org")) { |
161 | ia5org = 1; | 169 | ia5org = 1; |
162 | continue; | 170 | continue; |
163 | } else if(*pstr == '@') { | 171 | } else if (*pstr == '@') { |
164 | STACK_OF(CONF_VALUE) *polsect; | 172 | STACK_OF(CONF_VALUE) *polsect; |
165 | polsect = X509V3_get_section(ctx, pstr + 1); | 173 | polsect = X509V3_get_section(ctx, pstr + 1); |
166 | if(!polsect) { | 174 | if (!polsect) { |
167 | X509V3err(X509V3_F_R2I_CERTPOL,X509V3_R_INVALID_SECTION); | 175 | X509V3err(X509V3_F_R2I_CERTPOL, |
168 | 176 | X509V3_R_INVALID_SECTION); | |
169 | X509V3_conf_err(cnf); | 177 | X509V3_conf_err(cnf); |
170 | goto err; | 178 | goto err; |
171 | } | 179 | } |
172 | pol = policy_section(ctx, polsect, ia5org); | 180 | pol = policy_section(ctx, polsect, ia5org); |
173 | X509V3_section_free(ctx, polsect); | 181 | X509V3_section_free(ctx, polsect); |
174 | if(!pol) goto err; | 182 | if (!pol) |
183 | goto err; | ||
175 | } else { | 184 | } else { |
176 | if(!(pobj = OBJ_txt2obj(cnf->name, 0))) { | 185 | if (!(pobj = OBJ_txt2obj(cnf->name, 0))) { |
177 | X509V3err(X509V3_F_R2I_CERTPOL,X509V3_R_INVALID_OBJECT_IDENTIFIER); | 186 | X509V3err(X509V3_F_R2I_CERTPOL, |
187 | X509V3_R_INVALID_OBJECT_IDENTIFIER); | ||
178 | X509V3_conf_err(cnf); | 188 | X509V3_conf_err(cnf); |
179 | goto err; | 189 | goto err; |
180 | } | 190 | } |
@@ -189,123 +199,140 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, | |||
189 | } | 199 | } |
190 | sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); | 200 | sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); |
191 | return pols; | 201 | return pols; |
192 | err: | 202 | |
203 | err: | ||
193 | sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); | 204 | sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); |
194 | sk_POLICYINFO_pop_free(pols, POLICYINFO_free); | 205 | sk_POLICYINFO_pop_free(pols, POLICYINFO_free); |
195 | return NULL; | 206 | return NULL; |
196 | } | 207 | } |
197 | 208 | ||
198 | static POLICYINFO *policy_section(X509V3_CTX *ctx, | 209 | static POLICYINFO * |
199 | STACK_OF(CONF_VALUE) *polstrs, int ia5org) | 210 | policy_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *polstrs, int ia5org) |
200 | { | 211 | { |
201 | int i; | 212 | int i; |
202 | CONF_VALUE *cnf; | 213 | CONF_VALUE *cnf; |
203 | POLICYINFO *pol; | 214 | POLICYINFO *pol; |
204 | POLICYQUALINFO *qual; | 215 | POLICYQUALINFO *qual; |
205 | if(!(pol = POLICYINFO_new())) goto merr; | 216 | |
206 | for(i = 0; i < sk_CONF_VALUE_num(polstrs); i++) { | 217 | if (!(pol = POLICYINFO_new())) |
218 | goto merr; | ||
219 | for (i = 0; i < sk_CONF_VALUE_num(polstrs); i++) { | ||
207 | cnf = sk_CONF_VALUE_value(polstrs, i); | 220 | cnf = sk_CONF_VALUE_value(polstrs, i); |
208 | if(!strcmp(cnf->name, "policyIdentifier")) { | 221 | if (!strcmp(cnf->name, "policyIdentifier")) { |
209 | ASN1_OBJECT *pobj; | 222 | ASN1_OBJECT *pobj; |
210 | if(!(pobj = OBJ_txt2obj(cnf->value, 0))) { | 223 | if (!(pobj = OBJ_txt2obj(cnf->value, 0))) { |
211 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_INVALID_OBJECT_IDENTIFIER); | 224 | X509V3err(X509V3_F_POLICY_SECTION, |
225 | X509V3_R_INVALID_OBJECT_IDENTIFIER); | ||
212 | X509V3_conf_err(cnf); | 226 | X509V3_conf_err(cnf); |
213 | goto err; | 227 | goto err; |
214 | } | 228 | } |
215 | pol->policyid = pobj; | 229 | pol->policyid = pobj; |
216 | 230 | } else if (!name_cmp(cnf->name, "CPS")) { | |
217 | } else if(!name_cmp(cnf->name, "CPS")) { | 231 | if (!pol->qualifiers) |
218 | if(!pol->qualifiers) pol->qualifiers = | 232 | pol->qualifiers = sk_POLICYQUALINFO_new_null(); |
219 | sk_POLICYQUALINFO_new_null(); | 233 | if (!(qual = POLICYQUALINFO_new())) |
220 | if(!(qual = POLICYQUALINFO_new())) goto merr; | 234 | goto merr; |
221 | if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) | 235 | if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) |
222 | goto merr; | 236 | goto merr; |
223 | qual->pqualid = OBJ_nid2obj(NID_id_qt_cps); | 237 | qual->pqualid = OBJ_nid2obj(NID_id_qt_cps); |
224 | qual->d.cpsuri = M_ASN1_IA5STRING_new(); | 238 | qual->d.cpsuri = M_ASN1_IA5STRING_new(); |
225 | if(!ASN1_STRING_set(qual->d.cpsuri, cnf->value, | 239 | if (!ASN1_STRING_set(qual->d.cpsuri, cnf->value, |
226 | strlen(cnf->value))) goto merr; | 240 | strlen(cnf->value))) |
227 | } else if(!name_cmp(cnf->name, "userNotice")) { | 241 | goto merr; |
242 | } else if (!name_cmp(cnf->name, "userNotice")) { | ||
228 | STACK_OF(CONF_VALUE) *unot; | 243 | STACK_OF(CONF_VALUE) *unot; |
229 | if(*cnf->value != '@') { | 244 | if (*cnf->value != '@') { |
230 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_EXPECTED_A_SECTION_NAME); | 245 | X509V3err(X509V3_F_POLICY_SECTION, |
246 | X509V3_R_EXPECTED_A_SECTION_NAME); | ||
231 | X509V3_conf_err(cnf); | 247 | X509V3_conf_err(cnf); |
232 | goto err; | 248 | goto err; |
233 | } | 249 | } |
234 | unot = X509V3_get_section(ctx, cnf->value + 1); | 250 | unot = X509V3_get_section(ctx, cnf->value + 1); |
235 | if(!unot) { | 251 | if (!unot) { |
236 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_INVALID_SECTION); | 252 | X509V3err(X509V3_F_POLICY_SECTION, |
237 | 253 | X509V3_R_INVALID_SECTION); | |
238 | X509V3_conf_err(cnf); | 254 | X509V3_conf_err(cnf); |
239 | goto err; | 255 | goto err; |
240 | } | 256 | } |
241 | qual = notice_section(ctx, unot, ia5org); | 257 | qual = notice_section(ctx, unot, ia5org); |
242 | X509V3_section_free(ctx, unot); | 258 | X509V3_section_free(ctx, unot); |
243 | if(!qual) goto err; | 259 | if (!qual) |
244 | if(!pol->qualifiers) pol->qualifiers = | 260 | goto err; |
245 | sk_POLICYQUALINFO_new_null(); | 261 | if (!pol->qualifiers) pol->qualifiers = |
246 | if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) | 262 | sk_POLICYQUALINFO_new_null(); |
247 | goto merr; | 263 | if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) |
264 | goto merr; | ||
248 | } else { | 265 | } else { |
249 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_INVALID_OPTION); | 266 | X509V3err(X509V3_F_POLICY_SECTION, |
250 | 267 | X509V3_R_INVALID_OPTION); | |
251 | X509V3_conf_err(cnf); | 268 | X509V3_conf_err(cnf); |
252 | goto err; | 269 | goto err; |
253 | } | 270 | } |
254 | } | 271 | } |
255 | if(!pol->policyid) { | 272 | if (!pol->policyid) { |
256 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_NO_POLICY_IDENTIFIER); | 273 | X509V3err(X509V3_F_POLICY_SECTION, |
274 | X509V3_R_NO_POLICY_IDENTIFIER); | ||
257 | goto err; | 275 | goto err; |
258 | } | 276 | } |
259 | 277 | ||
260 | return pol; | 278 | return pol; |
261 | 279 | ||
262 | merr: | 280 | merr: |
263 | X509V3err(X509V3_F_POLICY_SECTION,ERR_R_MALLOC_FAILURE); | 281 | X509V3err(X509V3_F_POLICY_SECTION, ERR_R_MALLOC_FAILURE); |
264 | 282 | ||
265 | err: | 283 | err: |
266 | POLICYINFO_free(pol); | 284 | POLICYINFO_free(pol); |
267 | return NULL; | 285 | return NULL; |
268 | |||
269 | |||
270 | } | 286 | } |
271 | 287 | ||
272 | static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, | 288 | static POLICYQUALINFO * |
273 | STACK_OF(CONF_VALUE) *unot, int ia5org) | 289 | notice_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *unot, int ia5org) |
274 | { | 290 | { |
275 | int i, ret; | 291 | int i, ret; |
276 | CONF_VALUE *cnf; | 292 | CONF_VALUE *cnf; |
277 | USERNOTICE *not; | 293 | USERNOTICE *not; |
278 | POLICYQUALINFO *qual; | 294 | POLICYQUALINFO *qual; |
279 | if(!(qual = POLICYQUALINFO_new())) goto merr; | 295 | |
296 | if (!(qual = POLICYQUALINFO_new())) | ||
297 | goto merr; | ||
280 | qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice); | 298 | qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice); |
281 | if(!(not = USERNOTICE_new())) goto merr; | 299 | if (!(not = USERNOTICE_new())) |
300 | goto merr; | ||
282 | qual->d.usernotice = not; | 301 | qual->d.usernotice = not; |
283 | for(i = 0; i < sk_CONF_VALUE_num(unot); i++) { | 302 | for (i = 0; i < sk_CONF_VALUE_num(unot); i++) { |
284 | cnf = sk_CONF_VALUE_value(unot, i); | 303 | cnf = sk_CONF_VALUE_value(unot, i); |
285 | if(!strcmp(cnf->name, "explicitText")) { | 304 | if (!strcmp(cnf->name, "explicitText")) { |
286 | not->exptext = M_ASN1_VISIBLESTRING_new(); | 305 | not->exptext = M_ASN1_VISIBLESTRING_new(); |
287 | if(!ASN1_STRING_set(not->exptext, cnf->value, | 306 | if (!ASN1_STRING_set(not->exptext, cnf->value, |
288 | strlen(cnf->value))) goto merr; | 307 | strlen(cnf->value))) |
289 | } else if(!strcmp(cnf->name, "organization")) { | 308 | goto merr; |
309 | } else if (!strcmp(cnf->name, "organization")) { | ||
290 | NOTICEREF *nref; | 310 | NOTICEREF *nref; |
291 | if(!not->noticeref) { | 311 | if (!not->noticeref) { |
292 | if(!(nref = NOTICEREF_new())) goto merr; | 312 | if (!(nref = NOTICEREF_new())) |
313 | goto merr; | ||
293 | not->noticeref = nref; | 314 | not->noticeref = nref; |
294 | } else nref = not->noticeref; | 315 | } else |
295 | if(ia5org) nref->organization->type = V_ASN1_IA5STRING; | 316 | nref = not->noticeref; |
296 | else nref->organization->type = V_ASN1_VISIBLESTRING; | 317 | if (ia5org) |
297 | if(!ASN1_STRING_set(nref->organization, cnf->value, | 318 | nref->organization->type = V_ASN1_IA5STRING; |
298 | strlen(cnf->value))) goto merr; | 319 | else |
299 | } else if(!strcmp(cnf->name, "noticeNumbers")) { | 320 | nref->organization->type = V_ASN1_VISIBLESTRING; |
321 | if (!ASN1_STRING_set(nref->organization, cnf->value, | ||
322 | strlen(cnf->value))) | ||
323 | goto merr; | ||
324 | } else if (!strcmp(cnf->name, "noticeNumbers")) { | ||
300 | NOTICEREF *nref; | 325 | NOTICEREF *nref; |
301 | STACK_OF(CONF_VALUE) *nos; | 326 | STACK_OF(CONF_VALUE) *nos; |
302 | if(!not->noticeref) { | 327 | if (!not->noticeref) { |
303 | if(!(nref = NOTICEREF_new())) goto merr; | 328 | if (!(nref = NOTICEREF_new())) |
329 | goto merr; | ||
304 | not->noticeref = nref; | 330 | not->noticeref = nref; |
305 | } else nref = not->noticeref; | 331 | } else nref = not->noticeref; |
306 | nos = X509V3_parse_list(cnf->value); | 332 | nos = X509V3_parse_list(cnf->value); |
307 | if(!nos || !sk_CONF_VALUE_num(nos)) { | 333 | if (!nos || !sk_CONF_VALUE_num(nos)) { |
308 | X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_INVALID_NUMBERS); | 334 | X509V3err(X509V3_F_NOTICE_SECTION, |
335 | X509V3_R_INVALID_NUMBERS); | ||
309 | X509V3_conf_err(cnf); | 336 | X509V3_conf_err(cnf); |
310 | goto err; | 337 | goto err; |
311 | } | 338 | } |
@@ -314,94 +341,98 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, | |||
314 | if (!ret) | 341 | if (!ret) |
315 | goto err; | 342 | goto err; |
316 | } else { | 343 | } else { |
317 | X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_INVALID_OPTION); | 344 | X509V3err(X509V3_F_NOTICE_SECTION, |
345 | X509V3_R_INVALID_OPTION); | ||
318 | X509V3_conf_err(cnf); | 346 | X509V3_conf_err(cnf); |
319 | goto err; | 347 | goto err; |
320 | } | 348 | } |
321 | } | 349 | } |
322 | 350 | ||
323 | if(not->noticeref && | 351 | if (not->noticeref && |
324 | (!not->noticeref->noticenos || !not->noticeref->organization)) { | 352 | (!not->noticeref->noticenos || !not->noticeref->organization)) { |
325 | X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_NEED_ORGANIZATION_AND_NUMBERS); | 353 | X509V3err(X509V3_F_NOTICE_SECTION, |
326 | goto err; | 354 | X509V3_R_NEED_ORGANIZATION_AND_NUMBERS); |
355 | goto err; | ||
327 | } | 356 | } |
328 | 357 | ||
329 | return qual; | 358 | return qual; |
330 | 359 | ||
331 | merr: | 360 | merr: |
332 | X509V3err(X509V3_F_NOTICE_SECTION,ERR_R_MALLOC_FAILURE); | 361 | X509V3err(X509V3_F_NOTICE_SECTION, ERR_R_MALLOC_FAILURE); |
333 | 362 | ||
334 | err: | 363 | err: |
335 | POLICYQUALINFO_free(qual); | 364 | POLICYQUALINFO_free(qual); |
336 | return NULL; | 365 | return NULL; |
337 | } | 366 | } |
338 | 367 | ||
339 | static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos) | 368 | static int |
369 | nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos) | ||
340 | { | 370 | { |
341 | CONF_VALUE *cnf; | 371 | CONF_VALUE *cnf; |
342 | ASN1_INTEGER *aint; | 372 | ASN1_INTEGER *aint; |
343 | |||
344 | int i; | 373 | int i; |
345 | 374 | ||
346 | for(i = 0; i < sk_CONF_VALUE_num(nos); i++) { | 375 | for (i = 0; i < sk_CONF_VALUE_num(nos); i++) { |
347 | cnf = sk_CONF_VALUE_value(nos, i); | 376 | cnf = sk_CONF_VALUE_value(nos, i); |
348 | if(!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) { | 377 | if (!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) { |
349 | X509V3err(X509V3_F_NREF_NOS,X509V3_R_INVALID_NUMBER); | 378 | X509V3err(X509V3_F_NREF_NOS, X509V3_R_INVALID_NUMBER); |
350 | goto err; | 379 | goto err; |
351 | } | 380 | } |
352 | if(!sk_ASN1_INTEGER_push(nnums, aint)) goto merr; | 381 | if (!sk_ASN1_INTEGER_push(nnums, aint)) |
382 | goto merr; | ||
353 | } | 383 | } |
354 | return 1; | 384 | return 1; |
355 | 385 | ||
356 | merr: | 386 | merr: |
357 | X509V3err(X509V3_F_NREF_NOS,ERR_R_MALLOC_FAILURE); | 387 | X509V3err(X509V3_F_NREF_NOS, ERR_R_MALLOC_FAILURE); |
358 | 388 | ||
359 | err: | 389 | err: |
360 | sk_ASN1_INTEGER_pop_free(nnums, ASN1_STRING_free); | 390 | sk_ASN1_INTEGER_pop_free(nnums, ASN1_STRING_free); |
361 | return 0; | 391 | return 0; |
362 | } | 392 | } |
363 | 393 | ||
364 | 394 | static int | |
365 | static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, | 395 | i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, BIO *out, |
366 | BIO *out, int indent) | 396 | int indent) |
367 | { | 397 | { |
368 | int i; | 398 | int i; |
369 | POLICYINFO *pinfo; | 399 | POLICYINFO *pinfo; |
400 | |||
370 | /* First print out the policy OIDs */ | 401 | /* First print out the policy OIDs */ |
371 | for(i = 0; i < sk_POLICYINFO_num(pol); i++) { | 402 | for (i = 0; i < sk_POLICYINFO_num(pol); i++) { |
372 | pinfo = sk_POLICYINFO_value(pol, i); | 403 | pinfo = sk_POLICYINFO_value(pol, i); |
373 | BIO_printf(out, "%*sPolicy: ", indent, ""); | 404 | BIO_printf(out, "%*sPolicy: ", indent, ""); |
374 | i2a_ASN1_OBJECT(out, pinfo->policyid); | 405 | i2a_ASN1_OBJECT(out, pinfo->policyid); |
375 | BIO_puts(out, "\n"); | 406 | BIO_puts(out, "\n"); |
376 | if(pinfo->qualifiers) | 407 | if (pinfo->qualifiers) |
377 | print_qualifiers(out, pinfo->qualifiers, indent + 2); | 408 | print_qualifiers(out, pinfo->qualifiers, indent + 2); |
378 | } | 409 | } |
379 | return 1; | 410 | return 1; |
380 | } | 411 | } |
381 | 412 | ||
382 | static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, | 413 | static void |
383 | int indent) | 414 | print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, int indent) |
384 | { | 415 | { |
385 | POLICYQUALINFO *qualinfo; | 416 | POLICYQUALINFO *qualinfo; |
386 | int i; | 417 | int i; |
387 | for(i = 0; i < sk_POLICYQUALINFO_num(quals); i++) { | 418 | |
419 | for (i = 0; i < sk_POLICYQUALINFO_num(quals); i++) { | ||
388 | qualinfo = sk_POLICYQUALINFO_value(quals, i); | 420 | qualinfo = sk_POLICYQUALINFO_value(quals, i); |
389 | switch(OBJ_obj2nid(qualinfo->pqualid)) | 421 | switch (OBJ_obj2nid(qualinfo->pqualid)) { |
390 | { | 422 | case NID_id_qt_cps: |
391 | case NID_id_qt_cps: | ||
392 | BIO_printf(out, "%*sCPS: %s\n", indent, "", | 423 | BIO_printf(out, "%*sCPS: %s\n", indent, "", |
393 | qualinfo->d.cpsuri->data); | 424 | qualinfo->d.cpsuri->data); |
394 | break; | 425 | break; |
395 | 426 | ||
396 | case NID_id_qt_unotice: | 427 | case NID_id_qt_unotice: |
397 | BIO_printf(out, "%*sUser Notice:\n", indent, ""); | 428 | BIO_printf(out, "%*sUser Notice:\n", indent, ""); |
398 | print_notice(out, qualinfo->d.usernotice, indent + 2); | 429 | print_notice(out, qualinfo->d.usernotice, indent + 2); |
399 | break; | 430 | break; |
400 | 431 | ||
401 | default: | 432 | default: |
402 | BIO_printf(out, "%*sUnknown Qualifier: ", | 433 | BIO_printf(out, "%*sUnknown Qualifier: ", |
403 | indent + 2, ""); | 434 | indent + 2, ""); |
404 | 435 | ||
405 | i2a_ASN1_OBJECT(out, qualinfo->pqualid); | 436 | i2a_ASN1_OBJECT(out, qualinfo->pqualid); |
406 | BIO_puts(out, "\n"); | 437 | BIO_puts(out, "\n"); |
407 | break; | 438 | break; |
@@ -409,49 +440,51 @@ static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, | |||
409 | } | 440 | } |
410 | } | 441 | } |
411 | 442 | ||
412 | static void print_notice(BIO *out, USERNOTICE *notice, int indent) | 443 | static void |
444 | print_notice(BIO *out, USERNOTICE *notice, int indent) | ||
413 | { | 445 | { |
414 | int i; | 446 | int i; |
415 | if(notice->noticeref) { | 447 | |
448 | if (notice->noticeref) { | ||
416 | NOTICEREF *ref; | 449 | NOTICEREF *ref; |
417 | ref = notice->noticeref; | 450 | ref = notice->noticeref; |
418 | BIO_printf(out, "%*sOrganization: %s\n", indent, "", | 451 | BIO_printf(out, "%*sOrganization: %s\n", indent, "", |
419 | ref->organization->data); | 452 | ref->organization->data); |
420 | BIO_printf(out, "%*sNumber%s: ", indent, "", | 453 | BIO_printf(out, "%*sNumber%s: ", indent, "", |
421 | sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); | 454 | sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); |
422 | for(i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) { | 455 | for (i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) { |
423 | ASN1_INTEGER *num; | 456 | ASN1_INTEGER *num; |
424 | char *tmp; | 457 | char *tmp; |
425 | num = sk_ASN1_INTEGER_value(ref->noticenos, i); | 458 | num = sk_ASN1_INTEGER_value(ref->noticenos, i); |
426 | if(i) BIO_puts(out, ", "); | 459 | if (i) |
460 | BIO_puts(out, ", "); | ||
427 | tmp = i2s_ASN1_INTEGER(NULL, num); | 461 | tmp = i2s_ASN1_INTEGER(NULL, num); |
428 | BIO_puts(out, tmp); | 462 | BIO_puts(out, tmp); |
429 | free(tmp); | 463 | free(tmp); |
430 | } | 464 | } |
431 | BIO_puts(out, "\n"); | 465 | BIO_puts(out, "\n"); |
432 | } | 466 | } |
433 | if(notice->exptext) | 467 | if (notice->exptext) |
434 | BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", | 468 | BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", |
435 | notice->exptext->data); | 469 | notice->exptext->data); |
436 | } | 470 | } |
437 | 471 | ||
438 | void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) | 472 | void |
439 | { | 473 | X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) |
474 | { | ||
440 | const X509_POLICY_DATA *dat = node->data; | 475 | const X509_POLICY_DATA *dat = node->data; |
441 | 476 | ||
442 | BIO_printf(out, "%*sPolicy: ", indent, ""); | 477 | BIO_printf(out, "%*sPolicy: ", indent, ""); |
443 | 478 | ||
444 | i2a_ASN1_OBJECT(out, dat->valid_policy); | 479 | i2a_ASN1_OBJECT(out, dat->valid_policy); |
445 | BIO_puts(out, "\n"); | 480 | BIO_puts(out, "\n"); |
446 | BIO_printf(out, "%*s%s\n", indent + 2, "", | 481 | BIO_printf(out, "%*s%s\n", indent + 2, "", |
447 | node_data_critical(dat) ? "Critical" : "Non Critical"); | 482 | node_data_critical(dat) ? "Critical" : "Non Critical"); |
448 | if (dat->qualifier_set) | 483 | if (dat->qualifier_set) |
449 | print_qualifiers(out, dat->qualifier_set, indent + 2); | 484 | print_qualifiers(out, dat->qualifier_set, indent + 2); |
450 | else | 485 | else |
451 | BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); | 486 | BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); |
452 | } | 487 | } |
453 | |||
454 | 488 | ||
455 | IMPLEMENT_STACK_OF(X509_POLICY_NODE) | 489 | IMPLEMENT_STACK_OF(X509_POLICY_NODE) |
456 | IMPLEMENT_STACK_OF(X509_POLICY_DATA) | 490 | IMPLEMENT_STACK_OF(X509_POLICY_DATA) |
457 | |||