Add appropriate NULL checks in EVP_CIPHER api
authorNeil Horman <nhorman@openssl.org>
Sat, 9 Dec 2023 18:40:01 +0000 (13:40 -0500)
committerNeil Horman <nhorman@openssl.org>
Thu, 25 Jan 2024 13:27:53 +0000 (08:27 -0500)
commit6f22bcd631ab622c2436bc5b299ba2677c388375
treee62244a2a0e8f491ab3e3b582928dbc6383f7abf
parentff78d94b131d7bb3b761509d3ce0dd864b1420e3
Add appropriate NULL checks in EVP_CIPHER api

The EVP_CIPHER api currently assumes that calls made into several APIs
have already initalized the cipher in a given context via a call to
EVP_CipherInit[_ex[2]].  If that hasnt been done, instead of an error,
the result is typically a SIGSEGV.

Correct that by adding missing NULL checks in the apropriate apis prior
to using ctx->cipher

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22995)
17 files changed:
apps/enc.c
crypto/cmac/cmac.c
crypto/cms/cms_pwri.c
crypto/evp/bio_enc.c
crypto/evp/evp_key.c
crypto/evp/evp_lib.c
crypto/pkcs12/p12_decr.c
doc/man3/EVP_EncryptInit.pod
providers/implementations/kdfs/krb5kdf.c
ssl/record/methods/ssl3_meth.c
ssl/record/methods/tls1_meth.c
ssl/s3_enc.c
ssl/ssl_ciph.c
test/evp_extra_test.c
test/evp_libctx_test.c
test/evp_test.c
test/tls13encryptiontest.c