X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/600127f0c8669936093fc6bddda5a2dcb59cd076..813390c45f438f411662b1a55678e63f11681eb4:/dh.h diff --git a/dh.h b/dh.h index 90fdaa3..04b526e 100644 --- a/dh.h +++ b/dh.h @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: dh.h,v 1.7 2001/02/03 16:08:24 mdw Exp $ + * $Id$ * * Diffie-Hellman and related public-key systems * * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,39 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: dh.h,v $ - * Revision 1.7 2001/02/03 16:08:24 mdw - * Add consistency checking for public keys. - * - * Revision 1.6 2000/07/29 10:01:16 mdw - * Supply commentry for the Diffie-Hellman parameters. Add Lim-Lee - * parameter generation. - * - * Revision 1.5 2000/07/01 11:20:51 mdw - * New functions for freeing public and private keys. - * - * Revision 1.4 2000/06/17 10:52:47 mdw - * Minor changes for key fetching. - * - * Revision 1.3 2000/02/12 18:21:02 mdw - * Overhaul of key management (again). - * - */ - #ifndef CATACOMB_DH_H #define CATACOMB_DH_H @@ -57,6 +36,10 @@ /*----- Header files ------------------------------------------------------*/ +#ifndef CATACOMB_GROUP_H +# include "group.h" +#endif + #ifndef CATACOMB_GRAND_H # include "grand.h" #endif @@ -73,15 +56,16 @@ # include "pgen.h" #endif +#ifndef CATACOMB_QDPARSE_H +# include "qdparse.h" +#endif + /*----- Data structures ---------------------------------------------------*/ -typedef struct dh_param { - mp *p, *q; /* Prime numbers %$p$% and %$q$% */ - mp *g; /* Generates order-%$q$% subgroup */ -} dh_param; +typedef gprime_param dh_param; /* Group parameters */ typedef struct dh_pub { - dh_param dp; /* Shared parameters */ + dh_param dp; /* Shared parameters */ mp *y; /* Public key */ } dh_pub; @@ -154,11 +138,11 @@ extern int dh_gen(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/, * @unsigned flags@ = other generation flags * @unsigned steps@ = number of steps to go * @grand *r@ = random number source - * @pgen_proc *oev@ = outer event handler function - * @void *oec@ = argument for the outer event handler - * @pgen_proc *iev@ = inner event handler function - * @void *iec@ = argument for the inner event handler - * @size_t *nf@, @mp ***f@ = output array for factors + * @pgen_proc *oev@ = outer event handler function + * @void *oec@ = argument for the outer event handler + * @pgen_proc *iev@ = inner event handler function + * @void *iec@ = argument for the inner event handler + * @size_t *nf@, @mp ***f@ = output array for factors * * Returns: @PGEN_DONE@ if it worked, @PGEN_ABORT@ if it didn't. * @@ -182,6 +166,29 @@ extern int dh_limlee(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/, pgen_proc */*oev*/, void */*oec*/, pgen_proc */*iev*/, void */*iec*/, size_t */*nf*/, mp ***/*f*/); +/* --- @dh_kcdsagen@ --- * + * + * Arguments: @dh_param *dp@ = pointer to output parameter block + * @unsigned ql@ = size of small factor of %$(p - 1)/2$% + * @unsigned pl@ = size of %$p$% in bits + * @unsigned flags@ = other generation flags (none defined) + * @unsigned steps@ = number of steps to go + * @grand *r@ = random number source + * @pgen_proc *ev@ = event handler function + * @void *ec@ = context for the event handler + * + * Returns: @PGEN_DONE@ if it worked, @PGEN_ABORT@ if it failed. + * + * Use: Generates a KCDSA prime group. That is, it chooses a prime + * %$p$%, such that $%p = 2 q v + 1$%, for primes %$q$% and + * %$v$%. The actual group of interest is the subgroup of order + * %$q$%. + */ + +extern int dh_kcdsagen(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/, + unsigned /*flags*/, unsigned /*steps*/, grand */*r*/, + pgen_proc */*ev*/, void */*ec*/); + /* --- @dh_checkparam@ --- * * * Arguments: @keycheck *kc@ = keycheck state @@ -198,6 +205,34 @@ extern int dh_limlee(dh_param */*dp*/, unsigned /*ql*/, unsigned /*pl*/, extern int dh_checkparam(keycheck */*kc*/, const dh_param */*dp*/, mp **/*v*/, size_t /*n*/); +/* ---- @dh_infofromdata@ --- * + * + * Arguments: @dh_param *dp@ = parameters to fill in + * @pdata *pd@ = packed data structure + * + * Returns: --- + * + * Use: Fills in a parameters structure from a packed data block. + */ + +struct pdata; +extern void dh_infofromdata(dh_param */*dp*/, struct pdata */*pd*/); + +/* --- @dh_parse@, @dhbin_parse@ --- * + * + * Arguments: @qd_parse *qd@ = parser context + * @dh_param *dp@ = parameters to fill in + * + * Returns: Zero if OK, nonzero on error. + * + * Use: Parses a prime/binary group string. This is either one of + * the standard group strings, or a %$p$%, %$q$%, %$g$% triple + * separated by commas. + */ + +extern int dh_parse(qd_parse */*qd*/, dh_param */*dp*/); +extern int dhbin_parse(qd_parse */*qd*/, gbin_param */*gb*/); + /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus