From 74dea233bb42194c580774513de72678fcf018c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Wed, 17 Sep 2014 19:31:31 +0200
Subject: [PATCH] Use struct ecc_curve function pointers also in
 ecdsa_generate_keypair.

---
 ChangeLog      |  3 +++
 ecdsa-keygen.c | 11 ++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c196335c..3b673007 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2014-09-17  Niels Möller  <nisse@lysator.liu.se>
 
+	* ecdsa-keygen.c (ecdsa_generate_keypair): Use struct ecc_curve
+	function pointers.
+
 	* testsuite/curve25519-dup-test.c: Deleted file. In the way for
 	conversion to Edwards coordiante convention, and in the end
 	the tests will be done by ecc-dup-test.c.
diff --git a/ecdsa-keygen.c b/ecdsa-keygen.c
index d9f12405..d5b55256 100644
--- a/ecdsa-keygen.c
+++ b/ecdsa-keygen.c
@@ -48,13 +48,14 @@ ecdsa_generate_keypair (struct ecc_point *pub,
 			void *random_ctx, nettle_random_func *random)
 {
   TMP_DECL(p, mp_limb_t, 3*ECC_MAX_SIZE + ECC_MUL_G_ITCH (ECC_MAX_SIZE));
-  mp_size_t itch = 3*pub->ecc->size + ECC_MUL_G_ITCH (pub->ecc->size);
+  const struct ecc_curve *ecc = pub->ecc;
+  mp_size_t itch = 3*ecc->size + ecc->mul_g_itch;
 
-  assert (key->ecc == pub->ecc);
+  assert (key->ecc == ecc);
 
   TMP_ALLOC (p, itch);
 
-  ecc_modq_random (key->ecc, key->p, random_ctx, random, p);
-  ecc_mul_g (pub->ecc, p, key->p, p + 3*pub->ecc->size);
-  ecc_j_to_a (pub->ecc, 0, pub->p, p, p + 3*pub->ecc->size);
+  ecc_modq_random (ecc, key->p, random_ctx, random, p);
+  ecc->mul_g (ecc, p, key->p, p + 3*ecc->size);
+  ecc->h_to_a (ecc, 0, pub->p, p, p + 3*ecc->size);
 }
-- 
GitLab