aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-12 23:29:55 +0000
committerlloyd <[email protected]>2010-10-12 23:29:55 +0000
commit2af9ba577730f071eef44b3ba492c3bfad0a8ec6 (patch)
tree92a4c4e973756225d42bb99a99110b2669be7299 /src/hash
parent97e8d6086171772cd5e45bcf2f5b1ea1e38e6bf5 (diff)
Use size_t for BufferedComputation::add_data
Diffstat (limited to 'src/hash')
-rw-r--r--src/hash/bmw/bmw_512.cpp14
-rw-r--r--src/hash/bmw/bmw_512.h2
-rw-r--r--src/hash/comb4p/comb4p.cpp4
-rw-r--r--src/hash/comb4p/comb4p.h2
-rw-r--r--src/hash/gost_3411/gost_3411.cpp14
-rw-r--r--src/hash/gost_3411/gost_3411.h4
-rw-r--r--src/hash/has160/has160.cpp8
-rw-r--r--src/hash/has160/has160.h2
-rw-r--r--src/hash/md2/md2.cpp20
-rw-r--r--src/hash/md2/md2.h4
-rw-r--r--src/hash/md4/md4.cpp8
-rw-r--r--src/hash/md4/md4.h2
-rw-r--r--src/hash/md4_ia32/md4_ia32.cpp4
-rw-r--r--src/hash/md4_ia32/md4_ia32.h2
-rw-r--r--src/hash/md5/md5.cpp8
-rw-r--r--src/hash/md5/md5.h2
-rw-r--r--src/hash/md5_ia32/md5_ia32.cpp4
-rw-r--r--src/hash/md5_ia32/md5_ia32.h2
-rw-r--r--src/hash/mdx_hash/mdx_hash.cpp14
-rw-r--r--src/hash/mdx_hash/mdx_hash.h12
-rw-r--r--src/hash/par_hash/par_hash.cpp40
-rw-r--r--src/hash/par_hash/par_hash.h2
-rw-r--r--src/hash/rmd128/rmd128.cpp8
-rw-r--r--src/hash/rmd128/rmd128.h2
-rw-r--r--src/hash/rmd160/rmd160.cpp8
-rw-r--r--src/hash/rmd160/rmd160.h2
-rw-r--r--src/hash/sha1/sha160.cpp10
-rw-r--r--src/hash/sha1/sha160.h4
-rw-r--r--src/hash/sha1_amd64/sha1_amd64.cpp4
-rw-r--r--src/hash/sha1_amd64/sha1_amd64.h2
-rw-r--r--src/hash/sha1_ia32/sha1_ia32.cpp4
-rw-r--r--src/hash/sha1_ia32/sha1_ia32.h2
-rw-r--r--src/hash/sha1_sse2/sha1_sse2.cpp4
-rw-r--r--src/hash/sha1_sse2/sha1_sse2.h2
-rw-r--r--src/hash/sha2_32/sha2_32.cpp18
-rw-r--r--src/hash/sha2_32/sha2_32.h4
-rw-r--r--src/hash/sha2_64/sha2_64.cpp18
-rw-r--r--src/hash/sha2_64/sha2_64.h4
-rw-r--r--src/hash/skein/skein_512.cpp20
-rw-r--r--src/hash/skein/skein_512.h6
-rw-r--r--src/hash/tiger/tiger.cpp12
-rw-r--r--src/hash/tiger/tiger.h6
-rw-r--r--src/hash/whirlpool/whrlpool.cpp10
-rw-r--r--src/hash/whirlpool/whrlpool.h2
44 files changed, 165 insertions, 161 deletions
diff --git a/src/hash/bmw/bmw_512.cpp b/src/hash/bmw/bmw_512.cpp
index cfa0eee2c..a69d23bff 100644
--- a/src/hash/bmw/bmw_512.cpp
+++ b/src/hash/bmw/bmw_512.cpp
@@ -43,9 +43,9 @@ inline u64bit S4(u64bit X)
*/
void BMW_512_compress(u64bit H[16], const u64bit M[16], u64bit Q[32])
{
- const u32bit EXPAND_1_ROUNDS = 2;
+ const size_t EXPAND_1_ROUNDS = 2;
- for(u32bit i = 0; i != 16; ++i)
+ for(size_t i = 0; i != 16; ++i)
Q[i] = H[i] ^ M[i];
Q[16] = Q[ 5] - Q[ 7] + Q[10] + Q[13] + Q[14];
@@ -82,7 +82,7 @@ void BMW_512_compress(u64bit H[16], const u64bit M[16], u64bit Q[32])
Q[14] = S4(Q[30]) + H[15];
Q[15] = S0(Q[31]) + H[ 0];
- for(u32bit i = 16; i != 16 + EXPAND_1_ROUNDS; ++i)
+ for(size_t i = 16; i != 16 + EXPAND_1_ROUNDS; ++i)
{
Q[i] = S1(Q[i-16]) + S2(Q[i-15]) + S3(Q[i-14]) + S0(Q[i-13]) +
S1(Q[i-12]) + S2(Q[i-11]) + S3(Q[i-10]) + S0(Q[i- 9]) +
@@ -94,7 +94,7 @@ void BMW_512_compress(u64bit H[16], const u64bit M[16], u64bit Q[32])
(0x0555555555555555 * i)) ^ H[(i-16+7)%16]);
}
- for(u32bit i = 16 + EXPAND_1_ROUNDS; i != 32; ++i)
+ for(size_t i = 16 + EXPAND_1_ROUNDS; i != 32; ++i)
{
Q[i] = Q[i-16] + rotate_left(Q[i-15], 5) +
Q[i-14] + rotate_left(Q[i-13], 11) +
@@ -139,9 +139,9 @@ void BMW_512_compress(u64bit H[16], const u64bit M[16], u64bit Q[32])
}
-void BMW_512::compress_n(const byte input[], u32bit blocks)
+void BMW_512::compress_n(const byte input[], size_t blocks)
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_le(&M[0], input, M.size());
@@ -168,7 +168,7 @@ void BMW_512::copy_out(byte output[])
BMW_512_compress(final, &H[0], &Q[0]);
- for(u32bit i = 0; i != OUTPUT_LENGTH; i += 8)
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 8)
store_le(final[8 + i/8], output + i);
}
diff --git a/src/hash/bmw/bmw_512.h b/src/hash/bmw/bmw_512.h
index b1eaa6874..aa527c142 100644
--- a/src/hash/bmw/bmw_512.h
+++ b/src/hash/bmw/bmw_512.h
@@ -25,7 +25,7 @@ class BOTAN_DLL BMW_512 : public MDx_HashFunction
BMW_512() : MDx_HashFunction(64, 128, false, true), H(16), M(16), Q(32)
{ clear(); }
private:
- void compress_n(const byte input[], u32bit blocks);
+ void compress_n(const byte input[], size_t blocks);
void copy_out(byte output[]);
SecureVector<u64bit> H, M, Q;
diff --git a/src/hash/comb4p/comb4p.cpp b/src/hash/comb4p/comb4p.cpp
index ecbdc4671..681e20685 100644
--- a/src/hash/comb4p/comb4p.cpp
+++ b/src/hash/comb4p/comb4p.cpp
@@ -13,7 +13,7 @@ namespace Botan {
namespace {
-u32bit comb4p_block_size(const HashFunction* h1,
+size_t comb4p_block_size(const HashFunction* h1,
const HashFunction* h2)
{
if(h1->HASH_BLOCK_SIZE == h2->HASH_BLOCK_SIZE)
@@ -73,7 +73,7 @@ void Comb4P::clear()
hash2->update(0);
}
-void Comb4P::add_data(const byte input[], u32bit length)
+void Comb4P::add_data(const byte input[], size_t length)
{
hash1->update(input, length);
hash2->update(input, length);
diff --git a/src/hash/comb4p/comb4p.h b/src/hash/comb4p/comb4p.h
index 550b70b14..b09f2976b 100644
--- a/src/hash/comb4p/comb4p.h
+++ b/src/hash/comb4p/comb4p.h
@@ -39,7 +39,7 @@ class BOTAN_DLL Comb4P : public HashFunction
void clear();
private:
- void add_data(const byte input[], u32bit length);
+ void add_data(const byte input[], size_t length);
void final_result(byte out[]);
HashFunction* hash1;
diff --git a/src/hash/gost_3411/gost_3411.cpp b/src/hash/gost_3411/gost_3411.cpp
index b460de29c..dbd6335bd 100644
--- a/src/hash/gost_3411/gost_3411.cpp
+++ b/src/hash/gost_3411/gost_3411.cpp
@@ -38,7 +38,7 @@ void GOST_34_11::clear()
/**
* Hash additional inputs
*/
-void GOST_34_11::add_data(const byte input[], u32bit length)
+void GOST_34_11::add_data(const byte input[], size_t length)
{
count += length;
@@ -55,8 +55,8 @@ void GOST_34_11::add_data(const byte input[], u32bit length)
}
}
- const u32bit full_blocks = length / HASH_BLOCK_SIZE;
- const u32bit remaining = length % HASH_BLOCK_SIZE;
+ const size_t full_blocks = length / HASH_BLOCK_SIZE;
+ const size_t remaining = length % HASH_BLOCK_SIZE;
if(full_blocks)
compress_n(input, full_blocks);
@@ -68,11 +68,11 @@ void GOST_34_11::add_data(const byte input[], u32bit length)
/**
* The GOST 34.11 compression function
*/
-void GOST_34_11::compress_n(const byte input[], u32bit blocks)
+void GOST_34_11::compress_n(const byte input[], size_t blocks)
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- for(u32bit j = 0, carry = 0; j != 32; ++j)
+ for(size_t j = 0, carry = 0; j != 32; ++j)
{
u16bit s = sum[j] + input[32*i+j] + carry;
carry = get_byte(0, s);
@@ -85,7 +85,7 @@ void GOST_34_11::compress_n(const byte input[], u32bit blocks)
load_be(U, &hash[0], 4);
load_be(V, input + 32*i, 4);
- for(u32bit j = 0; j != 4; ++j)
+ for(size_t j = 0; j != 4; ++j)
{
byte key[32] = { 0 };
diff --git a/src/hash/gost_3411/gost_3411.h b/src/hash/gost_3411/gost_3411.h
index 5d26e8557..693b900d2 100644
--- a/src/hash/gost_3411/gost_3411.h
+++ b/src/hash/gost_3411/gost_3411.h
@@ -25,9 +25,9 @@ class BOTAN_DLL GOST_34_11 : public HashFunction
GOST_34_11();
private:
- void compress_n(const byte input[], u32bit blocks);
+ void compress_n(const byte input[], size_t blocks);
- void add_data(const byte[], u32bit);
+ void add_data(const byte[], size_t);
void final_result(byte[]);
GOST_28147_89 cipher;
diff --git a/src/hash/has160/has160.cpp b/src/hash/has160/has160.cpp
index 5786ae0ee..4f8db53f7 100644
--- a/src/hash/has160/has160.cpp
+++ b/src/hash/has160/has160.cpp
@@ -58,14 +58,14 @@ inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E,
/*
* HAS-160 Compression Function
*/
-void HAS_160::compress_n(const byte input[], u32bit blocks)
+void HAS_160::compress_n(const byte input[], size_t blocks)
{
using namespace HAS_160_F;
u32bit A = digest[0], B = digest[1], C = digest[2],
D = digest[3], E = digest[4];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_le(&X[0], input, 16);
@@ -144,8 +144,8 @@ void HAS_160::compress_n(const byte input[], u32bit blocks)
*/
void HAS_160::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
- store_le(digest[j/4], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
+ store_le(digest[i/4], output + i);
}
/*
diff --git a/src/hash/has160/has160.h b/src/hash/has160/has160.h
index 7cff320b8..83ed5ab56 100644
--- a/src/hash/has160/has160.h
+++ b/src/hash/has160/has160.h
@@ -26,7 +26,7 @@ class BOTAN_DLL HAS_160 : public MDx_HashFunction
HAS_160() : MDx_HashFunction(20, 64, false, true), X(20), digest(5)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> X, digest;
diff --git a/src/hash/md2/md2.cpp b/src/hash/md2/md2.cpp
index 462e43b25..5d8f5f15c 100644
--- a/src/hash/md2/md2.cpp
+++ b/src/hash/md2/md2.cpp
@@ -42,28 +42,31 @@ void MD2::hash(const byte input[])
X.copy(16, input, HASH_BLOCK_SIZE);
xor_buf(&X[32], &X[0], &X[16], HASH_BLOCK_SIZE);
byte T = 0;
- for(u32bit j = 0; j != 18; ++j)
+
+ for(size_t i = 0; i != 18; ++i)
{
- for(u32bit k = 0; k != 48; k += 8)
+ for(size_t k = 0; k != 48; k += 8)
{
T = X[k ] ^= SBOX[T]; T = X[k+1] ^= SBOX[T];
T = X[k+2] ^= SBOX[T]; T = X[k+3] ^= SBOX[T];
T = X[k+4] ^= SBOX[T]; T = X[k+5] ^= SBOX[T];
T = X[k+6] ^= SBOX[T]; T = X[k+7] ^= SBOX[T];
}
- T += j;
+ T += i;
}
+
T = checksum[15];
- for(u32bit j = 0; j != HASH_BLOCK_SIZE; ++j)
- T = checksum[j] ^= SBOX[input[j] ^ T];
+ for(size_t i = 0; i != HASH_BLOCK_SIZE; ++i)
+ T = checksum[i] ^= SBOX[input[i] ^ T];
}
/**
* Update the hash
*/
-void MD2::add_data(const byte input[], u32bit length)
+void MD2::add_data(const byte input[], size_t length)
{
buffer.copy(position, input, length);
+
if(position + length >= HASH_BLOCK_SIZE)
{
hash(&buffer[0]);
@@ -86,8 +89,9 @@ void MD2::add_data(const byte input[], u32bit length)
*/
void MD2::final_result(byte output[])
{
- for(u32bit j = position; j != HASH_BLOCK_SIZE; ++j)
- buffer[j] = static_cast<byte>(HASH_BLOCK_SIZE - position);
+ for(size_t i = position; i != HASH_BLOCK_SIZE; ++i)
+ buffer[i] = static_cast<byte>(HASH_BLOCK_SIZE - position);
+
hash(&buffer[0]);
hash(&checksum[0]);
copy_mem(output, &X[0], OUTPUT_LENGTH);
diff --git a/src/hash/md2/md2.h b/src/hash/md2/md2.h
index b25d5f410..86e0d3c80 100644
--- a/src/hash/md2/md2.h
+++ b/src/hash/md2/md2.h
@@ -25,12 +25,12 @@ class BOTAN_DLL MD2 : public HashFunction
MD2() : HashFunction(16, 16), X(48), checksum(16), buffer(16)
{ clear(); }
private:
- void add_data(const byte[], u32bit);
+ void add_data(const byte[], size_t);
void hash(const byte[]);
void final_result(byte[]);
SecureVector<byte> X, checksum, buffer;
- u32bit position;
+ size_t position;
};
}
diff --git a/src/hash/md4/md4.cpp b/src/hash/md4/md4.cpp
index 326ca8eba..3f9259deb 100644
--- a/src/hash/md4/md4.cpp
+++ b/src/hash/md4/md4.cpp
@@ -45,11 +45,11 @@ inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S)
/*
* MD4 Compression Function
*/
-void MD4::compress_n(const byte input[], u32bit blocks)
+void MD4::compress_n(const byte input[], size_t blocks)
{
u32bit A = digest[0], B = digest[1], C = digest[2], D = digest[3];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_le(&M[0], input, M.size());
@@ -94,8 +94,8 @@ void MD4::compress_n(const byte input[], u32bit blocks)
*/
void MD4::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
- store_le(digest[j/4], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
+ store_le(digest[i/4], output + i);
}
/*
diff --git a/src/hash/md4/md4.h b/src/hash/md4/md4.h
index 44081e635..07467fdfc 100644
--- a/src/hash/md4/md4.h
+++ b/src/hash/md4/md4.h
@@ -25,7 +25,7 @@ class BOTAN_DLL MD4 : public MDx_HashFunction
MD4() : MDx_HashFunction(16, 64, false, true), M(16), digest(4)
{ clear(); }
protected:
- void compress_n(const byte input[], u32bit blocks);
+ void compress_n(const byte input[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> M, digest;
diff --git a/src/hash/md4_ia32/md4_ia32.cpp b/src/hash/md4_ia32/md4_ia32.cpp
index 8a60d8f0e..8983995fc 100644
--- a/src/hash/md4_ia32/md4_ia32.cpp
+++ b/src/hash/md4_ia32/md4_ia32.cpp
@@ -14,9 +14,9 @@ extern "C" void botan_md4_ia32_compress(u32bit[4], const byte[64], u32bit[16]);
/*
* MD4 Compression Function
*/
-void MD4_IA32::compress_n(const byte input[], u32bit blocks)
+void MD4_IA32::compress_n(const byte input[], size_t blocks)
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
botan_md4_ia32_compress(digest, input, M);
input += HASH_BLOCK_SIZE;
diff --git a/src/hash/md4_ia32/md4_ia32.h b/src/hash/md4_ia32/md4_ia32.h
index ef8060d3f..4bb8f1add 100644
--- a/src/hash/md4_ia32/md4_ia32.h
+++ b/src/hash/md4_ia32/md4_ia32.h
@@ -20,7 +20,7 @@ class BOTAN_DLL MD4_IA32 : public MD4
public:
HashFunction* clone() const { return new MD4_IA32; }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
};
}
diff --git a/src/hash/md5/md5.cpp b/src/hash/md5/md5.cpp
index b1745b944..69ab89e63 100644
--- a/src/hash/md5/md5.cpp
+++ b/src/hash/md5/md5.cpp
@@ -58,11 +58,11 @@ inline void II(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg,
/*
* MD5 Compression Function
*/
-void MD5::compress_n(const byte input[], u32bit blocks)
+void MD5::compress_n(const byte input[], size_t blocks)
{
u32bit A = digest[0], B = digest[1], C = digest[2], D = digest[3];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_le(&M[0], input, M.size());
@@ -116,8 +116,8 @@ void MD5::compress_n(const byte input[], u32bit blocks)
*/
void MD5::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
- store_le(digest[j/4], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
+ store_le(digest[i/4], output + i);
}
/*
diff --git a/src/hash/md5/md5.h b/src/hash/md5/md5.h
index 732ec026d..f79a3ec65 100644
--- a/src/hash/md5/md5.h
+++ b/src/hash/md5/md5.h
@@ -25,7 +25,7 @@ class BOTAN_DLL MD5 : public MDx_HashFunction
MD5() : MDx_HashFunction(16, 64, false, true), M(16), digest(4)
{ clear(); }
protected:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> M, digest;
diff --git a/src/hash/md5_ia32/md5_ia32.cpp b/src/hash/md5_ia32/md5_ia32.cpp
index affd0b8f7..66a18e6f5 100644
--- a/src/hash/md5_ia32/md5_ia32.cpp
+++ b/src/hash/md5_ia32/md5_ia32.cpp
@@ -19,9 +19,9 @@ void botan_md5_ia32_compress(u32bit[4], const byte[64], u32bit[16]);
/*
* MD5 Compression Function
*/
-void MD5_IA32::compress_n(const byte input[], u32bit blocks)
+void MD5_IA32::compress_n(const byte input[], size_t blocks)
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
botan_md5_ia32_compress(digest, input, M);
input += HASH_BLOCK_SIZE;
diff --git a/src/hash/md5_ia32/md5_ia32.h b/src/hash/md5_ia32/md5_ia32.h
index b65490760..bf4b4c505 100644
--- a/src/hash/md5_ia32/md5_ia32.h
+++ b/src/hash/md5_ia32/md5_ia32.h
@@ -20,7 +20,7 @@ class BOTAN_DLL MD5_IA32 : public MD5
public:
HashFunction* clone() const { return new MD5_IA32; }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
};
}
diff --git a/src/hash/mdx_hash/mdx_hash.cpp b/src/hash/mdx_hash/mdx_hash.cpp
index 560832542..cea66044b 100644
--- a/src/hash/mdx_hash/mdx_hash.cpp
+++ b/src/hash/mdx_hash/mdx_hash.cpp
@@ -14,9 +14,9 @@ namespace Botan {
/*
* MDx_HashFunction Constructor
*/
-MDx_HashFunction::MDx_HashFunction(u32bit hash_len, u32bit block_len,
+MDx_HashFunction::MDx_HashFunction(size_t hash_len, size_t block_len,
bool byte_end, bool bit_end,
- u32bit cnt_size) :
+ size_t cnt_size) :
HashFunction(hash_len, block_len), buffer(block_len),
BIG_BYTE_ENDIAN(byte_end), BIG_BIT_ENDIAN(bit_end), COUNT_SIZE(cnt_size)
{
@@ -37,7 +37,7 @@ void MDx_HashFunction::clear()
/*
* Update the hash
*/
-void MDx_HashFunction::add_data(const byte input[], u32bit length)
+void MDx_HashFunction::add_data(const byte input[], size_t length)
{
count += length;
@@ -54,8 +54,8 @@ void MDx_HashFunction::add_data(const byte input[], u32bit length)
}
}
- const u32bit full_blocks = length / HASH_BLOCK_SIZE;
- const u32bit remaining = length % HASH_BLOCK_SIZE;
+ const size_t full_blocks = length / HASH_BLOCK_SIZE;
+ const size_t remaining = length % HASH_BLOCK_SIZE;
if(full_blocks)
compress_n(input, full_blocks);
@@ -70,8 +70,8 @@ void MDx_HashFunction::add_data(const byte input[], u32bit length)
void MDx_HashFunction::final_result(byte output[])
{
buffer[position] = (BIG_BIT_ENDIAN ? 0x80 : 0x01);
- for(u32bit j = position+1; j != HASH_BLOCK_SIZE; ++j)
- buffer[j] = 0;
+ for(size_t i = position+1; i != HASH_BLOCK_SIZE; ++i)
+ buffer[i] = 0;
if(position >= HASH_BLOCK_SIZE - COUNT_SIZE)
{
diff --git a/src/hash/mdx_hash/mdx_hash.h b/src/hash/mdx_hash/mdx_hash.h
index 087c7fc46..6603f54bc 100644
--- a/src/hash/mdx_hash/mdx_hash.h
+++ b/src/hash/mdx_hash/mdx_hash.h
@@ -25,15 +25,15 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction
* @param big_bit_endian specifies if the hash uses big-endian bits
* @param counter_size specifies the size of the counter var in bytes
*/
- MDx_HashFunction(u32bit hash_length,
- u32bit block_length,
+ MDx_HashFunction(size_t hash_length,
+ size_t block_length,
bool big_byte_endian,
bool big_bit_endian,
- u32bit counter_size = 8);
+ size_t counter_size = 8);
virtual ~MDx_HashFunction() {}
protected:
- void add_data(const byte input[], u32bit length);
+ void add_data(const byte input[], size_t length);
void final_result(byte output[]);
/**
@@ -41,7 +41,7 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction
* @param blocks the input
* @param block_n the number of blocks
*/
- virtual void compress_n(const byte blocks[], u32bit block_n) = 0;
+ virtual void compress_n(const byte blocks[], size_t block_n) = 0;
void clear();
@@ -59,7 +59,7 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction
private:
SecureVector<byte> buffer;
u64bit count;
- u32bit position;
+ size_t position;
const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN;
const u32bit COUNT_SIZE;
diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp
index 0ba3f5a4f..794166327 100644
--- a/src/hash/par_hash/par_hash.cpp
+++ b/src/hash/par_hash/par_hash.cpp
@@ -14,12 +14,12 @@ namespace {
/*
* Return the sum of the hash sizes
*/
-u32bit sum_of_hash_lengths(const std::vector<HashFunction*>& hashes)
+size_t sum_of_hash_lengths(const std::vector<HashFunction*>& hashes)
{
- u32bit sum = 0;
+ size_t sum = 0;
- for(u32bit j = 0; j != hashes.size(); ++j)
- sum += hashes[j]->OUTPUT_LENGTH;
+ for(size_t i = 0; i != hashes.size(); ++i)
+ sum += hashes[i]->OUTPUT_LENGTH;
return sum;
}
@@ -29,10 +29,10 @@ u32bit sum_of_hash_lengths(const std::vector<HashFunction*>& hashes)
/*
* Update the hash
*/
-void Parallel::add_data(const byte input[], u32bit length)
+void Parallel::add_data(const byte input[], size_t length)
{
- for(u32bit j = 0; j != hashes.size(); ++j)
- hashes[j]->update(input, length);
+ for(size_t i = 0; i != hashes.size(); ++i)
+ hashes[i]->update(input, length);
}
/*
@@ -40,11 +40,11 @@ void Parallel::add_data(const byte input[], u32bit length)
*/
void Parallel::final_result(byte hash[])
{
- u32bit offset = 0;
- for(u32bit j = 0; j != hashes.size(); ++j)
+ size_t offset = 0;
+ for(size_t i = 0; i != hashes.size(); ++i)
{
- hashes[j]->final(hash + offset);
- offset += hashes[j]->OUTPUT_LENGTH;
+ hashes[i]->final(hash + offset);
+ offset += hashes[i]->OUTPUT_LENGTH;
}
}
@@ -54,11 +54,11 @@ void Parallel::final_result(byte hash[])
std::string Parallel::name() const
{
std::string hash_names;
- for(u32bit j = 0; j != hashes.size(); ++j)
+ for(size_t i = 0; i != hashes.size(); ++i)
{
- if(j)
+ if(i)
hash_names += ',';
- hash_names += hashes[j]->name();
+ hash_names += hashes[i]->name();
}
return "Parallel(" + hash_names + ")";
}
@@ -69,8 +69,8 @@ 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(size_t i = 0; i != hashes.size(); ++i)
+ hash_copies.push_back(hashes[i]->clone());
return new Parallel(hash_copies);
}
@@ -79,8 +79,8 @@ HashFunction* Parallel::clone() const
*/
void Parallel::clear()
{
- for(u32bit j = 0; j != hashes.size(); ++j)
- hashes[j]->clear();
+ for(size_t i = 0; i != hashes.size(); ++i)
+ hashes[i]->clear();
}
/*
@@ -96,8 +96,8 @@ Parallel::Parallel(const std::vector<HashFunction*>& hash_in) :
*/
Parallel::~Parallel()
{
- for(u32bit j = 0; j != hashes.size(); ++j)
- delete hashes[j];
+ for(size_t i = 0; i != hashes.size(); ++i)
+ delete hashes[i];
}
}
diff --git a/src/hash/par_hash/par_hash.h b/src/hash/par_hash/par_hash.h
index d82a74a19..35154dde4 100644
--- a/src/hash/par_hash/par_hash.h
+++ b/src/hash/par_hash/par_hash.h
@@ -29,7 +29,7 @@ class BOTAN_DLL Parallel : public HashFunction
Parallel(const std::vector<HashFunction*>& hashes);
~Parallel();
private:
- void add_data(const byte[], u32bit);
+ void add_data(const byte[], size_t);
void final_result(byte[]);
std::vector<HashFunction*> hashes;
};
diff --git a/src/hash/rmd128/rmd128.cpp b/src/hash/rmd128/rmd128.cpp
index 3e7eb9143..61737a4a0 100644
--- a/src/hash/rmd128/rmd128.cpp
+++ b/src/hash/rmd128/rmd128.cpp
@@ -58,7 +58,7 @@ inline void F4(u32bit& A, u32bit B, u32bit C, u32bit D,
/*
* RIPEMD-128 Compression Function
*/
-void RIPEMD_128::compress_n(const byte input[], u32bit blocks)
+void RIPEMD_128::compress_n(const byte input[], size_t blocks)
{
using namespace RIPEMD_128_F;
@@ -66,7 +66,7 @@ void RIPEMD_128::compress_n(const byte input[], u32bit blocks)
MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0x50A28BE6,
MAGIC6 = 0x5C4DD124, MAGIC7 = 0x6D703EF3;
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_le(&M[0], input, M.size());
@@ -156,8 +156,8 @@ void RIPEMD_128::compress_n(const byte input[], u32bit blocks)
*/
void RIPEMD_128::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
- store_le(digest[j/4], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
+ store_le(digest[i/4], output + i);
}
/*
diff --git a/src/hash/rmd128/rmd128.h b/src/hash/rmd128/rmd128.h
index 23272c622..faead3245 100644
--- a/src/hash/rmd128/rmd128.h
+++ b/src/hash/rmd128/rmd128.h
@@ -25,7 +25,7 @@ class BOTAN_DLL RIPEMD_128 : public MDx_HashFunction
RIPEMD_128() : MDx_HashFunction(16, 64, false, true), M(16), digest(4)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> M, digest;
diff --git a/src/hash/rmd160/rmd160.cpp b/src/hash/rmd160/rmd160.cpp
index f832d4ec1..255f3f95a 100644
--- a/src/hash/rmd160/rmd160.cpp
+++ b/src/hash/rmd160/rmd160.cpp
@@ -73,14 +73,14 @@ inline void F5(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
/*
* RIPEMD-160 Compression Function
*/
-void RIPEMD_160::compress_n(const byte input[], u32bit blocks)
+void RIPEMD_160::compress_n(const byte input[], size_t blocks)
{
const u32bit MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1,
MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0xA953FD4E,
MAGIC6 = 0x50A28BE6, MAGIC7 = 0x5C4DD124,
MAGIC8 = 0x6D703EF3, MAGIC9 = 0x7A6D76E9;
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_le(&M[0], input, M.size());
@@ -189,8 +189,8 @@ void RIPEMD_160::compress_n(const byte input[], u32bit blocks)
*/
void RIPEMD_160::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
- store_le(digest[j/4], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
+ store_le(digest[i/4], output + i);
}
/*
diff --git a/src/hash/rmd160/rmd160.h b/src/hash/rmd160/rmd160.h
index 09c995628..69c6b4a40 100644
--- a/src/hash/rmd160/rmd160.h
+++ b/src/hash/rmd160/rmd160.h
@@ -25,7 +25,7 @@ class BOTAN_DLL RIPEMD_160 : public MDx_HashFunction
RIPEMD_160() : MDx_HashFunction(20, 64, false, true), M(16), digest(5)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> M, digest;
diff --git a/src/hash/sha1/sha160.cpp b/src/hash/sha1/sha160.cpp
index 79348a371..6c98b21d2 100644
--- a/src/hash/sha1/sha160.cpp
+++ b/src/hash/sha1/sha160.cpp
@@ -54,16 +54,16 @@ inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 Compression Function
*/
-void SHA_160::compress_n(const byte input[], u32bit blocks)
+void SHA_160::compress_n(const byte input[], size_t blocks)
{
u32bit A = digest[0], B = digest[1], C = digest[2],
D = digest[3], E = digest[4];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_be(&W[0], input, 16);
- for(u32bit j = 16; j != 80; j += 8)
+ for(size_t j = 16; j != 80; j += 8)
{
W[j ] = rotate_left((W[j-3] ^ W[j-8] ^ W[j-14] ^ W[j-16]), 1);
W[j+1] = rotate_left((W[j-2] ^ W[j-7] ^ W[j-13] ^ W[j-15]), 1);
@@ -134,7 +134,7 @@ void SHA_160::compress_n(const byte input[], u32bit blocks)
*/
void SHA_160::copy_out(byte output[])
{
- for(u32bit i = 0; i != OUTPUT_LENGTH; i += 4)
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
store_be(digest[i/4], output + i);
}
@@ -164,7 +164,7 @@ SHA_160::SHA_160() :
/*
* SHA_160 Constructor
*/
-SHA_160::SHA_160(u32bit W_size) :
+SHA_160::SHA_160(size_t W_size) :
MDx_HashFunction(20, 64, true, true), digest(5), W(W_size)
{
clear();
diff --git a/src/hash/sha1/sha160.h b/src/hash/sha1/sha160.h
index 690aea1d5..d420f8f94 100644
--- a/src/hash/sha1/sha160.h
+++ b/src/hash/sha1/sha160.h
@@ -30,9 +30,9 @@ class BOTAN_DLL SHA_160 : public MDx_HashFunction
* constraints
* @param W_size how big to make W
*/
- SHA_160(u32bit W_size);
+ SHA_160(size_t W_size);
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> digest;
diff --git a/src/hash/sha1_amd64/sha1_amd64.cpp b/src/hash/sha1_amd64/sha1_amd64.cpp
index 885853182..00b1788cb 100644
--- a/src/hash/sha1_amd64/sha1_amd64.cpp
+++ b/src/hash/sha1_amd64/sha1_amd64.cpp
@@ -19,9 +19,9 @@ void botan_sha160_amd64_compress(u32bit[5], const byte[64], u32bit[80]);
/*
* SHA-160 Compression Function
*/
-void SHA_160_AMD64::compress_n(const byte input[], u32bit blocks)
+void SHA_160_AMD64::compress_n(const byte input[], size_t blocks)
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
botan_sha160_amd64_compress(&digest[0], input, &W[0]);
input += HASH_BLOCK_SIZE;
diff --git a/src/hash/sha1_amd64/sha1_amd64.h b/src/hash/sha1_amd64/sha1_amd64.h
index 6cf3b0fb7..6b741184d 100644
--- a/src/hash/sha1_amd64/sha1_amd64.h
+++ b/src/hash/sha1_amd64/sha1_amd64.h
@@ -20,7 +20,7 @@ class BOTAN_DLL SHA_160_AMD64 : public SHA_160
public:
HashFunction* clone() const { return new SHA_160_AMD64; }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
};
}
diff --git a/src/hash/sha1_ia32/sha1_ia32.cpp b/src/hash/sha1_ia32/sha1_ia32.cpp
index 611cc1961..6bc9f31ec 100644
--- a/src/hash/sha1_ia32/sha1_ia32.cpp
+++ b/src/hash/sha1_ia32/sha1_ia32.cpp
@@ -19,9 +19,9 @@ void botan_sha160_ia32_compress(u32bit[5], const byte[64], u32bit[81]);
/*
* SHA-160 Compression Function
*/
-void SHA_160_IA32::compress_n(const byte input[], u32bit blocks)
+void SHA_160_IA32::compress_n(const byte input[], size_t blocks)
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
botan_sha160_ia32_compress(&digest[0], input, &W[0]);
input += HASH_BLOCK_SIZE;
diff --git a/src/hash/sha1_ia32/sha1_ia32.h b/src/hash/sha1_ia32/sha1_ia32.h
index f579fbc90..5cff03016 100644
--- a/src/hash/sha1_ia32/sha1_ia32.h
+++ b/src/hash/sha1_ia32/sha1_ia32.h
@@ -23,7 +23,7 @@ class BOTAN_DLL SHA_160_IA32 : public SHA_160
// Note 81 instead of normal 80: IA-32 asm needs an extra temp
SHA_160_IA32() : SHA_160(81) {}
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
};
}
diff --git a/src/hash/sha1_sse2/sha1_sse2.cpp b/src/hash/sha1_sse2/sha1_sse2.cpp
index f1102afc5..8270f9ac4 100644
--- a/src/hash/sha1_sse2/sha1_sse2.cpp
+++ b/src/hash/sha1_sse2/sha1_sse2.cpp
@@ -149,7 +149,7 @@ inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg)
/*
* SHA-160 Compression Function using SSE for message expansion
*/
-void SHA_160_SSE2::compress_n(const byte input_bytes[], u32bit blocks)
+void SHA_160_SSE2::compress_n(const byte input_bytes[], size_t blocks)
{
const __m128i K00_19 = _mm_set1_epi32(0x5A827999);
const __m128i K20_39 = _mm_set1_epi32(0x6ED9EBA1);
@@ -164,7 +164,7 @@ void SHA_160_SSE2::compress_n(const byte input_bytes[], u32bit blocks)
const __m128i* input = reinterpret_cast<const __m128i*>(input_bytes);
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
union v4si {
u32bit u32[4];
diff --git a/src/hash/sha1_sse2/sha1_sse2.h b/src/hash/sha1_sse2/sha1_sse2.h
index 90935c737..9b7b327f0 100644
--- a/src/hash/sha1_sse2/sha1_sse2.h
+++ b/src/hash/sha1_sse2/sha1_sse2.h
@@ -21,7 +21,7 @@ class BOTAN_DLL SHA_160_SSE2 : public SHA_160
HashFunction* clone() const { return new SHA_160_SSE2; }
SHA_160_SSE2() : SHA_160(0) {} // no W needed
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
};
}
diff --git a/src/hash/sha2_32/sha2_32.cpp b/src/hash/sha2_32/sha2_32.cpp
index acd06061e..6bbf6dec9 100644
--- a/src/hash/sha2_32/sha2_32.cpp
+++ b/src/hash/sha2_32/sha2_32.cpp
@@ -48,17 +48,17 @@ inline void F1(u32bit A, u32bit B, u32bit C, u32bit& D,
*/
void sha2_32_compress(MemoryRegion<u32bit>& W,
MemoryRegion<u32bit>& digest,
- const byte input[], u32bit blocks)
+ const byte input[], size_t blocks)
{
u32bit A = digest[0], B = digest[1], C = digest[2],
D = digest[3], E = digest[4], F = digest[5],
G = digest[6], H = digest[7];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_be(&W[0], input, 16);
- for(u32bit j = 16; j != 64; j += 8)
+ for(size_t j = 16; j != 64; j += 8)
{
W[j ] = sigma(W[j- 2], 17, 19, 10) + W[j-7] +
sigma(W[j-15], 7, 18, 3) + W[j-16];
@@ -161,7 +161,7 @@ void sha2_32_compress(MemoryRegion<u32bit>& W,
/*
* SHA-224 compression function
*/
-void SHA_224::compress_n(const byte input[], u32bit blocks)
+void SHA_224::compress_n(const byte input[], size_t blocks)
{
sha2_32_compress(W, digest, input, blocks);
}
@@ -171,8 +171,8 @@ void SHA_224::compress_n(const byte input[], u32bit blocks)
*/
void SHA_224::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
- store_be(digest[j/4], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
+ store_be(digest[i/4], output + i);
}
/*
@@ -195,7 +195,7 @@ void SHA_224::clear()
/*
* SHA-256 compression function
*/
-void SHA_256::compress_n(const byte input[], u32bit blocks)
+void SHA_256::compress_n(const byte input[], size_t blocks)
{
sha2_32_compress(W, digest, input, blocks);
}
@@ -205,8 +205,8 @@ void SHA_256::compress_n(const byte input[], u32bit blocks)
*/
void SHA_256::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
- store_be(digest[j/4], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 4)
+ store_be(digest[i/4], output + i);
}
/*
diff --git a/src/hash/sha2_32/sha2_32.h b/src/hash/sha2_32/sha2_32.h
index a3e3a6f19..3b95812b8 100644
--- a/src/hash/sha2_32/sha2_32.h
+++ b/src/hash/sha2_32/sha2_32.h
@@ -26,7 +26,7 @@ class BOTAN_DLL SHA_224 : public MDx_HashFunction
SHA_224() : MDx_HashFunction(28, 64, true, true), W(64), digest(8)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> W, digest;
@@ -45,7 +45,7 @@ class BOTAN_DLL SHA_256 : public MDx_HashFunction
SHA_256() : MDx_HashFunction(32, 64, true, true), W(64), digest(8)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u32bit> W, digest;
diff --git a/src/hash/sha2_64/sha2_64.cpp b/src/hash/sha2_64/sha2_64.cpp
index 5ca78173c..96e672819 100644
--- a/src/hash/sha2_64/sha2_64.cpp
+++ b/src/hash/sha2_64/sha2_64.cpp
@@ -47,17 +47,17 @@ inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift)
*/
void sha2_64_compress(MemoryRegion<u64bit>& W,
MemoryRegion<u64bit>& digest,
- const byte input[], u32bit blocks)
+ const byte input[], size_t blocks)
{
u64bit A = digest[0], B = digest[1], C = digest[2],
D = digest[3], E = digest[4], F = digest[5],
G = digest[6], H = digest[7];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_be(&W[0], input, 16);
- for(u32bit j = 16; j != 80; j += 8)
+ for(size_t j = 16; j != 80; j += 8)
{
W[j ] = sigma(W[j-2], 19, 61, 6) + W[j-7] + sigma(W[j-15], 1, 8, 7) + W[j-16];
W[j+1] = sigma(W[j-1], 19, 61, 6) + W[j-6] + sigma(W[j-14], 1, 8, 7) + W[j-15];
@@ -168,7 +168,7 @@ void sha2_64_compress(MemoryRegion<u64bit>& W,
/*
* SHA-384 compression function
*/
-void SHA_384::compress_n(const byte input[], u32bit blocks)
+void SHA_384::compress_n(const byte input[], size_t blocks)
{
sha2_64_compress(W, digest, input, blocks);
}
@@ -178,8 +178,8 @@ void SHA_384::compress_n(const byte input[], u32bit blocks)
*/
void SHA_384::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 8)
- store_be(digest[j/8], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 8)
+ store_be(digest[i/8], output + i);
}
/*
@@ -202,7 +202,7 @@ void SHA_384::clear()
/*
* SHA-512 compression function
*/
-void SHA_512::compress_n(const byte input[], u32bit blocks)
+void SHA_512::compress_n(const byte input[], size_t blocks)
{
sha2_64_compress(W, digest, input, blocks);
}
@@ -212,8 +212,8 @@ void SHA_512::compress_n(const byte input[], u32bit blocks)
*/
void SHA_512::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 8)
- store_be(digest[j/8], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 8)
+ store_be(digest[i/8], output + i);
}
/*
diff --git a/src/hash/sha2_64/sha2_64.h b/src/hash/sha2_64/sha2_64.h
index 726712221..59e2c4c83 100644
--- a/src/hash/sha2_64/sha2_64.h
+++ b/src/hash/sha2_64/sha2_64.h
@@ -25,7 +25,7 @@ class BOTAN_DLL SHA_384 : public MDx_HashFunction
SHA_384() : MDx_HashFunction(48, 128, true, true, 16), W(80), digest(8)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u64bit> W, digest;
@@ -43,7 +43,7 @@ class BOTAN_DLL SHA_512 : public MDx_HashFunction
SHA_512() : MDx_HashFunction(64, 128, true, true, 16), W(80), digest(8)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
SecureVector<u64bit> W, digest;
diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp
index a3aff52ab..665dd7248 100644
--- a/src/hash/skein/skein_512.cpp
+++ b/src/hash/skein/skein_512.cpp
@@ -29,11 +29,11 @@ enum type_code {
void ubi_512(MemoryRegion<u64bit>& H,
MemoryRegion<u64bit>& T,
- const byte msg[], u32bit msg_len)
+ const byte msg[], size_t msg_len)
{
do
{
- const u32bit to_proc = std::min<u32bit>(msg_len, 64);
+ const size_t to_proc = std::min<size_t>(msg_len, 64);
T[0] += to_proc;
u64bit M[8] = { 0 };
@@ -42,7 +42,7 @@ void ubi_512(MemoryRegion<u64bit>& H,
if(to_proc % 8)
{
- for(u32bit j = 0; j != to_proc % 8; ++j)
+ for(size_t j = 0; j != to_proc % 8; ++j)
M[to_proc/8] |= ((u64bit)msg[8*(to_proc/8)+j] << (8*j));
}
@@ -197,7 +197,7 @@ void Skein_512::clear()
buf_pos = 0;
}
-void Skein_512::add_data(const byte input[], u32bit length)
+void Skein_512::add_data(const byte input[], size_t length)
{
if(length == 0)
return;
@@ -215,7 +215,7 @@ void Skein_512::add_data(const byte input[], u32bit length)
}
}
- const u32bit full_blocks = (length - 1) / 64;
+ const size_t full_blocks = (length - 1) / 64;
if(full_blocks)
ubi_512(H, T, input, 64*full_blocks);
@@ -230,33 +230,33 @@ void Skein_512::final_result(byte out[])
{
T[1] |= ((u64bit)1 << 63); // final block flag
- for(u32bit i = buf_pos; i != buffer.size(); ++i)
+ for(size_t i = buf_pos; i != buffer.size(); ++i)
buffer[i] = 0;
ubi_512(H, T, &buffer[0], buf_pos);
byte counter[8] = { 0 };
- u32bit out_bytes = output_bits / 8;
+ size_t out_bytes = output_bits / 8;
SecureVector<u64bit> H_out(9);
while(out_bytes)
{
- const u32bit to_proc = std::min<u32bit>(out_bytes, 64);
+ const size_t to_proc = std::min<size_t>(out_bytes, 64);
H_out.copy(&H[0], 8);
reset_tweak(T, SKEIN_OUTPUT, true);
ubi_512(H_out, T, counter, sizeof(counter));
- for(u32bit i = 0; i != to_proc; ++i)
+ for(size_t i = 0; i != to_proc; ++i)
out[i] = get_byte(7-i%8, H_out[i/8]);
out_bytes -= to_proc;
out += to_proc;
- for(u32bit i = 0; i != sizeof(counter); ++i)
+ for(size_t i = 0; i != sizeof(counter); ++i)
if(++counter[i])
break;
}
diff --git a/src/hash/skein/skein_512.h b/src/hash/skein/skein_512.h
index 811b633eb..803f1c916 100644
--- a/src/hash/skein/skein_512.h
+++ b/src/hash/skein/skein_512.h
@@ -32,16 +32,16 @@ class BOTAN_DLL Skein_512 : public HashFunction
std::string name() const;
void clear();
private:
- void add_data(const byte input[], u32bit length);
+ void add_data(const byte input[], size_t length);
void final_result(byte out[]);
std::string personalization;
- u32bit output_bits;
+ size_t output_bits;
SecureVector<u64bit> H;
SecureVector<u64bit> T;
SecureVector<byte> buffer;
- u32bit buf_pos;
+ size_t buf_pos;
};
}
diff --git a/src/hash/tiger/tiger.cpp b/src/hash/tiger/tiger.cpp
index 9d3e2cbe4..fa5effd80 100644
--- a/src/hash/tiger/tiger.cpp
+++ b/src/hash/tiger/tiger.cpp
@@ -43,11 +43,11 @@ inline void mix(MemoryRegion<u64bit>& X)
/*
* Tiger Compression Function
*/
-void Tiger::compress_n(const byte input[], u32bit blocks)
+void Tiger::compress_n(const byte input[], size_t blocks)
{
u64bit A = digest[0], B = digest[1], C = digest[2];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_le(&X[0], input, X.size());
@@ -55,7 +55,7 @@ void Tiger::compress_n(const byte input[], u32bit blocks)
pass(C, A, B, X, 7); mix(X);
pass(B, C, A, X, 9);
- for(u32bit j = 3; j != PASS; ++j)
+ for(size_t j = 3; j != PASS; ++j)
{
mix(X);
pass(A, B, C, X, 9);
@@ -75,8 +75,8 @@ void Tiger::compress_n(const byte input[], u32bit blocks)
*/
void Tiger::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; ++j)
- output[j] = get_byte(7 - (j % 8), digest[j/8]);
+ for(size_t i = 0; i != OUTPUT_LENGTH; ++i)
+ output[i] = get_byte(7 - (i % 8), digest[i/8]);
}
/*
@@ -166,7 +166,7 @@ std::string Tiger::name() const
/*
* Tiger Constructor
*/
-Tiger::Tiger(u32bit hashlen, u32bit pass) :
+Tiger::Tiger(size_t hashlen, size_t pass) :
MDx_HashFunction(hashlen, 64, false, false),
X(8),
digest(3),
diff --git a/src/hash/tiger/tiger.h b/src/hash/tiger/tiger.h
index 4b8a99344..7305ddb46 100644
--- a/src/hash/tiger/tiger.h
+++ b/src/hash/tiger/tiger.h
@@ -30,9 +30,9 @@ class BOTAN_DLL Tiger : public MDx_HashFunction
* @param out_size specifies the output length; can be 16, 20, or 24
* @param passes to make in the algorithm
*/
- Tiger(u32bit out_size = 24, u32bit passes = 3);
+ Tiger(size_t out_size = 24, size_t passes = 3);
private:
- void compress_n(const byte[], u32bit block);
+ void compress_n(const byte[], size_t block);
void copy_out(byte[]);
static void pass(u64bit& A, u64bit& B, u64bit& C,
@@ -45,7 +45,7 @@ class BOTAN_DLL Tiger : public MDx_HashFunction
static const u64bit SBOX4[256];
SecureVector<u64bit> X, digest;
- const u32bit PASS;
+ const size_t PASS;
};
}
diff --git a/src/hash/whirlpool/whrlpool.cpp b/src/hash/whirlpool/whrlpool.cpp
index fcd244ce2..fdbdf5d0f 100644
--- a/src/hash/whirlpool/whrlpool.cpp
+++ b/src/hash/whirlpool/whrlpool.cpp
@@ -13,7 +13,7 @@ namespace Botan {
/*
* Whirlpool Compression Function
*/
-void Whirlpool::compress_n(const byte in[], u32bit blocks)
+void Whirlpool::compress_n(const byte in[], size_t blocks)
{
static const u64bit RC[10] = {
0x1823C6E887B8014F, 0x36A6D2F5796F9152,
@@ -23,7 +23,7 @@ void Whirlpool::compress_n(const byte in[], u32bit blocks)
0xFBEE7C66DD17479E, 0xCA2DBF07AD5A8333
};
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
load_be(&M[0], in, M.size());
@@ -35,7 +35,7 @@ void Whirlpool::compress_n(const byte in[], u32bit blocks)
B0 = K0 ^ M[0]; B1 = K1 ^ M[1]; B2 = K2 ^ M[2]; B3 = K3 ^ M[3];
B4 = K4 ^ M[4]; B5 = K5 ^ M[5]; B6 = K6 ^ M[6]; B7 = K7 ^ M[7];
- for(u32bit j = 0; j != 10; ++j)
+ for(size_t j = 0; j != 10; ++j)
{
u64bit T0, T1, T2, T3, T4, T5, T6, T7;
T0 = C0[get_byte(0, K0)] ^ C1[get_byte(1, K7)] ^
@@ -129,8 +129,8 @@ void Whirlpool::compress_n(const byte in[], u32bit blocks)
*/
void Whirlpool::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; j += 8)
- store_be(digest[j/8], output + j);
+ for(size_t i = 0; i != OUTPUT_LENGTH; i += 8)
+ store_be(digest[i/8], output + i);
}
/*
diff --git a/src/hash/whirlpool/whrlpool.h b/src/hash/whirlpool/whrlpool.h
index 98be0b480..30bf91a34 100644
--- a/src/hash/whirlpool/whrlpool.h
+++ b/src/hash/whirlpool/whrlpool.h
@@ -25,7 +25,7 @@ class BOTAN_DLL Whirlpool : public MDx_HashFunction
Whirlpool() : MDx_HashFunction(64, 64, true, true, 32), M(8), digest(8)
{ clear(); }
private:
- void compress_n(const byte[], u32bit blocks);
+ void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
static const u64bit C0[256];