3 * $Id: dh.h,v 1.5 2000/07/01 11:20:51 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.5 2000/07/01 11:20:51 mdw
34 * New functions for freeing public and private keys.
36 * Revision 1.4 2000/06/17 10:52:47 mdw
37 * Minor changes for key fetching.
39 * Revision 1.3 2000/02/12 18:21:02 mdw
40 * Overhaul of key management (again).
51 /*----- Header files ------------------------------------------------------*/
53 #ifndef CATACOMB_GRAND_H
57 #ifndef CATACOMB_KEY_H
61 #ifndef CATACOMB_PGEN_H
65 /*----- Data structures ---------------------------------------------------*/
67 typedef struct dh_param
{
72 typedef struct dh_pub
{
77 typedef struct dh_priv
{
83 /*----- Key fetching ------------------------------------------------------*/
85 extern const key_fetchdef dh_paramfetch
[];
86 #define DH_PARAMFETCHSZ 5
88 extern const key_fetchdef dh_pubfetch
[];
89 #define DH_PUBFETCHSZ 6
91 extern const key_fetchdef dh_privfetch
[];
92 #define DH_PRIVFETCHSZ 9
94 /* --- @dh_paramfree@, @dh_pubfree@, @dh_privfree@ --- *
96 * Arguments: @dh_param *dp@, @dh_pub *dp@, @dh_priv *dp@ = pointer to
101 * Use: Frees a Diffie-Hellman key block.
104 extern void dh_paramfree(dh_param */
*dp*/
);
105 extern void dh_pubfree(dh_pub */
*dp*/
);
106 extern void dh_privfree(dh_priv */
*dp*/
);
108 /*----- Functions provided ------------------------------------------------*/
110 /* --- @dh_gen@ --- *
112 * Arguments: @dh_param *dp@ = pointer to output parameter block
113 * @unsigned ql@ = length of %$q$% in bits, or zero
114 * @unsigned pl@ = length of %$p$% in bits
115 * @unsigned steps@ = number of steps to go
116 * @grand *r@ = random number source
117 * @pgen_proc *event@ = event handler function
118 * @void *ectx@ = argument for the event handler
120 * Returns: @PGEN_DONE@ if it worked, @PGEN_ABORT@ if it didn't.
122 * Use: Generates Diffie-Hellman parameters.
124 * The parameters are a prime %$q$%, relatively small, and a
125 * large prime %$p = kq + 1$% for some %$k$%, together with a
126 * generator %$g$% of the cyclic subgroup of order %$q$%. These
127 * are actually the same as the DSA parameter set, but the
128 * generation algorithm is different. Also, if @ql@ is zero,
129 * this algorithm forces %$k = 2$%, and chooses %$g = 4$%. Make
130 * sure you have something interesting to do if you choose this
134 extern int dh_gen(dh_param */
*dp*/
, unsigned /*ql*/, unsigned /*pl*/,
135 unsigned /*steps*/, grand */
*r*/
, pgen_proc */
*event*/
,
138 /*----- That's all, folks -------------------------------------------------*/