aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-09 02:53:56 +0000
committerlloyd <[email protected]>2010-03-09 02:53:56 +0000
commitcdcd3a9aba28cefcccb64f91fb56d3847f6c9130 (patch)
tree6f4efd137aad848e698f9f4fc48a8bc9145fea12 /src/hash
parent4a9afbb99bb73e43bcb3a30379d6a2dd59dae76a (diff)
parent3c15bd259f0921f1fa08ec91ee3cf2621c64a02d (diff)
propagate from branch 'net.randombit.botan' (head 9932d4d63417f7fcc199ada244cbaa6c1c32d9c1)
to branch 'net.randombit.botan.c++0x' (head f4a385a376311edc62ef506c72cc56f69e6efd5a)
Diffstat (limited to 'src/hash')
-rw-r--r--src/hash/par_hash/par_hash.cpp41
-rw-r--r--src/hash/skein/skein_512.cpp2
-rw-r--r--src/hash/tiger/tiger.cpp6
3 files changed, 27 insertions, 22 deletions
diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp
index 0ba3f5a4f..fdd028f58 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()
{
- 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);
}
}
diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp
index cb4b7a7a2..869257567 100644
--- a/src/hash/skein/skein_512.cpp
+++ b/src/hash/skein/skein_512.cpp
@@ -176,7 +176,7 @@ Skein_512::Skein_512(u32bit 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 3013ab38e..42df69eae 100644
--- a/src/hash/tiger/tiger.cpp
+++ b/src/hash/tiger/tiger.cpp
@@ -147,7 +147,7 @@ void Tiger::clear()
*/
std::string Tiger::name() const
{
- return "Tiger(" + to_string(OUTPUT_LENGTH) + "," + to_string(PASS) + ")";
+ return "Tiger(" + std::to_string(OUTPUT_LENGTH) + "," + std::to_string(PASS) + ")";
}
/*
@@ -158,10 +158,10 @@ Tiger::Tiger(u32bit hashlen, u32bit pass) :
{
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(PASS < 3)
throw Invalid_Argument("Tiger: Invalid number of passes: "
- + to_string(PASS));
+ + std::to_string(PASS));
clear();
}