math/mpreduce.h: Missing include files.
[u/mdw/catacomb] / symm / rmd128.h
CommitLineData
1c64c8e2 1/* -*-c-*-
2 *
1c64c8e2 3 * The RIPEMD-128 message digest function
4 *
5 * (c) 1998 Straylight/Edgeware
6 */
7
45c0fd36 8/*----- Licensing notice --------------------------------------------------*
1c64c8e2 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 *
1c64c8e2 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 *
1c64c8e2 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
1c64c8e2 28/*----- Notes on the RIPEMD-128 hash function -----------------------------*
29 *
30 * RIPEMD-128 was invented by Hans Dobbertin, Antoon Bosselaers and Bart
31 * Preneel, as a drop-in replacement for MD5 (with the same sized output).
32 * It's a cut-down version of RIPEMD-160, which should be used in preference.
33 */
34
35#ifndef CATACOMB_RMD128_H
36#define CATACOMB_RMD128_H
37
38#ifdef __cplusplus
39 extern "C" {
40#endif
41
42/*----- Header files ------------------------------------------------------*/
43
44#include <mLib/bits.h>
45
46#ifndef CATACOMB_GHASH_H
47# include "ghash.h"
48#endif
49
50/*----- Magic numbers -----------------------------------------------------*/
51
52#define RMD128_BUFSZ 64
53#define RMD128_HASHSZ 16
c850c0da 54#define RMD128_STATESZ 16
1c64c8e2 55
56/*----- Data structures ---------------------------------------------------*/
57
58typedef struct rmd128_ctx {
59 uint32 a, b, c, d; /* Chaining variables */
60 uint32 nl, nh; /* Byte count so far */
61 unsigned off; /* Offset into buffer */
62 octet buf[RMD128_BUFSZ]; /* Accumulation buffer */
63} rmd128_ctx;
64
65/*----- Functions provided ------------------------------------------------*/
66
67/* --- @rmd128_compress@ --- *
68 *
69 * Arguments: @rmd128_ctx *ctx@ = pointer to context block
70 * @const void *sbuf@ = pointer to buffer of appropriate size
71 *
72 * Returns: ---
73 *
74 * Use: RIPEMD-128 compression function.
75 */
76
77extern void rmd128_compress(rmd128_ctx */*ctx*/, const void */*sbuf*/);
78
79/* --- @rmd128_init@ --- *
80 *
81 * Arguments: @rmd128_ctx *ctx@ = pointer to context block to initialize
82 *
83 * Returns: ---
84 *
85 * Use: Initializes a context block ready for hashing.
86 */
87
88extern void rmd128_init(rmd128_ctx */*ctx*/);
89
90/* --- @rmd128_set@ --- *
91 *
92 * Arguments: @rmd128_ctx *ctx@ = pointer to context block
93 * @const void *buf@ = pointer to state buffer
94 * @unsigned long count@ = current count of bytes processed
95 *
96 * Returns: ---
97 *
98 * Use: Initializes a context block from a given state. This is
99 * useful in cases where the initial hash state is meant to be
100 * secret, e.g., for NMAC and HMAC support.
101 */
102
103extern void rmd128_set(rmd128_ctx */*ctx*/,
104 const void */*buf*/, unsigned long /*count*/);
105
106/* --- @rmd128_hash@ --- *
107 *
108 * Arguments: @rmd128_ctx *ctx@ = pointer to context block
109 * @const void *buf@ = buffer of data to hash
110 * @size_t sz@ = size of buffer to hash
111 *
112 * Returns: ---
113 *
114 * Use: Hashes a buffer of data. The buffer may be of any size and
115 * alignment.
116 */
117
118extern void rmd128_hash(rmd128_ctx */*ctx*/,
119 const void */*buf*/, size_t /*sz*/);
120
121/* --- @rmd128_done@ --- *
122 *
123 * Arguments: @rmd128_ctx *ctx@ = pointer to context block
124 * @void *hash@ = pointer to output buffer
125 *
126 * Returns: ---
127 *
128 * Use: Returns the hash of the data read so far.
129 */
130
131extern void rmd128_done(rmd128_ctx */*ctx*/, void */*hash*/);
132
133/* --- @rmd128_state@ --- *
134 *
135 * Arguments: @rmd128_ctx *ctx@ = pointer to context
136 * @void *state@ = pointer to buffer for current state
137 *
138 * Returns: Number of bytes written to the hash function so far.
139 *
140 * Use: Returns the current state of the hash function such that
141 * it can be passed to @rmd128_set@.
142 */
143
144extern unsigned long rmd128_state(rmd128_ctx */*ctx*/, void */*state*/);
145
146/*----- Generic hash interface --------------------------------------------*/
147
148extern const gchash rmd128;
149
150/*----- That's all, folks -------------------------------------------------*/
151
152#ifdef __cplusplus
153 }
154#endif
155
156#endif