1352 | 1352 |
// which I've modified to work on 64-bit machines
|
1353 | 1353 |
|
1354 | 1354 |
|
|
1355 |
#ifndef uint32
|
|
1356 |
# if NTL_BITS_PER_INT == 32
|
|
1357 |
typedef unsigned int uint32;
|
|
1358 |
# elif NTL_BITS_PER_LONG == 32
|
|
1359 |
typedef unsigned long uint32;
|
|
1360 |
# else
|
|
1361 |
# error unable to find 32 bit type
|
|
1362 |
# endif
|
|
1363 |
#endif
|
1355 | 1364 |
/*
|
1356 | |
* BEGIN RSA's md5 stuff
|
|
1365 |
* BEGIN md5 stuff
|
1357 | 1366 |
*
|
1358 | 1367 |
*/
|
1359 | 1368 |
|
1360 | 1369 |
/*
|
1361 | |
**********************************************************************
|
1362 | |
** md5.c **
|
1363 | |
** RSA Data Security, Inc. MD5 Message Digest Algorithm **
|
1364 | |
** Created: 2/17/90 RLR **
|
1365 | |
** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
|
1366 | |
**********************************************************************
|
|
1370 |
* This code implements the MD5 message-digest algorithm.
|
|
1371 |
* The algorithm is due to Ron Rivest. This code was
|
|
1372 |
* written by Colin Plumb in 1993, no copyright is claimed.
|
|
1373 |
* This code is in the public domain; do with it what you wish.
|
|
1374 |
*
|
|
1375 |
* Equivalent code is available from RSA Data Security, Inc.
|
|
1376 |
* This code has been tested against that, and is equivalent,
|
|
1377 |
* except that you don't need to include two pages of legalese
|
|
1378 |
* with every copy.
|
|
1379 |
*
|
|
1380 |
Modified to only contain the functions needed here.
|
1367 | 1381 |
*/
|
1368 | 1382 |
|
1369 | 1383 |
/*
|
1370 | |
**********************************************************************
|
1371 | |
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
|
1372 | |
** **
|
1373 | |
** License to copy and use this software is granted provided that **
|
1374 | |
** it is identified as the "RSA Data Security, Inc. MD5 Message **
|
1375 | |
** Digest Algorithm" in all material mentioning or referencing this **
|
1376 | |
** software or this function. **
|
1377 | |
** **
|
1378 | |
** License is also granted to make and use derivative works **
|
1379 | |
** provided that such works are identified as "derived from the RSA **
|
1380 | |
** Data Security, Inc. MD5 Message Digest Algorithm" in all **
|
1381 | |
** material mentioning or referencing the derived work. **
|
1382 | |
** **
|
1383 | |
** RSA Data Security, Inc. makes no representations concerning **
|
1384 | |
** either the merchantability of this software or the suitability **
|
1385 | |
** of this software for any particular purpose. It is provided "as **
|
1386 | |
** is" without express or implied warranty of any kind. **
|
1387 | |
** **
|
1388 | |
** These notices must be retained in any copies of any part of this **
|
1389 | |
** documentation and/or software. **
|
1390 | |
**********************************************************************
|
|
1384 |
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
|
1385 |
* initialization constants.
|
1391 | 1386 |
*/
|
1392 | |
|
1393 | |
|
1394 | |
#if (NTL_BITS_PER_LONG <= 32)
|
1395 | |
#define TRUNC32(x) (x)
|
1396 | |
#else
|
1397 | |
#define TRUNC32(x) ((x) & ((1UL << 32)-1UL))
|
1398 | |
#endif
|
1399 | |
|
1400 | |
/* F, G and H are basic MD5 functions: selection, majority, parity */
|
1401 | |
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
1402 | |
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
1403 | |
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
1404 | |
#define I(x, y, z) (TRUNC32((y) ^ ((x) | (~z))))
|
1405 | |
|
1406 | |
/* ROTATE_LEFT rotates x left n bits */
|
1407 | |
#define ROTATE_LEFT(x, n) (TRUNC32(((x) << (n)) | ((x) >> (32-(n)))))
|
1408 | |
|
1409 | |
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
|
1410 | |
/* Rotation is separate from addition to prevent recomputation */
|
1411 | |
#define FF(a, b, c, d, x, s, ac) \
|
1412 | |
{(a) = TRUNC32((a) + F((b), (c), (d)) + (x) + (ac)); \
|
1413 | |
(a) = ROTATE_LEFT((a), (s)); \
|
1414 | |
(a) = TRUNC32((a) + (b)); \
|
1415 | |
}
|
1416 | |
#define GG(a, b, c, d, x, s, ac) \
|
1417 | |
{(a) = TRUNC32((a) + G((b), (c), (d)) + (x) + (ac)); \
|
1418 | |
(a) = ROTATE_LEFT((a), (s)); \
|
1419 | |
(a) = TRUNC32((a) + (b)); \
|
1420 | |
}
|
1421 | |
#define HH(a, b, c, d, x, s, ac) \
|
1422 | |
{(a) = TRUNC32((a) + H((b), (c), (d)) + (x) + (ac)); \
|
1423 | |
(a) = ROTATE_LEFT((a), (s)); \
|
1424 | |
(a) = TRUNC32((a) + (b)); \
|
1425 | |
}
|
1426 | |
#define II(a, b, c, d, x, s, ac) \
|
1427 | |
{(a) = TRUNC32((a) + I((b), (c), (d)) + (x) + (ac)); \
|
1428 | |
(a) = ROTATE_LEFT((a), (s)); \
|
1429 | |
(a) = TRUNC32((a) + (b)); \
|
1430 | |
}
|
1431 | |
|
1432 | |
|
1433 | |
|
1434 | 1387 |
static
|
1435 | |
void MD5_default_IV(unsigned long *buf)
|
1436 | |
{
|
1437 | |
buf[0] = 0x67452301UL;
|
1438 | |
buf[1] = 0xefcdab89UL;
|
1439 | |
buf[2] = 0x98badcfeUL;
|
1440 | |
buf[3] = 0x10325476UL;
|
1441 | |
}
|
1442 | |
|
1443 | |
|
1444 | |
|
1445 | |
/* Basic MD5 step. Transform buf based on in.
|
|
1388 |
void MD5Init(uint32 buf[4])
|
|
1389 |
{
|
|
1390 |
buf[0] = 0x67452301U;
|
|
1391 |
buf[1] = 0xefcdab89U;
|
|
1392 |
buf[2] = 0x98badcfeU;
|
|
1393 |
buf[3] = 0x10325476U;
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
/* The four core functions - F1 is optimized somewhat */
|
|
1397 |
|
|
1398 |
/* #define F1(x, y, z) (x & y | ~x & z) */
|
|
1399 |
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
|
1400 |
#define F2(x, y, z) F1(z, x, y)
|
|
1401 |
#define F3(x, y, z) (x ^ y ^ z)
|
|
1402 |
#define F4(x, y, z) (y ^ (x | ~z))
|
|
1403 |
|
|
1404 |
/* This is the central step in the MD5 algorithm. */
|
|
1405 |
#define MD5STEP(f, w, x, y, z, data, s) \
|
|
1406 |
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
|
|
1407 |
|
|
1408 |
/*
|
|
1409 |
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
|
1410 |
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
|
1411 |
* the data and converts bytes into longwords for this routine.
|
1446 | 1412 |
*/
|
1447 | |
|
1448 | 1413 |
static
|
1449 | |
void MD5_compress(unsigned long *buf, unsigned long *in)
|
1450 | |
{
|
1451 | |
unsigned long a = buf[0], b = buf[1], c = buf[2], d = buf[3];
|
1452 | |
|
1453 | |
/* Round 1 */
|
1454 | |
#define S11 7
|
1455 | |
#define S12 12
|
1456 | |
#define S13 17
|
1457 | |
#define S14 22
|
1458 | |
FF ( a, b, c, d, in[ 0], S11, 3614090360UL); /* 1 */
|
1459 | |
FF ( d, a, b, c, in[ 1], S12, 3905402710UL); /* 2 */
|
1460 | |
FF ( c, d, a, b, in[ 2], S13, 606105819UL); /* 3 */
|
1461 | |
FF ( b, c, d, a, in[ 3], S14, 3250441966UL); /* 4 */
|
1462 | |
FF ( a, b, c, d, in[ 4], S11, 4118548399UL); /* 5 */
|
1463 | |
FF ( d, a, b, c, in[ 5], S12, 1200080426UL); /* 6 */
|
1464 | |
FF ( c, d, a, b, in[ 6], S13, 2821735955UL); /* 7 */
|
1465 | |
FF ( b, c, d, a, in[ 7], S14, 4249261313UL); /* 8 */
|
1466 | |
FF ( a, b, c, d, in[ 8], S11, 1770035416UL); /* 9 */
|
1467 | |
FF ( d, a, b, c, in[ 9], S12, 2336552879UL); /* 10 */
|
1468 | |
FF ( c, d, a, b, in[10], S13, 4294925233UL); /* 11 */
|
1469 | |
FF ( b, c, d, a, in[11], S14, 2304563134UL); /* 12 */
|
1470 | |
FF ( a, b, c, d, in[12], S11, 1804603682UL); /* 13 */
|
1471 | |
FF ( d, a, b, c, in[13], S12, 4254626195UL); /* 14 */
|
1472 | |
FF ( c, d, a, b, in[14], S13, 2792965006UL); /* 15 */
|
1473 | |
FF ( b, c, d, a, in[15], S14, 1236535329UL); /* 16 */
|
1474 | |
|
1475 | |
/* Round 2 */
|
1476 | |
#define S21 5
|
1477 | |
#define S22 9
|
1478 | |
#define S23 14
|
1479 | |
#define S24 20
|
1480 | |
GG ( a, b, c, d, in[ 1], S21, 4129170786UL); /* 17 */
|
1481 | |
GG ( d, a, b, c, in[ 6], S22, 3225465664UL); /* 18 */
|
1482 | |
GG ( c, d, a, b, in[11], S23, 643717713UL); /* 19 */
|
1483 | |
GG ( b, c, d, a, in[ 0], S24, 3921069994UL); /* 20 */
|
1484 | |
GG ( a, b, c, d, in[ 5], S21, 3593408605UL); /* 21 */
|
1485 | |
GG ( d, a, b, c, in[10], S22, 38016083UL); /* 22 */
|
1486 | |
GG ( c, d, a, b, in[15], S23, 3634488961UL); /* 23 */
|
1487 | |
GG ( b, c, d, a, in[ 4], S24, 3889429448UL); /* 24 */
|
1488 | |
GG ( a, b, c, d, in[ 9], S21, 568446438UL); /* 25 */
|
1489 | |
GG ( d, a, b, c, in[14], S22, 3275163606UL); /* 26 */
|
1490 | |
GG ( c, d, a, b, in[ 3], S23, 4107603335UL); /* 27 */
|
1491 | |
GG ( b, c, d, a, in[ 8], S24, 1163531501UL); /* 28 */
|
1492 | |
GG ( a, b, c, d, in[13], S21, 2850285829UL); /* 29 */
|
1493 | |
GG ( d, a, b, c, in[ 2], S22, 4243563512UL); /* 30 */
|
1494 | |
GG ( c, d, a, b, in[ 7], S23, 1735328473UL); /* 31 */
|
1495 | |
GG ( b, c, d, a, in[12], S24, 2368359562UL); /* 32 */
|
1496 | |
|
1497 | |
/* Round 3 */
|
1498 | |
#define S31 4
|
1499 | |
#define S32 11
|
1500 | |
#define S33 16
|
1501 | |
#define S34 23
|
1502 | |
HH ( a, b, c, d, in[ 5], S31, 4294588738UL); /* 33 */
|
1503 | |
HH ( d, a, b, c, in[ 8], S32, 2272392833UL); /* 34 */
|
1504 | |
HH ( c, d, a, b, in[11], S33, 1839030562UL); /* 35 */
|
1505 | |
HH ( b, c, d, a, in[14], S34, 4259657740UL); /* 36 */
|
1506 | |
HH ( a, b, c, d, in[ 1], S31, 2763975236UL); /* 37 */
|
1507 | |
HH ( d, a, b, c, in[ 4], S32, 1272893353UL); /* 38 */
|
1508 | |
HH ( c, d, a, b, in[ 7], S33, 4139469664UL); /* 39 */
|
1509 | |
HH ( b, c, d, a, in[10], S34, 3200236656UL); /* 40 */
|
1510 | |
HH ( a, b, c, d, in[13], S31, 681279174UL); /* 41 */
|
1511 | |
HH ( d, a, b, c, in[ 0], S32, 3936430074UL); /* 42 */
|
1512 | |
HH ( c, d, a, b, in[ 3], S33, 3572445317UL); /* 43 */
|
1513 | |
HH ( b, c, d, a, in[ 6], S34, 76029189UL); /* 44 */
|
1514 | |
HH ( a, b, c, d, in[ 9], S31, 3654602809UL); /* 45 */
|
1515 | |
HH ( d, a, b, c, in[12], S32, 3873151461UL); /* 46 */
|
1516 | |
HH ( c, d, a, b, in[15], S33, 530742520UL); /* 47 */
|
1517 | |
HH ( b, c, d, a, in[ 2], S34, 3299628645UL); /* 48 */
|
1518 | |
|
1519 | |
/* Round 4 */
|
1520 | |
#define S41 6
|
1521 | |
#define S42 10
|
1522 | |
#define S43 15
|
1523 | |
#define S44 21
|
1524 | |
II ( a, b, c, d, in[ 0], S41, 4096336452UL); /* 49 */
|
1525 | |
II ( d, a, b, c, in[ 7], S42, 1126891415UL); /* 50 */
|
1526 | |
II ( c, d, a, b, in[14], S43, 2878612391UL); /* 51 */
|
1527 | |
II ( b, c, d, a, in[ 5], S44, 4237533241UL); /* 52 */
|
1528 | |
II ( a, b, c, d, in[12], S41, 1700485571UL); /* 53 */
|
1529 | |
II ( d, a, b, c, in[ 3], S42, 2399980690UL); /* 54 */
|
1530 | |
II ( c, d, a, b, in[10], S43, 4293915773UL); /* 55 */
|
1531 | |
II ( b, c, d, a, in[ 1], S44, 2240044497UL); /* 56 */
|
1532 | |
II ( a, b, c, d, in[ 8], S41, 1873313359UL); /* 57 */
|
1533 | |
II ( d, a, b, c, in[15], S42, 4264355552UL); /* 58 */
|
1534 | |
II ( c, d, a, b, in[ 6], S43, 2734768916UL); /* 59 */
|
1535 | |
II ( b, c, d, a, in[13], S44, 1309151649UL); /* 60 */
|
1536 | |
II ( a, b, c, d, in[ 4], S41, 4149444226UL); /* 61 */
|
1537 | |
II ( d, a, b, c, in[11], S42, 3174756917UL); /* 62 */
|
1538 | |
II ( c, d, a, b, in[ 2], S43, 718787259UL); /* 63 */
|
1539 | |
II ( b, c, d, a, in[ 9], S44, 3951481745UL); /* 64 */
|
1540 | |
|
1541 | |
buf[0] = TRUNC32(buf[0] + a);
|
1542 | |
buf[1] = TRUNC32(buf[1] + b);
|
1543 | |
buf[2] = TRUNC32(buf[2] + c);
|
1544 | |
buf[3] = TRUNC32(buf[3] + d);
|
|
1414 |
void MD5Transform(uint32 buf[4], uint32 const in[16])
|
|
1415 |
{
|
|
1416 |
register uint32 a, b, c, d;
|
|
1417 |
|
|
1418 |
a = buf[0];
|
|
1419 |
b = buf[1];
|
|
1420 |
c = buf[2];
|
|
1421 |
d = buf[3];
|
|
1422 |
|
|
1423 |
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478U, 7);
|
|
1424 |
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756U, 12);
|
|
1425 |
MD5STEP(F1, c, d, a, b, in[2] + 0x242070dbU, 17);
|
|
1426 |
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceeeU, 22);
|
|
1427 |
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0fafU, 7);
|
|
1428 |
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62aU, 12);
|
|
1429 |
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613U, 17);
|
|
1430 |
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501U, 22);
|
|
1431 |
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8U, 7);
|
|
1432 |
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7afU, 12);
|
|
1433 |
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1U, 17);
|
|
1434 |
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7beU, 22);
|
|
1435 |
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122U, 7);
|
|
1436 |
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193U, 12);
|
|
1437 |
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438eU, 17);
|
|
1438 |
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821U, 22);
|
|
1439 |
|
|
1440 |
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562U, 5);
|
|
1441 |
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340U, 9);
|
|
1442 |
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51U, 14);
|
|
1443 |
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aaU, 20);
|
|
1444 |
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105dU, 5);
|
|
1445 |
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453U, 9);
|
|
1446 |
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
|
1447 |
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8U, 20);
|
|
1448 |
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6U, 5);
|
|
1449 |
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6U, 9);
|
|
1450 |
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87U, 14);
|
|
1451 |
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14edU, 20);
|
|
1452 |
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905U, 5);
|
|
1453 |
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8U, 9);
|
|
1454 |
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9U, 14);
|
|
1455 |
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8aU, 20);
|
|
1456 |
|
|
1457 |
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942U, 4);
|
|
1458 |
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681U, 11);
|
|
1459 |
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122U, 16);
|
|
1460 |
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380cU, 23);
|
|
1461 |
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44U, 4);
|
|
1462 |
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9U, 11);
|
|
1463 |
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60U, 16);
|
|
1464 |
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70U, 23);
|
|
1465 |
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6U, 4);
|
|
1466 |
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127faU, 11);
|
|
1467 |
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085U, 16);
|
|
1468 |
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05U, 23);
|
|
1469 |
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039U, 4);
|
|
1470 |
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5U, 11);
|
|
1471 |
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8U, 16);
|
|
1472 |
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665U, 23);
|
|
1473 |
|
|
1474 |
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244U, 6);
|
|
1475 |
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97U, 10);
|
|
1476 |
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7U, 15);
|
|
1477 |
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039U, 21);
|
|
1478 |
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3U, 6);
|
|
1479 |
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92U, 10);
|
|
1480 |
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47dU, 15);
|
|
1481 |
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1U, 21);
|
|
1482 |
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4fU, 6);
|
|
1483 |
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0U, 10);
|
|
1484 |
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314U, 15);
|
|
1485 |
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1U, 21);
|
|
1486 |
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82U, 6);
|
|
1487 |
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235U, 10);
|
|
1488 |
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bbU, 15);
|
|
1489 |
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391U, 21);
|
|
1490 |
|
|
1491 |
buf[0] += a;
|
|
1492 |
buf[1] += b;
|
|
1493 |
buf[2] += c;
|
|
1494 |
buf[3] += d;
|
1545 | 1495 |
}
|
1546 | 1496 |
|
1547 | 1497 |
|
1548 | 1498 |
/*
|
1549 | |
* END RSA's md5 stuff
|
|
1499 |
* END md5 stuff
|
1550 | 1500 |
*
|
1551 | 1501 |
*/
|
1552 | 1502 |
|
1553 | 1503 |
|
1554 | 1504 |
static
|
1555 | |
void words_from_bytes(unsigned long *txtl, unsigned char *txtc, long n)
|
|
1505 |
void words_from_bytes(uint32 *txtl, unsigned char *txtc, long n)
|
1556 | 1506 |
{
|
1557 | 1507 |
long i;
|
1558 | 1508 |
unsigned long v;
|
|
1567 | 1517 |
}
|
1568 | 1518 |
|
1569 | 1519 |
static
|
1570 | |
void bytes_from_words(unsigned char *txtc, unsigned long *txtl, long n)
|
|
1520 |
void bytes_from_words(unsigned char *txtc, uint32 *txtl, long n)
|
1571 | 1521 |
{
|
1572 | 1522 |
long i;
|
1573 | 1523 |
unsigned long v;
|
|
1586 | 1536 |
|
1587 | 1537 |
|
1588 | 1538 |
static
|
1589 | |
void MD5_compress1(unsigned long *buf, unsigned char *in, long n)
|
1590 | |
{
|
1591 | |
unsigned long txtl[16];
|
|
1539 |
void MD5_compress1(uint32 *buf, unsigned char *in, long n)
|
|
1540 |
{
|
|
1541 |
uint32 txtl[16];
|
1592 | 1542 |
unsigned char txtc[64];
|
1593 | 1543 |
long i, j, k;
|
1594 | 1544 |
|
|
1603 | 1553 |
for (; j < 64; j++)
|
1604 | 1554 |
txtc[j] = 0;
|
1605 | 1555 |
words_from_bytes(txtl, txtc, 16);
|
1606 | |
MD5_compress(buf, txtl);
|
|
1556 |
MD5Transform(buf, txtl);
|
1607 | 1557 |
i += k;
|
1608 | 1558 |
}
|
1609 | 1559 |
}
|
|
1688 | 1638 |
static long ran_initialized = 0;
|
1689 | 1639 |
static _ZZ_arc4_key ran_key;
|
1690 | 1640 |
|
1691 | |
static unsigned long default_md5_tab[16] = {
|
|
1641 |
static uint32 default_md5_tab[16] = {
|
1692 | 1642 |
744663023UL, 1011602954UL, 3163087192UL, 3383838527UL,
|
1693 | 1643 |
3305324122UL, 3197458079UL, 2266495600UL, 2760303563UL,
|
1694 | 1644 |
346234297UL, 1919920720UL, 1896169861UL, 2192176675UL,
|
|
1712 | 1662 |
|
1713 | 1663 |
bytes_from_words(txt + nb + 4, default_md5_tab, 16);
|
1714 | 1664 |
|
1715 | |
unsigned long buf[4];
|
1716 | |
|
1717 | |
unsigned long i;
|
|
1665 |
uint32 buf[4];
|
|
1666 |
|
|
1667 |
uint32 i;
|
1718 | 1668 |
for (i = 0; i < 16; i++) {
|
1719 | |
MD5_default_IV(buf);
|
|
1669 |
MD5Init(buf);
|
1720 | 1670 |
bytes_from_words(txt, &i, 1);
|
1721 | 1671 |
|
1722 | 1672 |
MD5_compress1(buf, txt, nb + 68);
|