X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/a22bbdf6fa8e43546da6b4d7f6b0e014cb8deb6c..ea932d59b3071ce00f9e510aad014ad64a3dc48c:/bbs-gen.c diff --git a/bbs-gen.c b/bbs-gen.c index c90ee40..c668b21 100644 --- a/bbs-gen.c +++ b/bbs-gen.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: bbs-gen.c,v 1.5 2000/07/01 11:20:36 mdw Exp $ + * $Id: bbs-gen.c,v 1.6 2004/04/08 01:36:15 mdw Exp $ * * Generate Blum integers * * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,38 +15,18 @@ * 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, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: bbs-gen.c,v $ - * Revision 1.5 2000/07/01 11:20:36 mdw - * Remove bad type name `bbs_param'. - * - * Revision 1.4 2000/06/17 10:43:57 mdw - * Move GCD filter to separate file. Handle failures from pgen_jump. - * - * Revision 1.3 2000/02/12 18:21:02 mdw - * Overhaul of key management (again). - * - * Revision 1.2 1999/12/22 15:52:28 mdw - * Reworking for new prime-search system. - * - * Revision 1.1 1999/12/10 23:14:59 mdw - * Blum-Blum-Shub generator, and Blum-Goldwasser encryption. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -73,7 +53,7 @@ * Returns: If it worked OK, @PGEN_DONE@, otherwise @PGEN_ABORT@. * * Use: Finds two prime numbers %$p'$% and %$q'$% such that both are - * congruent to %$3 \bmod 4$%, and $(p - 1)/2$% and + * congruent to %$3 \bmod 4$%, and $(p - 1)/2$% and * %$(q - 1)/2$% have no common factors. The product %$n = pq$% * is eminently suitable for use as a modulus in a Blum-Blum- * Shub pseudorandom bit generator. @@ -83,7 +63,8 @@ int bbs_gen(bbs_priv *bp, unsigned nbits, grand *r, unsigned n, pgen_proc *event, void *ectx) { rabin rb; - pgen_safejumpctx j; + pfilt jp; + pgen_jumpctx j; pgen_gcdstepctx g; unsigned nb = nbits/2; mp *x = MP_NEW; @@ -91,11 +72,12 @@ int bbs_gen(bbs_priv *bp, unsigned nbits, grand *r, unsigned n, /* --- Generate @p@ --- */ again: - if ((x = strongprime_setup("p", x, &j.jq, nb, r, n, event, ectx)) == 0) + if ((x = strongprime_setup("p", x, &jp, nb, r, n, event, ectx)) == 0) goto fail_x; - bp->p = pgen("p", MP_NEW, x, event, ectx, n, pgen_safejump, &j, + j.j = &jp; + bp->p = pgen("p", MP_NEW, x, event, ectx, n, pgen_jump, &j, rabin_iters(nb), pgen_test, &rb); - pfilt_destroy(&j.jq); + pfilt_destroy(&jp); if (!bp->p) { if (n) goto fail_p;