]> www.infradead.org Git - users/jedix/linux-maple.git/commit
crypto: rsassa-pkcs1 - Harden digest length verification
authorLukas Wunner <lukas@wunner.de>
Tue, 10 Sep 2024 14:30:17 +0000 (16:30 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 5 Oct 2024 05:22:04 +0000 (13:22 +0800)
commit5e00481bf0a8b4dbd1588ae08f1ff82492011987
tree2d456e615d3b2a597403f634606224492d3e0aec
parent1e562deacecca1f1bec7d23da526904a1e87525e
crypto: rsassa-pkcs1 - Harden digest length verification

The RSASSA-PKCS1-v1_5 sign operation currently only checks that the
digest length is less than "key_size - hash_prefix->size - 11".
The verify operation merely checks that it's more than zero.

Actually the precise digest length is known because the hash algorithm
is specified upon instance creation and the digest length is encoded
into the final byte of the hash algorithm's Full Hash Prefix.

So check for the exact digest length rather than solely relying on
imprecise maximum/minimum checks.

Keep the maximum length check for the sign operation as a safety net,
but drop the now unnecessary minimum check for the verify operation.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/rsassa-pkcs1.c