3 * $Id: dh.h,v 1.4 2000/06/17 10:52:47 mdw Exp $
5 * Diffie-Hellman and related public-key systems
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 /*----- Revision history --------------------------------------------------*
33 * Revision 1.4 2000/06/17 10:52:47 mdw
34 * Minor changes for key fetching.
36 * Revision 1.3 2000/02/12 18:21:02 mdw
37 * Overhaul of key management (again).
48 /*----- Header files ------------------------------------------------------*/
50 #ifndef CATACOMB_GRAND_H
54 #ifndef CATACOMB_KEY_H
58 #ifndef CATACOMB_PGEN_H
62 /*----- Data structures ---------------------------------------------------*/
64 typedef struct dh_param
{
69 typedef struct dh_pub
{
74 typedef struct dh_priv
{
80 /*----- Key fetching ------------------------------------------------------*/
82 extern const key_fetchdef dh_paramfetch
[];
83 #define DH_PARAMFETCHSZ 5
85 extern const key_fetchdef dh_pubfetch
[];
86 #define DH_PUBFETCHSZ 6
88 extern const key_fetchdef dh_privfetch
[];
89 #define DH_PRIVFETCHSZ 9
91 /*----- Functions provided ------------------------------------------------*/
95 * Arguments: @dh_param *dp@ = pointer to output parameter block
96 * @unsigned ql@ = length of %$q$% in bits, or zero
97 * @unsigned pl@ = length of %$p$% in bits
98 * @unsigned steps@ = number of steps to go
99 * @grand *r@ = random number source
100 * @pgen_proc *event@ = event handler function
101 * @void *ectx@ = argument for the event handler
103 * Returns: @PGEN_DONE@ if it worked, @PGEN_ABORT@ if it didn't.
105 * Use: Generates Diffie-Hellman parameters.
107 * The parameters are a prime %$q$%, relatively small, and a
108 * large prime %$p = kq + 1$% for some %$k$%, together with a
109 * generator %$g$% of the cyclic subgroup of order %$q$%. These
110 * are actually the same as the DSA parameter set, but the
111 * generation algorithm is different. Also, if @ql@ is zero,
112 * this algorithm forces %$k = 2$%, and chooses %$g = 4$%. Make
113 * sure you have something interesting to do if you choose this
117 extern int dh_gen(dh_param */
*dp*/
, unsigned /*ql*/, unsigned /*pl*/,
118 unsigned /*steps*/, grand */
*r*/
, pgen_proc */
*event*/
,
121 /*----- That's all, folks -------------------------------------------------*/