2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A ********************************************************************** 2N/A ** RSA Data Security, Inc. MD4 Message Digest Algorithm ** 2N/A ** Created: 2/17/90 RLR ** 2N/A ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version ** 2N/A ********************************************************************** 2N/A ********************************************************************** 2N/A ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** 2N/A ** License to copy and use this software is granted provided that ** 2N/A ** it is identified as the "RSA Data Security, Inc. MD4 Message ** 2N/A ** Digest Algorithm" in all material mentioning or referencing this ** 2N/A ** software or this function. ** 2N/A ** License is also granted to make and use derivative works ** 2N/A ** provided that such works are identified as "derived from the RSA ** 2N/A ** Data Security, Inc. MD4 Message Digest Algorithm" in all ** 2N/A ** material mentioning or referencing the derived work. ** 2N/A ** RSA Data Security, Inc. makes no representations concerning ** 2N/A ** either the merchantability of this software or the suitability ** 2N/A ** of this software for any particular purpose. It is provided "as ** 2N/A ** is" without express or implied warranty of any kind. ** 2N/A ** These notices must be retained in any copies of any part of this ** 2N/A ********************************************************************** 2N/A/* forward declaration */ 2N/A 0x80,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
2N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
2N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
2N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
2N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
2N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
2N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
2N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00 2N/A/* F, G and H are basic MD4 functions: selection, majority, parity */ 2N/A#
define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
2N/A#
define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
2N/A#
define H(x, y, z) ((x) ^ (y) ^ (z))
2N/A/* ROTATE_LEFT rotates x left n bits */ 2N/A#
define ROTATE_LEFT(x, n) ((((x) << (n)) &
0xffffffff) | ((x) >> (
32-(n))))
2N/A/* FF, GG and HH are MD4 transformations for rounds 1, 2 and 3 */ 2N/A/* Rotation is separate from addition to prevent recomputation */ 2N/A#
define FF(a, b, c, d, x, s) \
2N/A {(a) += F ((b), (c), (d)) + (x); \
2N/A (a) &=
0xffffffff; \
2N/A#
define GG(a, b, c, d, x, s) \
2N/A {(a) += G ((b), (c), (d)) + (x) + 0
13240474631UL; \
2N/A (a) &=
0xffffffff; \
2N/A#
define HH(a, b, c, d, x, s) \
2N/A {(a) += H ((b), (c), (d)) + (x) + 0
15666365641UL; \
2N/A (a) &=
0xffffffff; \
2N/A /* Load magic initialization constants. 2N/A /* compute number of bytes mod 64 */ 2N/A /* update number of bits */ 2N/A /* add new character to buffer, increment mdi */ 2N/A /* transform if necessary */ 2N/A for (i = 0,
ii = 0; i <
16; i++,
ii +=
4)
2N/A /* save number of bits */ 2N/A /* compute number of bytes mod 64 */ 2N/A /* pad out to 56 mod 64 */ 2N/A /* append length in bits and transform */ 2N/A for (i = 0,
ii = 0; i <
14; i++,
ii +=
4)
2N/A /* store buffer in digest */ 2N/A for (i = 0,
ii = 0; i <
4; i++,
ii +=
4) {
2N/A/* Basic MD4 step. Transform buf based on in. 2N/A for (i = 0; i <
16; i++) {
2N/A for (i = 0; i <
16; i++) {
2N/A 0,
4,
8,
12,
1,
5,
9,
13,
2,
6,
10,
14,
3,
7,
11,
15 2N/A for (i = 0; i <
16; i++) {
2N/A 0,
8,
4,
12,
2,
10,
6,
14,
1,
9,
5,
13,
3,
11,
7,
15 2N/A ********************************************************************** 2N/A ******************************* (cut) ********************************