Table for driving key data extraction.
[u/mdw/catacomb] / dh.h
CommitLineData
44c240ee 1/* -*-c-*-
2 *
052b36d0 3 * $Id: dh.h,v 1.3 2000/02/12 18:21:02 mdw Exp $
4 *
5 * Diffie-Hellman and related public-key systems
44c240ee 6 *
44c240ee 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: dh.h,v $
052b36d0 33 * Revision 1.3 2000/02/12 18:21:02 mdw
34 * Overhaul of key management (again).
44c240ee 35 *
36 */
37
b3f05084 38#ifndef CATACOMB_DH_H
39#define CATACOMB_DH_H
44c240ee 40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45/*----- Header files ------------------------------------------------------*/
46
052b36d0 47#ifndef CATACOMB_GRAND_H
48# include "grand.h"
44c240ee 49#endif
50
052b36d0 51#ifndef CATACOMB_PGEN_H
52# include "pgen.h"
53#endif
44c240ee 54
052b36d0 55/*----- Data structures ---------------------------------------------------*/
44c240ee 56
052b36d0 57typedef struct dh_param {
58 mp *p, *q;
59 mp *g;
60} dh_param;
44c240ee 61
62/*----- Functions provided ------------------------------------------------*/
63
052b36d0 64/* --- @dh_gen@ --- *
44c240ee 65 *
052b36d0 66 * Arguments: @dh_param *dp@ = pointer to output parameter block
67 * @unsigned ql@ = length of %$q$% in bits, or zero
68 * @unsigned pl@ = length of %$p$% in bits
69 * @unsigned steps@ = number of steps to go
70 * @grand *r@ = random number source
71 * @pgen_proc *event@ = event handler function
72 * @void *ectx@ = argument for the event handler
44c240ee 73 *
052b36d0 74 * Returns: @PGEN_DONE@ if it worked, @PGEN_ABORT@ if it didn't.
44c240ee 75 *
052b36d0 76 * Use: Generates Diffie-Hellman parameters.
44c240ee 77 *
052b36d0 78 * The parameters are a prime %$q$%, relatively small, and a
79 * large prime %$p = kq + 1$% for some %$k$%, together with a
80 * generator %$g$% of the cyclic subgroup of order %$q$%. These
81 * are actually the same as the DSA parameter set, but the
82 * generation algorithm is different. Also, if @ql@ is zero,
83 * this algorithm forces %$k = 2$%, and chooses %$g = 4$%. Make
84 * sure you have something interesting to do if you choose this
85 * option.
44c240ee 86 */
87
052b36d0 88extern int dh_gen(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/,
89 unsigned /*steps*/, grand */*r*/, pgen_proc */*event*/,
90 void */*ectx*/);
44c240ee 91
92/*----- That's all, folks -------------------------------------------------*/
93
94#ifdef __cplusplus
95 }
96#endif
97
98#endif