diff options
author | Stefan Berger <stefanb@linux.ibm.com> | 2024-04-04 10:18:47 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2024-04-12 15:07:52 +0800 |
commit | 43f6548dd86122c7e87a19c854ea6c54c845ba2e (patch) | |
tree | 8e33d71f3c5f2e422c81b7ad5d979adf98dc75ee /crypto/crypto_user.c | |
parent | 0086557046b018c7fe7ffa52680c0c7ea7af32d7 (diff) | |
download | linux-crypto-43f6548dd86122c7e87a19c854ea6c54c845ba2e.tar.gz linux-crypto-43f6548dd86122c7e87a19c854ea6c54c845ba2e.zip |
crypto: ecdsa - Extend res.x mod n calculation for NIST P521
res.x has been calculated by ecc_point_mult_shamir, which uses
'mod curve_prime' on res.x and therefore p > res.x with 'p' being the
curve_prime. Further, it is true that for the NIST curves p > n with 'n'
being the 'curve_order' and therefore the following may be true as well:
p > res.x >= n.
If res.x >= n then res.x mod n can be calculated by iteratively sub-
tracting n from res.x until res.x < n. For NIST P192/256/384 this can be
done in a single subtraction. This can also be done in a single
subtraction for NIST P521.
The mathematical reason why a single subtraction is sufficient is due to
the values of 'p' and 'n' of the NIST curves where the following holds
true:
note: max(res.x) = p - 1
max(res.x) - n < n
p - 1 - n < n
p - 1 < 2n => holds true for the NIST curves
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>
Diffstat (limited to '')
0 files changed, 0 insertions, 0 deletions