math/mpreduce.h: Missing include files.
[u/mdw/catacomb] / symm / md2.h
CommitLineData
d3187d77 1/* -*-c-*-
2 *
d3187d77 3 * The MD2 message digest function
4 *
5 * (c) 2001 Straylight/Edgeware
6 */
7
45c0fd36 8/*----- Licensing notice --------------------------------------------------*
d3187d77 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 *
d3187d77 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 *
d3187d77 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
d3187d77 28/*----- Notes on the MD2 hash function ------------------------------------*
29 *
30 * MD2 was designed by Ron Rivest. It's not recommended for new applications
31 * because only the `checksum' part of the function resists collision-finding
32 * attacks. It's not very fast either. However, it's still used in
33 * standards, and having it available can be useful.
34 */
35
36#ifndef CATACOMB_MD2_H
37#define CATACOMB_MD2_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 MD2_BUFSZ 16
54#define MD2_HASHSZ 16
55#define MD2_STATESZ 32
56
57/*----- Data structures ---------------------------------------------------*/
58
59typedef struct md2_ctx {
60 octet c[MD2_BUFSZ]; /* Checksum buffer */
61 octet h[MD2_BUFSZ]; /* Hash result buffer */
62 octet buf[MD2_BUFSZ]; /* Input buffer */
63 unsigned off; /* Offset into buffer */
64} md2_ctx;
65
66/*----- Functions provided ------------------------------------------------*/
67
68/* --- @md2_compress@ --- *
69 *
70 * Arguments: @md2_ctx *ctx@ = pointer to context block
71 * @const void *sbuf@ = pointer to buffer of appropriate size
72 *
73 * Returns: ---
74 *
75 * Use: MD2 compression function.
76 */
77
78extern void md2_compress(md2_ctx */*ctx*/, const void */*sbuf*/);
79
80/* --- @md2_init@ --- *
81 *
82 * Arguments: @md2_ctx *ctx@ = pointer to context block to initialize
83 *
84 * Returns: ---
85 *
86 * Use: Initializes a context block ready for hashing.
87 */
88
89extern void md2_init(md2_ctx */*ctx*/);
90
91/* --- @md2_set@ --- *
92 *
93 * Arguments: @md2_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
104extern void md2_set(md2_ctx */*ctx*/, const void */*buf*/,
105 unsigned long /*count*/);
106
107/* --- @md2_hash@ --- *
108 *
109 * Arguments: @md2_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
119extern void md2_hash(md2_ctx */*ctx*/, const void */*buf*/, size_t /*sz*/);
120
121/* --- @md2_done@ --- *
122 *
123 * Arguments: @md2_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 md2_done(md2_ctx */*ctx*/, void */*hash*/);
132
133/* --- @md2_state@ --- *
134 *
135 * Arguments: @md2_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 @md2_set@.
142 */
143
144extern unsigned long md2_state(md2_ctx */*ctx*/, void */*state*/);
145
146/*----- Generic hash interface --------------------------------------------*/
147
148extern const gchash md2;
149
150/*----- That's all, folks -------------------------------------------------*/
151
152#ifdef __cplusplus
153 }
154#endif
155
156#endif