summaryrefslogtreecommitdiff
path: root/ecc-internal.h
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2014-10-02 10:41:31 +0200
committerNiels Möller <nisse@lysator.liu.se>2014-10-02 10:41:31 +0200
commitc510cfa44fcab993d4214dbef1540de3f137760f (patch)
tree6321481e06f6c3fa74665e51cf4947dbd8ef1507 /ecc-internal.h
parent49157ac1119080877f6ea126094a6d1052c41ee6 (diff)
downloadnettle-c510cfa44fcab993d4214dbef1540de3f137760f.tar.gz
Added sqrt function to struct ecc_modulo.
Reorganized curve25519 implementation to take a ratio as input.
Diffstat (limited to 'ecc-internal.h')
-rw-r--r--ecc-internal.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/ecc-internal.h b/ecc-internal.h
index 04ca9668..f3a21bc8 100644
--- a/ecc-internal.h
+++ b/ecc-internal.h
@@ -58,7 +58,6 @@
#define sec_sub_1 _nettle_sec_sub_1
#define sec_tabselect _nettle_sec_tabselect
#define sec_modinv _nettle_sec_modinv
-#define ecc_25519_sqrt _nettle_ecc_25519_sqrt
#define curve25519_eh_to_x _nettle_curve25519_eh_to_x
#define ECC_MAX_SIZE ((521 + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)
@@ -83,6 +82,12 @@ typedef void ecc_mod_inv_func (const struct ecc_modulo *m,
mp_limb_t *vp, const mp_limb_t *ap,
mp_limb_t *scratch);
+/* Computes the square root of (u/v) (mod p) */
+typedef int ecc_mod_sqrt_func (const struct ecc_modulo *m,
+ mp_limb_t *rp,
+ const mp_limb_t *up, const mp_limb_t *vp,
+ mp_limb_t *scratch);
+
typedef void ecc_add_func (const struct ecc_curve *ecc,
mp_limb_t *r,
const mp_limb_t *p, const mp_limb_t *q,
@@ -108,6 +113,7 @@ struct ecc_modulo
unsigned short B_size;
unsigned short redc_size;
unsigned short invert_itch;
+ unsigned short sqrt_itch;
const mp_limb_t *m;
/* B^size mod m. Expected to have at least 32 leading zeros
@@ -123,6 +129,7 @@ struct ecc_modulo
ecc_mod_func *mod;
ecc_mod_func *reduce;
ecc_mod_inv_func *invert;
+ ecc_mod_sqrt_func *sqrt;
};
/* Represents an elliptic curve of the form
@@ -255,10 +262,6 @@ sec_tabselect (mp_limb_t *rp, mp_size_t rn,
const mp_limb_t *table, unsigned tn,
unsigned k);
-
-int
-ecc_25519_sqrt(mp_limb_t *rp, const mp_limb_t *ap);
-
void
curve25519_eh_to_x (mp_limb_t *xp, const mp_limb_t *p,
mp_limb_t *scratch);