chiark / gitweb /
math/mpmont.c: Make REDC coefficient as long as the modulus.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 12 Sep 2016 21:32:37 +0000 (22:32 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 2 Oct 2016 12:31:59 +0000 (13:31 +0100)
We'll have trouble later if it's too short.

math/mpmont.c

index b95e1cfe1a6741c9952cdc49a0bb1de390ae633e..a86623b29d38c84b97a76de1ae9c7d31c0358dfc 100644 (file)
@@ -209,6 +209,7 @@ int mpmont_create(mpmont *mm, mp *m)
   mp_build(&r, r2->v + n, r2->vl);
   mm->mi = mp_modinv(MP_NEW, m, &r);
   mm->mi = mp_sub(mm->mi, &r, mm->mi);
+  MP_ENSURE(mm->mi, n);
 
   /* --- Discover the values %$R \bmod m$% and %$R^2 \bmod m$% --- */