diff options
Diffstat (limited to 'src/lib/libcrypto/x509/x509_vpm.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_vpm.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/lib/libcrypto/x509/x509_vpm.c b/src/lib/libcrypto/x509/x509_vpm.c index 2b06718aec..dfd89d89fa 100644 --- a/src/lib/libcrypto/x509/x509_vpm.c +++ b/src/lib/libcrypto/x509/x509_vpm.c | |||
@@ -74,6 +74,7 @@ static void x509_verify_param_zero(X509_VERIFY_PARAM *param) | |||
74 | param->name = NULL; | 74 | param->name = NULL; |
75 | param->purpose = 0; | 75 | param->purpose = 0; |
76 | param->trust = 0; | 76 | param->trust = 0; |
77 | /*param->inh_flags = X509_VP_FLAG_DEFAULT;*/ | ||
77 | param->inh_flags = 0; | 78 | param->inh_flags = 0; |
78 | param->flags = 0; | 79 | param->flags = 0; |
79 | param->depth = -1; | 80 | param->depth = -1; |
@@ -198,8 +199,12 @@ int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *dest, | |||
198 | int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, | 199 | int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, |
199 | const X509_VERIFY_PARAM *from) | 200 | const X509_VERIFY_PARAM *from) |
200 | { | 201 | { |
202 | unsigned long save_flags = to->inh_flags; | ||
203 | int ret; | ||
201 | to->inh_flags |= X509_VP_FLAG_DEFAULT; | 204 | to->inh_flags |= X509_VP_FLAG_DEFAULT; |
202 | return X509_VERIFY_PARAM_inherit(to, from); | 205 | ret = X509_VERIFY_PARAM_inherit(to, from); |
206 | to->inh_flags = save_flags; | ||
207 | return ret; | ||
203 | } | 208 | } |
204 | 209 | ||
205 | int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name) | 210 | int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name) |
@@ -324,7 +329,7 @@ static const X509_VERIFY_PARAM default_table[] = { | |||
324 | NULL /* policies */ | 329 | NULL /* policies */ |
325 | }, | 330 | }, |
326 | { | 331 | { |
327 | "pkcs7", /* S/MIME signing parameters */ | 332 | "pkcs7", /* S/MIME sign parameters */ |
328 | 0, /* Check time */ | 333 | 0, /* Check time */ |
329 | 0, /* internal flags */ | 334 | 0, /* internal flags */ |
330 | 0, /* flags */ | 335 | 0, /* flags */ |
@@ -334,7 +339,7 @@ static const X509_VERIFY_PARAM default_table[] = { | |||
334 | NULL /* policies */ | 339 | NULL /* policies */ |
335 | }, | 340 | }, |
336 | { | 341 | { |
337 | "smime_sign", /* S/MIME signing parameters */ | 342 | "smime_sign", /* S/MIME sign parameters */ |
338 | 0, /* Check time */ | 343 | 0, /* Check time */ |
339 | 0, /* internal flags */ | 344 | 0, /* internal flags */ |
340 | 0, /* flags */ | 345 | 0, /* flags */ |
@@ -366,12 +371,17 @@ static const X509_VERIFY_PARAM default_table[] = { | |||
366 | 371 | ||
367 | static STACK_OF(X509_VERIFY_PARAM) *param_table = NULL; | 372 | static STACK_OF(X509_VERIFY_PARAM) *param_table = NULL; |
368 | 373 | ||
369 | static int table_cmp(const void *pa, const void *pb) | 374 | static int table_cmp(const X509_VERIFY_PARAM *a, const X509_VERIFY_PARAM *b) |
375 | |||
370 | { | 376 | { |
371 | const X509_VERIFY_PARAM *a = pa, *b = pb; | ||
372 | return strcmp(a->name, b->name); | 377 | return strcmp(a->name, b->name); |
373 | } | 378 | } |
374 | 379 | ||
380 | DECLARE_OBJ_BSEARCH_CMP_FN(X509_VERIFY_PARAM, X509_VERIFY_PARAM, | ||
381 | table); | ||
382 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(X509_VERIFY_PARAM, X509_VERIFY_PARAM, | ||
383 | table); | ||
384 | |||
375 | static int param_cmp(const X509_VERIFY_PARAM * const *a, | 385 | static int param_cmp(const X509_VERIFY_PARAM * const *a, |
376 | const X509_VERIFY_PARAM * const *b) | 386 | const X509_VERIFY_PARAM * const *b) |
377 | { | 387 | { |
@@ -407,6 +417,7 @@ const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name) | |||
407 | { | 417 | { |
408 | int idx; | 418 | int idx; |
409 | X509_VERIFY_PARAM pm; | 419 | X509_VERIFY_PARAM pm; |
420 | |||
410 | pm.name = (char *)name; | 421 | pm.name = (char *)name; |
411 | if (param_table) | 422 | if (param_table) |
412 | { | 423 | { |
@@ -414,11 +425,8 @@ const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name) | |||
414 | if (idx != -1) | 425 | if (idx != -1) |
415 | return sk_X509_VERIFY_PARAM_value(param_table, idx); | 426 | return sk_X509_VERIFY_PARAM_value(param_table, idx); |
416 | } | 427 | } |
417 | return (const X509_VERIFY_PARAM *) OBJ_bsearch((char *)&pm, | 428 | return OBJ_bsearch_table(&pm, default_table, |
418 | (char *)&default_table, | 429 | sizeof(default_table)/sizeof(X509_VERIFY_PARAM)); |
419 | sizeof(default_table)/sizeof(X509_VERIFY_PARAM), | ||
420 | sizeof(X509_VERIFY_PARAM), | ||
421 | table_cmp); | ||
422 | } | 430 | } |
423 | 431 | ||
424 | void X509_VERIFY_PARAM_table_cleanup(void) | 432 | void X509_VERIFY_PARAM_table_cleanup(void) |