diff options
author | Nils Schneider <nils.schneider@gmail.com> | 2011-09-27 20:16:07 +0200 |
---|---|---|
committer | Nils Schneider <nils.schneider@gmail.com> | 2011-09-30 20:00:22 +0200 |
commit | 6ccff2cbdebca38e4913b679784a4865edfbb12a (patch) | |
tree | e13e71eb80ffa412810edcae47eea4f2b86e5b2d /src/main.cpp | |
parent | f4769e44a326f61bdf47fa39346e1293b97e31c4 (diff) |
remove cryptopp dependency, add simple unittest for SHA256Transform()
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp index 472c80a33a..f157710816 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,6 @@ #include "db.h" #include "net.h" #include "init.h" -#include "cryptopp/sha.h" #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> @@ -2614,15 +2613,25 @@ int static FormatHashBlocks(void* pbuffer, unsigned int len) return blocks; } -using CryptoPP::ByteReverse; - static const unsigned int pSHA256InitState[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; -inline void SHA256Transform(void* pstate, void* pinput, const void* pinit) +void SHA256Transform(void* pstate, void* pinput, const void* pinit) { - memcpy(pstate, pinit, 32); - CryptoPP::SHA256::Transform((CryptoPP::word32*)pstate, (CryptoPP::word32*)pinput); + SHA256_CTX ctx; + unsigned char data[64]; + + SHA256_Init(&ctx); + + for (int i = 0; i < 16; i++) + ((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]); + + for (int i = 0; i < 8; i++) + ctx.h[i] = ((uint32_t*)pinit)[i]; + + SHA256_Update(&ctx, data, sizeof(data)); + for (int i = 0; i < 8; i++) + ((uint32_t*)pstate)[i] = ctx.h[i]; } // |