]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Minor changes to curve25519_mul_g. Use local variable ecc.
authorNiels Möller <nisse@lysator.liu.se>
Tue, 2 Sep 2014 20:30:12 +0000 (22:30 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 2 Sep 2014 20:30:12 +0000 (22:30 +0200)
ChangeLog
curve25519-mul-g.c

index 96175e2c848c75d1f43f8ddfae79647015a46d92..4530460ad3ea663c44628600ca9745a2e70c017e 100644 (file)
--- 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  <nisse@lysator.liu.se>
 
index 0106ac7c44e1fc9d26455be24150e86055838b73..9aec180b4b60bd089c35dbfcbf0424913ddc3967 100644 (file)
 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
 }