crypto: asymmetric_keys - Adjust signature size calculation for NIST P521
authorStefan Berger <stefanb@linux.ibm.com>
Thu, 4 Apr 2024 14:18:55 +0000 (10:18 -0400)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 12 Apr 2024 07:07:52 +0000 (15:07 +0800)
commit4dc50330a437e91063c68da074574bf6459d68a5
tree45b1acead0c4aa6e15a8216fe1638f1ca1b0394d
parenta7d45ba77d3d20ba029532090da4cbf058d3f36b
crypto: asymmetric_keys - Adjust signature size calculation for NIST P521

Adjust the calculation of the maximum signature size for support of
NIST P521. While existing curves may prepend a 0 byte to their coordinates
(to make the number positive), NIST P521 will not do this since only the
first bit in the most significant byte is used.

If the encoding of the x & y coordinates requires at least 128 bytes then
an additional byte is needed for the encoding of the length. Take this into
account when calculating the maximum signature size.

Reviewed-by: Lukas Wunner <lukas@wunner.de>
Tested-by: Lukas Wunner <lukas@wunner.de>
Reviewed-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>
crypto/asymmetric_keys/public_key.c