diff options
-rw-r--r-- | src/engine/def_engine/lookup_hash.cpp | 9 | ||||
-rw-r--r-- | src/hash/par_hash/par_hash.cpp | 21 | ||||
-rw-r--r-- | src/hash/par_hash/par_hash.h | 9 |
3 files changed, 22 insertions, 17 deletions
diff --git a/src/engine/def_engine/lookup_hash.cpp b/src/engine/def_engine/lookup_hash.cpp index 3c509ba42..10cc86785 100644 --- a/src/engine/def_engine/lookup_hash.cpp +++ b/src/engine/def_engine/lookup_hash.cpp @@ -200,8 +200,13 @@ Default_Engine::find_hash(const std::string& algo_spec) const { if(name.size() < 2) throw Invalid_Algorithm_Name(algo_spec); - name.erase(name.begin()); - return new Parallel(name); + + std::vector<HashFunction*> hashes; + + for(u32bit i = 1; i != name.size(); ++i) + hashes.push_back(get_hash(name[i])); + + return new Parallel(hashes); } #endif 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); |