validate requested key length in kdf_pbkdf1_do_derive
authorNeil Horman <nhorman@openssl.org>
Mon, 1 Jan 2024 16:53:50 +0000 (11:53 -0500)
committerNeil Horman <nhorman@openssl.org>
Wed, 3 Jan 2024 15:20:46 +0000 (10:20 -0500)
commit0b36386633b8b875de74313abe91ac1c48a06a8e
treea57e7c7e9ee15a4c4d83431188ed209132ebfae6
parentc739d762b8b28079467eb7f08f749b3d896beb6e
validate requested key length in kdf_pbkdf1_do_derive

When using pbkdf1 key deriviation, it is possible to request a key
length larger than the maximum digest size a given digest can produce,
leading to a read of random stack memory.

fix it by returning an error if the requested key size n is larger than
the EVP_MD_size of the digest

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23174)

(cherry picked from commit 8d89050f0f676b429043fd5445e5a570d54ad225)
providers/implementations/kdfs/pbkdf1.c
test/evp_kdf_test.c