Use C99 uint32_t rather than u_int32_t
[onak.git] / md5.h
1 /* Declaration of functions and data types used for MD5 sum computing
2    library functions.
3    Copyright (C) 1995,1996,1997,1999,2000,2001 Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #ifndef _MD5_H
22 #define _MD5_H 1
23
24 #include <stdio.h>
25 #include <sys/types.h>
26 typedef u_int32_t md5_uint32;
27 typedef size_t md5_uintptr;
28
29 /* Structure to save state of computation between the single steps.  */
30 struct md5_ctx
31 {
32   char buffer[128];
33   md5_uint32 A;
34   md5_uint32 B;
35   md5_uint32 C;
36   md5_uint32 D;
37
38   md5_uint32 total[2];
39   md5_uint32 buflen;
40 };
41
42 /*
43  * The following three functions are build up the low level used in
44  * the functions `md5_stream' and `md5_buffer'.
45  */
46
47 /* Initialize structure containing state of computation.
48    (RFC 1321, 3.3: Step 3)  */
49 extern void md5_init_ctx (struct md5_ctx *ctx);
50
51 /* Starting with the result of former calls of this function (or the
52    initialization function update the context for the next LEN bytes
53    starting at BUFFER.
54    It is necessary that LEN is a multiple of 64!!! */
55 extern void md5_process_block (const void *buffer, size_t len,
56                                       struct md5_ctx *ctx);
57
58 /* Starting with the result of former calls of this function (or the
59    initialization function update the context for the next LEN bytes
60    starting at BUFFER.
61    It is NOT required that LEN is a multiple of 64.  */
62 extern void md5_process_bytes (const void *buffer, size_t len,
63                                       struct md5_ctx *ctx);
64
65 /* Process the remaining bytes in the buffer and put result from CTX
66    in first 16 bytes following RESBUF.  The result is always in little
67    endian byte order, so that a byte-wise output yields to the wanted
68    ASCII representation of the message digest.
69
70    IMPORTANT: On some systems it is required that RESBUF is correctly
71    aligned for a 32 bits value.  */
72 extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
73
74
75 /* Put result from CTX in first 16 bytes following RESBUF.  The result is
76    always in little endian byte order, so that a byte-wise output yields
77    to the wanted ASCII representation of the message digest.
78
79    IMPORTANT: On some systems it is required that RESBUF is correctly
80    aligned for a 32 bits value.  */
81 extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
82
83
84 /* Compute MD5 message digest for bytes read from STREAM.  The
85    resulting message digest number will be written into the 16 bytes
86    beginning at RESBLOCK.  */
87 extern int md5_stream (FILE *stream, void *resblock);
88
89 /* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
90    result is always in little endian byte order, so that a byte-wise
91    output yields to the wanted ASCII representation of the message
92    digest.  */
93 extern void *md5_buffer (const char *buffer, size_t len,
94                                 void *resblock);
95
96 #endif /* md5.h */