a30942cc |
1 | /* -*-c-*- |
2 | * |
b817bfc6 |
3 | * $Id: strongprime.h,v 1.3 2004/04/08 01:36:15 mdw Exp $ |
a30942cc |
4 | * |
5 | * Generate `strong' prime numbers |
6 | * |
7 | * (c) 1999 Straylight/Edgeware |
8 | */ |
9 | |
45c0fd36 |
10 | /*----- Licensing notice --------------------------------------------------* |
a30942cc |
11 | * |
12 | * This file is part of Catacomb. |
13 | * |
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. |
45c0fd36 |
18 | * |
a30942cc |
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. |
45c0fd36 |
23 | * |
a30942cc |
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, |
27 | * MA 02111-1307, USA. |
28 | */ |
29 | |
a30942cc |
30 | #ifndef CATACOMB_STRONGPRIME_H |
31 | #define CATACOMB_STRONGPRIME_H |
32 | |
33 | #ifdef __cplusplus |
34 | extern "C" { |
35 | #endif |
36 | |
37 | /*----- Header files ------------------------------------------------------*/ |
38 | |
39 | #ifndef CATACOMB_GRAND_H |
40 | # include "grand.h" |
41 | #endif |
42 | |
43 | #ifndef CATACOMB_PGEN_H |
44 | # include "pgen.h" |
45 | #endif |
46 | |
47 | /*----- Functions provided ------------------------------------------------*/ |
48 | |
052b36d0 |
49 | /* --- @strongprime_setup@ --- * |
50 | * |
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 |
59 | * |
60 | * Returns: A starting point for a `strong' prime search, or zero. |
61 | * |
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). |
66 | */ |
67 | |
68 | extern mp *strongprime_setup(const char */*name*/, mp */*d*/, pfilt */*f*/, |
69 | unsigned /*nbits*/, grand */*r*/, |
70 | unsigned /*n*/, pgen_proc */*event*/, |
71 | void */*ectx*/); |
72 | |
a30942cc |
73 | /* --- @strongprime@ --- * |
74 | * |
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 |
82 | * |
83 | * Returns: A `strong' prime, or zero. |
84 | * |
85 | * Use: Finds `strong' primes. A strong prime %$p$% is such that |
86 | * |
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$%. |
90 | * |
91 | * The numbers produced may be slightly larger than requested, |
92 | * by a few bits. |
93 | */ |
94 | |
95 | extern mp *strongprime(const char */*name*/, mp */*d*/, unsigned /*nbits*/, |
96 | grand */*r*/, unsigned /*n*/, |
97 | pgen_proc */*event*/, void */*ectx*/); |
98 | |
99 | /*----- That's all, folks -------------------------------------------------*/ |
100 | |
101 | #ifdef __cplusplus |
102 | } |
103 | #endif |
104 | |
105 | #endif |