evp: process key length and iv length early if present
authorPauli <pauli@openssl.org>
Thu, 5 Oct 2023 23:26:23 +0000 (10:26 +1100)
committerMatt Caswell <matt@openssl.org>
Tue, 24 Oct 2023 13:35:09 +0000 (14:35 +0100)
commit5f69f5c65e483928c4b28ed16af6e5742929f1ee
tree503594b45dfb645f498f5fc7f60f77f40f133744
parent742e766f0e194d072209fe8b082278e88f62b26b
evp: process key length and iv length early if present

evp_cipher_init_internal() takes a params array argument and this is processed
late in the initialisation process for some ciphers (AEAD ones).

This means that changing the IV length as a parameter will either truncate the
IV (very bad if SP 800-38d section 8.2.1 is used) or grab extra uninitialised
bytes.

Truncation is very bad if SP 800-38d section 8.2.1 is being used to
contruct a deterministic IV.  This leads to an instant loss of confidentiality.

Grabbing extra bytes isn't so serious, it will most likely result in a bad
decryption.

Problem reported by Tony Battersby of Cybernetics.com but earlier discovered
and raised as issue #19822.

Fixes CVE-2023-5363
Fixes #19822

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/evp/evp_enc.c