math/mpreduce.h: Missing include files.
[u/mdw/catacomb] / pub / gkcdsa.h
CommitLineData
e9026a0a 1/* -*-c-*-
2 *
e9026a0a 3 * Generalized version of KCDSA
4 *
5 * (c) 2004 Straylight/Edgeware
6 */
7
45c0fd36 8/*----- Licensing notice --------------------------------------------------*
e9026a0a 9 *
10 * This file is part of Catacomb.
11 *
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.
45c0fd36 16 *
e9026a0a 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.
45c0fd36 21 *
e9026a0a 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,
25 * MA 02111-1307, USA.
26 */
27
e9026a0a 28#ifndef CATACOMB_GKCDSA_H
29#define CATACOMB_GKCDSA_H
30
31#ifdef __cplusplus
32 extern "C" {
33#endif
34
35/*----- Header files ------------------------------------------------------*/
36
37#ifndef CATACOMB_GROUP_H
38# include "group.h"
39#endif
40
41#ifndef CATACOMB_GHASH_H
42# include "ghash.h"
43#endif
44
45#ifndef CATACOMB_GDSA_H
46# include "gdsa.h"
47#endif
48
49/*----- Data structures ---------------------------------------------------*/
50
51/* --- Careful! --- *
52 *
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
55 * fail hopelessly.
56 */
57
58typedef gdsa gkcdsa;
59
60typedef struct gkcdsa_sig {
61 octet *r; /* Null means @xmalloc@ me */
62 mp *s;
63} gkcdsa_sig;
64#define GKCDSA_SIG_INIT { 0, 0 }
65
66/*----- Functions provided ------------------------------------------------*/
67
f4535c64 68/* --- @gkcdsa_beginhash@ --- *
e9026a0a 69 *
f4535c64 70 * Arguments: @const gkcdsa *c@ = pointer to the context structure
e9026a0a 71 *
72 * Returns: A hashing context for you to hash the message.
73 *
74 * Use: Initializes a hash function correctly for you to hash a
75 * message. Requires @h@, @g@ and @p@.
76 */
77
78extern ghash *gkcdsa_beginhash(const gkcdsa */*c*/);
79
80/* --- @gkcdsa_endhash@ --- *
81 *
82 * Arguments: @const gkcdsa *c@ = pointer to the context structure
83 * @ghash *h@ = the hashing context
84 *
85 * Returns: ---
86 *
87 * Use: Does any final thing that KCDSA wants to do when hashing a
45c0fd36 88 * message. (Actually, there's nothing.) The hashing context
e9026a0a 89 * isn't finalized.
90 */
91
f4535c64 92extern void gkcdsa_endhash(const gkcdsa */*c*/, ghash */*h*/);
e9026a0a 93
94/* --- @gkcdsa_sign@ --- *
95 *
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
100 *
101 * Returns: ---
102 *
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.
105 */
106
107extern void gkcdsa_sign(const gkcdsa */*c*/, gkcdsa_sig */*s*/,
108 const void */*m*/, mp */*k*/);
109
110/* --- @gkcdsa_verify@ --- *
111 *
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
115 *
116 * Returns: Zero if OK, negative on failure.
117 *
118 * Use: Checks a signature on a message, Requires @g@, @p@, @h@.
119 */
120
121extern int gkcdsa_verify(const gkcdsa */*c*/, const gkcdsa_sig */*s*/,
122 const void */*m*/);
123
124/*----- That's all, folks -------------------------------------------------*/
125
126#ifdef __cplusplus
127 }
128#endif
129
130#endif