]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: rsa-pkcs1pad - restore signature length check
authorEric Biggers <ebiggers@google.com>
Wed, 19 Jan 2022 00:13:04 +0000 (16:13 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 31 Jan 2022 00:21:44 +0000 (11:21 +1100)
commitabcbfb723f0a16ab18d561c36c93ede6a620d1cd
treed4d2e189b93a4784d9162fba6974c3d17ef296d9
parent270893e2785ebdf89a6fb0204c1b4a8b2402712e
crypto: rsa-pkcs1pad - restore signature length check

RSA PKCS#1 v1.5 signatures are required to be the same length as the RSA
key size.  RFC8017 specifically requires the verifier to check this
(https://datatracker.ietf.org/doc/html/rfc8017#section-8.2.2).

Commit 59e7f1fa216e ("crypto: Add hash param to pkcs1pad") changed the
kernel to allow longer signatures, but didn't explain this part of the
change; it seems to be unrelated to the rest of the commit.

Revert this change, since it doesn't appear to be correct.

We can be pretty sure that no one is relying on overly-long signatures
(which would have to be front-padded with zeroes) being supported, given
that they would have been broken since commit e128455665f5
("crypto: akcipher - new verify API for public key algorithms").

Fixes: 59e7f1fa216e ("crypto: Add hash param to pkcs1pad")
Cc: <stable@vger.kernel.org> # v4.6+
Cc: Tadeusz Struk <tadeusz.struk@linaro.org>
Suggested-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/rsa-pkcs1pad.c