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-mul-a-eh.c | |
parent | 2b552abd4edc775de854014c7b0135902ca2ecd3 (diff) | |
download | nettle-a78c9459fda9204b870350a3e075cd78d448fca2.tar.gz |
Introduced struct ecc_modulo.
Diffstat (limited to 'ecc-mul-a-eh.c')
-rw-r--r-- | ecc-mul-a-eh.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/ecc-mul-a-eh.c b/ecc-mul-a-eh.c index 095e870c..2e273349 100644 --- a/ecc-mul-a-eh.c +++ b/ecc-mul-a-eh.c @@ -41,13 +41,13 @@ mp_size_t ecc_mul_a_eh_itch (const struct ecc_curve *ecc) { - /* Binary algorithm needs 6*ecc->size + scratch for ecc_add_ehh, - total 13 ecc->size + /* Binary algorithm needs 6*ecc->p.size + scratch for ecc_add_ehh, + total 13 ecc->p.size - Window algorithm needs (3<<w) * ecc->size for the table, - 3*ecc->size for a temporary point, and scratch for + Window algorithm needs (3<<w) * ecc->p.size for the table, + 3*ecc->p.size for a temporary point, and scratch for ecc_add_ehh. */ - return ECC_MUL_A_EH_ITCH (ecc->size); + return ECC_MUL_A_EH_ITCH (ecc->p.size); } #if ECC_MUL_A_EH_WBITS == 0 @@ -58,18 +58,18 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, mp_limb_t *scratch) { #define pe scratch -#define tp (scratch + 3*ecc->size) -#define scratch_out (scratch + 6*ecc->size) +#define tp (scratch + 3*ecc->p.size) +#define scratch_out (scratch + 6*ecc->p.size) unsigned i; ecc_a_to_j (ecc, pe, p); /* x = 0, y = 1, z = 1 */ - mpn_zero (r, 3*ecc->size); - r[ecc->size] = r[2*ecc->size] = 1; + mpn_zero (r, 3*ecc->p.size); + r[ecc->p.size] = r[2*ecc->p.size] = 1; - for (i = ecc->size; i-- > 0; ) + for (i = ecc->p.size; i-- > 0; ) { mp_limb_t w = np[i]; mp_limb_t bit; @@ -85,7 +85,7 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, digit = (w & bit) > 0; /* If we had a one-bit, use the sum. */ - cnd_copy (digit, r, tp, 3*ecc->size); + cnd_copy (digit, r, tp, 3*ecc->p.size); } } } @@ -94,7 +94,7 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, #define TABLE_SIZE (1U << ECC_MUL_A_EH_WBITS) #define TABLE_MASK (TABLE_SIZE - 1) -#define TABLE(j) (table + (j) * 3*ecc->size) +#define TABLE(j) (table + (j) * 3*ecc->p.size) static void table_init (const struct ecc_curve *ecc, @@ -105,8 +105,8 @@ table_init (const struct ecc_curve *ecc, unsigned size = 1 << bits; unsigned j; - mpn_zero (TABLE(0), 3*ecc->size); - TABLE(0)[ecc->size] = TABLE(0)[2*ecc->size] = 1; + mpn_zero (TABLE(0), 3*ecc->p.size); + TABLE(0)[ecc->p.size] = TABLE(0)[2*ecc->p.size] = 1; ecc_a_to_j (ecc, TABLE(1), p); @@ -124,12 +124,12 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, mp_limb_t *scratch) { #define tp scratch -#define table (scratch + 3*ecc->size) - mp_limb_t *scratch_out = table + (3*ecc->size << ECC_MUL_A_EH_WBITS); +#define table (scratch + 3*ecc->p.size) + mp_limb_t *scratch_out = table + (3*ecc->p.size << ECC_MUL_A_EH_WBITS); /* Avoid the mp_bitcnt_t type for compatibility with older GMP versions. */ - unsigned blocks = (ecc->bit_size + ECC_MUL_A_EH_WBITS - 1) / ECC_MUL_A_EH_WBITS; + unsigned blocks = (ecc->p.bit_size + ECC_MUL_A_EH_WBITS - 1) / ECC_MUL_A_EH_WBITS; unsigned bit_index = (blocks-1) * ECC_MUL_A_EH_WBITS; mp_size_t limb_index = bit_index / GMP_NUMB_BITS; @@ -140,12 +140,12 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, w = np[limb_index]; bits = w >> shift; - if (limb_index < ecc->size - 1) + if (limb_index < ecc->p.size - 1) bits |= np[limb_index + 1] << (GMP_NUMB_BITS - shift); assert (bits < TABLE_SIZE); - sec_tabselect (r, 3*ecc->size, table, TABLE_SIZE, bits); + sec_tabselect (r, 3*ecc->p.size, table, TABLE_SIZE, bits); for (;;) { @@ -171,7 +171,7 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, ecc_dup_eh (ecc, r, r, scratch_out); bits &= TABLE_MASK; - sec_tabselect (tp, 3*ecc->size, table, TABLE_SIZE, bits); + sec_tabselect (tp, 3*ecc->p.size, table, TABLE_SIZE, bits); ecc_add_ehh (ecc, r, tp, r, scratch_out); } #undef table |