Commit 51e45744 authored by Niels Möller's avatar Niels Möller
Browse files

Minor changes to curve25519_mul_g. Use local variable ecc.

parent fd179ede
......@@ -5,8 +5,10 @@
but which should eventually be eliminted from that function.
* (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 <>
......@@ -44,28 +44,30 @@
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
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