aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash/comb4p
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-04-23 12:53:06 +0000
committerlloyd <[email protected]>2010-04-23 12:53:06 +0000
commit70787ef941d709680d3fc0862c807ac6af4fdc61 (patch)
tree3f329b6caaf876bb9d52132d56d74effe41c63e8 /src/hash/comb4p
parent5285c91f975c319078f6de7ad4568ce7f925bd6b (diff)
Check to make sure the user didn't provide two of the same has for
Comb4P. If you do this, the first N bytes are all zero, which could expose some problems, especially if the caller truncates or is relying on Comb4P acting like a random function.
Diffstat (limited to 'src/hash/comb4p')
-rw-r--r--src/hash/comb4p/comb4p.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/hash/comb4p/comb4p.cpp b/src/hash/comb4p/comb4p.cpp
index 1afc5c8e7..6ae36b9d3 100644
--- a/src/hash/comb4p/comb4p.cpp
+++ b/src/hash/comb4p/comb4p.cpp
@@ -52,6 +52,9 @@ Comb4P::Comb4P(HashFunction* h1, HashFunction* h2) :
comb4p_block_size(h1, h2)),
hash1(h1), hash2(h2)
{
+ if(hash1->name() == hash2->name())
+ throw std::invalid_argument("Comb4P: Must use two distinct hashes");
+
if(hash1->OUTPUT_LENGTH != hash2->OUTPUT_LENGTH)
throw std::invalid_argument("Comb4P: Incompatible hashes " +
hash1->name() + " and " +