]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Additional function pointers in struct ecc_curve.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 25 Aug 2014 19:17:39 +0000 (21:17 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 25 Aug 2014 19:17:39 +0000 (21:17 +0200)
To support curve25519 point operations.

ChangeLog
ecc-192.c
ecc-224.c
ecc-25519.c
ecc-256.c
ecc-384.c
ecc-521.c
ecc-internal.h

index 0621b3ee597dff81907baf5c88be1fa87ae6e457..551bd23658cccaf25e529fadc19135171b40ab9a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2014-08-25  Niels Möller  <nisse@lysator.liu.se>
 
+       * ecc-internal.h (ecc_mul_g_func, ecc_mul_func, ecc_h_to_a_func):
+       New typedefs.
+       (struct ecc_curve): New function pointers mul, mul_g, h_to_a, and
+       constans for their scratch requirements. Updated all instances.
+
        * ecc-point.c (ecc_point_set): Handle curve25519 as a special
        case, when checking if the point is on the curve.
 
index fe624dee128503ae2b54512f111acb7f86ee0ad6..29ff7f6a2ee00aff90ea2fae4905d052e3583790 100644 (file)
--- a/ecc-192.c
+++ b/ecc-192.c
@@ -39,6 +39,9 @@
 
 #include <assert.h>
 
+/* FIXME: Remove ecc.h include, once prototypes of more internal
+   functions are moved to ecc-internal.h */
+#include "ecc.h"
 #include "ecc-internal.h"
 
 #define USE_REDC 0
@@ -118,11 +121,19 @@ const struct ecc_curve nettle_secp_192r1 =
   ECC_PIPPENGER_K,
   ECC_PIPPENGER_C,
 
+  ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
+  ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
+  ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
+
   ecc_192_modp,
   ecc_generic_redc,
   ecc_192_modp,
   ecc_generic_modq,
 
+  ecc_mul_a,
+  ecc_mul_g,
+  ecc_j_to_a,
+
   ecc_p,
   ecc_b,
   ecc_q,
index fb3e4d5fa37c71fd26be4c02a2d52e6fb91692f0..8a99f0e38ad0ca5894d024e3e7c85e733c21948f 100644 (file)
--- a/ecc-224.c
+++ b/ecc-224.c
@@ -37,6 +37,7 @@
 # include "config.h"
 #endif
 
+#include "ecc.h"
 #include "ecc-internal.h"
 
 #if HAVE_NATIVE_ecc_224_modp
@@ -64,11 +65,19 @@ const struct ecc_curve nettle_secp_224r1 =
   ECC_PIPPENGER_K,
   ECC_PIPPENGER_C,
 
+  ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
+  ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
+  ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
+
   ecc_224_modp,
   ecc_generic_redc,
   USE_REDC ? ecc_generic_redc : ecc_224_modp,
   ecc_generic_modq,
 
+  ecc_mul_a,
+  ecc_mul_g,
+  ecc_j_to_a,
+
   ecc_p,
   ecc_b,
   ecc_q,
index 5b3a7468cc63cc68ff0ab77ea31aa02fc93db2ed..6781475a9dd38d1247f002ef5de7cb0f10246733 100644 (file)
@@ -35,6 +35,7 @@
 # include "config.h"
 #endif
 
+#include "ecc.h"
 #include "ecc-internal.h"
 
 #define USE_REDC 0
@@ -210,11 +211,19 @@ const struct ecc_curve nettle_curve25519 =
   ECC_PIPPENGER_K,
   ECC_PIPPENGER_C,
 
+  ECC_MUL_A_EH_ITCH (ECC_LIMB_SIZE),
+  ECC_MUL_G_EH_ITCH (ECC_LIMB_SIZE),
+  ECC_EH_TO_A_ITCH (ECC_LIMB_SIZE),
+
   ecc_25519_modp,
   NULL,
   ecc_25519_modp,
   NULL,
 
+  ecc_mul_a_eh,
+  ecc_mul_g_eh,
+  ecc_eh_to_a,
+
   ecc_p,
   ecc_d, /* Use the Edwards curve constant. */
   ecc_q,
index 2ded5b3bde94aa70dc856f303cd48be8920a6367..f888aafef92510ae555fad9e547ed5598ef4ec30 100644 (file)
--- a/ecc-256.c
+++ b/ecc-256.c
@@ -39,6 +39,7 @@
 
 #include <assert.h>
 
+#include "ecc.h"
 #include "ecc-internal.h"
 
 #if HAVE_NATIVE_ecc_256_redc
@@ -229,11 +230,19 @@ const struct ecc_curve nettle_secp_256r1 =
   ECC_PIPPENGER_K,
   ECC_PIPPENGER_C,
 
+  ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
+  ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
+  ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
+
   ecc_256_modp,
   ecc_256_redc,
   USE_REDC ? ecc_256_redc : ecc_256_modp,
   ecc_256_modq,
 
+  ecc_mul_a,
+  ecc_mul_g,
+  ecc_j_to_a,
+
   ecc_p,
   ecc_b,
   ecc_q,
index dff0cd015de2cbe9162551231cd9b4ac7ab1fa2f..c20d8ab425dce7073e314b912a81e0911568b029 100644 (file)
--- a/ecc-384.c
+++ b/ecc-384.c
@@ -39,6 +39,7 @@
 
 #include <assert.h>
 
+#include "ecc.h"
 #include "ecc-internal.h"
 
 #define USE_REDC 0
@@ -157,11 +158,19 @@ const struct ecc_curve nettle_secp_384r1 =
   ECC_PIPPENGER_K,
   ECC_PIPPENGER_C,
 
+  ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
+  ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
+  ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
+
   ecc_384_modp,
   ECC_REDC_SIZE != 0 ? ecc_generic_redc : NULL,
   ecc_384_modp,
   ecc_generic_modq,
 
+  ecc_mul_a,
+  ecc_mul_g,
+  ecc_j_to_a,
+
   ecc_p,
   ecc_b,
   ecc_q,
index 25fc2b08340ce9a74aa86c815d0724d2ff866da5..821c77c769681d7760cc0ea3bbfc9fe27187b7f1 100644 (file)
--- a/ecc-521.c
+++ b/ecc-521.c
@@ -37,6 +37,7 @@
 # include "config.h"
 #endif
 
+#include "ecc.h"
 #include "ecc-internal.h"
 
 #define USE_REDC 0
@@ -85,11 +86,19 @@ const struct ecc_curve nettle_secp_521r1 =
   ECC_PIPPENGER_K,
   ECC_PIPPENGER_C,
 
+  ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
+  ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
+  ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
+
   ecc_521_modp,
   ecc_generic_redc,
   ecc_521_modp,
   ecc_generic_modq,
 
+  ecc_mul_a,
+  ecc_mul_g,
+  ecc_j_to_a,
+
   ecc_p,
   ecc_b,
   ecc_q,
index d180122b4d45d299fccc2cb0d09b97f298a3d380..6e52415bb63539d04443159ba6c28f237a7ca336 100644 (file)
    modp_mul and modp_add. */
 typedef void ecc_mod_func (const struct ecc_curve *ecc, mp_limb_t *rp);
 
+typedef void ecc_mul_g_func (const struct ecc_curve *ecc, mp_limb_t *r,
+                            const mp_limb_t *np, mp_limb_t *scratch);
+
+typedef void ecc_mul_func (const struct ecc_curve *ecc,
+                          mp_limb_t *r,
+                          const mp_limb_t *np, const mp_limb_t *p,
+                          mp_limb_t *scratch);
+
+typedef void ecc_h_to_a_func (const struct ecc_curve *ecc,
+                             int flags,
+                             mp_limb_t *r, const mp_limb_t *p,
+                             mp_limb_t *scratch);
+
 /* Represents an elliptic curve of the form
 
      y^2 = x^3 - 3x + b (mod p)
@@ -102,11 +115,19 @@ struct ecc_curve
   unsigned short pippenger_k;
   unsigned short pippenger_c;
 
+  unsigned short mul_itch;
+  unsigned short mul_g_itch;
+  unsigned short h_to_a_itch;
+
   ecc_mod_func *modp;
   ecc_mod_func *redc;
   ecc_mod_func *reduce;
   ecc_mod_func *modq;
-  
+
+  ecc_mul_func *mul;
+  ecc_mul_g_func *mul_g;
+  ecc_h_to_a_func *h_to_a;
+
   /* The prime p. */
   const mp_limb_t *p;
   const mp_limb_t *b;