3 * $Id: strongprime.h,v 1.3 2004/04/08 01:36:15 mdw Exp $
5 * Generate `strong' prime numbers
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 #ifndef CATACOMB_STRONGPRIME_H
31 #define CATACOMB_STRONGPRIME_H
37 /*----- Header files ------------------------------------------------------*/
39 #ifndef CATACOMB_GRAND_H
43 #ifndef CATACOMB_PGEN_H
47 /*----- Functions provided ------------------------------------------------*/
49 /* --- @strongprime_setup@ --- *
51 * Arguments: @const char *name@ = pointer to name root
52 * @mp *d@ = destination for search start point
53 * @pfilt *f@ = where to store filter jump context
54 * @unsigned nbits@ = number of bits wanted
55 * @grand *r@ = random number source
56 * @unsigned n@ = number of attempts to make
57 * @pgen_proc *event@ = event handler function
58 * @void *ectx@ = argument for the event handler
60 * Returns: A starting point for a `strong' prime search, or zero.
62 * Use: Sets up for a strong prime search, so that primes with
63 * particular properties can be found. It's probably important
64 * to note that the number left in the filter context @f@ is
65 * congruent to 2 (mod 4).
68 extern mp
*strongprime_setup(const char */
*name*/
, mp */
*d*/
, pfilt */
*f*/
,
69 unsigned /*nbits*/, grand */
*r*/
,
70 unsigned /*n*/, pgen_proc */
*event*/
,
73 /* --- @strongprime@ --- *
75 * Arguments: @const char *name@ = pointer to name root
76 * @mp *d@ = destination integer
77 * @unsigned nbits@ = number of bits wanted
78 * @grand *r@ = random number source
79 * @unsigned n@ = number of attempts to make
80 * @pgen_proc *event@ = event handler function
81 * @void *ectx@ = argument for the event handler
83 * Returns: A `strong' prime, or zero.
85 * Use: Finds `strong' primes. A strong prime %$p$% is such that
87 * * %$p - 1$% has a large prime factor %$r$%,
88 * * %$p + 1$% has a large prime factor %$s$%, and
89 * * %$r - 1$% has a large prime factor %$t$%.
91 * The numbers produced may be slightly larger than requested,
95 extern mp
*strongprime(const char */
*name*/
, mp */
*d*/
, unsigned /*nbits*/,
96 grand */
*r*/
, unsigned /*n*/,
97 pgen_proc */
*event*/
, void */
*ectx*/
);
99 /*----- That's all, folks -------------------------------------------------*/