Calculate product of small primes for DSA prime search.
authormdw <mdw>
Wed, 22 Dec 1999 15:51:02 +0000 (15:51 +0000)
committermdw <mdw>
Wed, 22 Dec 1999 15:51:02 +0000 (15:51 +0000)
primorial.c [new file with mode: 0644]
primorial.h [new file with mode: 0644]

diff --git a/primorial.c b/primorial.c
new file mode 100644 (file)
index 0000000..49cc054
--- /dev/null
@@ -0,0 +1,78 @@
+/* -*-c-*-
+ *
+ * $Id: primorial.c,v 1.1 1999/12/22 15:51:02 mdw Exp $
+ *
+ * Computes the product of the small primes
+ *
+ * (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: primorial.c,v $
+ * Revision 1.1  1999/12/22 15:51:02  mdw
+ * Calculate product of small primes for DSA prime search.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include "mp.h"
+#include "primetab.h"
+
+/*----- Global variables --------------------------------------------------*/
+
+mp *primorial = 0;
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @primorial_setup@ --- *
+ *
+ * Arguments:  ---
+ *
+ * Returns:    ---
+ *
+ * Use:                Computes the product of the small primes in the table
+ *             @primetab@.
+ */
+
+void primorial_setup(void)
+{
+  mp *p;
+  mp q;
+  mpw qw;
+  int i;
+
+  if (primorial)
+    return;
+  mp_build(&q, &qw, &qw + 1);
+  p = MP_ONE;
+  for (i = 0; i < NPRIME; i++) {
+    qw = primetab[i];
+    p = mp_mul(p, p, &q);
+  }
+  mp_minimize(p);
+  primorial = p;
+}
+
+/*----- That's all, folks -------------------------------------------------*/
diff --git a/primorial.h b/primorial.h
new file mode 100644 (file)
index 0000000..787c5a9
--- /dev/null
@@ -0,0 +1,75 @@
+/* -*-c-*-
+ *
+ * $Id: primorial.h,v 1.1 1999/12/22 15:51:02 mdw Exp $
+ *
+ * Computes the product of the small primes
+ *
+ * (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: primorial.h,v $
+ * Revision 1.1  1999/12/22 15:51:02  mdw
+ * Calculate product of small primes for DSA prime search.
+ *
+ */
+
+#ifndef CATACOMB_PRIMORIAL_H
+#define CATACOMB_PRIMORIAL_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#ifndef CATACOMB_MP_H
+#  include "mp.h"
+#endif
+
+/*----- Global variables --------------------------------------------------*/
+
+extern mp *primorial;
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @primorial_setup@ --- *
+ *
+ * Arguments:  ---
+ *
+ * Returns:    ---
+ *
+ * Use:                Computes the product of the small primes in the table
+ *             @primetab@.
+ */
+
+extern void primorial_setup(void);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif