Bladeren bron

hydro_x25519_mul: don't specify the number of limbs in the prototype

The ladder step requires a multiplication with (A-2)/4 which is small
enough to fit in a single limb, but the hydro_x25519_mul prototype
expected 5 limbs.

No code changes, but
fixes #123
Frank Denis 3 jaren geleden
bovenliggende
commit
6da7fac2c0
1 gewijzigde bestanden met toevoegingen van 4 en 2 verwijderingen
  1. 4 2
      impl/x25519.h

+ 4 - 2
impl/x25519.h

@@ -138,15 +138,17 @@ hydro_x25519_swapout(uint8_t *out, hydro_x25519_limb_t *x)
 }
 
 static void
-hydro_x25519_mul(hydro_x25519_fe out, const hydro_x25519_fe a, const hydro_x25519_fe b, int nb)
+hydro_x25519_mul(hydro_x25519_fe out, const hydro_x25519_fe a, const hydro_x25519_limb_t b[],
+                 const int nb)
 {
     hydro_x25519_limb_t accum[2 * hydro_x25519_NLIMBS] = { 0 };
     hydro_x25519_limb_t carry2;
     int                 i, j;
 
     for (i = 0; i < nb; i++) {
-        carry2                   = 0;
         hydro_x25519_limb_t mand = b[i];
+        carry2                   = 0;
+
         for (j = 0; j < hydro_x25519_NLIMBS; j++) {
             accum[i + j] = hydro_x25519_umaal(&carry2, accum[i + j], mand, a[j]);
         }