From 40d322a685789a37eb5cb94014694014e56be6af Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 25 Dec 2023 22:14:23 +0000 Subject: Remove unused X509_LOOKUP_METHODs None of these function pointers were ever set. Now that the structure is opaque they won't ever be, so time for them to hit the bitbucket. Infinite extensibility of the toolkit results in complications, bugs, and dead code. ok jsing --- src/lib/libcrypto/x509/by_dir.c | 7 +------ src/lib/libcrypto/x509/by_file.c | 7 +------ src/lib/libcrypto/x509/by_mem.c | 7 +------ src/lib/libcrypto/x509/x509_local.h | 10 +--------- src/lib/libcrypto/x509/x509_lu.c | 24 ++++++++---------------- 5 files changed, 12 insertions(+), 43 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c index 9fa6a10048..88c06513ad 100644 --- a/src/lib/libcrypto/x509/by_dir.c +++ b/src/lib/libcrypto/x509/by_dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_dir.c,v 1.44 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: by_dir.c,v 1.45 2023/12/25 22:14:23 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -103,13 +103,8 @@ static X509_LOOKUP_METHOD x509_dir_lookup = { .name = "Load certs from files in a directory", .new_item = new_dir, .free = free_dir, - .init = NULL, - .shutdown = NULL, .ctrl = dir_ctrl, .get_by_subject = get_cert_by_subject, - .get_by_issuer_serial = NULL, - .get_by_fingerprint = NULL, - .get_by_alias = NULL, }; X509_LOOKUP_METHOD * diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c index fc2d72bbd2..bfab3761d3 100644 --- a/src/lib/libcrypto/x509/by_file.c +++ b/src/lib/libcrypto/x509/by_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_file.c,v 1.29 2023/11/30 17:01:04 beck Exp $ */ +/* $OpenBSD: by_file.c,v 1.30 2023/12/25 22:14:23 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -75,13 +75,8 @@ static X509_LOOKUP_METHOD x509_file_lookup = { .name = "Load file into cache", .new_item = NULL, .free = NULL, - .init = NULL, - .shutdown = NULL, .ctrl = by_file_ctrl, .get_by_subject = NULL, - .get_by_issuer_serial = NULL, - .get_by_fingerprint = NULL, - .get_by_alias = NULL, }; X509_LOOKUP_METHOD * diff --git a/src/lib/libcrypto/x509/by_mem.c b/src/lib/libcrypto/x509/by_mem.c index 579eecd36d..ac3a24dea2 100644 --- a/src/lib/libcrypto/x509/by_mem.c +++ b/src/lib/libcrypto/x509/by_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_mem.c,v 1.8 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: by_mem.c,v 1.9 2023/12/25 22:14:23 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -76,13 +76,8 @@ static X509_LOOKUP_METHOD x509_mem_lookup = { .name = "Load cert from memory", .new_item = NULL, .free = NULL, - .init = NULL, - .shutdown = NULL, .ctrl = by_mem_ctrl, .get_by_subject = NULL, - .get_by_issuer_serial = NULL, - .get_by_fingerprint = NULL, - .get_by_alias = NULL, }; X509_LOOKUP_METHOD * diff --git a/src/lib/libcrypto/x509/x509_local.h b/src/lib/libcrypto/x509/x509_local.h index 0312e6cac7..d4197e66c0 100644 --- a/src/lib/libcrypto/x509/x509_local.h +++ b/src/lib/libcrypto/x509/x509_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_local.h,v 1.14 2023/12/22 13:31:35 tb Exp $ */ +/* $OpenBSD: x509_local.h,v 1.15 2023/12/25 22:14:23 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2013. */ @@ -248,18 +248,10 @@ struct x509_lookup_method_st { const char *name; int (*new_item)(X509_LOOKUP *ctx); void (*free)(X509_LOOKUP *ctx); - int (*init)(X509_LOOKUP *ctx); - int (*shutdown)(X509_LOOKUP *ctx); int (*ctrl)(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); int (*get_by_subject)(X509_LOOKUP *ctx, int type, X509_NAME *name, X509_OBJECT *ret); - int (*get_by_issuer_serial)(X509_LOOKUP *ctx, int type, X509_NAME *name, - ASN1_INTEGER *serial,X509_OBJECT *ret); - int (*get_by_fingerprint)(X509_LOOKUP *ctx, int type, - const unsigned char *bytes, int len, X509_OBJECT *ret); - int (*get_by_alias)(X509_LOOKUP *ctx, int type, const char *str, - int len, X509_OBJECT *ret); } /* X509_LOOKUP_METHOD */; struct X509_VERIFY_PARAM_st { diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c index 05730f56cc..5a8fe96368 100644 --- a/src/lib/libcrypto/x509/x509_lu.c +++ b/src/lib/libcrypto/x509/x509_lu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lu.c,v 1.60 2023/04/25 18:32:42 tb Exp $ */ +/* $OpenBSD: x509_lu.c,v 1.61 2023/12/25 22:14:23 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -102,9 +102,8 @@ X509_LOOKUP_init(X509_LOOKUP *ctx) { if (ctx->method == NULL) return 0; - if (ctx->method->init == NULL) - return 1; - return ctx->method->init(ctx); + /* Historical behavior: make init succeed even without method. */ + return 1; } LCRYPTO_ALIAS(X509_LOOKUP_init); @@ -113,9 +112,8 @@ X509_LOOKUP_shutdown(X509_LOOKUP *ctx) { if (ctx->method == NULL) return 0; - if (ctx->method->shutdown == NULL) - return 1; - return ctx->method->shutdown(ctx); + /* Historical behavior: make shutdown succeed even without method. */ + return 1; } LCRYPTO_ALIAS(X509_LOOKUP_shutdown); @@ -145,9 +143,7 @@ int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, X509_NAME *name, ASN1_INTEGER *serial, X509_OBJECT *ret) { - if (ctx->method == NULL || ctx->method->get_by_issuer_serial == NULL) - return 0; - return ctx->method->get_by_issuer_serial(ctx, type, name, serial, ret); + return 0; } LCRYPTO_ALIAS(X509_LOOKUP_by_issuer_serial); @@ -155,9 +151,7 @@ int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const unsigned char *bytes, int len, X509_OBJECT *ret) { - if (ctx->method == NULL || ctx->method->get_by_fingerprint == NULL) - return 0; - return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret); + return 0; } LCRYPTO_ALIAS(X509_LOOKUP_by_fingerprint); @@ -165,9 +159,7 @@ int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const char *str, int len, X509_OBJECT *ret) { - if (ctx->method == NULL || ctx->method->get_by_alias == NULL) - return 0; - return ctx->method->get_by_alias(ctx, type, str, len, ret); + return 0; } LCRYPTO_ALIAS(X509_LOOKUP_by_alias); -- cgit v1.2.3-55-g6feb