To support curve25519 point operations.
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.
#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
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,
# include "config.h"
#endif
+#include "ecc.h"
#include "ecc-internal.h"
#if HAVE_NATIVE_ecc_224_modp
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,
# include "config.h"
#endif
+#include "ecc.h"
#include "ecc-internal.h"
#define USE_REDC 0
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,
#include <assert.h>
+#include "ecc.h"
#include "ecc-internal.h"
#if HAVE_NATIVE_ecc_256_redc
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,
#include <assert.h>
+#include "ecc.h"
#include "ecc-internal.h"
#define USE_REDC 0
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,
# include "config.h"
#endif
+#include "ecc.h"
#include "ecc-internal.h"
#define USE_REDC 0
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,
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)
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;