Added SHA256Compress to Bitcoin's SHA256 implementation.

This commit is contained in:
Sean Bowe
2016-03-31 14:23:56 -06:00
parent 9bab3e89a2
commit 8466467a35
4 changed files with 48 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
#include "crypto/common.h"
#include <string.h>
#include <stdexcept>
// Internal implementation code.
namespace
@@ -171,6 +172,15 @@ void CSHA256::Finalize(unsigned char hash[OUTPUT_SIZE])
WriteBE64(sizedesc, bytes << 3);
Write(pad, 1 + ((119 - (bytes % 64)) % 64));
Write(sizedesc, 8);
FinalizeNoPadding(hash, false);
}
void CSHA256::FinalizeNoPadding(unsigned char hash[OUTPUT_SIZE], bool enforce_compression)
{
if (enforce_compression && bytes != 64) {
throw std::length_error("SHA256Compress should be invoked with a 512-bit block");
}
WriteBE32(hash, s[0]);
WriteBE32(hash + 4, s[1]);
WriteBE32(hash + 8, s[2]);