diff options
author | Niels Möller <nisse@lysator.liu.se> | 2021-11-06 17:10:26 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2021-11-07 20:35:44 +0100 |
commit | c2726388d1bf23ac8c61dd815ad831e680917778 (patch) | |
tree | 6ed824bce37ab56d7f15cb82caff6e8bf9e375c0 | |
parent | 03421be19e7b953bb3334044a4f1e7b14286cf46 (diff) | |
download | nettle-c2726388d1bf23ac8c61dd815ad831e680917778.tar.gz |
Renamed sqrt_itch --> sqrt_ratio_itch, and curve25519 and curve448 sqrt functions.
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | ecc-curve25519.c | 12 | ||||
-rw-r--r-- | ecc-curve448.c | 12 | ||||
-rw-r--r-- | ecc-internal.h | 13 | ||||
-rw-r--r-- | eddsa-decompress.c | 2 | ||||
-rw-r--r-- | testsuite/ecc-sqrt-test.c | 2 |
6 files changed, 38 insertions, 21 deletions
@@ -1,4 +1,20 @@ -2021-11-06 Niels Möller <nisse@lysator.liu.se> +2021-11-07 Niels Möller <nisse@lysator.liu.se> + + * ecc-internal.h (struct ecc_modulo): Renamed sqrt_itch to + sqrt_ratio_itch. + * eddsa-decompress.c (_eddsa_decompress_itch): Updated. + + * ecc-curve448.c (ECC_CURVE448_SQRT_RATIO_ITCH): Renamed, from ... + (ECC_CURVE448_SQRT_ITCH): ... old name. + (ecc_curve448_sqrt_ratio): Renamed, from ... + (ecc_curve448_sqrt): ... old name. + (_nettle_curve448): Updated. + + * ecc-curve25519.c (ECC_25519_SQRT_RATIO_ITCH): Renamed, from ... + (ECC_25519_SQRT_ITCH): ... old name + (ecc_curve25519_sqrt_ratio): Renamed, from ... + (ecc_curve25519_sqrt): ... old name. + (_nettle_curve25519): Updated. * ecc-internal.h (ecc_mod_sqrt_ratio_func): Renamed typedef... (ecc_mod_sqrt_func): ... from old name. diff --git a/ecc-curve25519.c b/ecc-curve25519.c index a1d68afd..e461c197 100644 --- a/ecc-curve25519.c +++ b/ecc-curve25519.c @@ -198,12 +198,12 @@ ecc_curve25519_zero_p (const struct ecc_modulo *p, mp_limb_t *xp) #endif /* Needs 2*n space + scratch for ecc_mod_pow_252m3. */ -#define ECC_25519_SQRT_ITCH (6*ECC_LIMB_SIZE) +#define ECC_25519_SQRT_RATIO_ITCH (6*ECC_LIMB_SIZE) static int -ecc_curve25519_sqrt(const struct ecc_modulo *p, mp_limb_t *rp, - const mp_limb_t *up, const mp_limb_t *vp, - mp_limb_t *scratch) +ecc_curve25519_sqrt_ratio(const struct ecc_modulo *p, mp_limb_t *rp, + const mp_limb_t *up, const mp_limb_t *vp, + mp_limb_t *scratch) { int pos, neg; @@ -260,7 +260,7 @@ const struct ecc_curve _nettle_curve25519 = ECC_BMODP_SIZE, 0, ECC_25519_INV_ITCH, - ECC_25519_SQRT_ITCH, + ECC_25519_SQRT_RATIO_ITCH, ecc_p, ecc_Bmodp, @@ -271,7 +271,7 @@ const struct ecc_curve _nettle_curve25519 = ecc_curve25519_modp, ecc_curve25519_modp, ecc_curve25519_inv, - ecc_curve25519_sqrt, + ecc_curve25519_sqrt_ratio, }, { 253, diff --git a/ecc-curve448.c b/ecc-curve448.c index a83be121..67d197eb 100644 --- a/ecc-curve448.c +++ b/ecc-curve448.c @@ -169,12 +169,12 @@ static void ecc_curve448_inv (const struct ecc_modulo *p, */ /* Needs 2*n space + scratch for ecc_mod_pow_446m224m1. */ -#define ECC_CURVE448_SQRT_ITCH (6*ECC_LIMB_SIZE) +#define ECC_CURVE448_SQRT_RATIO_ITCH (6*ECC_LIMB_SIZE) static int -ecc_curve448_sqrt(const struct ecc_modulo *p, mp_limb_t *rp, - const mp_limb_t *up, const mp_limb_t *vp, - mp_limb_t *scratch) +ecc_curve448_sqrt_ratio(const struct ecc_modulo *p, mp_limb_t *rp, + const mp_limb_t *up, const mp_limb_t *vp, + mp_limb_t *scratch) { #define uv scratch #define u3v (scratch + ECC_LIMB_SIZE) @@ -214,7 +214,7 @@ const struct ecc_curve _nettle_curve448 = ECC_BMODP_SIZE, 0, ECC_CURVE448_INV_ITCH, - ECC_CURVE448_SQRT_ITCH, + ECC_CURVE448_SQRT_RATIO_ITCH, ecc_p, ecc_Bmodp, @@ -225,7 +225,7 @@ const struct ecc_curve _nettle_curve448 = ecc_curve448_modp, ecc_curve448_modp, ecc_curve448_inv, - ecc_curve448_sqrt, + ecc_curve448_sqrt_ratio, }, { 446, diff --git a/ecc-internal.h b/ecc-internal.h index 4d2d8f41..a3e19331 100644 --- a/ecc-internal.h +++ b/ecc-internal.h @@ -125,7 +125,7 @@ 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) */ +/* Computes the square root of (u/v) (mod p). */ typedef int ecc_mod_sqrt_ratio_func (const struct ecc_modulo *m, mp_limb_t *rp, const mp_limb_t *up, const mp_limb_t *vp, @@ -161,7 +161,7 @@ struct ecc_modulo unsigned short B_size; unsigned short redc_size; unsigned short invert_itch; - unsigned short sqrt_itch; + unsigned short sqrt_ratio_itch; const mp_limb_t *m; /* B^size mod m. Expected to have at least 32 leading zeros @@ -227,7 +227,7 @@ struct ecc_curve The following entries differ by powers of 2^{kc}, T[i] = 2^{kc} T[i-2^c] - */ + */ const mp_limb_t *pippenger_table; }; @@ -238,7 +238,8 @@ ecc_mod_func ecc_pm1_redc; ecc_mod_inv_func ecc_mod_inv; /* Side channel silent. Requires that x < 2m, so checks if x == 0 or x == p */ -int ecc_mod_zero_p (const struct ecc_modulo *m, const mp_limb_t *xp); +int +ecc_mod_zero_p (const struct ecc_modulo *m, const mp_limb_t *xp); void ecc_mod_add (const struct ecc_modulo *m, mp_limb_t *rp, @@ -354,7 +355,7 @@ ecc_dup_jj (const struct ecc_curve *ecc, P = Q != 0 Duplication of non-zero point P = 0, Q != 0 or P != 0, Q = 0 One input zero - + Correctly gives R = 0 if P = Q = 0 or P = -Q. */ void ecc_add_jja (const struct ecc_curve *ecc, @@ -402,7 +403,7 @@ ecc_add_thh (const struct ecc_curve *ecc, /* Computes N * the group generator. N is an array of ecc_size() limbs. It must be in the range 0 < N < group order, then R != 0, and the algorithm can work without any intermediate values getting - to zero. */ + to zero. */ void ecc_mul_g (const struct ecc_curve *ecc, mp_limb_t *r, const mp_limb_t *np, mp_limb_t *scratch); diff --git a/eddsa-decompress.c b/eddsa-decompress.c index 1708f16f..8517fb7b 100644 --- a/eddsa-decompress.c +++ b/eddsa-decompress.c @@ -44,7 +44,7 @@ mp_size_t _eddsa_decompress_itch (const struct ecc_curve *ecc) { - return 4*ecc->p.size + ecc->p.sqrt_itch; + return 4*ecc->p.size + ecc->p.sqrt_ratio_itch; } int diff --git a/testsuite/ecc-sqrt-test.c b/testsuite/ecc-sqrt-test.c index 4c70677d..026d7f7a 100644 --- a/testsuite/ecc-sqrt-test.c +++ b/testsuite/ecc-sqrt-test.c @@ -89,7 +89,7 @@ test_modulo (gmp_randstate_t rands, const struct ecc_modulo *m) up = xalloc_limbs (m->size); vp = xalloc_limbs (m->size); rp = xalloc_limbs (2*m->size); - scratch = xalloc_limbs (m->sqrt_itch); + scratch = xalloc_limbs (m->sqrt_ratio_itch); /* Find a non-square */ for (z = 2; mpz_ui_kronecker (z, p) != -1; z++) |