a30942cc |
1 | /* -*-c-*- |
a30942cc |
2 | * |
3 | * Generate `strong' prime numbers |
4 | * |
5 | * (c) 1999 Straylight/Edgeware |
6 | */ |
7 | |
45c0fd36 |
8 | /*----- Licensing notice --------------------------------------------------* |
a30942cc |
9 | * |
10 | * This file is part of Catacomb. |
11 | * |
12 | * Catacomb is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU Library General Public License as |
14 | * published by the Free Software Foundation; either version 2 of the |
15 | * License, or (at your option) any later version. |
45c0fd36 |
16 | * |
a30942cc |
17 | * Catacomb is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | * GNU Library General Public License for more details. |
45c0fd36 |
21 | * |
a30942cc |
22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with Catacomb; if not, write to the Free |
24 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
25 | * MA 02111-1307, USA. |
26 | */ |
27 | |
a30942cc |
28 | #ifndef CATACOMB_STRONGPRIME_H |
29 | #define CATACOMB_STRONGPRIME_H |
30 | |
31 | #ifdef __cplusplus |
32 | extern "C" { |
33 | #endif |
34 | |
35 | /*----- Header files ------------------------------------------------------*/ |
36 | |
37 | #ifndef CATACOMB_GRAND_H |
38 | # include "grand.h" |
39 | #endif |
40 | |
41 | #ifndef CATACOMB_PGEN_H |
42 | # include "pgen.h" |
43 | #endif |
44 | |
45 | /*----- Functions provided ------------------------------------------------*/ |
46 | |
052b36d0 |
47 | /* --- @strongprime_setup@ --- * |
48 | * |
49 | * Arguments: @const char *name@ = pointer to name root |
50 | * @mp *d@ = destination for search start point |
51 | * @pfilt *f@ = where to store filter jump context |
52 | * @unsigned nbits@ = number of bits wanted |
53 | * @grand *r@ = random number source |
54 | * @unsigned n@ = number of attempts to make |
55 | * @pgen_proc *event@ = event handler function |
56 | * @void *ectx@ = argument for the event handler |
57 | * |
58 | * Returns: A starting point for a `strong' prime search, or zero. |
59 | * |
60 | * Use: Sets up for a strong prime search, so that primes with |
61 | * particular properties can be found. It's probably important |
62 | * to note that the number left in the filter context @f@ is |
63 | * congruent to 2 (mod 4). |
64 | */ |
65 | |
66 | extern mp *strongprime_setup(const char */*name*/, mp */*d*/, pfilt */*f*/, |
67 | unsigned /*nbits*/, grand */*r*/, |
68 | unsigned /*n*/, pgen_proc */*event*/, |
69 | void */*ectx*/); |
70 | |
a30942cc |
71 | /* --- @strongprime@ --- * |
72 | * |
73 | * Arguments: @const char *name@ = pointer to name root |
74 | * @mp *d@ = destination integer |
75 | * @unsigned nbits@ = number of bits wanted |
76 | * @grand *r@ = random number source |
77 | * @unsigned n@ = number of attempts to make |
78 | * @pgen_proc *event@ = event handler function |
79 | * @void *ectx@ = argument for the event handler |
80 | * |
81 | * Returns: A `strong' prime, or zero. |
82 | * |
83 | * Use: Finds `strong' primes. A strong prime %$p$% is such that |
84 | * |
85 | * * %$p - 1$% has a large prime factor %$r$%, |
86 | * * %$p + 1$% has a large prime factor %$s$%, and |
87 | * * %$r - 1$% has a large prime factor %$t$%. |
a30942cc |
88 | */ |
89 | |
90 | extern mp *strongprime(const char */*name*/, mp */*d*/, unsigned /*nbits*/, |
91 | grand */*r*/, unsigned /*n*/, |
92 | pgen_proc */*event*/, void */*ectx*/); |
93 | |
94 | /*----- That's all, folks -------------------------------------------------*/ |
95 | |
96 | #ifdef __cplusplus |
97 | } |
98 | #endif |
99 | |
100 | #endif |