summaryrefslogtreecommitdiffstats
path: root/crypto/evp/evp_fetch.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-10-17 07:07:41 +0200
committerRichard Levitte <levitte@openssl.org>2021-01-12 19:02:11 +0100
commitd6d42cda5fbc05aeaadf8c760db60e9089e3609b (patch)
tree273838dfcbed4ddcd97b287a8db2187508536e13 /crypto/evp/evp_fetch.c
parent0d11846e4b2850773d1ee0df206608549a7d45d0 (diff)
Use centralized fetching errors
We've spread around FETCH_FAILED errors in quite a few places, and that gives somewhat crude error records, as there's no way to tell if the error was unavailable algorithms or some other error at such high levels. As an alternative, we take recording of these kinds of errors down to the fetching functions, which are in a much better place to tell what kind of error it was, thereby relieving the higher level calls from having to guess. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13467)
Diffstat (limited to 'crypto/evp/evp_fetch.c')
-rw-r--r--crypto/evp/evp_fetch.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/crypto/evp/evp_fetch.c b/crypto/evp/evp_fetch.c
index 7a0a3fcda7..5d6d3dbb29 100644
--- a/crypto/evp/evp_fetch.c
+++ b/crypto/evp/evp_fetch.c
@@ -215,19 +215,6 @@ static void destruct_evp_method(void *method, void *data)
methdata->destruct_method(method);
}
-static const char *libctx_descriptor(OSSL_LIB_CTX *libctx)
-{
-#ifdef FIPS_MODULE
- return "FIPS internal library context";
-#else
- if (ossl_lib_ctx_is_global_default(libctx))
- return "Global default library context";
- if (ossl_lib_ctx_is_default(libctx))
- return "Thread-local default library context";
- return "Non-default library context";
-#endif
-}
-
static void *
inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
int name_id, const char *name,
@@ -245,7 +232,7 @@ inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
int unsupported = 0;
if (store == NULL || namemap == NULL) {
- ERR_raise(ERR_LIB_CRYPTO, ERR_R_PASSED_INVALID_ARGUMENT);
+ ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_INVALID_ARGUMENT);
return NULL;
}
@@ -254,7 +241,7 @@ inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
* programming error.
*/
if (!ossl_assert(operation_id > 0)) {
- ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR);
+ ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
return NULL;
}
@@ -263,7 +250,7 @@ inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
* internal programming error.
*/
if (!ossl_assert(name_id != 0 || name != NULL)) {
- ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR);
+ ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
return NULL;
}
@@ -280,7 +267,7 @@ inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
* For all intents and purposes, this is an internal error.
*/
if (name_id != 0 && (meth_id = evp_method_id(name_id, operation_id)) == 0) {
- ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR);
+ ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
return NULL;
}
@@ -337,14 +324,13 @@ inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
}
if (method == NULL) {
- int code =
- unsupported ? EVP_R_UNSUPPORTED_ALGORITHM : EVP_R_FETCH_FAILED;
+ int code = unsupported ? ERR_R_UNSUPPORTED : ERR_R_FETCH_FAILED;
if (name == NULL)
name = ossl_namemap_num2name(namemap, name_id, 0);
ERR_raise_data(ERR_LIB_EVP, code,
"%s, Algorithm (%s : %d), Properties (%s)",
- libctx_descriptor(libctx),
+ ossl_lib_ctx_get_descriptor(libctx),
name = NULL ? "<null>" : name, name_id,
properties == NULL ? "<null>" : properties);
}