3 * Generalized version of KCDSA
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_GKCDSA_H
29 #define CATACOMB_GKCDSA_H
35 /*----- Header files ------------------------------------------------------*/
37 #ifndef CATACOMB_GROUP_H
41 #ifndef CATACOMB_GHASH_H
45 #ifndef CATACOMB_GDSA_H
49 /*----- Data structures ---------------------------------------------------*/
53 * These structures are the same as for DSA. However, the private key @u@ is
54 * the %$\emph{inverse}$% of the exponent. Do this wrong and the maths will
60 typedef struct gkcdsa_sig {
61 octet *r; /* Null means @xmalloc@ me */
64 #define GKCDSA_SIG_INIT { 0, 0 }
66 /*----- Functions provided ------------------------------------------------*/
68 /* --- @gkcdsa_beginhash@ --- *
70 * Arguments: @const gkcdsa *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@, @g@ and @p@.
78 extern ghash *gkcdsa_beginhash(const gkcdsa */*c*/);
80 /* --- @gkcdsa_endhash@ --- *
82 * Arguments: @const gkcdsa *c@ = pointer to the context structure
83 * @ghash *h@ = the hashing context
87 * Use: Does any final thing that KCDSA wants to do when hashing a
88 * message. (Actually, there's nothing.) The hashing context
92 extern void gkcdsa_endhash(const gkcdsa */*c*/, ghash */*h*/);
94 /* --- @gkcdsa_sign@ --- *
96 * Arguments: @const gkcdsa *c@ = my context structure
97 * @gkcdsa_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 gkcdsa_sign(const gkcdsa */*c*/, gkcdsa_sig */*s*/,
108 const void */*m*/, mp */*k*/);
110 /* --- @gkcdsa_verify@ --- *
112 * Arguments: @const gkcdsa *c@ = my context structure
113 * @const gkcdsa_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 gkcdsa_verify(const gkcdsa */*c*/, const gkcdsa_sig */*s*/,
124 /*----- That's all, folks -------------------------------------------------*/