** Warning: Cannot open xref database.
1 /*
2 * Local defines for the md5 functions.
3 *
4 * $Id: md5_loc.h,v 1.2 2002/06/12 14:30:12 pbd Exp $
5 */
6
7 /*
8 * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
9 * rights reserved.
10 *
11 * License to copy and use this software is granted provided that it is
12 * identified as the "RSA Data Security, Inc. MD5 Message-Digest
13 * Algorithm" in all material mentioning or referencing this software
14 * or this function.
15 *
16 * License is also granted to make and use derivative works provided that
17 * such works are identified as "derived from the RSA Data Security,
18 * Inc. MD5 Message-Digest Algorithm" in all material mentioning or
19 * referencing the derived work.
20 *
21 * RSA Data Security, Inc. makes no representations concerning either the
22 * merchantability of this software or the suitability of this
23 * software for any particular purpose. It is provided "as is" without
24 * express or implied warranty of any kind.
25 *
26 * These notices must be retained in any copies of any part of this
27 * documentation and/or software.
28 */
29
30 #ifndef __MD5_LOC_H__
31 #define __MD5_LOC_H__
32
33 #define HEX_STRING "0123456789abcdef" /* to convert to hex */
34 #define BLOCK_SIZE_MASK (MD5_BLOCK_SIZE - 1)
35
36
37 #include <config.h>
38
39 /*
40 * Define my endian-ness. Could not do in a portable manner using the
41 * include files -- grumble.
42 */
43 #ifdef WORDS_BIGENDIAN
44 /*
45 * big endian - big is better
46 */
47 #define SWAP(n) \
48 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
49 #else
50 /*
51 + * little endian
52 + */
53 #define SWAP(n) (n)
54 #endif
55
56 /*
57 * These are the four functions used in the four steps of the MD5
58 * algorithm and defined in the RFC 1321. The first function is a
59 * little bit optimized (as found in Colin Plumbs public domain
60 * implementation).
61 */
62 /* #define FF(b, c, d) ((b & c) | (~b & d)) */
63 #define FF(b, c, d) (d ^ (b & (c ^ d)))
64 #define FG(b, c, d) FF(d, b, c)
65 #define FH(b, c, d) (b ^ c ^ d)
66 #define FI(b, c, d) (c ^ (b | ~d))
67
68 /*
69 * It is unfortunate that C does not provide an operator for cyclic
70 * rotation. Hope the C compiler is smart enough. -- Modified to
71 * remove the w = at the front - Gray 2/97
72 */
73 #define CYCLIC(w, s) ((w << s) | (w >> (32 - s)))
74
75 /*
76 * First Round: using the given function, the context and a constant
77 * the next context is computed. Because the algorithms processing
78 * unit is a 32-bit word and it is determined to work on words in
79 * little endian byte order we perhaps have to change the byte order
80 * before the computation. To reduce the work for the next steps we
81 * store the swapped words in the array CORRECT_WORDS. -- Modified to
82 * fix the handling of unaligned buffer spaces - Gray 7/97
83 */
84 #define OP1(a, b, c, d, b_p, c_p, s, T) \
85 do { \
86 memcpy(c_p, b_p, sizeof(md5_uint32)); \
87 *c_p = SWAP(*c_p); \
88 a += FF (b, c, d) + *c_p + T; \
89 a = CYCLIC (a, s); \
90 a += b; \
91 b_p = (char *)b_p + sizeof(md5_uint32); \
92 c_p++; \
93 } while (0)
94
95 /*
96 * Second to Fourth Round: we have the possibly swapped words in
97 * CORRECT_WORDS. Redefine the macro to take an additional first
98 * argument specifying the function to use.
99 */
100 #define OP234(FUNC, a, b, c, d, k, s, T) \
101 do { \
102 a += FUNC (b, c, d) + k + T; \
103 a = CYCLIC (a, s); \
104 a += b; \
105 } while (0)
106
107 #endif /* ! __MD5_LOC_H__ */
108
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.