Add set -e.
[u/mdw/catacomb] / gkcdsa.h
CommitLineData
e9026a0a 1/* -*-c-*-
2 *
3 * $Id: gkcdsa.h,v 1.1 2004/04/04 19:42:59 mdw Exp $
4 *
5 * Generalized version of KCDSA
6 *
7 * (c) 2004 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: gkcdsa.h,v $
33 * Revision 1.1 2004/04/04 19:42:59 mdw
34 * Add set -e.
35 *
36 */
37
38#ifndef CATACOMB_GKCDSA_H
39#define CATACOMB_GKCDSA_H
40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45/*----- Header files ------------------------------------------------------*/
46
47#ifndef CATACOMB_GROUP_H
48# include "group.h"
49#endif
50
51#ifndef CATACOMB_GHASH_H
52# include "ghash.h"
53#endif
54
55#ifndef CATACOMB_GDSA_H
56# include "gdsa.h"
57#endif
58
59/*----- Data structures ---------------------------------------------------*/
60
61/* --- Careful! --- *
62 *
63 * These structures are the same as for DSA. However, the private key @u@ is
64 * the %$\emph{inverse}$% of the exponent. Do this wrong and the maths will
65 * fail hopelessly.
66 */
67
68typedef gdsa gkcdsa;
69
70typedef struct gkcdsa_sig {
71 octet *r; /* Null means @xmalloc@ me */
72 mp *s;
73} gkcdsa_sig;
74#define GKCDSA_SIG_INIT { 0, 0 }
75
76/*----- Functions provided ------------------------------------------------*/
77
78/* --- @gdsa_beginhash@ --- *
79 *
80 * Arguments: @const gdsa *c@ = pointer to the context structure
81 *
82 * Returns: A hashing context for you to hash the message.
83 *
84 * Use: Initializes a hash function correctly for you to hash a
85 * message. Requires @h@, @g@ and @p@.
86 */
87
88extern ghash *gkcdsa_beginhash(const gkcdsa */*c*/);
89
90/* --- @gkcdsa_endhash@ --- *
91 *
92 * Arguments: @const gkcdsa *c@ = pointer to the context structure
93 * @ghash *h@ = the hashing context
94 *
95 * Returns: ---
96 *
97 * Use: Does any final thing that KCDSA wants to do when hashing a
98 * message. (Actually, there's nothing.) The hashing context
99 * isn't finalized.
100 */
101
102extern void gkcdsa_endhash(gkcdsa */*c*/, ghash */*h*/);
103
104/* --- @gkcdsa_sign@ --- *
105 *
106 * Arguments: @const gkcdsa *c@ = my context structure
107 * @gkcdsa_sig *s@ = where to put the signature (initialized)
108 * @const void *m@ = pointer to message hash
109 * @mp *k@ = random exponent for this message or null
110 *
111 * Returns: ---
112 *
113 * Use: Signs a message. Requires @g@, @u@, @h@, and @r@ if @k@ is
114 * null. This is a better idea than inventing @k@ yourself.
115 */
116
117extern void gkcdsa_sign(const gkcdsa */*c*/, gkcdsa_sig */*s*/,
118 const void */*m*/, mp */*k*/);
119
120/* --- @gkcdsa_verify@ --- *
121 *
122 * Arguments: @const gkcdsa *c@ = my context structure
123 * @const gkcdsa_sig *s@ = the signature to verify
124 * @const void *m@ = pointer to message hash
125 *
126 * Returns: Zero if OK, negative on failure.
127 *
128 * Use: Checks a signature on a message, Requires @g@, @p@, @h@.
129 */
130
131extern int gkcdsa_verify(const gkcdsa */*c*/, const gkcdsa_sig */*s*/,
132 const void */*m*/);
133
134/*----- That's all, folks -------------------------------------------------*/
135
136#ifdef __cplusplus
137 }
138#endif
139
140#endif