mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge branch 'no-cryptopp' of https://github.com/tcatm/bitcoin
This commit is contained in:
21
src/main.cpp
21
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];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user