2
* Local defines for the md5 functions.
7
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
10
* License to copy and use this software is granted provided that it is
11
* identified as the "RSA Data Security, Inc. MD5 Message-Digest
12
* Algorithm" in all material mentioning or referencing this software
15
* License is also granted to make and use derivative works provided that
16
* such works are identified as "derived from the RSA Data Security,
17
* Inc. MD5 Message-Digest Algorithm" in all material mentioning or
18
* referencing the derived work.
20
* RSA Data Security, Inc. makes no representations concerning either the
21
* merchantability of this software or the suitability of this
22
* software for any particular purpose. It is provided "as is" without
23
* express or implied warranty of any kind.
25
* These notices must be retained in any copies of any part of this
26
* documentation and/or software.
32
#define HEX_STRING "0123456789abcdef" /* to convert to hex */
33
#define BLOCK_SIZE_MASK (MD5_BLOCK_SIZE - 1)
39
* Define my endian-ness. Could not do in a portable manner using the
40
* include files -- grumble.
42
#ifdef WORDS_BIGENDIAN
44
* big endian - big is better
47
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
56
* These are the four functions used in the four steps of the MD5
57
* algorithm and defined in the RFC 1321. The first function is a
58
* little bit optimized (as found in Colin Plumbs public domain
61
/* #define FF(b, c, d) ((b & c) | (~b & d)) */
62
#define FF(b, c, d) (d ^ (b & (c ^ d)))
63
#define FG(b, c, d) FF(d, b, c)
64
#define FH(b, c, d) (b ^ c ^ d)
65
#define FI(b, c, d) (c ^ (b | ~d))
68
* It is unfortunate that C does not provide an operator for cyclic
69
* rotation. Hope the C compiler is smart enough. -- Modified to
70
* remove the w = at the front - Gray 2/97
72
#define CYCLIC(w, s) ((w << s) | (w >> (32 - s)))
75
* First Round: using the given function, the context and a constant
76
* the next context is computed. Because the algorithms processing
77
* unit is a 32-bit word and it is determined to work on words in
78
* little endian byte order we perhaps have to change the byte order
79
* before the computation. To reduce the work for the next steps we
80
* store the swapped words in the array CORRECT_WORDS. -- Modified to
81
* fix the handling of unaligned buffer spaces - Gray 7/97
83
#define OP1(a, b, c, d, b_p, c_p, s, T) \
85
memcpy(c_p, b_p, sizeof(md5_uint32)); \
87
a += FF (b, c, d) + *c_p + T; \
90
b_p = (char *)b_p + sizeof(md5_uint32); \
95
* Second to Fourth Round: we have the possibly swapped words in
96
* CORRECT_WORDS. Redefine the macro to take an additional first
97
* argument specifying the function to use.
99
#define OP234(FUNC, a, b, c, d, k, s, T) \
101
a += FUNC (b, c, d) + k + T; \
106
#endif /* ! __MD5_LOC_H__ */