]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Renamed sqrt_itch --> sqrt_ratio_itch, and curve25519 and curve448 sqrt functions.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 6 Nov 2021 16:10:26 +0000 (17:10 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Sun, 7 Nov 2021 19:35:44 +0000 (20:35 +0100)
ChangeLog
ecc-curve25519.c
ecc-curve448.c
ecc-internal.h
eddsa-decompress.c
testsuite/ecc-sqrt-test.c

index 4af1e650660414eedb98f2a761a0bd023b61f96e..3b4115043c1c3e4d591c905dff7420ec1ac9521a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index a1d68afd32f3f6eb785c17ad542173262437e2d0..e461c1978b31c57357d4d966a0a7ac2cdda4db0c 100644 (file)
@@ -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,
index a83be1213e1f43e2b0905400daf66fecaac1a80a..67d197eb61ecfb98c71247dec9bdffc24183714d 100644 (file)
@@ -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,
index 4d2d8f4112d666ba47fe93377e5c2e5c081afce8..a3e1933154b985ff04531042e1ae16a0f1ba105d 100644 (file)
@@ -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);
index 1708f16f492f92758e3224b09874a85469e64b4b..8517fb7bbd3490dce3272614efee42c823d775a2 100644 (file)
@@ -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
index 4c70677dfd5aab8f1a0241022342aec7df0cb688..026d7f7a9640bb6e712c390aa80047670efa1e46 100644 (file)
@@ -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++)