math/mpreduce.h: Missing include files.
[u/mdw/catacomb] / symm / has160.h
1 /* -*-c-*-
2 *
3 * The HAS160 message digest function
4 *
5 * (c) 2004 Straylight/Edgeware
6 */
7
8 /*----- Licensing notice --------------------------------------------------*
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.
16 *
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.
21 *
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
28 /*----- Notes on the HAS160 hash function ---------------------------------*
29 *
30 * HAS160 was designed by Chae Hoon Lim and the Korean Information Security
31 * Agency (KISA). It's recommended for use with KCDSA (though I think I'm
32 * happer with RIPEMD-160 or SHA1). It's here so I can check KCDSA test
33 * vectors.
34 */
35
36 #ifndef CATACOMB_HAS160_H
37 #define CATACOMB_HAS160_H
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /*----- Header files ------------------------------------------------------*/
44
45 #include <mLib/bits.h>
46
47 #ifndef CATACOMB_GHASH_H
48 # include "ghash.h"
49 #endif
50
51 /*----- Magic numbers -----------------------------------------------------*/
52
53 #define HAS160_BUFSZ 64
54 #define HAS160_HASHSZ 20
55 #define HAS160_STATESZ 20
56
57 /*----- Data structures ---------------------------------------------------*/
58
59 typedef struct has160_ctx {
60 uint32 a, b, c, d, e; /* Chaining variables */
61 uint32 nl, nh; /* Byte count so far */
62 unsigned off; /* Offset into buffer */
63 octet buf[HAS160_BUFSZ]; /* Accumulation buffer */
64 } has160_ctx;
65
66 /*----- Functions provided ------------------------------------------------*/
67
68 /* --- @has160_compress@ --- *
69 *
70 * Arguments: @has160_ctx *ctx@ = pointer to context block
71 * @const void *sbuf@ = pointer to buffer of appropriate size
72 *
73 * Returns: ---
74 *
75 * Use: HAS160 compression function.
76 */
77
78 extern void has160_compress(has160_ctx */*ctx*/, const void */*sbuf*/);
79
80 /* --- @has160_init@ --- *
81 *
82 * Arguments: @has160_ctx *ctx@ = pointer to context block to initialize
83 *
84 * Returns: ---
85 *
86 * Use: Initializes a context block ready for hashing.
87 */
88
89 extern void has160_init(has160_ctx */*ctx*/);
90
91 /* --- @has160_set@ --- *
92 *
93 * Arguments: @has160_ctx *ctx@ = pointer to context block
94 * @const void *buf@ = pointer to state buffer
95 * @unsigned long count@ = current count of bytes processed
96 *
97 * Returns: ---
98 *
99 * Use: Initializes a context block from a given state. This is
100 * useful in cases where the initial hash state is meant to be
101 * secret, e.g., for NMAC and HMAC support.
102 */
103
104 extern void has160_set(has160_ctx */*ctx*/, const void */*buf*/,
105 unsigned long /*count*/);
106
107 /* --- @has160_hash@ --- *
108 *
109 * Arguments: @has160_ctx *ctx@ = pointer to context block
110 * @const void *buf@ = buffer of data to hash
111 * @size_t sz@ = size of buffer to hash
112 *
113 * Returns: ---
114 *
115 * Use: Hashes a buffer of data. The buffer may be of any size and
116 * alignment.
117 */
118
119 extern void has160_hash(has160_ctx */*ctx*/,
120 const void */*buf*/, size_t /*sz*/);
121
122 /* --- @has160_done@ --- *
123 *
124 * Arguments: @has160_ctx *ctx@ = pointer to context block
125 * @void *hash@ = pointer to output buffer
126 *
127 * Returns: ---
128 *
129 * Use: Returns the hash of the data read so far.
130 */
131
132 extern void has160_done(has160_ctx */*ctx*/, void */*hash*/);
133
134 /* --- @has160_state@ --- *
135 *
136 * Arguments: @has160_ctx *ctx@ = pointer to context
137 * @void *state@ = pointer to buffer for current state
138 *
139 * Returns: Number of bytes written to the hash function so far.
140 *
141 * Use: Returns the current state of the hash function such that
142 * it can be passed to @has160_set@.
143 */
144
145 extern unsigned long has160_state(has160_ctx */*ctx*/, void */*state*/);
146
147 /*----- Generic hash interface --------------------------------------------*/
148
149 extern const gchash has160;
150
151 /*----- That's all, folks -------------------------------------------------*/
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif