/* -*-c-*-
*
- * $Id: bbs-gen.c,v 1.4 2000/06/17 10:43:57 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.
*
* 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.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 <stdio.h>
/* --- @bbs_gen@ --- *
*
- * Arguments: @bbs_param *bp@ = pointer to parameter block
+ * Arguments: @bbs_priv *bp@ = pointer to parameter block
* @unsigned nbits@ = number of bits in the modulus
* @grand *r@ = pointer to random number source
* @unsigned n@ = number of attempts to make
* 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.
*/
-int bbs_gen(bbs_param *bp, unsigned nbits, grand *r, unsigned n,
+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;
/* --- 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;