diff options
Diffstat (limited to 'src/crypto')
-rw-r--r-- | src/crypto/ripemd160.cpp | 2 | ||||
-rw-r--r-- | src/crypto/ripemd160.h | 4 | ||||
-rw-r--r-- | src/crypto/sha1.cpp | 2 | ||||
-rw-r--r-- | src/crypto/sha1.h | 4 | ||||
-rw-r--r-- | src/crypto/sha2.cpp | 6 | ||||
-rw-r--r-- | src/crypto/sha2.h | 12 |
6 files changed, 20 insertions, 10 deletions
diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp index c5e6e2d696..24bd318d43 100644 --- a/src/crypto/ripemd160.cpp +++ b/src/crypto/ripemd160.cpp @@ -184,7 +184,7 @@ CRIPEMD160& CRIPEMD160::Write(const unsigned char *data, size_t len) { return *this; } -void CRIPEMD160::Finalize(unsigned char *hash) { +void CRIPEMD160::Finalize(unsigned char hash[OUTPUT_SIZE]) { static const unsigned char pad[64] = {0x80}; unsigned char sizedesc[8]; WriteLE64(sizedesc, bytes << 3); diff --git a/src/crypto/ripemd160.h b/src/crypto/ripemd160.h index cab1d0bb46..44bd4879a5 100644 --- a/src/crypto/ripemd160.h +++ b/src/crypto/ripemd160.h @@ -16,9 +16,11 @@ private: size_t bytes; public: + static const size_t OUTPUT_SIZE = 20; + CRIPEMD160(); CRIPEMD160& Write(const unsigned char *data, size_t len); - void Finalize(unsigned char *hash); + void Finalize(unsigned char hash[OUTPUT_SIZE]); CRIPEMD160& Reset(); }; diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index e0f32b7d1d..304401a50f 100644 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -172,7 +172,7 @@ CSHA1& CSHA1::Write(const unsigned char *data, size_t len) { return *this; } -void CSHA1::Finalize(unsigned char *hash) { +void CSHA1::Finalize(unsigned char hash[OUTPUT_SIZE]) { static const unsigned char pad[64] = {0x80}; unsigned char sizedesc[8]; WriteBE64(sizedesc, bytes << 3); diff --git a/src/crypto/sha1.h b/src/crypto/sha1.h index 6efde78a5b..b16f2c88ce 100644 --- a/src/crypto/sha1.h +++ b/src/crypto/sha1.h @@ -16,9 +16,11 @@ private: size_t bytes; public: + static const size_t OUTPUT_SIZE = 20; + CSHA1(); CSHA1& Write(const unsigned char *data, size_t len); - void Finalize(unsigned char *hash); + void Finalize(unsigned char hash[OUTPUT_SIZE]); CSHA1& Reset(); }; diff --git a/src/crypto/sha2.cpp b/src/crypto/sha2.cpp index 77f35f38d8..99a251cb12 100644 --- a/src/crypto/sha2.cpp +++ b/src/crypto/sha2.cpp @@ -295,7 +295,7 @@ CSHA256& CSHA256::Write(const unsigned char *data, size_t len) { return *this; } -void CSHA256::Finalize(unsigned char *hash) { +void CSHA256::Finalize(unsigned char hash[OUTPUT_SIZE]) { static const unsigned char pad[64] = {0x80}; unsigned char sizedesc[8]; WriteBE64(sizedesc, bytes << 3); @@ -348,7 +348,7 @@ CSHA512& CSHA512::Write(const unsigned char *data, size_t len) { return *this; } -void CSHA512::Finalize(unsigned char *hash) { +void CSHA512::Finalize(unsigned char hash[OUTPUT_SIZE]) { static const unsigned char pad[128] = {0x80}; unsigned char sizedesc[16] = {0x00}; WriteBE64(sizedesc+8, bytes << 3); @@ -391,7 +391,7 @@ CHMAC_SHA512::CHMAC_SHA512(const unsigned char *key, size_t keylen) { inner.Write(rkey, 128); } -void CHMAC_SHA512::Finalize(unsigned char *hash) { +void CHMAC_SHA512::Finalize(unsigned char hash[OUTPUT_SIZE]) { unsigned char temp[64]; inner.Finalize(temp); outer.Write(temp, 64).Finalize(hash); diff --git a/src/crypto/sha2.h b/src/crypto/sha2.h index 001bfc647c..088d5e194c 100644 --- a/src/crypto/sha2.h +++ b/src/crypto/sha2.h @@ -16,9 +16,11 @@ private: size_t bytes; public: + static const size_t OUTPUT_SIZE = 32; + CSHA256(); CSHA256& Write(const unsigned char *data, size_t len); - void Finalize(unsigned char *hash); + void Finalize(unsigned char hash[OUTPUT_SIZE]); CSHA256& Reset(); }; @@ -30,9 +32,11 @@ private: size_t bytes; public: + static const size_t OUTPUT_SIZE = 64; + CSHA512(); CSHA512& Write(const unsigned char *data, size_t len); - void Finalize(unsigned char *hash); + void Finalize(unsigned char hash[OUTPUT_SIZE]); CSHA512& Reset(); }; @@ -43,12 +47,14 @@ private: CSHA512 inner; public: + static const size_t OUTPUT_SIZE = 64; + CHMAC_SHA512(const unsigned char *key, size_t keylen); CHMAC_SHA512& Write(const unsigned char *data, size_t len) { inner.Write(data, len); return *this; } - void Finalize(unsigned char *hash); + void Finalize(unsigned char hash[OUTPUT_SIZE]); }; #endif |