diff options
Diffstat (limited to 'src/hash')
-rw-r--r-- | src/hash/keccak/keccak.cpp | 4 | ||||
-rw-r--r-- | src/hash/par_hash/par_hash.cpp | 39 | ||||
-rw-r--r-- | src/hash/skein/skein_512.cpp | 2 | ||||
-rw-r--r-- | src/hash/tiger/tiger.cpp | 7 |
4 files changed, 29 insertions, 23 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..a95ba36b9 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 */ @@ -14,20 +14,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.begin(); hash != hashes.end(); ++hash) + (*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.begin(); hash != hashes.end(); ++hash) { - hashes[i]->final(hash + offset); - offset += hashes[i]->output_length(); + (*hash)->final(out + offset); + offset += (*hash)->output_length(); } } @@ -48,12 +49,14 @@ size_t Parallel::output_length() const std::string Parallel::name() const { std::string hash_names; - for(size_t i = 0; i != hashes.size(); ++i) + + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) { - if(i) + if(hash != hashes.begin()) hash_names += ','; - hash_names += hashes[i]->name(); + hash_names += (*hash)->name(); } + return "Parallel(" + hash_names + ")"; } @@ -63,8 +66,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.begin(); hash != hashes.end(); ++hash) + hash_copies.push_back((*hash)->clone()); + return new Parallel(hash_copies); } @@ -73,8 +78,8 @@ HashFunction* Parallel::clone() const */ void Parallel::clear() { - for(size_t i = 0; i != hashes.size(); ++i) - hashes[i]->clear(); + for(auto hash = hashes.begin(); hash != hashes.end(); ++hash) + (*hash)->clear(); } /* @@ -90,8 +95,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.begin(); hash != hashes.end(); ++hash) + delete (*hash); } } diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp index f85968e84..b5f7677db 100644 --- a/src/hash/skein/skein_512.cpp +++ b/src/hash/skein/skein_512.cpp @@ -184,7 +184,7 @@ Skein_512::Skein_512(size_t arg_output_bits, std::string Skein_512::name() const { - 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(); } |