prime generation: Deploy the new Baillie--PSW testers.
[catacomb] / math / strongprime.c
index a12c0d0..958cd28 100644 (file)
@@ -28,6 +28,7 @@
 /*----- Header files ------------------------------------------------------*/
 
 #include <mLib/dstr.h>
+#include <mLib/macros.h>
 
 #include "grand.h"
 #include "mp.h"
@@ -39,6 +40,9 @@
 
 /*----- Main code ---------------------------------------------------------*/
 
+/* Oh, just shut up. */
+CLANG_WARNING("-Wempty-body")
+
 /* --- @strongprime_setup@ --- *
  *
  * Arguments:  @const char *name@ = pointer to name root
@@ -75,7 +79,6 @@ mp *strongprime_setup(const char *name, mp *d, pfilt *f, unsigned nbits,
   mp *rr = d;
   pgen_filterctx c;
   pgen_jumpctx j;
-  rabin rb;
 
   /* --- Figure out how large the smaller primes should be --- *
    *
@@ -112,13 +115,13 @@ mp *strongprime_setup(const char *name, mp *d, pfilt *f, unsigned nbits,
   rr = mprand(rr, nb, r, 1);
   DRESET(&dn); dstr_putf(&dn, "%s [s]", name);
   if ((s = pgen(dn.buf, MP_NEWSEC, rr, event, ectx, n, pgen_filter, &c,
-               rabin_iters(nb), pgen_test, &rb)) == 0)
+               PGEN_BAILLIEPSWNTESTS, pgen_bailliepswtest, 0)) == 0)
     goto fail_s;
 
   rr = mprand(rr, nb, r, 1);
   DRESET(&dn); dstr_putf(&dn, "%s [t]", name);
   if ((t = pgen(dn.buf, MP_NEWSEC, rr, event, ectx, n, pgen_filter, &c,
-               rabin_iters(nb), pgen_test, &rb)) == 0)
+               PGEN_BAILLIEPSWNTESTS, pgen_bailliepswtest, 0)) == 0)
     goto fail_t;
 
   /* --- Choose a suitable value for %$r = 2it + 1$% for some %$i$% --- *
@@ -133,7 +136,7 @@ mp *strongprime_setup(const char *name, mp *d, pfilt *f, unsigned nbits,
   DRESET(&dn); dstr_putf(&dn, "%s [r]", name);
   j.j = &c.f;
   q = pgen(dn.buf, MP_NEW, rr, event, ectx, n, pgen_jump, &j,
-          rabin_iters(nb + slop), pgen_test, &rb);
+          PGEN_BAILLIEPSWNTESTS, pgen_bailliepswtest, 0);
   pfilt_destroy(&c.f);
   if (!q)
     goto fail_r;
@@ -215,14 +218,13 @@ mp *strongprime(const char *name, mp *d, unsigned nbits, grand *r,
   mp *p;
   pfilt f;
   pgen_jumpctx j;
-  rabin rb;
 
   if (d) mp_copy(d);
   p = strongprime_setup(name, d, &f, nbits, r, n, event, ectx);
   if (!p) { mp_drop(d); return (0); }
   j.j = &f;
   p = pgen(name, p, p, event, ectx, n, pgen_jump, &j,
-          rabin_iters(nbits), pgen_test, &rb);
+          PGEN_BAILLIEPSWNTESTS, pgen_bailliepswtest, 0);
   if (mp_bits(p) != nbits) { mp_drop(p); return (0); }
   pfilt_destroy(&f);
   mp_drop(d);