diff options
author | lloyd <[email protected]> | 2009-07-15 13:33:51 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-07-15 13:33:51 +0000 |
commit | b1fc3ff3fe19152eaf1adbdd9f503dfaf2b8a500 (patch) | |
tree | 05634e88229058a59c8ab0d84332f1baf148f4a5 /src/hash | |
parent | 864b9c9e8b8f0b7e8f7e15dc1905c2d501a1498e (diff) | |
parent | b438a3c6d08893ca77a1d18baef1b02e955eccf8 (diff) |
propagate from branch 'net.randombit.botan' (head 5438defd358f82e876917a8bd6d735305ecb0a8e)
to branch 'net.randombit.botan.c++0x' (head cbdb2fd418557add29a536f7bdb6e78db16f725c)
Diffstat (limited to 'src/hash')
-rw-r--r-- | src/hash/par_hash/par_hash.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp index 4b0c7c466..789238647 100644 --- a/src/hash/par_hash/par_hash.cpp +++ b/src/hash/par_hash/par_hash.cpp @@ -1,6 +1,6 @@ /* * Parallel -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -18,8 +18,8 @@ u32bit sum_of_hash_lengths(const std::vector<HashFunction*>& hashes) { u32bit sum = 0; - for(u32bit j = 0; j != hashes.size(); ++j) - sum += hashes[j]->OUTPUT_LENGTH; + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) + sum += (*hash)->OUTPUT_LENGTH; return sum; } @@ -31,20 +31,21 @@ u32bit sum_of_hash_lengths(const std::vector<HashFunction*>& hashes) */ void Parallel::add_data(const byte input[], u32bit length) { - for(u32bit j = 0; j != hashes.size(); ++j) - hashes[j]->update(input, length); + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) + (*hash)->update(input, length); } /* * Finalize the hash */ -void Parallel::final_result(byte hash[]) +void Parallel::final_result(byte out[]) { u32bit offset = 0; - for(u32bit j = 0; j != hashes.size(); ++j) + + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) { - hashes[j]->final(hash + offset); - offset += hashes[j]->OUTPUT_LENGTH; + (*hash)->final(out + offset); + offset += (*hash)->OUTPUT_LENGTH; } } @@ -54,12 +55,14 @@ void Parallel::final_result(byte hash[]) std::string Parallel::name() const { std::string hash_names; - for(u32bit j = 0; j != hashes.size(); ++j) + + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) { - if(j) + if(hash != hashes.begin()) hash_names += ','; - hash_names += hashes[j]->name(); + hash_names += (*hash)->name(); } + return "Parallel(" + hash_names + ")"; } @@ -69,8 +72,10 @@ std::string Parallel::name() const HashFunction* Parallel::clone() const { std::vector<HashFunction*> hash_copies; - for(u32bit j = 0; j != hashes.size(); ++j) - hash_copies.push_back(hashes[j]->clone()); + + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) + hash_copies.push_back((*hash)->clone()); + return new Parallel(hash_copies); } @@ -79,8 +84,8 @@ HashFunction* Parallel::clone() const */ void Parallel::clear() throw() { - for(u32bit j = 0; j != hashes.size(); ++j) - hashes[j]->clear(); + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) + (*hash)->clear(); } /* @@ -96,8 +101,8 @@ Parallel::Parallel(const std::vector<HashFunction*>& hash_in) : */ Parallel::~Parallel() { - for(u32bit j = 0; j != hashes.size(); ++j) - delete hashes[j]; + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) + delete (*hash); } } |