Changeset 1330:112784adfac8


Ignore:
Timestamp:
09/03/09 20:48:06 (2 years ago)
Author:
niam
Branch:
default
Message:

{issue #68[fixed]} fixed SHA for x86_64

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/libdodo/toolsCode.h

    r1296 r1330  
    342342                         */ 
    343343                        struct __SHA1_256Context__ { 
    344                                 unsigned long      intermediateHash[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] 
    345345 
    346346                                unsigned long long length;                  ///< message length in bits 
  • trunk/src/toolsCode.cc

    r1319 r1330  
    13511351 
    13521352//------------------------------------------------------------------- 
     1353#include <iostream> 
     1354using namespace std; 
    13531355 
    13541356void 
     
    13581360        context->messageBlockIndex = 0; 
    13591361 
    1360                 /* Initial Hash Values: FIPS-180-2 section 5.3.1 */ 
     1362        /* Initial Hash Values: FIPS-180-2 section 5.3.1 */ 
    13611363        context->intermediateHash[0] = 0x67452301; 
    13621364        context->intermediateHash[1] = 0xEFCDAB89; 
     
    14121414 
    14131415                SHA1ProcessMessageBlock(context); 
    1414         } else 
     1416        } else { 
    14151417                context->messageBlock[context->messageBlockIndex++] = padByte; 
     1418        } 
    14161419 
    14171420        while (context->messageBlockIndex < 56) 
     
    14351438code::SHA1ProcessMessageBlock(__SHA1_256Context__ *context) 
    14361439{ 
    1437                 /* Constants defined in FIPS-180-2, section 4.2.1 */ 
     1440        /* Constants defined in FIPS-180-2, section 4.2.1 */ 
    14381441        const static unsigned long K[4] = { 
    14391442                0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 
     
    14411444 
    14421445        int t; 
    1443         unsigned long temp; 
    1444         unsigned long W[80]; 
    1445         unsigned long A, B, C, D, E; 
     1446        unsigned int temp; 
     1447        unsigned int W[80]; 
     1448        unsigned int A, B, C, D, E; 
    14461449 
    14471450        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]; 
    14521455        } 
    14531456 
     
    16361639 
    16371640        int t, t4; 
    1638         unsigned long temp1, temp2; 
    1639         unsigned long W[64]; 
    1640         unsigned long A, 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; 
    16411644 
    16421645        /* 
     
    16441647         */ 
    16451648        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]); 
    16501653        } 
    16511654 
Note: See TracChangeset for help on using the changeset viewer.