Supply commentry for the Diffie-Hellman parameters. Add Lim-Lee
authormdw <mdw>
Sat, 29 Jul 2000 10:01:16 +0000 (10:01 +0000)
committermdw <mdw>
Sat, 29 Jul 2000 10:01:16 +0000 (10:01 +0000)
parameter generation.

dh.h

diff --git a/dh.h b/dh.h
index 2ae710c..c2f2311 100644 (file)
--- a/dh.h
+++ b/dh.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: dh.h,v 1.5 2000/07/01 11:20:51 mdw Exp $
+ * $Id: dh.h,v 1.6 2000/07/29 10:01:16 mdw Exp $
  *
  * Diffie-Hellman and related public-key systems
  *
  *
  * Diffie-Hellman and related public-key systems
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: dh.h,v $
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: dh.h,v $
+ * Revision 1.6  2000/07/29 10:01:16  mdw
+ * Supply commentry for the Diffie-Hellman parameters.  Add Lim-Lee
+ * parameter generation.
+ *
  * Revision 1.5  2000/07/01 11:20:51  mdw
  * New functions for freeing public and private keys.
  *
  * Revision 1.5  2000/07/01 11:20:51  mdw
  * New functions for freeing public and private keys.
  *
 
 /*----- Data structures ---------------------------------------------------*/
 
 
 /*----- Data structures ---------------------------------------------------*/
 
-typedef struct dh_param {
-  mp *p, *q;
+typedef struct dh_param {              /* Prime numbers %$p$% and %$q$% */
+  mp *p, *q;                           /* Generates order-%$q$% subgroup */
   mp *g;
 } dh_param;
 
   mp *g;
 } dh_param;
 
-typedef struct dh_pub {
-  dh_param dp;
+typedef struct dh_pub {                        /* Shared parameters */
+  dh_param dp;                         /* Public key */
   mp *y;
 } dh_pub;
 
   mp *y;
 } dh_pub;
 
-typedef struct dh_priv {
-  dh_param dp;
-  mp *x;
+typedef struct dh_priv {               /* Shared parameters */
+  dh_param dp;                         /* Private key */
+  mp *x;                               /* %$y \equiv g^x \pmod{p}$% */
   mp *y;
 } dh_priv;
 
   mp *y;
 } dh_priv;
 
@@ -135,6 +139,42 @@ extern int dh_gen(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/,
                  unsigned /*steps*/, grand */*r*/, pgen_proc */*event*/,
                  void */*ectx*/);
 
                  unsigned /*steps*/, grand */*r*/, pgen_proc */*event*/,
                  void */*ectx*/);
 
+/* --- @dh_limlee@ --- *
+ *
+ * Arguments:  @dh_param *dp@ = pointer to output parameter block
+ *             @unsigned ql@ = length of smallest factor of %$(p - 1)/2$%
+ *             @unsigned pl@ = length of %$p$% in bits
+ *             @unsigned flags@ = other generation flags
+ *             @unsigned steps@ = number of steps to go
+ *             @grand *r@ = random number source
+ *              @pgen_proc *oev@ = outer event handler function
+ *              @void *oec@ = argument for the outer event handler
+ *              @pgen_proc *iev@ = inner event handler function
+ *              @void *iec@ = argument for the inner event handler
+ *              @size_t *nf@, @mp ***f@ = output array for factors
+ *
+ * Returns:    @PGEN_DONE@ if it worked, @PGEN_ABORT@ if it didn't.
+ *
+ * Use:                Generates Diffie-Hellman parameters based on a Lim-Lee prime.
+ *
+ *             The modulus is a large prime %$p = 2 \prod q_i + 1$%, @pl@
+ *             bits long, where the %$q_i$% are smaller primes each at least
+ *             @ql@ bits long.  It is safe to set @nf@ and @f@ to zero if
+ *             you're not interested in the factor values.
+ *
+ *             The returned %$g$% generates a subgroup of order %$q_0$% (the
+ *             first factor, returned as @f[0]@), if the flag @DH_SUBGROUP@
+ *             is set on entry; otherwise %$g$% will have order
+ *             %$(p - 1)/2$%.
+ */
+
+#define DH_SUBGROUP 1u
+
+extern int dh_limlee(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/,
+                    unsigned /*flags*/, unsigned /*steps*/, grand */*r*/,
+                    pgen_proc */*oev*/, void */*oec*/, pgen_proc */*iev*/,
+                    void */*iec*/, size_t */*nf*/, mp ***/*f*/);
+
 /*----- That's all, folks -------------------------------------------------*/
 
 #ifdef __cplusplus
 /*----- That's all, folks -------------------------------------------------*/
 
 #ifdef __cplusplus