summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.ibm.com>2024-04-04 10:18:46 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2024-04-12 15:07:52 +0800
commit0086557046b018c7fe7ffa52680c0c7ea7af32d7 (patch)
treecd16341b642ba5690544f8c34c7aa8f9f0e2bdc1
parentc95f28e4efbe38a3c4bb2d09289287452486fa8c (diff)
downloadlinux-crypto-0086557046b018c7fe7ffa52680c0c7ea7af32d7.tar.gz
linux-crypto-0086557046b018c7fe7ffa52680c0c7ea7af32d7.zip
crypto: ecdsa - Adjust tests on length of key parameters
In preparation for support of NIST P521, adjust the basic tests on the length of the provided key parameters to only ensure that the length of the x plus y coordinates parameter array is not an odd number and that each coordinate fits into an array of 'ndigits' digits. Mathematical tests on the key's parameters are then done in ecc_is_pubkey_valid_full rejecting invalid keys. The change is necessary since NIST P521 keys do not have keys with coordinates that each require 'full' digits (= all bits in u64 used). NIST P521 only requires 2 bytes (9 bits) in the most significant digit unlike NIST P192/256/384 that each require multiple 'full' digits. Tested-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Tested-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/ecdsa.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
index e819d098..9462a4d6 100644
--- a/crypto/ecdsa.c
+++ b/crypto/ecdsa.c
@@ -230,7 +230,7 @@ static int ecdsa_set_pub_key(struct crypto_akcipher *tfm, const void *key, unsig
if (ret < 0)
return ret;
- if (keylen < 1 || (((keylen - 1) >> 1) % sizeof(u64)) != 0)
+ if (keylen < 1 || ((keylen - 1) & 1) != 0)
return -EINVAL;
/* we only accept uncompressed format indicated by '4' */
if (d[0] != 4)