6d88a4da3e12eeb809bb45f4a0add106e3d6d1ce
3 * $Id: gdsa.h,v 1.1 2004/04/04 19:42:59 mdw Exp $
5 * Generalized version of DSA
7 * (c) 2004 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.1 2004/04/04 19:42:59 mdw
38 #ifndef CATACOMB_GDSA_H
39 #define CATACOMB_GDSA_H
45 /*----- Header files ------------------------------------------------------*/
47 #ifndef CATACOMB_GHASH_H
51 #ifndef CATACOMB_GROUP_H
55 /*----- Data structures ---------------------------------------------------*/
57 /* --- GDSA context --- *
59 * You don't need to fill in all of this stuff. See the description of the
60 * function you want to use to find out what members are needed.
64 group
*g
; /* The group we work in */
65 mp
*u
; /* Private key, for signing */
66 ge
*p
; /* Public key, for verifying */
67 grand
*r
; /* Random number source */
68 const gchash
*h
; /* Hash function */
71 /* --- GDSA signatures --- */
73 typedef struct gdsa_sig
{ mp
*r
, *s
; } gdsa_sig
;
74 #define GDSA_SIG_INIT { MP_NEW, MP_NEW }
76 /*----- Functions provided ------------------------------------------------*/
78 /* --- @gdsa_beginhash@ --- *
80 * Arguments: @const gdsa *c@ = pointer to the context structure
82 * Returns: A hashing context for you to hash the message.
84 * Use: Initializes a hash function correctly for you to hash a
85 * message. Requires @h@.
88 extern ghash
*gdsa_beginhash(const gdsa */
*c*/
);
90 /* --- @gdsa_endhash@ --- *
92 * Arguments: @const gdsa *c@ = pointer to the context structure
93 * @ghash *h@ = the hashing context
97 * Use: Does any final thing that DSA wants to do when hashing a
98 * message. (Actually, there's nothing.) The hashing context
102 extern void gdsa_endhash(gdsa */
*c*/
, ghash */
*h*/
);
104 /* --- @gdsa_sign@ --- *
106 * Arguments: @const gdsa *c@ = my context structure
107 * @gdsa_sig *s@ = where to put the signature (initialized)
108 * @const void *m@ = pointer to message hash
109 * @mp *k@ = random exponent for this message or null
113 * Use: Signs a message. Requires @g@, @u@, @h@, and @r@ if @k@ is
114 * null. This is a better idea than inventing @k@ yourself.
117 extern void gdsa_sign(const gdsa */
*c*/
, gdsa_sig */
*s*/
,
118 const void */
*m*/
, mp */
*k*/
);
120 /* --- @gdsa_verify@ --- *
122 * Arguments: @const gdsa *c@ = my context structure
123 * @const gdsa_sig *s@ = the signature to verify
124 * @const void *m@ = pointer to message hash
126 * Returns: Zero if OK, negative on failure.
128 * Use: Checks a signature on a message, Requires @g@, @p@, @h@.
131 extern int gdsa_verify(const gdsa */
*c*/
, const gdsa_sig */
*s*/
,
134 /*----- That's all, folks -------------------------------------------------*/