summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorDr. David von Oheimb <dev@ddvo.net>2023-10-20 20:51:17 +0200
committerHugo Landau <hlandau@openssl.org>2023-10-26 16:05:03 +0100
commit51f4115dcc818a35e2c8838c01b3b08740d0c1e1 (patch)
treeaa3f6ed6bdb8d50d318424adb5c99d49538486ae /crypto/evp
parent7eab00ec470693bd44c9de7ab5c06fe691aa3077 (diff)
EVP_PKEY_get_{bits,security_bits,size}(): add missing error queue entry on failure
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22459) (cherry picked from commit ae643b32f91affe61dd411a58b76c8a44cbd7f50)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp_err.c6
-rw-r--r--crypto/evp/p_lib.c18
2 files changed, 20 insertions, 4 deletions
diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c
index c0d9232103..42dd7e4009 100644
--- a/crypto/evp/evp_err.c
+++ b/crypto/evp/evp_err.c
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -160,12 +160,16 @@ static const ERR_STRING_DATA EVP_str_reasons[] = {
"unable to lock context"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNABLE_TO_SET_CALLBACKS),
"unable to set callbacks"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_BITS), "unknown bits"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_CIPHER), "unknown cipher"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_DIGEST), "unknown digest"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_KEY_TYPE), "unknown key type"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_MAX_SIZE), "unknown max size"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_OPTION), "unknown option"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_PBE_ALGORITHM),
"unknown pbe algorithm"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNKNOWN_SECURITY_BITS),
+ "unknown security bits"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNSUPPORTED_ALGORITHM),
"unsupported algorithm"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_UNSUPPORTED_CIPHER), "unsupported cipher"},
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index eb937d52ca..06a127a820 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -68,7 +68,11 @@ int EVP_PKEY_get_bits(const EVP_PKEY *pkey)
if (pkey->ameth != NULL && pkey->ameth->pkey_bits != NULL)
size = pkey->ameth->pkey_bits(pkey);
}
- return size < 0 ? 0 : size;
+ if (size <= 0) {
+ ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_BITS);
+ return 0;
+ }
+ return size;
}
int EVP_PKEY_get_security_bits(const EVP_PKEY *pkey)
@@ -80,7 +84,11 @@ int EVP_PKEY_get_security_bits(const EVP_PKEY *pkey)
if (pkey->ameth != NULL && pkey->ameth->pkey_security_bits != NULL)
size = pkey->ameth->pkey_security_bits(pkey);
}
- return size < 0 ? 0 : size;
+ if (size <= 0) {
+ ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_SECURITY_BITS);
+ return 0;
+ }
+ return size;
}
int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)
@@ -1812,7 +1820,11 @@ int EVP_PKEY_get_size(const EVP_PKEY *pkey)
size = pkey->ameth->pkey_size(pkey);
#endif
}
- return size < 0 ? 0 : size;
+ if (size <= 0) {
+ ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_MAX_SIZE);
+ return 0;
+ }
+ return size;
}
const char *EVP_PKEY_get0_description(const EVP_PKEY *pkey)