Changeset 1330:112784adfac8
- Timestamp:
- 09/03/09 20:48:06 (2 years ago)
- Branch:
- default
- Location:
- trunk
- Files:
-
- 2 edited
-
include/libdodo/toolsCode.h (modified) (1 diff)
-
src/toolsCode.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/libdodo/toolsCode.h
r1296 r1330 342 342 */ 343 343 struct __SHA1_256Context__ { 344 unsigned longintermediateHash[8]; ///< message digest [5 for SHA-1 and 8 for SHA-251]344 unsigned int intermediateHash[8]; ///< message digest [5 for SHA-1 and 8 for SHA-251] 345 345 346 346 unsigned long long length; ///< message length in bits -
trunk/src/toolsCode.cc
r1319 r1330 1351 1351 1352 1352 //------------------------------------------------------------------- 1353 #include <iostream> 1354 using namespace std; 1353 1355 1354 1356 void … … 1358 1360 context->messageBlockIndex = 0; 1359 1361 1360 /* Initial Hash Values: FIPS-180-2 section 5.3.1 */1362 /* Initial Hash Values: FIPS-180-2 section 5.3.1 */ 1361 1363 context->intermediateHash[0] = 0x67452301; 1362 1364 context->intermediateHash[1] = 0xEFCDAB89; … … 1412 1414 1413 1415 SHA1ProcessMessageBlock(context); 1414 } else 1416 } else { 1415 1417 context->messageBlock[context->messageBlockIndex++] = padByte; 1418 } 1416 1419 1417 1420 while (context->messageBlockIndex < 56) … … 1435 1438 code::SHA1ProcessMessageBlock(__SHA1_256Context__ *context) 1436 1439 { 1437 /* Constants defined in FIPS-180-2, section 4.2.1 */1440 /* Constants defined in FIPS-180-2, section 4.2.1 */ 1438 1441 const static unsigned long K[4] = { 1439 1442 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 … … 1441 1444 1442 1445 int t; 1443 unsigned longtemp;1444 unsigned longW[80];1445 unsigned longA, B, C, D, E;1446 unsigned int temp; 1447 unsigned int W[80]; 1448 unsigned int A, B, C, D, E; 1446 1449 1447 1450 for (t = 0; t < 16; ++t) { 1448 W[t] = (unsigned long)context->messageBlock[t * 4] << 24;1449 W[t] |= (unsigned long)context->messageBlock[t * 4 + 1] << 16;1450 W[t] |= (unsigned long)context->messageBlock[t * 4 + 2] << 8;1451 W[t] |= (unsigned long)context->messageBlock[t * 4 + 3];1451 W[t] = (unsigned int)context->messageBlock[t * 4] << 24; 1452 W[t] |= (unsigned int)context->messageBlock[t * 4 + 1] << 16; 1453 W[t] |= (unsigned int)context->messageBlock[t * 4 + 2] << 8; 1454 W[t] |= (unsigned int)context->messageBlock[t * 4 + 3]; 1452 1455 } 1453 1456 … … 1636 1639 1637 1640 int t, t4; 1638 unsigned longtemp1, temp2;1639 unsigned longW[64];1640 unsigned longA, B, C, D, E, F, G, H;1641 unsigned int temp1, temp2; 1642 unsigned int W[64]; 1643 unsigned int A, B, C, D, E, F, G, H; 1641 1644 1642 1645 /* … … 1644 1647 */ 1645 1648 for (t = t4 = 0; t < 16; t++, t4 += 4) { 1646 W[t] = ((unsigned long)context->messageBlock[t4] << 24) |1647 ((unsigned long)context->messageBlock[t4 + 1] << 16) |1648 ((unsigned long)context->messageBlock[t4 + 2] << 8) |1649 ((unsigned long)context->messageBlock[t4 + 3]);1649 W[t] = ((unsigned int)context->messageBlock[t4] << 24) | 1650 ((unsigned int)context->messageBlock[t4 + 1] << 16) | 1651 ((unsigned int)context->messageBlock[t4 + 2] << 8) | 1652 ((unsigned int)context->messageBlock[t4 + 3]); 1650 1653 } 1651 1654
Note: See TracChangeset
for help on using the changeset viewer.
