Commit 7dc6d3e9 authored by Eric Biggers's avatar Eric Biggers Committed by Yongqiang Liu
Browse files

crypto: rsa-pkcs1pad - restore signature length check

mainline inclusion
from mainline-v5.18-rc1
commit d3481acc
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6ETWH
CVE: NA

--------------------------------

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 a49de377 ("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 c7381b01
("crypto: akcipher - new verify API for public key algorithms").

Fixes: a49de377 ("crypto: Add hash param to pkcs1pad")
Cc: <stable@vger.kernel.org> # v4.6+
Cc: Tadeusz Struk <tadeusz.struk@linaro.org>
Suggested-by: default avatarVitaly Chikunov <vt@altlinux.org>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Conflicts:
	crypto/rsa-pkcs1pad.c
Signed-off-by: default avatarGUO Zihua <guozihua@huawei.com>
Reviewed-by: default avataryiyang <yiyang13@huawei.com>
Reviewed-by: default avatarWang Weiyang <wangweiyang2@huawei.com>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent 52c0780d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment