MCPcopy Create free account
hub / github.com/ElementsProject/elements / CSHA256

Class CSHA256

src/crypto/sha256.h:14–34  ·  view source on GitHub ↗

A hasher class for SHA-256. */

Source from the content-addressed store, hash-verified

12
13/** A hasher class for SHA-256. */
14class CSHA256
15{
16private:
17 uint32_t s[8];
18 unsigned char buf[64];
19 uint64_t bytes;
20
21public:
22 static const size_t OUTPUT_SIZE = 32;
23
24 CSHA256();
25 CSHA256& Write(const unsigned char* data, size_t len);
26 void Finalize(unsigned char hash[OUTPUT_SIZE]);
27 //TODO: Midstate is a hack'ish speedup that probably should make way for something
28 //akin to the SHA256D64 speedups
29 void Midstate(unsigned char hash[OUTPUT_SIZE], uint64_t* len, unsigned char *buffer);
30 std::vector<unsigned char> Save() const;
31 bool Load(const std::vector<unsigned char>& vch);
32 CSHA256& Reset();
33 bool SafeWrite(const unsigned char* data, size_t len);
34};
35
36/** Autodetect the best available SHA256 implementation.
37 * Returns the name of the implementation.

Callers 15

SHA256Uint256Function · 0.85
TaggedHashFunction · 0.85
SetInternalMethod · 0.85
UnblindConfidentialPairFunction · 0.85
CHMAC_SHA256Method · 0.85
GetIDMethod · 0.85
EvalScriptFunction · 0.85

Calls

no outgoing calls

Tested by 7

BOOST_AUTO_TEST_CASEFunction · 0.68
TestBuilderMethod · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
TestSHA256Function · 0.68
FUZZ_TARGET_INITFunction · 0.68
ConsumeScriptFunction · 0.68
InitializerMethod · 0.68