chiark / gitweb /
Overhaul of key management (again).
[catacomb] / strongprime.h
1 /* -*-c-*-
2  *
3  * $Id: strongprime.h,v 1.2 2000/02/12 18:21:03 mdw Exp $
4  *
5  * Generate `strong' prime numbers
6  *
7  * (c) 1999 Straylight/Edgeware
8  */
9
10 /*----- Licensing notice --------------------------------------------------* 
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.
18  * 
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.
23  * 
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
30 /*----- Revision history --------------------------------------------------* 
31  *
32  * $Log: strongprime.h,v $
33  * Revision 1.2  2000/02/12 18:21:03  mdw
34  * Overhaul of key management (again).
35  *
36  * Revision 1.1  1999/12/22 15:51:22  mdw
37  * Find `strong' RSA primes using Gordon's algorithm.
38  *
39  */
40
41 #ifndef CATACOMB_STRONGPRIME_H
42 #define CATACOMB_STRONGPRIME_H
43
44 #ifdef __cplusplus
45   extern "C" {
46 #endif
47
48 /*----- Header files ------------------------------------------------------*/
49
50 #ifndef CATACOMB_GRAND_H
51 #  include "grand.h"
52 #endif
53
54 #ifndef CATACOMB_PGEN_H
55 #  include "pgen.h"
56 #endif
57
58 /*----- Functions provided ------------------------------------------------*/
59
60 /* --- @strongprime_setup@ --- *
61  *
62  * Arguments:   @const char *name@ = pointer to name root
63  *              @mp *d@ = destination for search start point
64  *              @pfilt *f@ = where to store filter jump context
65  *              @unsigned nbits@ = number of bits wanted
66  *              @grand *r@ = random number source
67  *              @unsigned n@ = number of attempts to make
68  *              @pgen_proc *event@ = event handler function
69  *              @void *ectx@ = argument for the event handler
70  *
71  * Returns:     A starting point for a `strong' prime search, or zero.
72  *
73  * Use:         Sets up for a strong prime search, so that primes with
74  *              particular properties can be found.  It's probably important
75  *              to note that the number left in the filter context @f@ is
76  *              congruent to 2 (mod 4).
77  */
78
79 extern mp *strongprime_setup(const char */*name*/, mp */*d*/, pfilt */*f*/,
80                              unsigned /*nbits*/, grand */*r*/,
81                              unsigned /*n*/, pgen_proc */*event*/,
82                              void */*ectx*/);
83
84 /* --- @strongprime@ --- *
85  *
86  * Arguments:   @const char *name@ = pointer to name root
87  *              @mp *d@ = destination integer
88  *              @unsigned nbits@ = number of bits wanted
89  *              @grand *r@ = random number source
90  *              @unsigned n@ = number of attempts to make
91  *              @pgen_proc *event@ = event handler function
92  *              @void *ectx@ = argument for the event handler
93  *
94  * Returns:     A `strong' prime, or zero.
95  *
96  * Use:         Finds `strong' primes.  A strong prime %$p$% is such that
97  *
98  *                * %$p - 1$% has a large prime factor %$r$%,
99  *                * %$p + 1$% has a large prime factor %$s$%, and
100  *                * %$r - 1$% has a large prime factor %$t$%.
101  *
102  *              The numbers produced may be slightly larger than requested,
103  *              by a few bits.
104  */
105
106 extern mp *strongprime(const char */*name*/, mp */*d*/, unsigned /*nbits*/,
107                        grand */*r*/, unsigned /*n*/,
108                        pgen_proc */*event*/, void */*ectx*/);
109
110 /*----- That's all, folks -------------------------------------------------*/
111
112 #ifdef __cplusplus
113   }
114 #endif
115
116 #endif