Add cyclic group abstraction, with test code. Separate off exponentation
[u/mdw/catacomb] / dh.h
diff --git a/dh.h b/dh.h
index 90fdaa3..56dbf0a 100644 (file)
--- a/dh.h
+++ b/dh.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: dh.h,v 1.7 2001/02/03 16:08:24 mdw Exp $
+ * $Id: dh.h,v 1.8 2004/04/01 12:50:09 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.8  2004/04/01 12:50:09  mdw
+ * Add cyclic group abstraction, with test code.  Separate off exponentation
+ * functions for better static linking.  Fix a buttload of bugs on the way.
+ * Generally ensure that negative exponents do inversion correctly.  Add
+ * table of standard prime-field subgroups.  (Binary field subgroups are
+ * currently unimplemented but easy to add if anyone ever finds a good one.)
+ *
  * Revision 1.7  2001/02/03 16:08:24  mdw
  * Add consistency checking for public keys.
  *
  * Revision 1.7  2001/02/03 16:08:24  mdw
  * Add consistency checking for public keys.
  *
 
 /*----- Header files ------------------------------------------------------*/
 
 
 /*----- Header files ------------------------------------------------------*/
 
+#ifndef CATACOMB_GROUP_H
+#  include "group.h"
+#endif
+
 #ifndef CATACOMB_GRAND_H
 #  include "grand.h"
 #endif
 #ifndef CATACOMB_GRAND_H
 #  include "grand.h"
 #endif
 #  include "pgen.h"
 #endif
 
 #  include "pgen.h"
 #endif
 
+#ifndef CATACOMB_QDPARSE_H
+#  include "qdparse.h"
+#endif
+
 /*----- Data structures ---------------------------------------------------*/
 
 /*----- Data structures ---------------------------------------------------*/
 
-typedef struct dh_param {
-  mp *p, *q;                           /* Prime numbers %$p$% and %$q$% */
-  mp *g;                               /* Generates order-%$q$% subgroup */
-} dh_param;
+typedef gprime_param dh_param;         /* Group parameters */
 
 typedef struct dh_pub {
   dh_param dp;                         /* Shared parameters */         
 
 typedef struct dh_pub {
   dh_param dp;                         /* Shared parameters */         
@@ -198,6 +210,20 @@ extern int dh_limlee(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/,
 extern int dh_checkparam(keycheck */*kc*/, const dh_param */*dp*/,
                         mp **/*v*/, size_t /*n*/);
 
 extern int dh_checkparam(keycheck */*kc*/, const dh_param */*dp*/,
                         mp **/*v*/, size_t /*n*/);
 
+/* --- @dh_parse@ --- *
+ *
+ * Arguments:  @qd_parse *qd@ = parser context
+ *             @dh_param *dp@ = parameters to fill in
+ *
+ * Returns:    Zero if OK, nonzero on error.
+ *
+ * Use:                Parses a prime group string.  This is either one of the
+ *             standard group strings, or a %$p$%, %$q$%, %$g$% triple
+ *             separated by commas.
+ */
+
+extern int dh_parse(qd_parse */*qd*/, dh_param */*dp*/);
+
 /*----- That's all, folks -------------------------------------------------*/
 
 #ifdef __cplusplus
 /*----- That's all, folks -------------------------------------------------*/
 
 #ifdef __cplusplus