1N/A/* md5.c - an implementation of the MD5 algorithm and MD5 crypt */ 1N/A * GRUB -- GRand Unified Bootloader 1N/A * Copyright (C) 2000, 2001 Free Software Foundation, Inc. 1N/A * This program is free software; you can redistribute it and/or modify 1N/A * it under the terms of the GNU General Public License as published by 1N/A * the Free Software Foundation; either version 2 of the License, or 1N/A * (at your option) any later version. 1N/A * This program is distributed in the hope that it will be useful, 1N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of 1N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1N/A * GNU General Public License for more details. 1N/A * You should have received a copy of the GNU General Public License 1N/A * along with this program; if not, write to the Free Software 1N/A * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 1N/A/* See RFC 1321 for a description of the MD5 algorithm. 1N/A/* F, G, H and I are basic MD5 functions. 1N/A#
define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
1N/A#
define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
1N/A#
define H(x, y, z) ((x) ^ (y) ^ (z))
1N/A#
define I(x, y, z) ((y) ^ ((x) | (~z)))
1N/A/* ROTATE_LEFT rotates x left n bits. 1N/A 0x67452301,
0xefcdab89,
0x98badcfe,
0x10325476 1N/Astatic char s1[
4] = {
7,
12,
17,
22 };
1N/Astatic char s2[
4] = {
5,
9,
14,
20 };
1N/Astatic char s3[
4] = {
4,
11,
16,
23 };
1N/Astatic char s4[
4] = {
6,
10,
15,
21 };
1N/A 0xd76aa478,
0xe8c7b756,
0x242070db,
0xc1bdceee,
1N/A 0xf57c0faf,
0x4787c62a,
0xa8304613,
0xfd469501,
1N/A 0x698098d8,
0x8b44f7af,
0xffff5bb1,
0x895cd7be,
1N/A 0x6b901122,
0xfd987193,
0xa679438e,
0x49b40821,
1N/A 0xf61e2562,
0xc040b340,
0x265e5a51,
0xe9b6c7aa,
1N/A 0xd62f105d,
0x02441453,
0xd8a1e681,
0xe7d3fbc8,
1N/A 0x21e1cde6,
0xc33707d6,
0xf4d50d87,
0x455a14ed,
1N/A 0xa9e3e905,
0xfcefa3f8,
0x676f02d9,
0x8d2a4c8a,
1N/A 0xfffa3942,
0x8771f681,
0x6d9d6122,
0xfde5380c,
1N/A 0xa4beea44,
0x4bdecfa9,
0xf6bb4b60,
0xbebfbc70,
1N/A 0x289b7ec6,
0xeaa127fa,
0xd4ef3085,
0x04881d05,
1N/A 0xd9d4d039,
0xe6db99e5,
0x1fa27cf8,
0xc4ac5665,
1N/A 0xf4292244,
0x432aff97,
0xab9423a7,
0xfc93a039,
1N/A 0x655b59c3,
0x8f0ccc92,
0xffeff47d,
0x85845dd1,
1N/A 0x6fa87e4f,
0xfe2ce6e0,
0xa3014314,
0x4e0811a1,
1N/A 0xf7537e82,
0xbd3af235,
0x2ad7d2bb,
0xeb86d391 1N/A"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
1N/A for (i = 0; i <
16; i++)
1N/A for (i = 0, j =
1; i <
16; i++, j +=
5)
1N/A for (i = 0, j =
5; i <
16; i++, j +=
3)
1N/A for (i = 0, j = 0; i <
16; i++, j +=
7)
1N/Astatic unsigned char *
1N/A for (i = 0; i <
4; i++)
1N/A/* If CHECK is true, check a password for correctness. Returns 0 1N/A if password was correct, and a value != 0 for error, similarly 1N/A If CHECK is false, crypt KEY and save the result in CRYPTED. 1N/A CRYPTED must have a salt. */ 1N/A /* If our crypted password isn't 3 chars, then it can't be md5 1N/A crypted. So, they don't match. */ 1N/A for (i = 0; i <
1000; i++)
1N/A for (i = 0; i <
5; i++)
1N/A for (n =
4; n-- > 0;)
1N/A for (n =
2; n-- > 0;)
1N/A for (i=0; i <
16; i++)
1N/A test (
"",
"d41d8cd98f00b204e9800998ecf8427e");
1N/A test (
"a",
"0cc175b9c0f1b6a831c399e269772661");
1N/A test (
"abc",
"900150983cd24fb0d6963f7d28e17f72");
1N/A test (
"message digest",
"f96b697d7cb7938d525a2f31aaf161d0");
1N/A test (
"abcdefghijklmnopqrstuvwxyz",
"c3fcd3d76192e4007dfb496cca67e13b");
1N/A test (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
1N/A "d174ab98d277d9f5a5611c2c9f419d9f");
1N/A test (
"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
1N/A "57edf4a22be3c955ac49da2e2107b67a");
1N/A test (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz3456",
1N/A "6831fa90115bb9a54fbcd4f9fee0b5c4");
1N/A test (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz345",
1N/A "bc40505cc94a43b7ff3e2ac027325233");
1N/A test (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz34567",
1N/A "fa94b73a6f072a0239b52acacfbcf9fa");
1N/A test (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz345678901234",
1N/A "bd201eae17f29568927414fa326f1267");
1N/A test (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz34567890123",
1N/A "80063db1e6b70a2e91eac903f0e46b85");
1N/A "$1$saltstri$YMyguxXMBpd2TEZ.vS/3q1"))