aboutsummaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
authorPieter Wuille <sipa@ulyssis.org>2014-06-12 13:34:29 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-06-21 19:47:43 +0200
commita0495bb68c6eff9c732d458bacab10490d6452b4 (patch)
tree191a3bb7929e1de43ea484873587249fd2533b19 /src/hash.h
parent4791b99e2dea0593775a8c75f62c8406d340191e (diff)
Add <Hasher>::OUTPUT_SIZE
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/hash.h b/src/hash.h
index 39d42eefe2..f2a0ebfe1f 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -19,10 +19,12 @@ class CHash256 {
private:
CSHA256 sha;
public:
- void Finalize(unsigned char *hash) {
- unsigned char buf[32];
+ static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE;
+
+ void Finalize(unsigned char hash[OUTPUT_SIZE]) {
+ unsigned char buf[sha.OUTPUT_SIZE];
sha.Finalize(buf);
- sha.Reset().Write(buf, 32).Finalize(hash);
+ sha.Reset().Write(buf, sha.OUTPUT_SIZE).Finalize(hash);
}
CHash256& Write(const unsigned char *data, size_t len) {
@@ -41,10 +43,12 @@ class CHash160 {
private:
CSHA256 sha;
public:
- void Finalize(unsigned char *hash) {
- unsigned char buf[32];
+ static const size_t OUTPUT_SIZE = CRIPEMD160::OUTPUT_SIZE;
+
+ void Finalize(unsigned char hash[OUTPUT_SIZE]) {
+ unsigned char buf[sha.OUTPUT_SIZE];
sha.Finalize(buf);
- CRIPEMD160().Write(buf, 32).Finalize(hash);
+ CRIPEMD160().Write(buf, sha.OUTPUT_SIZE).Finalize(hash);
}
CHash160& Write(const unsigned char *data, size_t len) {