bglibs
bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/md4.h
1/* Declaration of functions and data types used for MD4 hash computing
2 library functions.
3 Copyright (C) 2000,2002,2005 Bruce Guenter.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20#ifndef _MD4_H
21#define _MD4_H 1
22
23#include <stdio.h>
24
25#if defined HAVE_LIMITS_H || _LIBC
26# include <limits.h>
27#endif
28
29/* The following contortions are an attempt to use the C preprocessor
30 to determine an unsigned integral type that is 32 bits wide. An
31 alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
32 doing that would require that the configure script compile and *run*
33 the resulting executable. Locally running cross-compiled executables
34 is usually not possible. */
35
36#ifdef _LIBC
37# include <sys/types.h>
38typedef u_int32_t md4_uint32;
39#else
40# if defined __STDC__ && __STDC__
41# define UINT_MAX_32_BITS 4294967295U
42# else
43# define UINT_MAX_32_BITS 0xFFFFFFFF
44# endif
45
46/* If UINT_MAX isn't defined, assume it's a 32-bit type.
47 This should be valid for all systems GNU cares about because
48 that doesn't include 16-bit systems, and only modern systems
49 (that certainly have <limits.h>) have 64+-bit integral types. */
50
51# ifndef UINT_MAX
52# define UINT_MAX UINT_MAX_32_BITS
53# endif
54
55# if UINT_MAX == UINT_MAX_32_BITS
56 typedef unsigned int md4_uint32;
57# else
58# if USHRT_MAX == UINT_MAX_32_BITS
59 typedef unsigned short md4_uint32;
60# else
61# if ULONG_MAX == UINT_MAX_32_BITS
62 typedef unsigned long md4_uint32;
63# else
64 /* The following line is intended to evoke an error.
65 Using #error is not portable enough. */
66 "Cannot determine unsigned 32-bit data type."
67# endif
68# endif
69# endif
70#endif
71
72#undef __P
73#if defined (__STDC__) && __STDC__
74# define __P(x) x
75#else
76# define __P(x) ()
77#endif
78
79/* Structure to save state of computation between the single steps. */
80struct md4_ctx
81{
82 md4_uint32 A;
83 md4_uint32 B;
84 md4_uint32 C;
85 md4_uint32 D;
86
87 md4_uint32 total[2];
88 md4_uint32 buflen;
89 char buffer[64];
90};
91typedef struct md4_ctx MD4_CTX;
92
93/*
94 * The following three functions are build up the low level used in
95 * the functions `md4_stream' and `md4_buffer'.
96 */
97
98/* Initialize structure containing state of computation.
99 (RFC 1320, 3.3: Step 3) */
100extern void md4_init_ctx __P ((struct md4_ctx *ctx));
101
102/* Starting with the result of former calls of this function (or the
103 initialization function update the context for the next LEN bytes
104 starting at BUFFER.
105 It is necessary that LEN is a multiple of 64!!! */
106extern void md4_process_block __P ((const void *buffer, struct md4_ctx *ctx));
107
108/* Starting with the result of former calls of this function (or the
109 initialization function update the context for the next LEN bytes
110 starting at BUFFER.
111 It is NOT required that LEN is a multiple of 64. */
112extern void md4_process_bytes __P ((const void *buffer, size_t len,
113 struct md4_ctx *ctx));
114
115/* Process the remaining bytes in the buffer and put result from CTX
116 in first 16 bytes following RESBUF. The result is always in little
117 endian byte order, so that a byte-wise output yields to the wanted
118 ASCII representation of the message digest.
119
120 IMPORTANT: On some systems it is required that RESBUF is correctly
121 aligned for a 32 bits value. */
122extern void *md4_finish_ctx __P ((struct md4_ctx *ctx, void *resbuf));
123
124
125/* Put result from CTX in first 16 bytes following RESBUF. The result is
126 always in little endian byte order, so that a byte-wise output yields
127 to the wanted ASCII representation of the message digest.
128
129 IMPORTANT: On some systems it is required that RESBUF is correctly
130 aligned for a 32 bits value. */
131extern void *md4_read_ctx __P ((const struct md4_ctx *ctx, void *resbuf));
132
133#endif /* md4.h */
Definition: bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/bglibs/md4.h:81