EVP_CIPHER_CTX_get_key_length(): Add null check of ctx->cipher

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22964)
This commit is contained in:
Max Ammann 2024-05-07 23:06:39 +01:00 committed by Tomas Mraz
parent f3b988dc29
commit 46f55238d2

View File

@ -670,6 +670,9 @@ int EVP_CIPHER_get_key_length(const EVP_CIPHER *cipher)
int EVP_CIPHER_CTX_get_key_length(const EVP_CIPHER_CTX *ctx)
{
if (ctx->cipher == NULL)
return 0;
if (ctx->key_len <= 0 && ctx->cipher->prov != NULL) {
int ok;
OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };