chiark / gitweb /
Make it build\!
[become] / src / md5.h
CommitLineData
c4f2d992 1/* -*-c-*-
2 *
c758e654 3 * $Id: md5.h,v 1.3 1998/01/12 16:46:13 mdw Exp $
c4f2d992 4 *
5 * MD-5 secure hash routines
6 * Based on RSA MD-5 code
7 *
c758e654 8 * (c) 1996-1998 Mark Wooding
c4f2d992 9 */
10
03f996bd 11/*----- Licensing notice --------------------------------------------------*
c4f2d992 12 *
13 * This file is part of `become'
14 *
15 * `Become' is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * `Become' is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
03f996bd 26 * along with `become'; if not, write to the Free Software Foundation,
27 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
c4f2d992 28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: md5.h,v $
c758e654 33 * Revision 1.3 1998/01/12 16:46:13 mdw
34 * Fix copyright date.
35 *
03f996bd 36 * Revision 1.2 1997/08/04 10:24:23 mdw
37 * Sources placed under CVS control.
38 *
39 * Revision 1.1 1997/07/21 13:47:47 mdw
c4f2d992 40 * Initial revision
41 *
42 */
43
44#ifndef MD5_H
45#define MD5_H
46
47#ifdef __cplusplus
48 extern "C" {
49#endif
50
51/*----- Required headers --------------------------------------------------*/
52
53#include <stddef.h>
54
55#ifndef CONFIG_H
56# include "config.h"
57#endif
58
59/*----- Useful constants --------------------------------------------------*/
60
61#define MD5_HASHSIZE (16u) /* Size of an MD5 hash */
62
63/*----- Type definitions --------------------------------------------------*/
64
65/* --- MD5 context buffer --- */
66
67typedef struct {
68 uint_32 val[4]; /* Result of the hash function */
69 unsigned long size; /* Current size of data in bytes */
70 unsigned char buf[64]; /* Buffer accumulating next block */
71} md5;
72
73/*----- Functions provided ------------------------------------------------*/
74
75/* --- @md5_trans@ --- *
76 *
77 * Arguments: @unsigned char *v@ = pointer to chaining block (updated)
78 * @const unsigned char *buf@ = pointer to input buffer
79 *
80 * Returns: ---
81 *
82 * Use: Performs the MD5 transformation on a chunk of data. This may
83 * be useful for using MD5 in MDC-type cipher constructions.
84 */
85
86extern void md5_trans(unsigned char */*v*/, const unsigned char */*buf*/);
87
88/* --- @md5_buffer@ --- *
89 *
90 * Arguments: @md5 *m@ = pointer to an MD5 context
91 * @const void *buff@ = pointer to buffer of data
92 * @size_t size@ = size of buffer
93 *
94 * Returns: ---
95 *
96 * Use: Hashes the buffer of data. You can call md5_buffer
97 * lots of times during an MD5 job, to allow big files to be
98 * split into little ones.
99 *
100 * This routine could be improved lots, to compare with the
101 * Straylight ARM assembler implementation, although that
102 * requires lots of work. Remember that the ARM version
103 * doesn't need to do endianness-fiddling.
104 */
105
106extern void md5_buffer(md5 */*m*/, const void */*buff*/, size_t /*size*/);
107
108/* --- @md5_key@ --- *
109 *
110 * Arguments: @md5 *m@ = pointer to an MD5 context
111 * @const unsigned char *k@ = pointer to a 4-word `key'
112 *
113 * Returns: ---
114 *
115 * Use: Initialises a context buffer, with a chosen initialisation
116 * string (instead of the standard MD5 value). This allows you
117 * to use NMAC message authentication, should the urge take you.
118 */
119
120extern void md5_key(md5 */*m*/, const unsigned char */*k*/);
121
122/* --- @md5_init@ --- *
123 *
124 * Arguments: @md5 *m@ = pointer to an MD5 context
125 *
126 * Returns: ---
127 *
128 * Use: Initialises the context buffer, so that you can do an
129 * MD5 job.
130 */
131
132extern void md5_init(md5 */*m*/);
133
134/* --- @md5_final@ --- *
135 *
136 * Arguments: @md5 *m@ = pointer to context buffer
137 * @unsigned char *v@ = where to store the value
138 *
139 * Returns: ---
140 *
141 * Use: Finalises an MD5 buffer, so that you can use the result.
142 */
143
144extern void md5_final(md5 */*m*/, unsigned char */*v*/);
145
146/*----- That's all, folks -------------------------------------------------*/
147
148#ifdef __cplusplus
149 }
150#endif
151
152#endif