diff options
author | lloyd <[email protected]> | 2011-07-12 11:52:39 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-07-12 11:52:39 +0000 |
commit | 9e84dbf6c6ee9297f2a707f49d1cf175b6e149a5 (patch) | |
tree | e93fc28388c762d11bae0a52edcc17576a2ae1f6 /src/hash | |
parent | 82e218500e6f305d02feecc000b43a5d9448e11a (diff) | |
parent | dcc7e959eff557811c3cf414adde096285821816 (diff) |
propagate from branch 'net.randombit.botan' (head 23a326fa36a31dd39347a8864e1f5740669a905e)
to branch 'net.randombit.botan.cxx11' (head 9d3ac8dd45f7673c85dca41968e7750acc90bdff)
Diffstat (limited to 'src/hash')
-rw-r--r-- | src/hash/keccak/keccak.cpp | 4 | ||||
-rw-r--r-- | src/hash/par_hash/par_hash.cpp | 51 | ||||
-rw-r--r-- | src/hash/skein/skein_512.cpp | 2 | ||||
-rw-r--r-- | src/hash/tiger/tiger.cpp | 7 |
4 files changed, 34 insertions, 30 deletions
diff --git a/src/hash/keccak/keccak.cpp b/src/hash/keccak/keccak.cpp index 922167b61..107055509 100644 --- a/src/hash/keccak/keccak.cpp +++ b/src/hash/keccak/keccak.cpp @@ -112,12 +112,12 @@ Keccak_1600::Keccak_1600(size_t output_bits) : if(output_bits != 224 && output_bits != 256 && output_bits != 384 && output_bits != 512) throw Invalid_Argument("Keccak_1600: Invalid output length " + - to_string(output_bits)); + std::to_string(output_bits)); } std::string Keccak_1600::name() const { - return "Keccak-1600(" + to_string(output_bits) + ")"; + return "Keccak-1600(" + std::to_string(output_bits) + ")"; } HashFunction* Keccak_1600::clone() const diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp index 328be6a11..df47780ef 100644 --- a/src/hash/par_hash/par_hash.cpp +++ b/src/hash/par_hash/par_hash.cpp @@ -1,11 +1,12 @@ /* * Parallel -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ #include <botan/par_hash.h> +#include <botan/parsing.h> namespace Botan { @@ -14,20 +15,21 @@ namespace Botan { */ void Parallel::add_data(const byte input[], size_t length) { - for(size_t i = 0; i != hashes.size(); ++i) - hashes[i]->update(input, length); + for(auto hash : hashes) + hash->update(input, length); } /* * Finalize the hash */ -void Parallel::final_result(byte hash[]) +void Parallel::final_result(byte out[]) { - size_t offset = 0; - for(size_t i = 0; i != hashes.size(); ++i) + u32bit offset = 0; + + for(auto hash : hashes) { - hashes[i]->final(hash + offset); - offset += hashes[i]->output_length(); + hash->final(out + offset); + offset += hash->output_length(); } } @@ -37,8 +39,9 @@ void Parallel::final_result(byte hash[]) size_t Parallel::output_length() const { size_t sum = 0; - for(size_t i = 0; i != hashes.size(); ++i) - sum += hashes[i]->output_length(); + + for(auto hash : hashes) + sum += hash->output_length(); return sum; } @@ -47,14 +50,12 @@ size_t Parallel::output_length() const */ std::string Parallel::name() const { - std::string hash_names; - for(size_t i = 0; i != hashes.size(); ++i) - { - if(i) - hash_names += ','; - hash_names += hashes[i]->name(); - } - return "Parallel(" + hash_names + ")"; + std::vector<std::string> names; + + for(auto hash : hashes) + names.push_back(hash->name()); + + return "Parallel(" + string_join(names, ',') + ")"; } /* @@ -63,8 +64,10 @@ std::string Parallel::name() const HashFunction* Parallel::clone() const { std::vector<HashFunction*> hash_copies; - for(size_t i = 0; i != hashes.size(); ++i) - hash_copies.push_back(hashes[i]->clone()); + + for(auto hash : hashes) + hash_copies.push_back(hash->clone()); + return new Parallel(hash_copies); } @@ -73,8 +76,8 @@ HashFunction* Parallel::clone() const */ void Parallel::clear() { - for(size_t i = 0; i != hashes.size(); ++i) - hashes[i]->clear(); + for(auto hash : hashes) + hash->clear(); } /* @@ -90,8 +93,8 @@ Parallel::Parallel(const std::vector<HashFunction*>& hash_in) : */ Parallel::~Parallel() { - for(size_t i = 0; i != hashes.size(); ++i) - delete hashes[i]; + for(auto hash : hashes) + delete hash; } } diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp index 571bf9c0b..e5d59ed45 100644 --- a/src/hash/skein/skein_512.cpp +++ b/src/hash/skein/skein_512.cpp @@ -186,7 +186,7 @@ std::string Skein_512::name() const { if(personalization != "") return "Skein-512(" + to_string(output_bits) + "," + personalization + ")"; - return "Skein-512(" + to_string(output_bits) + ")"; + return "Skein-512(" + std::to_string(output_bits) + ")"; } HashFunction* Skein_512::clone() const diff --git a/src/hash/tiger/tiger.cpp b/src/hash/tiger/tiger.cpp index 6f40f84c8..daa0939b9 100644 --- a/src/hash/tiger/tiger.cpp +++ b/src/hash/tiger/tiger.cpp @@ -160,7 +160,8 @@ void Tiger::clear() */ std::string Tiger::name() const { - return "Tiger(" + to_string(output_length()) + "," + to_string(passes) + ")"; + return "Tiger(" + std::to_string(output_length()) + "," + + std::to_string(passes) + ")"; } /* @@ -175,11 +176,11 @@ Tiger::Tiger(size_t hash_len, size_t passes) : { if(output_length() != 16 && output_length() != 20 && output_length() != 24) throw Invalid_Argument("Tiger: Illegal hash output size: " + - to_string(output_length())); + std::to_string(output_length())); if(passes < 3) throw Invalid_Argument("Tiger: Invalid number of passes: " - + to_string(passes)); + + std::to_string(passes)); clear(); } |