summaryrefslogtreecommitdiff
path: root/crypto/evp
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2022-05-04 14:54:13 +1000
committerPauli <pauli@openssl.org>2022-05-06 10:38:55 +1000
commit16ff70a58cfb5c40197e6a940cf4666226f31b79 (patch)
tree06fc97def75b045e9bdd339aeaf5aa3dfdc674b8 /crypto/evp
parent32e3c071373280b69be02ba91fc3204495e2e1bf (diff)
downloadopenssl-new-16ff70a58cfb5c40197e6a940cf4666226f31b79.tar.gz
Remove the _fetch_by_number functions
These functions are unused and untested. They are also implemented rather inefficiently. If we ever needed them in the future, they'd almost surely need to be rewritten more efficiently. Fixes #18227 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18237)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp_fetch.c55
-rw-r--r--crypto/evp/evp_local.h7
-rw-r--r--crypto/evp/keymgmt_meth.c10
3 files changed, 8 insertions, 64 deletions
diff --git a/crypto/evp/evp_fetch.c b/crypto/evp/evp_fetch.c
index e3c43f419e..9af92bd412 100644
--- a/crypto/evp/evp_fetch.c
+++ b/crypto/evp/evp_fetch.c
@@ -100,7 +100,7 @@ static void *get_evp_method_from_store(void *store, const OSSL_PROVIDER **prov,
{
struct evp_method_data_st *methdata = data;
void *method = NULL;
- int name_id = 0;
+ int name_id;
uint32_t meth_id;
/*
@@ -217,8 +217,7 @@ static void destruct_evp_method(void *method, void *data)
static void *
inner_evp_generic_fetch(struct evp_method_data_st *methdata,
OSSL_PROVIDER *prov, int operation_id,
- int name_id, const char *name,
- const char *properties,
+ const char *name, const char *properties,
void *(*new_method)(int name_id,
const OSSL_ALGORITHM *algodef,
OSSL_PROVIDER *prov),
@@ -230,7 +229,7 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata,
const char *const propq = properties != NULL ? properties : "";
uint32_t meth_id = 0;
void *method = NULL;
- int unsupported = 0;
+ int unsupported, name_id;
if (store == NULL || namemap == NULL) {
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_INVALID_ARGUMENT);
@@ -246,18 +245,8 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata,
return NULL;
}
- /*
- * If we have been passed both a name_id and a name, we have an
- * internal programming error.
- */
- if (!ossl_assert(name_id == 0 || name == NULL)) {
- ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
- return NULL;
- }
-
/* If we haven't received a name id yet, try to get one for the name */
- if (name_id == 0 && name != NULL)
- name_id = ossl_namemap_name2num(namemap, name);
+ name_id = name != NULL ? ossl_namemap_name2num(namemap, name) : 0;
/*
* If we have a name id, calculate a method id with evp_method_id().
@@ -276,8 +265,7 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata,
* If we haven't found the name yet, chances are that the algorithm to
* be fetched is unsupported.
*/
- if (name_id == 0)
- unsupported = 1;
+ unsupported = name_id == 0;
if (meth_id == 0
|| !ossl_method_store_cache_get(store, prov, meth_id, propq, &method)) {
@@ -350,34 +338,7 @@ void *evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
methdata.libctx = libctx;
methdata.tmp_store = NULL;
method = inner_evp_generic_fetch(&methdata, NULL, operation_id,
- 0, name, properties,
- new_method, up_ref_method, free_method);
- dealloc_tmp_evp_method_store(methdata.tmp_store);
- return method;
-}
-
-/*
- * evp_generic_fetch_by_number() is special, and only returns methods for
- * already known names, i.e. it refuses to work if no name_id can be found
- * (it's considered an internal programming error).
- * This is meant to be used when one method needs to fetch an associated
- * method.
- */
-void *evp_generic_fetch_by_number(OSSL_LIB_CTX *libctx, int operation_id,
- int name_id, const char *properties,
- void *(*new_method)(int name_id,
- const OSSL_ALGORITHM *algodef,
- OSSL_PROVIDER *prov),
- int (*up_ref_method)(void *),
- void (*free_method)(void *))
-{
- struct evp_method_data_st methdata;
- void *method;
-
- methdata.libctx = libctx;
- methdata.tmp_store = NULL;
- method = inner_evp_generic_fetch(&methdata, NULL, operation_id,
- name_id, NULL, properties,
+ name, properties,
new_method, up_ref_method, free_method);
dealloc_tmp_evp_method_store(methdata.tmp_store);
return method;
@@ -403,7 +364,7 @@ void *evp_generic_fetch_from_prov(OSSL_PROVIDER *prov, int operation_id,
methdata.libctx = ossl_provider_libctx(prov);
methdata.tmp_store = NULL;
method = inner_evp_generic_fetch(&methdata, prov, operation_id,
- 0, name, properties,
+ name, properties,
new_method, up_ref_method, free_method);
dealloc_tmp_evp_method_store(methdata.tmp_store);
return method;
@@ -607,7 +568,7 @@ void evp_generic_do_all(OSSL_LIB_CTX *libctx, int operation_id,
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- (void)inner_evp_generic_fetch(&methdata, NULL, operation_id, 0, NULL, NULL,
+ (void)inner_evp_generic_fetch(&methdata, NULL, operation_id, NULL, NULL,
new_method, up_ref_method, free_method);
data.operation_id = operation_id;
diff --git a/crypto/evp/evp_local.h b/crypto/evp/evp_local.h
index 8e45e2682f..71b5b20aba 100644
--- a/crypto/evp/evp_local.h
+++ b/crypto/evp/evp_local.h
@@ -270,13 +270,6 @@ void *evp_generic_fetch(OSSL_LIB_CTX *ctx, int operation_id,
OSSL_PROVIDER *prov),
int (*up_ref_method)(void *),
void (*free_method)(void *));
-void *evp_generic_fetch_by_number(OSSL_LIB_CTX *ctx, int operation_id,
- int name_id, const char *properties,
- void *(*new_method)(int name_id,
- const OSSL_ALGORITHM *algodef,
- OSSL_PROVIDER *prov),
- int (*up_ref_method)(void *),
- void (*free_method)(void *));
void *evp_generic_fetch_from_prov(OSSL_PROVIDER *prov, int operation_id,
const char *name, const char *properties,
void *(*new_method)(int name_id,
diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c
index fb999c7fd0..cbc61682a8 100644
--- a/crypto/evp/keymgmt_meth.c
+++ b/crypto/evp/keymgmt_meth.c
@@ -203,16 +203,6 @@ static void *keymgmt_from_algorithm(int name_id,
return keymgmt;
}
-EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OSSL_LIB_CTX *ctx, int name_id,
- const char *properties)
-{
- return evp_generic_fetch_by_number(ctx,
- OSSL_OP_KEYMGMT, name_id, properties,
- keymgmt_from_algorithm,
- (int (*)(void *))EVP_KEYMGMT_up_ref,
- (void (*)(void *))EVP_KEYMGMT_free);
-}
-
EVP_KEYMGMT *evp_keymgmt_fetch_from_prov(OSSL_PROVIDER *prov,
const char *name,
const char *properties)