Files
linux/include/crypto
Lukas Wunner 40466ce607 crypto: ecdsa - Fix NIST P521 key size reported by KEYCTL_PKEY_QUERY
[ Upstream commit 6b7f9397c9 ]

When user space issues a KEYCTL_PKEY_QUERY system call for a NIST P521
key, the key_size is incorrectly reported as 528 bits instead of 521.

That's because the key size obtained through crypto_sig_keysize() is in
bytes and software_key_query() multiplies by 8 to yield the size in bits.
The underlying assumption is that the key size is always a multiple of 8.
With the recent addition of NIST P521, that's no longer the case.

Fix by returning the key_size in bits from crypto_sig_keysize() and
adjusting the calculations in software_key_query().

The ->key_size() callbacks of sig_alg algorithms now return the size in
bits, whereas the ->digest_size() and ->max_size() callbacks return the
size in bytes.  This matches with the units in struct keyctl_pkey_query.

Fixes: a7d45ba77d ("crypto: ecdsa - Register NIST P521 and extend test suite")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Ignat Korchagin <ignat@cloudflare.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-19 15:39:16 +02:00
..
2024-04-02 10:49:38 +08:00
2022-12-02 18:12:40 +08:00
2023-06-05 09:36:35 +02:00
2024-04-02 10:49:38 +08:00
2019-08-05 18:40:19 -04:00
2024-04-02 10:49:38 +08:00
2022-04-08 16:12:46 +08:00
2023-01-06 17:15:47 +08:00