Added SHA256Compress to Bitcoin's SHA256 implementation.
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user