Commit 0276b45a authored by Niels Möller's avatar Niels Möller
Browse files

ecc_25519_modq: Access q via the ecc struct.

parent 1e14955a
2014-08-28 Niels Möller <>
* ecc-25519.c (ecc_25519_modq): Access q via the ecc struct.
* ecc-eh-to-a.c (ecc_eh_to_a): Analogous change as for ecc_j_to_a.
The modulo q case (op == 2) is hardcoded for curve25519.
......@@ -86,20 +86,18 @@ ecc_25519_modq (const struct ecc_curve *ecc, mp_limb_t *rp)
/* n is the offset where we add in the next term */
for (n = ECC_LIMB_SIZE; n-- > 0;)
mp_limb_t cy;
cy = mpn_submul_1 (rp + n,
ecc->Bmodq_shifted, ECC_LIMB_SIZE,
rp[n + ECC_LIMB_SIZE]);
/* Top limb of mBmodq_shifted is zero, so we get cy == 0 or 1 */
assert (cy < 2);
cnd_add_n (cy, rp+n, ecc_q, ECC_LIMB_SIZE);
cnd_add_n (cy, rp+n, ecc->q, ECC_LIMB_SIZE);
cy = mpn_submul_1 (rp, ecc_q, ECC_LIMB_SIZE,
cy = mpn_submul_1 (rp, ecc->q, ECC_LIMB_SIZE,
assert (cy < 2);
cnd_add_n (cy, rp, ecc_q, ECC_LIMB_SIZE);
cnd_add_n (cy, rp, ecc->q, ECC_LIMB_SIZE);
/* Needs 2*ecc->size limbs at rp, and 2*ecc->size additional limbs of
Supports Markdown
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