3 * Generalized version of DSA
5 * (c) 2004 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_GDSA_H
29 #define CATACOMB_GDSA_H
35 /*----- Header files ------------------------------------------------------*/
37 #ifndef CATACOMB_GHASH_H
41 #ifndef CATACOMB_GROUP_H
45 /*----- Data structures ---------------------------------------------------*/
47 /* --- GDSA context --- *
49 * You don't need to fill in all of this stuff. See the description of the
50 * function you want to use to find out what members are needed.
54 group *g; /* The group we work in */
55 mp *u; /* Private key, for signing */
56 ge *p; /* Public key, for verifying */
57 grand *r; /* Random number source */
58 const gchash *h; /* Hash function */
61 /* --- GDSA signatures --- */
63 typedef struct gdsa_sig { mp *r, *s; } gdsa_sig;
64 #define GDSA_SIG_INIT { MP_NEW, MP_NEW }
66 /*----- Functions provided ------------------------------------------------*/
68 /* --- @gdsa_beginhash@ --- *
70 * Arguments: @const gdsa *c@ = pointer to the context structure
72 * Returns: A hashing context for you to hash the message.
74 * Use: Initializes a hash function correctly for you to hash a
75 * message. Requires @h@.
78 extern ghash *gdsa_beginhash(const gdsa */*c*/);
80 /* --- @gdsa_endhash@ --- *
82 * Arguments: @const gdsa *c@ = pointer to the context structure
83 * @ghash *h@ = the hashing context
87 * Use: Does any final thing that DSA wants to do when hashing a
88 * message. (Actually, there's nothing.) The hashing context
92 extern void gdsa_endhash(const gdsa */*c*/, ghash */*h*/);
94 /* --- @gdsa_sign@ --- *
96 * Arguments: @const gdsa *c@ = my context structure
97 * @gdsa_sig *s@ = where to put the signature (initialized)
98 * @const void *m@ = pointer to message hash
99 * @mp *k@ = random exponent for this message or null
103 * Use: Signs a message. Requires @g@, @u@, @h@, and @r@ if @k@ is
104 * null. This is a better idea than inventing @k@ yourself.
107 extern void gdsa_sign(const gdsa */*c*/, gdsa_sig */*s*/,
108 const void */*m*/, mp */*k*/);
110 /* --- @gdsa_verify@ --- *
112 * Arguments: @const gdsa *c@ = my context structure
113 * @const gdsa_sig *s@ = the signature to verify
114 * @const void *m@ = pointer to message hash
116 * Returns: Zero if OK, negative on failure.
118 * Use: Checks a signature on a message, Requires @g@, @p@, @h@.
121 extern int gdsa_verify(const gdsa */*c*/, const gdsa_sig */*s*/,
124 /*----- That's all, folks -------------------------------------------------*/