* (c) 2006 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of Catacomb.
*
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
- *
+ *
* Catacomb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Library General Public
* License along with Catacomb; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
/* --- First trick: find %$q$% --- */
pf.step = 2;
- x = mprand(MP_NEW, ql, r, 1);
- dp->q = pgen("q", MP_NEW, x, ev, ec,
- steps, pgen_filter, &pf,
- rabin_iters(ql), pgen_test, &rb);
- if (!dp->q)
+ x = mprand(MP_NEW, pl - ql, r, 1);
+ x = pgen("v", x, x, ev, ec,
+ steps, pgen_filter, &pf,
+ rabin_iters(pl - ql), pgen_test, &rb);
+ if (!x)
goto fail_0;
/* --- Second trick: find %$p$% and %$v$% --- */
- x = mp_lsl(x, dp->q, 1);
+ x = mp_lsl(x, x, 1);
sp[0].add = MP_ZERO; sp[0].mul = MP_ONE; sp[0].f = 0;
sp[1].add = MP_ONE; sp[1].mul = x; sp[1].f = PGENF_KEEP;
ss.step = MP_TWO; ss.v = sp; ss.n = N(sp);
- x = mprand(MP_NEW, pl - ql, r, 1);
- x = pgen("p", x, x, ev, ec,
- steps, pgen_simulstep, &ss,
- rabin_iters(pl - ql), pgen_simultest, &ss);
+ x = mprand(MP_NEW, ql, r, 1);
+ dp->q = pgen("p", MP_NEW, x, ev, ec,
+ steps, pgen_simulstep, &ss,
+ rabin_iters(ql), pgen_simultest, &ss);
mp_drop(sp[0].mul);
- if (!x)
+ if (!dp->q)
goto fail_1;
dp->p = sp[1].u.x;
fail_2:
mp_drop(dp->p);
fail_1:
- mp_drop(dp->q);
fail_0:
done:
mp_drop(x);