3 * $Id: gdsa.h,v 1.2 2004/04/08 01:36:15 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 #ifndef CATACOMB_GDSA_H
31 #define CATACOMB_GDSA_H
37 /*----- Header files ------------------------------------------------------*/
39 #ifndef CATACOMB_GHASH_H
43 #ifndef CATACOMB_GROUP_H
47 /*----- Data structures ---------------------------------------------------*/
49 /* --- GDSA context --- *
51 * You don't need to fill in all of this stuff. See the description of the
52 * function you want to use to find out what members are needed.
56 group
*g
; /* The group we work in */
57 mp
*u
; /* Private key, for signing */
58 ge
*p
; /* Public key, for verifying */
59 grand
*r
; /* Random number source */
60 const gchash
*h
; /* Hash function */
63 /* --- GDSA signatures --- */
65 typedef struct gdsa_sig
{ mp
*r
, *s
; } gdsa_sig
;
66 #define GDSA_SIG_INIT { MP_NEW, MP_NEW }
68 /*----- Functions provided ------------------------------------------------*/
70 /* --- @gdsa_beginhash@ --- *
72 * Arguments: @const gdsa *c@ = pointer to the context structure
74 * Returns: A hashing context for you to hash the message.
76 * Use: Initializes a hash function correctly for you to hash a
77 * message. Requires @h@.
80 extern ghash
*gdsa_beginhash(const gdsa */
*c*/
);
82 /* --- @gdsa_endhash@ --- *
84 * Arguments: @const gdsa *c@ = pointer to the context structure
85 * @ghash *h@ = the hashing context
89 * Use: Does any final thing that DSA wants to do when hashing a
90 * message. (Actually, there's nothing.) The hashing context
94 extern void gdsa_endhash(gdsa */
*c*/
, ghash */
*h*/
);
96 /* --- @gdsa_sign@ --- *
98 * Arguments: @const gdsa *c@ = my context structure
99 * @gdsa_sig *s@ = where to put the signature (initialized)
100 * @const void *m@ = pointer to message hash
101 * @mp *k@ = random exponent for this message or null
105 * Use: Signs a message. Requires @g@, @u@, @h@, and @r@ if @k@ is
106 * null. This is a better idea than inventing @k@ yourself.
109 extern void gdsa_sign(const gdsa */
*c*/
, gdsa_sig */
*s*/
,
110 const void */
*m*/
, mp */
*k*/
);
112 /* --- @gdsa_verify@ --- *
114 * Arguments: @const gdsa *c@ = my context structure
115 * @const gdsa_sig *s@ = the signature to verify
116 * @const void *m@ = pointer to message hash
118 * Returns: Zero if OK, negative on failure.
120 * Use: Checks a signature on a message, Requires @g@, @p@, @h@.
123 extern int gdsa_verify(const gdsa */
*c*/
, const gdsa_sig */
*s*/
,
126 /*----- That's all, folks -------------------------------------------------*/