mutt stable branch with some hacks
1/* Declaration of functions and data types used for MD5 sum computing
2 library functions.
3 Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006,2008
4 Free Software Foundation, Inc.
5
6 NOTE: The canonical source of this file is maintained with the GNU C
7 Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
8
9 This program is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2, or (at your option) any
12 later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
22
23#ifndef _MD5_H
24#define _MD5_H 1
25
26#include <stdio.h>
27
28#if HAVE_INTTYPES_H
29# include <inttypes.h>
30#endif
31#if HAVE_STDINT_H || _LIBC
32# include <stdint.h>
33#endif
34#if HAVE_SYS_TYPES_H
35# include <sys/types.h>
36#endif
37
38#ifndef __GNUC_PREREQ
39# if defined __GNUC__ && defined __GNUC_MINOR__
40# define __GNUC_PREREQ(maj, min) \
41 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
42# else
43# define __GNUC_PREREQ(maj, min) 0
44# endif
45#endif
46
47#ifndef __THROW
48# if defined __cplusplus && __GNUC_PREREQ (2,8)
49# define __THROW throw ()
50# else
51# define __THROW
52# endif
53#endif
54
55#ifndef _LIBC
56# define __md5_buffer md5_buffer
57# define __md5_finish_ctx md5_finish_ctx
58# define __md5_init_ctx md5_init_ctx
59# define __md5_process_block md5_process_block
60# define __md5_process_bytes md5_process_bytes
61# define __md5_read_ctx md5_read_ctx
62# define __md5_stream md5_stream
63#endif
64
65typedef uint32_t md5_uint32;
66
67/* Structure to save state of computation between the single steps. */
68struct md5_ctx
69{
70 md5_uint32 A;
71 md5_uint32 B;
72 md5_uint32 C;
73 md5_uint32 D;
74
75 md5_uint32 total[2];
76 md5_uint32 buflen;
77 md5_uint32 buffer[32];
78};
79
80/*
81 * The following three functions are build up the low level used in
82 * the functions `md5_stream' and `md5_buffer'.
83 */
84
85/* Initialize structure containing state of computation.
86 (RFC 1321, 3.3: Step 3) */
87extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
88
89/* Starting with the result of former calls of this function (or the
90 initialization function update the context for the next LEN bytes
91 starting at BUFFER.
92 It is necessary that LEN is a multiple of 64!!! */
93extern void __md5_process_block (const void *buffer, size_t len,
94 struct md5_ctx *ctx) __THROW;
95
96/* Starting with the result of former calls of this function (or the
97 initialization function update the context for the next LEN bytes
98 starting at BUFFER.
99 It is NOT required that LEN is a multiple of 64. */
100extern void __md5_process_bytes (const void *buffer, size_t len,
101 struct md5_ctx *ctx) __THROW;
102
103/* Process the remaining bytes in the buffer and put result from CTX
104 in first 16 bytes following RESBUF. The result is always in little
105 endian byte order, so that a byte-wise output yields to the wanted
106 ASCII representation of the message digest. */
107extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
108
109
110/* Put result from CTX in first 16 bytes following RESBUF. The result is
111 always in little endian byte order, so that a byte-wise output yields
112 to the wanted ASCII representation of the message digest. */
113extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
114
115
116/* Compute MD5 message digest for bytes read from STREAM. The
117 resulting message digest number will be written into the 16 bytes
118 beginning at RESBLOCK. */
119extern int __md5_stream (FILE *stream, void *resblock) __THROW;
120
121/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
122 result is always in little endian byte order, so that a byte-wise
123 output yields to the wanted ASCII representation of the message
124 digest. */
125extern void *__md5_buffer (const char *buffer, size_t len,
126 void *resblock) __THROW;
127
128#endif /* md5.h */