Commit 6cf6abd6 authored by Daiki Ueno's avatar Daiki Ueno Committed by Niels Möller

ecc-eh-to-a, eddsa-sign: Parameterize hard-coded value

This allows the same code to be reused in curve448 and Ed448.
Signed-off-by: default avatarDaiki Ueno <dueno@redhat.com>
parent 49181d3f
......@@ -73,7 +73,7 @@ ecc_eh_to_a (const struct ecc_curve *ecc,
at all? Full reduction mod p is maybe sufficient. */
unsigned shift;
assert (ecc->p.bit_size == 255);
shift = 252 - GMP_NUMB_BITS * (ecc->p.size - 1);
shift = ecc->q.bit_size - 1 - GMP_NUMB_BITS * (ecc->p.size - 1);
cy = mpn_submul_1 (r, ecc->q.m, ecc->p.size,
r[ecc->p.size-1] >> shift);
assert (cy < 2);
......
......@@ -92,7 +92,7 @@ _eddsa_sign (const struct ecc_curve *ecc,
unsigned shift;
mp_limb_t cy;
assert (ecc->p.bit_size == 255);
shift = 252 - GMP_NUMB_BITS * (ecc->p.size - 1);
shift = ecc->q.bit_size - 1 - GMP_NUMB_BITS * (ecc->p.size - 1);
cy = mpn_submul_1 (sp, ecc->q.m, ecc->p.size,
sp[ecc->p.size-1] >> shift);
assert (cy < 2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment