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