| OLD | NEW |
| 1 /* x509_vpm.c */ | 1 /* x509_vpm.c */ |
| 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 * project 2004. | 3 * project 2004. |
| 4 */ | 4 */ |
| 5 /* ==================================================================== | 5 /* ==================================================================== |
| 6 * Copyright (c) 2004 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2004 The OpenSSL Project. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 /* X509_VERIFY_PARAM functions */ | 68 /* X509_VERIFY_PARAM functions */ |
| 69 | 69 |
| 70 static void x509_verify_param_zero(X509_VERIFY_PARAM *param) | 70 static void x509_verify_param_zero(X509_VERIFY_PARAM *param) |
| 71 { | 71 { |
| 72 if (!param) | 72 if (!param) |
| 73 return; | 73 return; |
| 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; |
| 80 if (param->policies) | 81 if (param->policies) |
| 81 { | 82 { |
| 82 sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free); | 83 sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free); |
| 83 param->policies = NULL; | 84 param->policies = NULL; |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 | 87 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 "default", /* X509 default parameters */ | 322 "default", /* X509 default parameters */ |
| 322 0, /* Check time */ | 323 0, /* Check time */ |
| 323 0, /* internal flags */ | 324 0, /* internal flags */ |
| 324 0, /* flags */ | 325 0, /* flags */ |
| 325 0, /* purpose */ | 326 0, /* purpose */ |
| 326 0, /* trust */ | 327 0, /* trust */ |
| 327 100, /* depth */ | 328 100, /* depth */ |
| 328 NULL /* policies */ | 329 NULL /* policies */ |
| 329 }, | 330 }, |
| 330 { | 331 { |
| 331 » "pkcs7",» » » /* S/MIME signing parameters */ | 332 » "pkcs7",» » » /* S/MIME sign parameters */ |
| 332 0, /* Check time */ | 333 0, /* Check time */ |
| 333 0, /* internal flags */ | 334 0, /* internal flags */ |
| 334 0, /* flags */ | 335 0, /* flags */ |
| 335 X509_PURPOSE_SMIME_SIGN, /* purpose */ | 336 X509_PURPOSE_SMIME_SIGN, /* purpose */ |
| 336 X509_TRUST_EMAIL, /* trust */ | 337 X509_TRUST_EMAIL, /* trust */ |
| 337 -1, /* depth */ | 338 -1, /* depth */ |
| 338 NULL /* policies */ | 339 NULL /* policies */ |
| 339 }, | 340 }, |
| 340 { | 341 { |
| 341 » "smime_sign",» » » /* S/MIME signing parameters */ | 342 » "smime_sign",» » » /* S/MIME sign parameters */ |
| 342 0, /* Check time */ | 343 0, /* Check time */ |
| 343 0, /* internal flags */ | 344 0, /* internal flags */ |
| 344 0, /* flags */ | 345 0, /* flags */ |
| 345 X509_PURPOSE_SMIME_SIGN, /* purpose */ | 346 X509_PURPOSE_SMIME_SIGN, /* purpose */ |
| 346 X509_TRUST_EMAIL, /* trust */ | 347 X509_TRUST_EMAIL, /* trust */ |
| 347 -1, /* depth */ | 348 -1, /* depth */ |
| 348 NULL /* policies */ | 349 NULL /* policies */ |
| 349 }, | 350 }, |
| 350 { | 351 { |
| 351 "ssl_client", /* SSL/TLS client parameters */ | 352 "ssl_client", /* SSL/TLS client parameters */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 363 0, /* internal flags */ | 364 0, /* internal flags */ |
| 364 0, /* flags */ | 365 0, /* flags */ |
| 365 X509_PURPOSE_SSL_SERVER, /* purpose */ | 366 X509_PURPOSE_SSL_SERVER, /* purpose */ |
| 366 X509_TRUST_SSL_SERVER, /* trust */ | 367 X509_TRUST_SSL_SERVER, /* trust */ |
| 367 -1, /* depth */ | 368 -1, /* depth */ |
| 368 NULL /* policies */ | 369 NULL /* policies */ |
| 369 }}; | 370 }}; |
| 370 | 371 |
| 371 static STACK_OF(X509_VERIFY_PARAM) *param_table = NULL; | 372 static STACK_OF(X509_VERIFY_PARAM) *param_table = NULL; |
| 372 | 373 |
| 373 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 |
| 374 { | 376 { |
| 375 const X509_VERIFY_PARAM *a = pa, *b = pb; | |
| 376 return strcmp(a->name, b->name); | 377 return strcmp(a->name, b->name); |
| 377 } | 378 } |
| 378 | 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 |
| 379 static int param_cmp(const X509_VERIFY_PARAM * const *a, | 385 static int param_cmp(const X509_VERIFY_PARAM * const *a, |
| 380 const X509_VERIFY_PARAM * const *b) | 386 const X509_VERIFY_PARAM * const *b) |
| 381 { | 387 { |
| 382 return strcmp((*a)->name, (*b)->name); | 388 return strcmp((*a)->name, (*b)->name); |
| 383 } | 389 } |
| 384 | 390 |
| 385 int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param) | 391 int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param) |
| 386 { | 392 { |
| 387 int idx; | 393 int idx; |
| 388 X509_VERIFY_PARAM *ptmp; | 394 X509_VERIFY_PARAM *ptmp; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 404 } | 410 } |
| 405 if (!sk_X509_VERIFY_PARAM_push(param_table, param)) | 411 if (!sk_X509_VERIFY_PARAM_push(param_table, param)) |
| 406 return 0; | 412 return 0; |
| 407 return 1; | 413 return 1; |
| 408 } | 414 } |
| 409 | 415 |
| 410 const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name) | 416 const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name) |
| 411 { | 417 { |
| 412 int idx; | 418 int idx; |
| 413 X509_VERIFY_PARAM pm; | 419 X509_VERIFY_PARAM pm; |
| 420 |
| 414 pm.name = (char *)name; | 421 pm.name = (char *)name; |
| 415 if (param_table) | 422 if (param_table) |
| 416 { | 423 { |
| 417 idx = sk_X509_VERIFY_PARAM_find(param_table, &pm); | 424 idx = sk_X509_VERIFY_PARAM_find(param_table, &pm); |
| 418 if (idx != -1) | 425 if (idx != -1) |
| 419 return sk_X509_VERIFY_PARAM_value(param_table, idx); | 426 return sk_X509_VERIFY_PARAM_value(param_table, idx); |
| 420 } | 427 } |
| 421 » return (const X509_VERIFY_PARAM *) OBJ_bsearch((char *)&pm, | 428 » return OBJ_bsearch_table(&pm, default_table, |
| 422 » » » » (char *)&default_table, | 429 » » » sizeof(default_table)/sizeof(X509_VERIFY_PARAM)); |
| 423 » » » » sizeof(default_table)/sizeof(X509_VERIFY_PARAM), | |
| 424 » » » » sizeof(X509_VERIFY_PARAM), | |
| 425 » » » » table_cmp); | |
| 426 } | 430 } |
| 427 | 431 |
| 428 void X509_VERIFY_PARAM_table_cleanup(void) | 432 void X509_VERIFY_PARAM_table_cleanup(void) |
| 429 { | 433 { |
| 430 if (param_table) | 434 if (param_table) |
| 431 sk_X509_VERIFY_PARAM_pop_free(param_table, | 435 sk_X509_VERIFY_PARAM_pop_free(param_table, |
| 432 X509_VERIFY_PARAM_free); | 436 X509_VERIFY_PARAM_free); |
| 433 param_table = NULL; | 437 param_table = NULL; |
| 434 } | 438 } |
| OLD | NEW |