Add Diffie-Hellman support.
[u/mdw/catacomb] / dh.h
1 /* -*-c-*-
2 *
3 * $Id: dh.h,v 1.1 1999/11/20 22:24:44 mdw Exp $
4 *
5 * [Diffie-Hellman key negotiation *
6 * (c) 1999 Straylight/Edgeware
7 */
8
9 /*----- Licensing notice --------------------------------------------------*
10 *
11 * This file is part of Catacomb.
12 *
13 * Catacomb is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU Library General Public License as
15 * published by the Free Software Foundation; either version 2 of the
16 * License, or (at your option) any later version.
17 *
18 * Catacomb is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Library General Public License for more details.
22 *
23 * You should have received a copy of the GNU Library General Public
24 * License along with Catacomb; if not, write to the Free
25 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26 * MA 02111-1307, USA.
27 */
28
29 /*----- Revision history --------------------------------------------------*
30 *
31 * $Log: dh.h,v $
32 * Revision 1.1 1999/11/20 22:24:44 mdw
33 * Add Diffie-Hellman support.
34 *
35 */
36
37 #ifndef DH_H
38 #define DH_H
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /*----- Header files ------------------------------------------------------*/
45
46 #ifndef MP_H
47 # include "mp.h"
48 #endif
49
50 /*----- Event codes -------------------------------------------------------*/
51
52 enum {
53 DHEV_OK,
54
55 DHEV_FAIL,
56 DHEV_PASS
57 };
58
59 /*----- Functions provided ------------------------------------------------*/
60
61 /* --- @dh_prime@ --- *
62 *
63 * Arguments: @mp *s@ = start point for search (must be odd)
64 * @size_t n@ = number of concerted attempts to make, or zero
65 * @void (*proc)(int ev, void *p)@ = event handler
66 * @void *p@ = argument for event handler
67 *
68 * Returns: A prime number %$p$% where %$p = 2q + 1$% for prime %$q$%.
69 *
70 * Use: Finds a safe prime by sequential search from a given starting
71 * point. If it fails, a null pointer is returned.
72 *
73 * The event handler is informed of the progress of the search.
74 * It may abort the search at any time by returning a nonzero
75 * value.
76 */
77
78 extern mp *dh_prime(mp */*s*/, size_t /*n*/,
79 int (*proc)(int /*ev*/, void */*p*/), void */*p*/);
80
81 /*----- That's all, folks -------------------------------------------------*/
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif