From: tb Date: Mon, 25 Dec 2023 22:14:23 +0000 (+0000) Subject: Remove unused X509_LOOKUP_METHODs X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3b2bee84c2292b186f320233a1a1d5ff9481a5d4;p=openbsd 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 --- diff --git a/lib/libcrypto/x509/by_dir.c b/lib/libcrypto/x509/by_dir.c index 9fa6a100480..88c06513ade 100644 --- a/lib/libcrypto/x509/by_dir.c +++ b/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/lib/libcrypto/x509/by_file.c b/lib/libcrypto/x509/by_file.c index fc2d72bbd2b..bfab3761d39 100644 --- a/lib/libcrypto/x509/by_file.c +++ b/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/lib/libcrypto/x509/by_mem.c b/lib/libcrypto/x509/by_mem.c index 579eecd36de..ac3a24dea2c 100644 --- a/lib/libcrypto/x509/by_mem.c +++ b/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/lib/libcrypto/x509/x509_local.h b/lib/libcrypto/x509/x509_local.h index 0312e6cac76..d4197e66c05 100644 --- a/lib/libcrypto/x509/x509_local.h +++ b/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/lib/libcrypto/x509/x509_lu.c b/lib/libcrypto/x509/x509_lu.c index 05730f56cce..5a8fe963688 100644 --- a/lib/libcrypto/x509/x509_lu.c +++ b/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);