|
Hi, On little-endian machines the following code generates
different results than it does on big-endian machines.
byte Data[128];
byte shaSig[20];
for( int i = 0; i < 128; i++ )
{ Data[
i ] = i;
}
SHA sSHA;
sSHA.CalculateDigest((byte*)shaSig, (byte*)Data, 128 );
printf( "SHA = " );
for( int i=0; i<20; i++ )
{ int
temp = (unsigned char)shaSig[i]; printf(
"\\x%x", temp );
}
printf( "\n" ); Little endian: SHA = \xe6\x43\x4b\xc4\x1\xf9\x86\x3\xd7\xed\xa5\x4\x79\xc\x98\xc6\x73\x85\xd5\x35 Big endian: SHA =
\xf3\xea\xa8\xb0\xde\x40\xc8\xcd\xbc\x53\x56\x96\xfd\x1d\x6b\xc3\x19\xaa\xbd\x21 (I’m running on linux with gcc 3, solaris with gcc 4,
windows with VC6, and hp itanium with gcc 3, and a whole bunch of others.
I’m using cryptopp 5.2.1.) This affects NR<SHA> so that a byte stream signed on
one platform won’t be verified on another. There is surely some
obvious way to get the behavior I desire, but I don’t see what it is. Thanks, Bill |
- Endian issues with SHA? Bill Shanahan
- Re: Endian issues with SHA? Wei Dai
- RE: Endian issues with SHA? Bill Shanahan
- Re: Endian issues with SHA? Wei Dai
- RE: Endian issues with SHA? Nicholas Land
