diff options
author | lloyd <[email protected]> | 2008-11-08 23:02:17 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-08 23:02:17 +0000 |
commit | 33b52f8ff1663f0a20edc824331fa9c22c7a2a11 (patch) | |
tree | fabf9e62a2baf884de4716a1060213cba489b451 /src/hash | |
parent | 5e79ee8939aa3cfcaed9159168153ee020ebd8de (diff) |
Remove lookup from parallel hash construction
Diffstat (limited to 'src/hash')
-rw-r--r-- | src/hash/par_hash/par_hash.cpp | 21 | ||||
-rw-r--r-- | src/hash/par_hash/par_hash.h | 9 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp index 12786523f..67c4799ee 100644 --- a/src/hash/par_hash/par_hash.cpp +++ b/src/hash/par_hash/par_hash.cpp @@ -4,7 +4,6 @@ *************************************************/ #include <botan/par_hash.h> -#include <botan/lookup.h> namespace Botan { @@ -13,11 +12,13 @@ namespace { /************************************************* * Return the sum of the hash sizes * *************************************************/ -u32bit sum_of_hash_lengths(const std::vector<std::string>& names) +u32bit sum_of_hash_lengths(const std::vector<HashFunction*>& hashes) { u32bit sum = 0; - for(u32bit j = 0; j != names.size(); ++j) - sum += output_length_of(names[j]); + + for(u32bit j = 0; j != hashes.size(); ++j) + sum += hashes[j]->OUTPUT_LENGTH; + return sum; } @@ -65,10 +66,10 @@ std::string Parallel::name() const *************************************************/ HashFunction* Parallel::clone() const { - std::vector<std::string> names; + std::vector<HashFunction*> hash_copies; for(u32bit j = 0; j != hashes.size(); ++j) - names.push_back(hashes[j]->name()); - return new Parallel(names); + hash_copies.push_back(hashes[j]->clone()); + return new Parallel(hash_copies); } /************************************************* @@ -83,11 +84,9 @@ void Parallel::clear() throw() /************************************************* * Parallel Constructor * *************************************************/ -Parallel::Parallel(const std::vector<std::string>& names) : - HashFunction(sum_of_hash_lengths(names)) +Parallel::Parallel(const std::vector<HashFunction*>& hash_in) : + HashFunction(sum_of_hash_lengths(hash_in)), hashes(hash_in) { - for(u32bit j = 0; j != names.size(); ++j) - hashes.push_back(get_hash(names[j])); } /************************************************* diff --git a/src/hash/par_hash/par_hash.h b/src/hash/par_hash/par_hash.h index e794f0704..7d71dae11 100644 --- a/src/hash/par_hash/par_hash.h +++ b/src/hash/par_hash/par_hash.h @@ -1,10 +1,10 @@ /************************************************* -* Parallel Header File * +* Parallel Hash Header File * * (C) 1999-2007 Jack Lloyd * *************************************************/ -#ifndef BOTAN_PAR_HASH_H__ -#define BOTAN_PAR_HASH_H__ +#ifndef BOTAN_PARALLEL_HASH_H__ +#define BOTAN_PARALLEL_HASH_H__ #include <botan/hash.h> #include <vector> @@ -20,7 +20,8 @@ class BOTAN_DLL Parallel : public HashFunction void clear() throw(); std::string name() const; HashFunction* clone() const; - Parallel(const std::vector<std::string>&); + + Parallel(const std::vector<HashFunction*>&); ~Parallel(); private: void add_data(const byte[], u32bit); |