Add Diffie-Hellman support.
[u/mdw/catacomb] / dh.h
diff --git a/dh.h b/dh.h
new file mode 100644 (file)
index 0000000..330c258
--- /dev/null
+++ b/dh.h
@@ -0,0 +1,87 @@
+/* -*-c-*-
+ *
+ * $Id: dh.h,v 1.1 1999/11/20 22:24:44 mdw Exp $
+ *
+ * [Diffie-Hellman key negotiation *
+ * (c) 1999 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------* 
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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: dh.h,v $
+ * Revision 1.1  1999/11/20 22:24:44  mdw
+ * Add Diffie-Hellman support.
+ *
+ */
+
+#ifndef DH_H
+#define DH_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#ifndef MP_H
+#  include "mp.h"
+#endif
+
+/*----- Event codes -------------------------------------------------------*/
+
+enum {
+  DHEV_OK,
+
+  DHEV_FAIL,
+  DHEV_PASS
+};
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @dh_prime@ --- *
+ *
+ * Arguments:  @mp *s@ = start point for search (must be odd)
+ *             @size_t n@ = number of concerted attempts to make, or zero
+ *             @void (*proc)(int ev, void *p)@ = event handler
+ *             @void *p@ = argument for event handler
+ *
+ * Returns:    A prime number %$p$% where %$p = 2q + 1$% for prime %$q$%.
+ *
+ * Use:                Finds a safe prime by sequential search from a given starting
+ *             point.  If it fails, a null pointer is returned.
+ *
+ *             The event handler is informed of the progress of the search.
+ *             It may abort the search at any time by returning a nonzero
+ *             value.
+ */
+
+extern mp *dh_prime(mp */*s*/, size_t /*n*/,
+                   int (*proc)(int /*ev*/, void */*p*/), void */*p*/);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif