/* -*-c-*-
*
- * $Id: bbs.h,v 1.3 2000/02/12 18:21:02 mdw Exp $
+ * $Id: bbs.h,v 1.5 2000/07/01 11:20:24 mdw Exp $
*
* The Blum-Blum-Shub random bit generator
*
/*----- Revision history --------------------------------------------------*
*
* $Log: bbs.h,v $
+ * Revision 1.5 2000/07/01 11:20:24 mdw
+ * New functions for freeing public and private keys. Remove bad type name
+ * `bbs_param'.
+ *
+ * Revision 1.4 2000/06/17 10:45:48 mdw
+ * Minor changes for key fetching. Typesetting fixes.
+ *
* Revision 1.3 2000/02/12 18:21:02 mdw
* Overhaul of key management (again).
*
* sequence %$x_i = x_{i - 1}^2 \bmod n$%, where %$n = pq$% is the product of
* two primes %$p$% and %$q$%, each of which are congruent to %$3 \bmod 4$%.
* For maximum period of the generator, %$(p - 1)/2$% and %$(q - 1)/1$%
- * should be coprime. It is safe to use the least significant %$\log \log
- * n$% bits of each step in the sequence -- an adversary must factor the
- * modulus before being able to work forwards or backwards. The output of
- * the generator cannot be distinguished from a (uniform, independent) random
- * sequence of bits using any polynomial-time test. This is by far the
- * strongest pseudorandom number generator provided in Catacomb, and by far
- * the slowest too. For normal use, the standard Catacomb @rand@ generator
- * should be more than adequate.
+ * should be coprime. It is safe to use the least significant
+ * %$\log \log n$% bits of each step in the sequence -- an adversary must
+ * factor the modulus before being able to work forwards or backwards. The
+ * output of the generator cannot be distinguished from a (uniform,
+ * independent) random sequence of bits using any polynomial-time test. This
+ * is by far the strongest pseudorandom number generator provided in
+ * Catacomb, and by far the slowest too. For normal use, the standard
+ * Catacomb @rand@ generator should be more than adequate.
*/
#ifndef CATACOMB_BBS_H
# include "grand.h"
#endif
+#ifndef CATACOMB_KEY_H
+# include "key.h"
+#endif
+
#ifndef CATACOMB_MP_H
# include "mp.h"
#endif
/* --- Parameters --- */
-typedef struct bbs_param {
+typedef struct bbs_pub {
+ mp *n;
+} bbs_pub;
+
+typedef struct bbs_priv {
mp *p, *q; /* Prime factors (3 mod 4) */
mp *n; /* Product @pq@ -- a Blum integer */
-} bbs_param;
+} bbs_priv;
+
+/*----- Key fetching ------------------------------------------------------*/
+
+extern const key_fetchdef bbs_pubfetch[];
+#define BBS_PUBFETCHSZ 3
+
+extern const key_fetchdef bbs_privfetch[];
+#define BBS_PRIVFETCHSZ 7
+
+/* --- @bbs_pubfree@, @bbs_privfree@ --- *
+ *
+ * Arguments: @bbs_pub *bp@, @bbs_priv *bp@ = pointer to key block
+ *
+ * Returns: ---
+ *
+ * Use: Frees a BBS key block.
+ */
+
+extern void bbs_pubfree(bbs_pub */*bp*/);
+extern void bbs_privfree(bbs_priv */*bp*/);
/*----- The basic generator -----------------------------------------------*/
*
* If a generator is seeded, %$b$% bits are extracted, and then
* @bbs_wrap@ is called, the generator will have been stepped
- * %$\lceil b/k \rceil% times.
+ * %$\lceil b/k \rceil$% times.
*/
extern void bbs_wrap(bbs */*b*/);
/* --- @bbs_ff@ --- *
*
* Arguments: @bbs *b@ = pointer to a BBS generator state
- * @bbs_param *bp@ = pointer to BBS modulus factors
+ * @bbs_priv *bp@ = pointer to BBS modulus factors
* @unsigned long n@ = number of steps to make
*
* Returns: ---
* efficiently.
*/
-extern void bbs_ff(bbs */*b*/, bbs_param */*bp*/, unsigned long /*n*/);
+extern void bbs_ff(bbs */*b*/, bbs_priv */*bp*/, unsigned long /*n*/);
/* --- @bbs_rew@ --- *
*
* Arguments: @bbs *b@ = pointer to a BBS generator state
- * @bbs_param *bp@ = pointer to BBS modulus factors
+ * @bbs_priv *bp@ = pointer to BBS modulus factors
* @unsigned long n@ = number of steps to make
*
* Returns: ---
* at all.
*/
-extern void bbs_rew(bbs */*b*/, bbs_param */*bp*/, unsigned long /*n*/);
+extern void bbs_rew(bbs */*b*/, bbs_priv */*bp*/, unsigned long /*n*/);
/*----- Parameter generation ----------------------------------------------*/
/* --- @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
* Shub pseudorandom bit generator.
*/
-extern int bbs_gen(bbs_param */*bp*/, unsigned /*nbits*/, grand */*r*/,
+extern int bbs_gen(bbs_priv */*bp*/, unsigned /*nbits*/, grand */*r*/,
unsigned /*n*/, pgen_proc */*event*/, void */*ectx*/);
/*----- Generic random number generator interface -------------------------*/