summaryrefslogtreecommitdiff
path: root/crypto/memneq.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2022-02-07 21:24:48 -0800
committerJarkko Sakkinen <jarkko@kernel.org>2022-03-10 01:47:13 +0200
commit3eb2574f7ff8ebb6ac6a6309696af7d066e71013 (patch)
treecfe0ffaed47d32513e13c777c2a236835a8c4405 /crypto/memneq.c
parent814514a988b8b764168c6b038801178b521fe824 (diff)
downloadlinux-crypto-3eb2574f7ff8ebb6ac6a6309696af7d066e71013.tar.gz
linux-crypto-3eb2574f7ff8ebb6ac6a6309696af7d066e71013.zip
KEYS: asymmetric: properly validate hash_algo and encoding
It is insecure to allow arbitrary hash algorithms and signature encodings to be used with arbitrary signature algorithms. Notably, ECDSA, ECRDSA, and SM2 all sign/verify raw hash values and don't disambiguate between different hash algorithms like RSA PKCS#1 v1.5 padding does. Therefore, they need to be restricted to certain sets of hash algorithms (ideally just one, but in practice small sets are used). Additionally, the encoding is an integral part of modern signature algorithms, and is not supposed to vary. Therefore, tighten the checks of hash_algo and encoding done by software_key_determine_akcipher(). Also rearrange the parameters to software_key_determine_akcipher() to put the public_key first, as this is the most important parameter and it often determines everything else. Fixes: 2ceaf2ab3fcf ("x509: Add support for parsing x509 certs with ECDSA keys") Fixes: d944b5afa332 ("X.509: support OSCCA SM2-with-SM3 certificate verification") Fixes: 223475c353b6 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm") Cc: stable@vger.kernel.org Tested-by: Stefan Berger <stefanb@linux.ibm.com> Tested-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Vitaly Chikunov <vt@altlinux.org> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Diffstat (limited to 'crypto/memneq.c')
0 files changed, 0 insertions, 0 deletions