5 * Generalized version of KCDSA
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_GKCDSA_H
31 #define CATACOMB_GKCDSA_H
37 /*----- Header files ------------------------------------------------------*/
39 #ifndef CATACOMB_GROUP_H
43 #ifndef CATACOMB_GHASH_H
47 #ifndef CATACOMB_GDSA_H
51 /*----- Data structures ---------------------------------------------------*/
55 * These structures are the same as for DSA. However, the private key @u@ is
56 * the %$\emph{inverse}$% of the exponent. Do this wrong and the maths will
62 typedef struct gkcdsa_sig {
63 octet *r; /* Null means @xmalloc@ me */
66 #define GKCDSA_SIG_INIT { 0, 0 }
68 /*----- Functions provided ------------------------------------------------*/
70 /* --- @gkcdsa_beginhash@ --- *
72 * Arguments: @const gkcdsa *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@, @g@ and @p@.
80 extern ghash *gkcdsa_beginhash(const gkcdsa */*c*/);
82 /* --- @gkcdsa_endhash@ --- *
84 * Arguments: @const gkcdsa *c@ = pointer to the context structure
85 * @ghash *h@ = the hashing context
89 * Use: Does any final thing that KCDSA wants to do when hashing a
90 * message. (Actually, there's nothing.) The hashing context
94 extern void gkcdsa_endhash(const gkcdsa */*c*/, ghash */*h*/);
96 /* --- @gkcdsa_sign@ --- *
98 * Arguments: @const gkcdsa *c@ = my context structure
99 * @gkcdsa_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 gkcdsa_sign(const gkcdsa */*c*/, gkcdsa_sig */*s*/,
110 const void */*m*/, mp */*k*/);
112 /* --- @gkcdsa_verify@ --- *
114 * Arguments: @const gkcdsa *c@ = my context structure
115 * @const gkcdsa_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 gkcdsa_verify(const gkcdsa */*c*/, const gkcdsa_sig */*s*/,
126 /*----- That's all, folks -------------------------------------------------*/