Skip to content

Commit

Permalink
EVP_CIPHER_CTX_get_key_length(): Add null check of ctx->cipher
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from #22964)
  • Loading branch information
maxammann authored and t8m committed May 24, 2024
1 parent f3b988d commit 46f5523
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crypto/evp/evp_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 46f5523

Please sign in to comment.