From 51e4574478c680991428ac644c7e2df932f88c71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niels=20M=C3=B6ller?= Date: Tue, 2 Sep 2014 22:30:12 +0200 Subject: [PATCH] Minor changes to curve25519_mul_g. Use local variable ecc. --- ChangeLog | 4 +++- curve25519-mul-g.c | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96175e2c..4530460a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,8 +5,10 @@ but which should eventually be eliminted from that function. * Makefile.in (hogweed_SOURCES): Added curve25519-eh-to-x.c. * ecc-internal.h (curve25519_eh_to_x): Declare it. + * curve25519-mul.c (curve25519_mul): Use it. - * curve25519-mul-g.c (curve25519_mul_g): Likewise. + * curve25519-mul-g.c (curve25519_mul_g): Likewise. Also introduce + local variable ecc, and use ecc->mul_g_itch. 2014-08-29 Niels Möller diff --git a/curve25519-mul-g.c b/curve25519-mul-g.c index 0106ac7c..9aec180b 100644 --- a/curve25519-mul-g.c +++ b/curve25519-mul-g.c @@ -44,28 +44,30 @@ void curve25519_mul_g (uint8_t *r, const uint8_t *n) { + const struct ecc_curve *ecc = &nettle_curve25519; uint8_t t[CURVE25519_SIZE]; mp_limb_t *scratch; - mp_size_t ecc_size; mp_size_t itch; #define p scratch -#define x (scratch + 3*ecc_size) -#define scratch_out (scratch + 4*ecc_size) +#define x (scratch + 3*ecc->size) +#define scratch_out (scratch + 4*ecc->size) memcpy (t, n, sizeof(t)); t[0] &= ~7; t[CURVE25519_SIZE-1] = (t[CURVE25519_SIZE-1] & 0x3f) | 0x40; - ecc_size = nettle_curve25519.size; - itch = 4*ecc_size + ECC_MUL_G_EH_ITCH(ecc_size); + itch = 4*ecc->size + ecc->mul_g_itch; scratch = gmp_alloc_limbs (itch); - mpn_set_base256_le (x, ecc_size, t, CURVE25519_SIZE); + mpn_set_base256_le (x, ecc->size, t, CURVE25519_SIZE); - ecc_mul_g_eh (&nettle_curve25519, p, x, scratch_out); + ecc_mul_g_eh (ecc, p, x, scratch_out); curve25519_eh_to_x (x, p, scratch_out); - mpn_get_base256_le (r, CURVE25519_SIZE, x, ecc_size); + mpn_get_base256_le (r, CURVE25519_SIZE, x, ecc->size); gmp_free_limbs (scratch, itch); +#undef p +#undef x +#undef scratch_out } -- 2.47.2