Table for driving key data extraction.
[u/mdw/catacomb] / bbs.h
diff --git a/bbs.h b/bbs.h
index 851dcb8..6e23d02 100644 (file)
--- a/bbs.h
+++ b/bbs.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: bbs.h,v 1.1 1999/12/10 23:14:59 mdw Exp $
+ * $Id: bbs.h,v 1.3 2000/02/12 18:21:02 mdw Exp $
  *
  * The Blum-Blum-Shub random bit generator
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: bbs.h,v $
+ * Revision 1.3  2000/02/12 18:21:02  mdw
+ * Overhaul of key management (again).
+ *
+ * Revision 1.2  1999/12/22 15:52:08  mdw
+ * Rename `bbs_params' to `bbs_param' for consistency.
+ *
  * Revision 1.1  1999/12/10 23:14:59  mdw
  * Blum-Blum-Shub generator, and Blum-Goldwasser encryption.
  *
 #  include "mpbarrett.h"
 #endif
 
+#ifndef CATACOMB_PGEN_H
+#  include "pgen.h"
+#endif
+
 /*----- Data structures ---------------------------------------------------*/
 
 /* --- Basic generator state --- */
@@ -88,28 +98,10 @@ typedef struct bbs {
 
 /* --- Parameters --- */
 
-typedef struct bbs_params {
+typedef struct bbs_param {
   mp *p, *q;                           /* Prime factors (3 mod 4) */
   mp *n;                               /* Product @pq@ -- a Blum integer */
-} bbs_params;
-
-/*----- Event codes from @bbs_gen@ ----------------------------------------*/
-
-enum {
-  BBSEV_OK,
-
-  BBSEV_FINDP,
-  BBSEV_TRYP,
-  BBSEV_PASSP,
-  BBSEV_FAILP,
-  BBSEV_GOODP,
-
-  BBSEV_FINDQ,
-  BBSEV_TRYQ,
-  BBSEV_PASSQ,
-  BBSEV_FAILQ,
-  BBSEV_GOODQ
-};  
+} bbs_param;
 
 /*----- The basic generator -----------------------------------------------*/
 
@@ -210,7 +202,7 @@ extern void bbs_wrap(bbs */*b*/);
 /* --- @bbs_ff@ --- *
  *
  * Arguments:  @bbs *b@ = pointer to a BBS generator state
- *             @bbs_params *bp@ = pointer to BBS modulus factors
+ *             @bbs_param *bp@ = pointer to BBS modulus factors
  *             @unsigned long n@ = number of steps to make
  *
  * Returns:    ---
@@ -220,12 +212,12 @@ extern void bbs_wrap(bbs */*b*/);
  *             efficiently.
  */
 
-extern void bbs_ff(bbs */*b*/, bbs_params */*bp*/, unsigned long /*n*/);
+extern void bbs_ff(bbs */*b*/, bbs_param */*bp*/, unsigned long /*n*/);
 
 /* --- @bbs_rew@ --- *
  *
  * Arguments:  @bbs *b@ = pointer to a BBS generator state
- *             @bbs_params *bp@ = pointer to BBS modulus factors
+ *             @bbs_param *bp@ = pointer to BBS modulus factors
  *             @unsigned long n@ = number of steps to make
  *
  * Returns:    ---
@@ -235,20 +227,20 @@ extern void bbs_ff(bbs */*b*/, bbs_params */*bp*/, unsigned long /*n*/);
  *             at all.
  */
 
-extern void bbs_rew(bbs */*b*/, bbs_params */*bp*/, unsigned long /*n*/);
+extern void bbs_rew(bbs */*b*/, bbs_param */*bp*/, unsigned long /*n*/);
 
 /*----- Parameter generation ----------------------------------------------*/
 
 /* --- @bbs_gen@ --- *
  *
- * Arguments:  @bbs_params *bp@ = pointer to parameter block
- *             @mp *p, *q@ = initial numbers to search from
- *             @size_t n@ = number of attempts to make
- *             @void (*proc)(int ev, mp *m, void *p)@ = event handler
- *             @void *arg@ = argument for event handler
+ * Arguments:  @bbs_param *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
+ *             @pgen_proc *event@ = event handler function
+ *             @void *ectx@ = argument for event handler
  *
- * Returns:    Zero if all went well, otherwise an event code which explains
- *             the problem.
+ * 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
@@ -257,9 +249,8 @@ extern void bbs_rew(bbs */*b*/, bbs_params */*bp*/, unsigned long /*n*/);
  *             Shub pseudorandom bit generator.
  */
 
-extern int bbs_gen(bbs_params */*bp*/, mp */*p*/, mp */*q*/, size_t /*n*/,
-                  int (*/*proc*/)(int /*ev*/, mp */*m*/, void */*p*/),
-                  void */*arg*/);
+extern int bbs_gen(bbs_param */*bp*/, unsigned /*nbits*/, grand */*r*/,
+                  unsigned /*n*/, pgen_proc */*event*/, void */*ectx*/);
 
 /*----- Generic random number generator interface -------------------------*/