diff options
author | tb <> | 2024-08-28 08:59:03 +0000 |
---|---|---|
committer | tb <> | 2024-08-28 08:59:03 +0000 |
commit | fb8ae0072a5962f3c195e9ed2bb2879d0f5a8c6e (patch) | |
tree | b1f125f4455592dd52fb580844b95a05fc9bfc46 | |
parent | cfeae5ca77e441b1a417004ca811135648ad3da4 (diff) | |
download | openbsd-fb8ae0072a5962f3c195e9ed2bb2879d0f5a8c6e.tar.gz openbsd-fb8ae0072a5962f3c195e9ed2bb2879d0f5a8c6e.tar.bz2 openbsd-fb8ae0072a5962f3c195e9ed2bb2879d0f5a8c6e.zip |
Get rid of last use of db_meth
Nothing touches db_meth in ports. Thus only way a db_meth can be set is
now as a side effect X509V3_set_conf() in which case the db is an NCONF
database and the db_meth will be a thin wrapper of NCONF_get_section().
Make that explicit in the implementation, remove the guts of the unused
X509V3_get_string() and X509V3_string_free(), turn X509V3_section_free()
into a noop and replace several checks for ctx->db, ctx->db->meth, ...
with a simple ctx->db != NULL check.
ok beck jsing
-rw-r--r-- | src/lib/libcrypto/hidden/openssl/x509v3.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_conf.c | 49 |
2 files changed, 14 insertions, 41 deletions
diff --git a/src/lib/libcrypto/hidden/openssl/x509v3.h b/src/lib/libcrypto/hidden/openssl/x509v3.h index f0db675e48..d0d4e97ec9 100644 --- a/src/lib/libcrypto/hidden/openssl/x509v3.h +++ b/src/lib/libcrypto/hidden/openssl/x509v3.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509v3.h,v 1.11 2024/08/28 08:43:55 tb Exp $ */ | 1 | /* $OpenBSD: x509v3.h,v 1.12 2024/08/28 08:59:03 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2022 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2022 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -147,9 +147,9 @@ LCRYPTO_USED(X509V3_get_value_bool); | |||
147 | LCRYPTO_USED(X509V3_get_value_int); | 147 | LCRYPTO_USED(X509V3_get_value_int); |
148 | LCRYPTO_USED(X509V3_set_nconf); | 148 | LCRYPTO_USED(X509V3_set_nconf); |
149 | LCRYPTO_UNUSED(X509V3_set_conf_lhash); | 149 | LCRYPTO_UNUSED(X509V3_set_conf_lhash); |
150 | LCRYPTO_USED(X509V3_get_string); | 150 | LCRYPTO_UNUSED(X509V3_get_string); |
151 | LCRYPTO_USED(X509V3_get_section); | 151 | LCRYPTO_USED(X509V3_get_section); |
152 | LCRYPTO_USED(X509V3_string_free); | 152 | LCRYPTO_UNUSED(X509V3_string_free); |
153 | LCRYPTO_USED(X509V3_section_free); | 153 | LCRYPTO_USED(X509V3_section_free); |
154 | LCRYPTO_USED(X509V3_set_ctx); | 154 | LCRYPTO_USED(X509V3_set_ctx); |
155 | LCRYPTO_USED(X509V3_add_value); | 155 | LCRYPTO_USED(X509V3_add_value); |
diff --git a/src/lib/libcrypto/x509/x509_conf.c b/src/lib/libcrypto/x509/x509_conf.c index d2f5afb065..25f0ad0b26 100644 --- a/src/lib/libcrypto/x509/x509_conf.c +++ b/src/lib/libcrypto/x509/x509_conf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_conf.c,v 1.21 2024/08/28 08:50:41 tb Exp $ */ | 1 | /* $OpenBSD: x509_conf.c,v 1.22 2024/08/28 08:59:03 tb Exp $ */ |
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 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -150,7 +150,7 @@ do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int nid, int crit, const char *value) | |||
150 | } else if (method->s2i) { | 150 | } else if (method->s2i) { |
151 | ext_struct = method->s2i(method, ctx, value); | 151 | ext_struct = method->s2i(method, ctx, value); |
152 | } else if (method->r2i) { | 152 | } else if (method->r2i) { |
153 | if (!ctx->db || !ctx->db_meth) { | 153 | if (ctx->db == NULL) { |
154 | X509V3error(X509V3_R_NO_CONFIG_DATABASE); | 154 | X509V3error(X509V3_R_NO_CONFIG_DATABASE); |
155 | return NULL; | 155 | return NULL; |
156 | } | 156 | } |
@@ -403,71 +403,44 @@ X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, | |||
403 | } | 403 | } |
404 | LCRYPTO_ALIAS(X509V3_EXT_REQ_add_nconf); | 404 | LCRYPTO_ALIAS(X509V3_EXT_REQ_add_nconf); |
405 | 405 | ||
406 | /* XXX - remove in next bump. */ | ||
406 | char * | 407 | char * |
407 | X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section) | 408 | X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section) |
408 | { | 409 | { |
409 | if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_string) { | 410 | X509V3error(ERR_R_DISABLED); |
410 | X509V3error(X509V3_R_OPERATION_NOT_DEFINED); | 411 | return NULL; |
411 | return NULL; | ||
412 | } | ||
413 | return ctx->db_meth->get_string(ctx->db, name, section); | ||
414 | } | 412 | } |
415 | LCRYPTO_ALIAS(X509V3_get_string); | 413 | LCRYPTO_ALIAS(X509V3_get_string); |
416 | 414 | ||
417 | STACK_OF(CONF_VALUE) * | 415 | STACK_OF(CONF_VALUE) * |
418 | X509V3_get_section(X509V3_CTX *ctx, const char *section) | 416 | X509V3_get_section(X509V3_CTX *ctx, const char *section) |
419 | { | 417 | { |
420 | if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section) { | 418 | if (ctx->db == NULL) { |
421 | X509V3error(X509V3_R_OPERATION_NOT_DEFINED); | 419 | X509V3error(X509V3_R_OPERATION_NOT_DEFINED); |
422 | return NULL; | 420 | return NULL; |
423 | } | 421 | } |
424 | return ctx->db_meth->get_section(ctx->db, section); | 422 | return NCONF_get_section(ctx->db, section); |
425 | } | 423 | } |
426 | LCRYPTO_ALIAS(X509V3_get_section); | 424 | LCRYPTO_ALIAS(X509V3_get_section); |
427 | 425 | ||
426 | /* XXX - remove in next bump. */ | ||
428 | void | 427 | void |
429 | X509V3_string_free(X509V3_CTX *ctx, char *str) | 428 | X509V3_string_free(X509V3_CTX *ctx, char *str) |
430 | { | 429 | { |
431 | if (!str) | 430 | return; |
432 | return; | ||
433 | if (ctx->db_meth->free_string) | ||
434 | ctx->db_meth->free_string(ctx->db, str); | ||
435 | } | 431 | } |
436 | LCRYPTO_ALIAS(X509V3_string_free); | 432 | LCRYPTO_ALIAS(X509V3_string_free); |
437 | 433 | ||
438 | void | 434 | void |
439 | X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) | 435 | X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) |
440 | { | 436 | { |
441 | if (!section) | 437 | return; |
442 | return; | ||
443 | if (ctx->db_meth->free_section) | ||
444 | ctx->db_meth->free_section(ctx->db, section); | ||
445 | } | 438 | } |
446 | LCRYPTO_ALIAS(X509V3_section_free); | 439 | LCRYPTO_ALIAS(X509V3_section_free); |
447 | 440 | ||
448 | static char * | ||
449 | nconf_get_string(void *db, const char *section, const char *value) | ||
450 | { | ||
451 | return NCONF_get_string(db, section, value); | ||
452 | } | ||
453 | |||
454 | static STACK_OF(CONF_VALUE) * | ||
455 | nconf_get_section(void *db, const char *section) | ||
456 | { | ||
457 | return NCONF_get_section(db, section); | ||
458 | } | ||
459 | |||
460 | static X509V3_CONF_METHOD nconf_method = { | ||
461 | nconf_get_string, | ||
462 | nconf_get_section, | ||
463 | NULL, | ||
464 | NULL | ||
465 | }; | ||
466 | |||
467 | void | 441 | void |
468 | X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf) | 442 | X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf) |
469 | { | 443 | { |
470 | ctx->db_meth = &nconf_method; | ||
471 | ctx->db = conf; | 444 | ctx->db = conf; |
472 | } | 445 | } |
473 | LCRYPTO_ALIAS(X509V3_set_nconf); | 446 | LCRYPTO_ALIAS(X509V3_set_nconf); |
@@ -507,7 +480,7 @@ X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int nid, | |||
507 | LCRYPTO_ALIAS(X509V3_EXT_conf_nid); | 480 | LCRYPTO_ALIAS(X509V3_EXT_conf_nid); |
508 | 481 | ||
509 | /* | 482 | /* |
510 | * XXX -remove everything below in the next bump. | 483 | * XXX - remove everything below in the next bump. |
511 | */ | 484 | */ |
512 | 485 | ||
513 | void | 486 | void |