diff options
author | Niels Möller <nisse@lysator.liu.se> | 2014-09-22 12:39:19 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2014-09-22 12:39:19 +0200 |
commit | a78c9459fda9204b870350a3e075cd78d448fca2 (patch) | |
tree | 5570986a3a7ee931bc4a43b47b6fa62b6133e8cc /ecc-j-to-a.c | |
parent | 2b552abd4edc775de854014c7b0135902ca2ecd3 (diff) | |
download | nettle-a78c9459fda9204b870350a3e075cd78d448fca2.tar.gz |
Introduced struct ecc_modulo.
Diffstat (limited to 'ecc-j-to-a.c')
-rw-r--r-- | ecc-j-to-a.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/ecc-j-to-a.c b/ecc-j-to-a.c index e945929d..eb22ecab 100644 --- a/ecc-j-to-a.c +++ b/ecc-j-to-a.c @@ -42,7 +42,7 @@ mp_size_t ecc_j_to_a_itch (const struct ecc_curve *ecc) { /* Needs 2*ecc->size + scratch for ecc_modq_inv */ - return ECC_J_TO_A_ITCH (ecc->size); + return ECC_J_TO_A_ITCH (ecc->p.size); } void @@ -52,10 +52,10 @@ ecc_j_to_a (const struct ecc_curve *ecc, mp_limb_t *scratch) { #define izp scratch -#define up (scratch + ecc->size) -#define iz2p (scratch + ecc->size) -#define iz3p (scratch + 2*ecc->size) -#define izBp (scratch + 3*ecc->size) +#define up (scratch + ecc->p.size) +#define iz2p (scratch + ecc->p.size) +#define iz3p (scratch + 2*ecc->p.size) +#define izBp (scratch + 3*ecc->p.size) #define tp scratch mp_limb_t cy; @@ -71,17 +71,17 @@ ecc_j_to_a (const struct ecc_curve *ecc, representation. */ - mpn_copyi (up, p + 2*ecc->size, ecc->size); - mpn_zero (up + ecc->size, ecc->size); + mpn_copyi (up, p + 2*ecc->p.size, ecc->p.size); + mpn_zero (up + ecc->p.size, ecc->p.size); ecc->redc (ecc, up); - mpn_zero (up + ecc->size, ecc->size); + mpn_zero (up + ecc->p.size, ecc->p.size); ecc->redc (ecc, up); - ecc_modp_inv (ecc, izp, up, up + ecc->size); + ecc_modp_inv (ecc, izp, up, up + ecc->p.size); /* Divide this common factor by B */ - mpn_copyi (izBp, izp, ecc->size); - mpn_zero (izBp + ecc->size, ecc->size); + mpn_copyi (izBp, izp, ecc->p.size); + mpn_zero (izBp + ecc->p.size, ecc->p.size); ecc->redc (ecc, izBp); ecc_modp_mul (ecc, iz2p, izp, izBp); @@ -90,8 +90,8 @@ ecc_j_to_a (const struct ecc_curve *ecc, { /* Set s = p_z^{-1}, r_x = p_x s^2, r_y = p_y s^3 */ - mpn_copyi (up, p+2*ecc->size, ecc->size); /* p_z */ - ecc_modp_inv (ecc, izp, up, up + ecc->size); + mpn_copyi (up, p+2*ecc->p.size, ecc->p.size); /* p_z */ + ecc_modp_inv (ecc, izp, up, up + ecc->p.size); ecc_modp_sqr (ecc, iz2p, izp); } @@ -99,8 +99,8 @@ ecc_j_to_a (const struct ecc_curve *ecc, ecc_modp_mul (ecc, iz3p, iz2p, p); /* ecc_modp (and ecc_modp_mul) may return a value up to 2p - 1, so do a conditional subtraction. */ - cy = mpn_sub_n (r, iz3p, ecc->p, ecc->size); - cnd_copy (cy, r, iz3p, ecc->size); + cy = mpn_sub_n (r, iz3p, ecc->p.m, ecc->p.size); + cnd_copy (cy, r, iz3p, ecc->p.size); if (op) { @@ -110,16 +110,16 @@ ecc_j_to_a (const struct ecc_curve *ecc, /* Also reduce the x coordinate mod ecc->q. It should already be < 2*ecc->q, so one subtraction should suffice. */ - cy = mpn_sub_n (scratch, r, ecc->q, ecc->size); - cnd_copy (cy == 0, r, scratch, ecc->size); + cy = mpn_sub_n (scratch, r, ecc->q.m, ecc->p.size); + cnd_copy (cy == 0, r, scratch, ecc->p.size); } return; } ecc_modp_mul (ecc, iz3p, iz2p, izp); - ecc_modp_mul (ecc, tp, iz3p, p + ecc->size); + ecc_modp_mul (ecc, tp, iz3p, p + ecc->p.size); /* And a similar subtraction. */ - cy = mpn_sub_n (r + ecc->size, tp, ecc->p, ecc->size); - cnd_copy (cy, r + ecc->size, tp, ecc->size); + cy = mpn_sub_n (r + ecc->p.size, tp, ecc->p.m, ecc->p.size); + cnd_copy (cy, r + ecc->p.size, tp, ecc->p.size); #undef izp #undef up |