Machine details:
NetBSD quickie 4.99.7 NetBSD 4.99.7 (quickie) #0: Tue Jan 2 14:47:23
PST 2007 r...@shoggoth:/v/src/sys/arch/i386/compile/quickie i386
AMD Athlon XP 2500+ (686-class), 1837.58 MHz, id 0x6a0
total memory = 2559 MB
g++ -v
Using built-in specs.
Target: i386--netbsdelf
Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --
enable-long-long --disable-multilib --enable-threads --disable-symvers
--build=i386-unknown-netbsdelf3.99.17 --host=i386--netbsdelf --
target=i386--netbsdelf
Thread model: posix
gcc version 4.1.2 20060628 prerelease (NetBSD nb2 20060711)
ld -v
GNU ld version 2.16.1
as -v
GNU assembler version 2.16.1 (i386--netbsdelf) using BFD version
2.16.1
I have crypt++ 5.6.0.
SHA256 (cryptopp560.zip) =
b522f0b5f850b50e9917823ea986f855295407380fafbe30f358875c41998bc5
I built it like so:
unzip cryptopp560.zip
gmake
My program which demonstrates the problem is:
#include <iostream>
#include "cryptlib.h"
#include "sha.h"
#include "hex.h"
#include "filters.h"
USING_NAMESPACE(CryptoPP);
int main() {
SHA256 *hash;
hash = new SHA256();
SHA256 *hash2;
hash2 = new SHA256();
std::string digest="";
std::string digest2="";
std::string a1, a2, a3;
const byte *b1, *b2, *b3;
byte b4[1024], b5[1024];
a1="aaa";
a2="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
a3="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
b1=(const byte *)a1.c_str();
b2=(const byte *)a2.c_str();
b3=(const byte *)a3.c_str();
hash->Update(b1, 3);
hash->Update(b2, 125);
hash->Final(b4);
hash2->Update(b3, 128);
hash2->Final(b5);
HexEncoder encoder(NULL, true, 2, "");
encoder.Attach(new StringSink(digest));
encoder.Put(b4, 32);
encoder.MessageEnd();
std::cout << "STRING: " << a1 << ":" << a2 << "\n";
std::cout << "SHA256: " << digest << "\n";
HexEncoder encoder2(NULL, true, 2, "");
encoder2.Attach(new StringSink(digest2));
encoder2.Put(b5, 32);
encoder2.MessageEnd();
std::cout << "STRING: " << a3 << "\n";
std::cout << "SHA256: " << digest2 << "\n";
}
Using the following two compilation lines returns different results:
g++ -DCRYPTOPP_DISABLE_X86ASM -DNDEBUG -g -O2 -DCRYPTOPP_DISABLE_SSSE3
-pipe -I. -c mytest2.cpp && g++ -o mytest2 mytest2.o -L. -lcryptopp
&& ./mytest2
WORKS and returns:
STRING:
aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SHA256:
6836CF13BAC400E9105071CD6AF47084DFACAD4E5E302C94BFED24E013AFB73E
STRING:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SHA256:
6836CF13BAC400E9105071CD6AF47084DFACAD4E5E302C94BFED24E013AFB73E
g++ -DNDEBUG -g -O2 -DCRYPTOPP_DISABLE_SSSE3 -pipe -I. -c mytest2.cpp
&& g++ -o mytest2 mytest2.o -L. -lcryptopp && ./mytest2
DOES NOT WORK and returns:
STRING:
aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SHA256:
D159F4747C64249633829F8355DC84678A67CCCE92ABC8F770D33111AFB43E42
STRING:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SHA256:
6836CF13BAC400E9105071CD6AF47084DFACAD4E5E302C94BFED24E013AFB73E
Can someone sanity check this for me please and tell me if I'm doing
something wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---