Skip to content

Commit

Permalink
Don't attempt to set provider params on an ENGINE based cipher
Browse files Browse the repository at this point in the history
If an ENGINE has been loaded after the SSL_CTX has been created then
the cipher we have cached might be provider based, but the cipher we
actually end up using might not be. Don't try to set provider params on
a cipher that is actually ENGINE based.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from #22865)
  • Loading branch information
mattcaswell committed Dec 12, 2023
1 parent dda9208 commit ed5f9ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ssl/s3_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ int ssl3_change_cipher_state(SSL *s, int which)
goto err;
}

if (EVP_CIPHER_get0_provider(c) != NULL
/*
* The cipher we actually ended up using in the EVP_CIPHER_CTX may be
* different to that in c if we have an ENGINE in use
*/
if (EVP_CIPHER_get0_provider(EVP_CIPHER_CTX_get0_cipher(dd)) != NULL
&& !tls_provider_set_tls_params(s, dd, c, m)) {
/* SSLfatal already called */
goto err;
Expand Down
7 changes: 6 additions & 1 deletion ssl/t1_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ int tls1_change_cipher_state(SSL *s, int which)
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
goto err;
}
if (EVP_CIPHER_get0_provider(c) != NULL

/*
* The cipher we actually ended up using in the EVP_CIPHER_CTX may be
* different to that in c if we have an ENGINE in use
*/
if (EVP_CIPHER_get0_provider(EVP_CIPHER_CTX_get0_cipher(dd)) != NULL
&& !tls_provider_set_tls_params(s, dd, c, m)) {
/* SSLfatal already called */
goto err;
Expand Down

0 comments on commit ed5f9ce

Please sign in to comment.