aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/block/aes/aes.cpp8
-rw-r--r--src/block/aes/aes.h4
-rw-r--r--src/block/aes_ssse3/aes_ssse3.cpp38
-rw-r--r--src/block/aes_ssse3/aes_ssse3.h12
-rw-r--r--src/block/block_cipher.h4
-rw-r--r--src/block/blowfish/blowfish.cpp18
-rw-r--r--src/block/blowfish/blowfish.h4
-rw-r--r--src/block/cascade/cascade.cpp20
-rw-r--r--src/block/cascade/cascade.h4
-rw-r--r--src/block/cast/cast128.cpp14
-rw-r--r--src/block/cast/cast128.h4
-rw-r--r--src/block/cast/cast256.cpp12
-rw-r--r--src/block/cast/cast256.h4
-rw-r--r--src/block/des/des.cpp16
-rw-r--r--src/block/des/des.h8
-rw-r--r--src/block/des/desx.cpp8
-rw-r--r--src/block/des/desx.h4
-rw-r--r--src/block/gost_28147/gost_28147.cpp20
-rw-r--r--src/block/gost_28147/gost_28147.h6
-rw-r--r--src/block/idea/idea.cpp18
-rw-r--r--src/block/idea/idea.h4
-rw-r--r--src/block/idea_sse2/idea_sse2.cpp6
-rw-r--r--src/block/idea_sse2/idea_sse2.h4
-rw-r--r--src/block/kasumi/kasumi.cpp36
-rw-r--r--src/block/kasumi/kasumi.h4
-rw-r--r--src/block/lion/lion.cpp12
-rw-r--r--src/block/lion/lion.h8
-rw-r--r--src/block/lubyrack/lubyrack.cpp12
-rw-r--r--src/block/lubyrack/lubyrack.h4
-rw-r--r--src/block/mars/mars.cpp68
-rw-r--r--src/block/mars/mars.h4
-rw-r--r--src/block/misty1/misty1.cpp32
-rw-r--r--src/block/misty1/misty1.h6
-rw-r--r--src/block/noekeon/noekeon.cpp14
-rw-r--r--src/block/noekeon/noekeon.h4
-rw-r--r--src/block/noekeon_simd/noekeon_simd.cpp8
-rw-r--r--src/block/noekeon_simd/noekeon_simd.h4
-rw-r--r--src/block/rc2/rc2.cpp24
-rw-r--r--src/block/rc2/rc2.h6
-rw-r--r--src/block/rc5/rc5.cpp44
-rw-r--r--src/block/rc5/rc5.h8
-rw-r--r--src/block/rc6/rc6.cpp22
-rw-r--r--src/block/rc6/rc6.h4
-rw-r--r--src/block/safer/safer_sk.cpp29
-rw-r--r--src/block/safer/safer_sk.h8
-rw-r--r--src/block/seed/seed.cpp26
-rw-r--r--src/block/seed/seed.h4
-rw-r--r--src/block/serpent/serpent.cpp21
-rw-r--r--src/block/serpent/serpent.h4
-rw-r--r--src/block/serpent_simd/serp_simd.cpp4
-rw-r--r--src/block/serpent_simd/serp_simd.h4
-rw-r--r--src/block/skipjack/skipjack.cpp20
-rw-r--r--src/block/skipjack/skipjack.h4
-rw-r--r--src/block/square/square.cpp28
-rw-r--r--src/block/square/square.h4
-rw-r--r--src/block/tea/tea.cpp22
-rw-r--r--src/block/tea/tea.h4
-rw-r--r--src/block/twofish/twofish.cpp28
-rw-r--r--src/block/twofish/twofish.h6
-rw-r--r--src/block/xtea/xtea.cpp26
-rw-r--r--src/block/xtea/xtea.h4
-rw-r--r--src/block/xtea_simd/xtea_simd.cpp4
-rw-r--r--src/block/xtea_simd/xtea_simd.h4
-rw-r--r--src/engine/openssl/ossl_bc.cpp11
-rw-r--r--src/filters/modes/ecb/ecb.cpp4
65 files changed, 430 insertions, 403 deletions
diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp
index f2f1bc9e5..66f9c5eb1 100644
--- a/src/block/aes/aes.cpp
+++ b/src/block/aes/aes.cpp
@@ -412,14 +412,14 @@ const u32bit TD[1024] = {
/*
* AES Encryption
*/
-void AES::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* TE0 = TE;
const u32bit* TE1 = TE + 256;
const u32bit* TE2 = TE + 512;
const u32bit* TE3 = TE + 768;
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit T0 = load_be<u32bit>(in, 0) ^ EK[0];
u32bit T1 = load_be<u32bit>(in, 1) ^ EK[1];
@@ -529,14 +529,14 @@ void AES::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* AES Decryption
*/
-void AES::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* TD0 = TD;
const u32bit* TD1 = TD + 256;
const u32bit* TD2 = TD + 512;
const u32bit* TD3 = TD + 768;
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit T0 = load_be<u32bit>(in, 0) ^ DK[0];
u32bit T1 = load_be<u32bit>(in, 1) ^ DK[1];
diff --git a/src/block/aes/aes.h b/src/block/aes/aes.h
index ba688a6e3..6bc1f44b4 100644
--- a/src/block/aes/aes.h
+++ b/src/block/aes/aes.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL AES : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const { return "AES"; }
diff --git a/src/block/aes_ssse3/aes_ssse3.cpp b/src/block/aes_ssse3/aes_ssse3.cpp
index 07e36e25e..dda5941b7 100644
--- a/src/block/aes_ssse3/aes_ssse3.cpp
+++ b/src/block/aes_ssse3/aes_ssse3.cpp
@@ -171,7 +171,7 @@ __m128i aes_schedule_round(__m128i* rcon, __m128i input1, __m128i input2)
smeared);
}
-__m128i aes_ssse3_encrypt(__m128i B, const __m128i* keys, u32bit rounds)
+__m128i aes_ssse3_encrypt(__m128i B, const __m128i* keys, size_t rounds)
{
const __m128i sb2u = _mm_set_epi32(
0x5EB7E955, 0xBC982FCD, 0xE27A93C6, 0x0B712400);
@@ -197,7 +197,7 @@ __m128i aes_ssse3_encrypt(__m128i B, const __m128i* keys, u32bit rounds)
4)),
_mm_loadu_si128(keys));
- for(u32bit r = 1; ; ++r)
+ for(size_t r = 1; ; ++r)
{
const __m128i K = _mm_loadu_si128(keys + r);
@@ -240,7 +240,7 @@ __m128i aes_ssse3_encrypt(__m128i B, const __m128i* keys, u32bit rounds)
}
}
-__m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, u32bit rounds)
+__m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, size_t rounds)
{
const __m128i k_dipt1 = _mm_set_epi32(
0x154A411E, 0x114E451A, 0x0F505B04, 0x0B545F00);
@@ -278,7 +278,7 @@ __m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, u32bit rounds)
B = mm_xor3(t, _mm_loadu_si128(keys),
_mm_shuffle_epi8(k_dipt1, _mm_and_si128(B, low_nibs)));
- for(u32bit r = 1; ; ++r)
+ for(size_t r = 1; ; ++r)
{
const __m128i K = _mm_loadu_si128(keys + r);
@@ -337,14 +337,14 @@ __m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, u32bit rounds)
/*
* AES-128 Encryption
*/
-void AES_128_SSSE3::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES_128_SSSE3::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const __m128i* in_mm = (const __m128i*)in;
__m128i* out_mm = (__m128i*)out;
const __m128i* keys = (const __m128i*)&EK[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
__m128i B = _mm_loadu_si128(in_mm + i);
_mm_storeu_si128(out_mm + i, aes_ssse3_encrypt(B, keys, 10));
@@ -354,14 +354,14 @@ void AES_128_SSSE3::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* AES-128 Decryption
*/
-void AES_128_SSSE3::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES_128_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const __m128i* in_mm = (const __m128i*)in;
__m128i* out_mm = (__m128i*)out;
const __m128i* keys = (const __m128i*)&DK[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
__m128i B = _mm_loadu_si128(in_mm + i);
_mm_storeu_si128(out_mm + i, aes_ssse3_decrypt(B, keys, 10));
@@ -387,7 +387,7 @@ void AES_128_SSSE3::key_schedule(const byte keyb[], u32bit)
_mm_storeu_si128(EK_mm, key);
- for(u32bit i = 1; i != 10; ++i)
+ for(size_t i = 1; i != 10; ++i)
{
key = aes_schedule_round(&rcon, key, key);
@@ -406,14 +406,14 @@ void AES_128_SSSE3::key_schedule(const byte keyb[], u32bit)
/*
* AES-192 Encryption
*/
-void AES_192_SSSE3::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES_192_SSSE3::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const __m128i* in_mm = (const __m128i*)in;
__m128i* out_mm = (__m128i*)out;
const __m128i* keys = (const __m128i*)&EK[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
__m128i B = _mm_loadu_si128(in_mm + i);
_mm_storeu_si128(out_mm + i, aes_ssse3_encrypt(B, keys, 12));
@@ -423,14 +423,14 @@ void AES_192_SSSE3::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* AES-192 Decryption
*/
-void AES_192_SSSE3::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES_192_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const __m128i* in_mm = (const __m128i*)in;
__m128i* out_mm = (__m128i*)out;
const __m128i* keys = (const __m128i*)&DK[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
__m128i B = _mm_loadu_si128(in_mm + i);
_mm_storeu_si128(out_mm + i, aes_ssse3_decrypt(B, keys, 12));
@@ -461,7 +461,7 @@ void AES_192_SSSE3::key_schedule(const byte keyb[], u32bit)
// key2 with 8 high bytes masked off
__m128i t = _mm_slli_si128(_mm_srli_si128(key2, 8), 8);
- for(u32bit i = 0; i != 4; ++i)
+ for(size_t i = 0; i != 4; ++i)
{
key2 = aes_schedule_round(&rcon, key2, key1);
@@ -505,14 +505,14 @@ void AES_192_SSSE3::key_schedule(const byte keyb[], u32bit)
/*
* AES-256 Encryption
*/
-void AES_256_SSSE3::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES_256_SSSE3::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const __m128i* in_mm = (const __m128i*)in;
__m128i* out_mm = (__m128i*)out;
const __m128i* keys = (const __m128i*)&EK[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
__m128i B = _mm_loadu_si128(in_mm + i);
_mm_storeu_si128(out_mm + i, aes_ssse3_encrypt(B, keys, 14));
@@ -522,14 +522,14 @@ void AES_256_SSSE3::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* AES-256 Decryption
*/
-void AES_256_SSSE3::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void AES_256_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const __m128i* in_mm = (const __m128i*)in;
__m128i* out_mm = (__m128i*)out;
const __m128i* keys = (const __m128i*)&DK[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
__m128i B = _mm_loadu_si128(in_mm + i);
_mm_storeu_si128(out_mm + i, aes_ssse3_decrypt(B, keys, 14));
@@ -560,7 +560,7 @@ void AES_256_SSSE3::key_schedule(const byte keyb[], u32bit)
_mm_storeu_si128(DK_mm + 13, aes_schedule_mangle_dec(key2, 1));
- for(u32bit i = 2; i != 14; i += 2)
+ for(size_t i = 2; i != 14; i += 2)
{
__m128i k_t = key2;
key1 = key2 = aes_schedule_round(&rcon, key2, key1);
diff --git a/src/block/aes_ssse3/aes_ssse3.h b/src/block/aes_ssse3/aes_ssse3.h
index 6e7d29a37..7b2a43cb7 100644
--- a/src/block/aes_ssse3/aes_ssse3.h
+++ b/src/block/aes_ssse3/aes_ssse3.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL AES_128_SSSE3 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); zeroise(DK); }
std::string name() const { return "AES-128"; }
@@ -38,8 +38,8 @@ class BOTAN_DLL AES_128_SSSE3 : public BlockCipher
class BOTAN_DLL AES_192_SSSE3 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); zeroise(DK); }
std::string name() const { return "AES-192"; }
@@ -58,8 +58,8 @@ class BOTAN_DLL AES_192_SSSE3 : public BlockCipher
class BOTAN_DLL AES_256_SSSE3 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); zeroise(DK); }
std::string name() const { return "AES-256"; }
diff --git a/src/block/block_cipher.h b/src/block/block_cipher.h
index 67a989822..8f9a4e121 100644
--- a/src/block/block_cipher.h
+++ b/src/block/block_cipher.h
@@ -95,7 +95,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param blocks the number of blocks to process
*/
virtual void encrypt_n(const byte in[], byte out[],
- u32bit blocks) const = 0;
+ size_t blocks) const = 0;
/**
* Decrypt one or more blocks
@@ -104,7 +104,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param blocks the number of blocks to process
*/
virtual void decrypt_n(const byte in[], byte out[],
- u32bit blocks) const = 0;
+ size_t blocks) const = 0;
/**
* Get a new object representing the same algorithm as *this
diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp
index 91d25884d..e72dbb2ae 100644
--- a/src/block/blowfish/blowfish.cpp
+++ b/src/block/blowfish/blowfish.cpp
@@ -13,19 +13,19 @@ namespace Botan {
/*
* Blowfish Encryption
*/
-void Blowfish::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* S1 = &S[0];
const u32bit* S2 = &S[256];
const u32bit* S3 = &S[512];
const u32bit* S4 = &S[768];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit L = load_be<u32bit>(in, 0);
u32bit R = load_be<u32bit>(in, 1);
- for(u32bit j = 0; j != 16; j += 2)
+ for(size_t j = 0; j != 16; j += 2)
{
L ^= P[j];
R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^
@@ -48,19 +48,19 @@ void Blowfish::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Blowfish Decryption
*/
-void Blowfish::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* S1 = &S[0];
const u32bit* S2 = &S[256];
const u32bit* S3 = &S[512];
const u32bit* S4 = &S[768];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit L = load_be<u32bit>(in, 0);
u32bit R = load_be<u32bit>(in, 1);
- for(u32bit j = 17; j != 1; j -= 2)
+ for(size_t j = 17; j != 1; j -= 2)
{
L ^= P[j];
R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^
@@ -87,7 +87,7 @@ void Blowfish::key_schedule(const byte key[], u32bit length)
{
clear();
- for(u32bit j = 0, k = 0; j != 18; ++j, k += 4)
+ for(size_t j = 0, k = 0; j != 18; ++j, k += 4)
P[j] ^= make_u32bit(key[(k ) % length], key[(k+1) % length],
key[(k+2) % length], key[(k+3) % length]);
@@ -107,9 +107,9 @@ void Blowfish::generate_sbox(MemoryRegion<u32bit>& box,
const u32bit* S3 = &S[512];
const u32bit* S4 = &S[768];
- for(u32bit j = 0; j != box.size(); j += 2)
+ for(size_t j = 0; j != box.size(); j += 2)
{
- for(u32bit k = 0; k != 16; k += 2)
+ for(size_t k = 0; k != 16; k += 2)
{
L ^= P[k];
R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^
diff --git a/src/block/blowfish/blowfish.h b/src/block/blowfish/blowfish.h
index 0b4df50ad..32fb4cbd4 100644
--- a/src/block/blowfish/blowfish.h
+++ b/src/block/blowfish/blowfish.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Blowfish : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const { return "Blowfish"; }
diff --git a/src/block/cascade/cascade.cpp b/src/block/cascade/cascade.cpp
index f72ef7b76..e93e81d33 100644
--- a/src/block/cascade/cascade.cpp
+++ b/src/block/cascade/cascade.cpp
@@ -10,20 +10,20 @@
namespace Botan {
void Cascade_Cipher::encrypt_n(const byte in[], byte out[],
- u32bit blocks) const
+ size_t blocks) const
{
- u32bit c1_blocks = blocks * (BLOCK_SIZE / cipher1->BLOCK_SIZE);
- u32bit c2_blocks = blocks * (BLOCK_SIZE / cipher2->BLOCK_SIZE);
+ size_t c1_blocks = blocks * (BLOCK_SIZE / cipher1->BLOCK_SIZE);
+ size_t c2_blocks = blocks * (BLOCK_SIZE / cipher2->BLOCK_SIZE);
cipher1->encrypt_n(in, out, c1_blocks);
cipher2->encrypt_n(out, out, c2_blocks);
}
void Cascade_Cipher::decrypt_n(const byte in[], byte out[],
- u32bit blocks) const
+ size_t blocks) const
{
- u32bit c1_blocks = blocks * (BLOCK_SIZE / cipher1->BLOCK_SIZE);
- u32bit c2_blocks = blocks * (BLOCK_SIZE / cipher2->BLOCK_SIZE);
+ size_t c1_blocks = blocks * (BLOCK_SIZE / cipher1->BLOCK_SIZE);
+ size_t c2_blocks = blocks * (BLOCK_SIZE / cipher2->BLOCK_SIZE);
cipher2->decrypt_n(in, out, c2_blocks);
cipher1->decrypt_n(out, out, c1_blocks);
@@ -56,11 +56,11 @@ BlockCipher* Cascade_Cipher::clone() const
namespace {
-u32bit euclids_algorithm(u32bit a, u32bit b)
+size_t euclids_algorithm(size_t a, size_t b)
{
while(b != 0) // gcd
{
- u32bit t = b;
+ size_t t = b;
b = a % b;
a = t;
}
@@ -68,12 +68,12 @@ u32bit euclids_algorithm(u32bit a, u32bit b)
return a;
}
-u32bit block_size_for_cascade(u32bit bs, u32bit bs2)
+size_t block_size_for_cascade(size_t bs, size_t bs2)
{
if(bs == bs2)
return bs;
- u32bit gcd = euclids_algorithm(bs, bs2);
+ size_t gcd = euclids_algorithm(bs, bs2);
return (bs * bs2) / gcd;
}
diff --git a/src/block/cascade/cascade.h b/src/block/cascade/cascade.h
index abd9b015d..6e9d43cf7 100644
--- a/src/block/cascade/cascade.h
+++ b/src/block/cascade/cascade.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Cascade_Cipher : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const;
diff --git a/src/block/cast/cast128.cpp b/src/block/cast/cast128.cpp
index 48eb910ce..538c1bd5b 100644
--- a/src/block/cast/cast128.cpp
+++ b/src/block/cast/cast128.cpp
@@ -48,9 +48,9 @@ inline void R3(u32bit& L, u32bit R, u32bit MK, u32bit RK)
/*
* CAST-128 Encryption
*/
-void CAST_128::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void CAST_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit L = load_be<u32bit>(in, 0);
u32bit R = load_be<u32bit>(in, 1);
@@ -82,9 +82,9 @@ void CAST_128::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* CAST-128 Decryption
*/
-void CAST_128::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit L = load_be<u32bit>(in, 0);
u32bit R = load_be<u32bit>(in, 1);
@@ -120,13 +120,13 @@ void CAST_128::key_schedule(const byte key[], u32bit length)
{
clear();
SecureVector<u32bit> X(4);
- for(u32bit j = 0; j != length; ++j)
+ for(size_t j = 0; j != length; ++j)
X[j/4] = (X[j/4] << 8) + key[j];
cast_ks(MK, X);
cast_ks(RK, X);
- for(u32bit j = 0; j != 16; ++j)
+ for(size_t j = 0; j != 16; ++j)
RK[j] %= 32;
}
@@ -139,7 +139,7 @@ void CAST_128::cast_ks(MemoryRegion<u32bit>& K,
class ByteReader
{
public:
- byte operator()(u32bit i) { return (X[i/4] >> (8*(3 - (i%4)))); }
+ byte operator()(size_t i) { return (X[i/4] >> (8*(3 - (i%4)))); }
ByteReader(const u32bit* x) : X(x) {}
private:
const u32bit* X;
diff --git a/src/block/cast/cast128.h b/src/block/cast/cast128.h
index bb8332aca..18c0c1868 100644
--- a/src/block/cast/cast128.h
+++ b/src/block/cast/cast128.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL CAST_128 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(MK); zeroise(RK); }
std::string name() const { return "CAST-128"; }
diff --git a/src/block/cast/cast256.cpp b/src/block/cast/cast256.cpp
index 551d4e387..6567ffbd4 100644
--- a/src/block/cast/cast256.cpp
+++ b/src/block/cast/cast256.cpp
@@ -48,9 +48,9 @@ void round3(u32bit& out, u32bit in, u32bit mask, u32bit rot)
/*
* CAST-256 Encryption
*/
-void CAST_256::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void CAST_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_be<u32bit>(in, 0);
u32bit B = load_be<u32bit>(in, 1);
@@ -92,9 +92,9 @@ void CAST_256::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* CAST-256 Decryption
*/
-void CAST_256::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void CAST_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_be<u32bit>(in, 0);
u32bit B = load_be<u32bit>(in, 1);
@@ -139,13 +139,13 @@ void CAST_256::decrypt_n(const byte in[], byte out[], u32bit blocks) const
void CAST_256::key_schedule(const byte key[], u32bit length)
{
SecureVector<u32bit> K(8);
- for(u32bit j = 0; j != length; ++j)
+ for(size_t j = 0; j != length; ++j)
K[j/4] = (K[j/4] << 8) + key[j];
u32bit A = K[0], B = K[1], C = K[2], D = K[3],
E = K[4], F = K[5], G = K[6], H = K[7];
- for(u32bit j = 0; j != 48; j += 4)
+ for(size_t j = 0; j != 48; j += 4)
{
round1(G, H, KEY_MASK[4*j+ 0], KEY_ROT[(4*j+ 0) % 32]);
round2(F, G, KEY_MASK[4*j+ 1], KEY_ROT[(4*j+ 1) % 32]);
diff --git a/src/block/cast/cast256.h b/src/block/cast/cast256.h
index 533f57ac1..ef73fbf94 100644
--- a/src/block/cast/cast256.h
+++ b/src/block/cast/cast256.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL CAST_256 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(MK); zeroise(RK); }
std::string name() const { return "CAST-256"; }
diff --git a/src/block/des/des.cpp b/src/block/des/des.cpp
index 37424cd35..043391938 100644
--- a/src/block/des/des.cpp
+++ b/src/block/des/des.cpp
@@ -140,9 +140,9 @@ void des_decrypt(u32bit& L, u32bit& R,
/*
* DES Encryption
*/
-void DES::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void DES::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
@@ -170,9 +170,9 @@ void DES::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* DES Decryption
*/
-void DES::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
@@ -209,9 +209,9 @@ void DES::key_schedule(const byte key[], u32bit)
/*
* TripleDES Encryption
*/
-void TripleDES::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void TripleDES::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
@@ -242,9 +242,9 @@ void TripleDES::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* TripleDES Decryption
*/
-void TripleDES::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
diff --git a/src/block/des/des.h b/src/block/des/des.h
index e338b9a29..dbca8ddfd 100644
--- a/src/block/des/des.h
+++ b/src/block/des/des.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL DES : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(round_key); }
std::string name() const { return "DES"; }
@@ -38,8 +38,8 @@ class BOTAN_DLL DES : public BlockCipher
class BOTAN_DLL TripleDES : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(round_key); }
std::string name() const { return "TripleDES"; }
diff --git a/src/block/des/desx.cpp b/src/block/des/desx.cpp
index cc97c4e7b..cb53448b4 100644
--- a/src/block/des/desx.cpp
+++ b/src/block/des/desx.cpp
@@ -13,9 +13,9 @@ namespace Botan {
/*
* DESX Encryption
*/
-void DESX::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void DESX::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
xor_buf(out, in, &K1[0], BLOCK_SIZE);
des.encrypt(out);
@@ -29,9 +29,9 @@ void DESX::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* DESX Decryption
*/
-void DESX::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
xor_buf(out, in, &K2[0], BLOCK_SIZE);
des.decrypt(out);
diff --git a/src/block/des/desx.h b/src/block/des/desx.h
index cb452c47b..5b7f10281 100644
--- a/src/block/des/desx.h
+++ b/src/block/des/desx.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL DESX : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { des.clear(); zeroise(K1); zeroise(K2); }
std::string name() const { return "DESX"; }
diff --git a/src/block/gost_28147/gost_28147.cpp b/src/block/gost_28147/gost_28147.cpp
index 8d7e950c6..c23c31dfb 100644
--- a/src/block/gost_28147/gost_28147.cpp
+++ b/src/block/gost_28147/gost_28147.cpp
@@ -11,7 +11,7 @@
namespace Botan {
-byte GOST_28147_89_Params::sbox_entry(u32bit row, u32bit col) const
+byte GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const
{
byte x = sboxes[4 * col + (row / 2)];
@@ -85,11 +85,12 @@ GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) :
/*
* GOST Encryption
*/
-void GOST_28147_89::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void GOST_28147_89::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit N1 = load_le<u32bit>(in, 0), N2 = load_le<u32bit>(in, 1);
+ u32bit N1 = load_le<u32bit>(in, 0);
+ u32bit N2 = load_le<u32bit>(in, 1);
for(size_t j = 0; j != 3; ++j)
{
@@ -114,11 +115,12 @@ void GOST_28147_89::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* GOST Decryption
*/
-void GOST_28147_89::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit N1 = load_le<u32bit>(in, 0), N2 = load_le<u32bit>(in, 1);
+ u32bit N1 = load_le<u32bit>(in, 0);
+ u32bit N2 = load_le<u32bit>(in, 1);
GOST_2ROUND(N1, N2, 0, 1);
GOST_2ROUND(N1, N2, 2, 3);
@@ -144,8 +146,8 @@ void GOST_28147_89::decrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void GOST_28147_89::key_schedule(const byte key[], u32bit)
{
- for(u32bit j = 0; j != 8; ++j)
- EK[j] = load_le<u32bit>(key, j);
+ for(size_t i = 0; i != 8; ++i)
+ EK[i] = load_le<u32bit>(key, i);
}
}
diff --git a/src/block/gost_28147/gost_28147.h b/src/block/gost_28147/gost_28147.h
index 501e621e0..f70c6650f 100644
--- a/src/block/gost_28147/gost_28147.h
+++ b/src/block/gost_28147/gost_28147.h
@@ -26,7 +26,7 @@ class BOTAN_DLL GOST_28147_89_Params
* @param col the column
* @return sbox entry at this row/column
*/
- byte sbox_entry(u32bit row, u32bit col) const;
+ byte sbox_entry(size_t row, size_t col) const;
/**
* @return name of this parameter set
@@ -52,8 +52,8 @@ class BOTAN_DLL GOST_28147_89_Params
class BOTAN_DLL GOST_28147_89 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); }
diff --git a/src/block/idea/idea.cpp b/src/block/idea/idea.cpp
index 5f0b5f195..8201c9193 100644
--- a/src/block/idea/idea.cpp
+++ b/src/block/idea/idea.cpp
@@ -46,7 +46,7 @@ u16bit mul_inv(u16bit x)
{
u16bit y = x;
- for(u32bit i = 0; i != 15; ++i)
+ for(size_t i = 0; i != 15; ++i)
{
y = mul(y, y); // square
y = mul(y, x);
@@ -58,18 +58,18 @@ u16bit mul_inv(u16bit x)
/**
* IDEA is involutional, depending only on the key schedule
*/
-void idea_op(const byte in[], byte out[], u32bit blocks, const u16bit K[52])
+void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
{
const u32bit BLOCK_SIZE = 8;
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit X1 = load_be<u16bit>(in, 0);
u16bit X2 = load_be<u16bit>(in, 1);
u16bit X3 = load_be<u16bit>(in, 2);
u16bit X4 = load_be<u16bit>(in, 3);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t j = 0; j != 8; ++j)
{
X1 = mul(X1, K[6*j+0]);
X2 += K[6*j+1];
@@ -106,7 +106,7 @@ void idea_op(const byte in[], byte out[], u32bit blocks, const u16bit K[52])
/*
* IDEA Encryption
*/
-void IDEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
idea_op(in, out, blocks, &EK[0]);
}
@@ -114,7 +114,7 @@ void IDEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* IDEA Decryption
*/
-void IDEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
idea_op(in, out, blocks, &DK[0]);
}
@@ -124,10 +124,10 @@ void IDEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void IDEA::key_schedule(const byte key[], u32bit)
{
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t j = 0; j != 8; ++j)
EK[j] = load_be<u16bit>(key, j);
- for(u32bit j = 1, k = 8, offset = 0; k != 52; j %= 8, ++j, ++k)
+ for(size_t j = 1, k = 8, offset = 0; k != 52; j %= 8, ++j, ++k)
{
EK[j+7+offset] = static_cast<u16bit>((EK[(j % 8) + offset] << 9) |
(EK[((j+1) % 8) + offset] >> 7));
@@ -139,7 +139,7 @@ void IDEA::key_schedule(const byte key[], u32bit)
DK[49] = -EK[1];
DK[48] = mul_inv(EK[0]);
- for(u32bit j = 1, k = 4, counter = 47; j != 8; ++j, k += 6)
+ for(size_t j = 1, k = 4, counter = 47; j != 8; ++j, k += 6)
{
DK[counter--] = EK[k+1];
DK[counter--] = EK[k];
diff --git a/src/block/idea/idea.h b/src/block/idea/idea.h
index 1a315ce3f..566d9afd4 100644
--- a/src/block/idea/idea.h
+++ b/src/block/idea/idea.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL IDEA : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); zeroise(DK); }
std::string name() const { return "IDEA"; }
diff --git a/src/block/idea_sse2/idea_sse2.cpp b/src/block/idea_sse2/idea_sse2.cpp
index 857869115..469a33943 100644
--- a/src/block/idea_sse2/idea_sse2.cpp
+++ b/src/block/idea_sse2/idea_sse2.cpp
@@ -144,7 +144,7 @@ void idea_op_8(const byte in[64], byte out[64], const u16bit EK[52])
B2 = _mm_or_si128(_mm_slli_epi16(B2, 8), _mm_srli_epi16(B2, 8));
B3 = _mm_or_si128(_mm_slli_epi16(B3, 8), _mm_srli_epi16(B3, 8));
- for(u32bit i = 0; i != 8; ++i)
+ for(size_t i = 0; i != 8; ++i)
{
B0 = mul(B0, EK[6*i+0]);
B1 = _mm_add_epi16(B1, _mm_set1_epi16(EK[6*i+1]));
@@ -194,7 +194,7 @@ void idea_op_8(const byte in[64], byte out[64], const u16bit EK[52])
/*
* IDEA Encryption
*/
-void IDEA_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void IDEA_SSE2::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u16bit* KS = &this->get_EK()[0];
@@ -213,7 +213,7 @@ void IDEA_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* IDEA Decryption
*/
-void IDEA_SSE2::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void IDEA_SSE2::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u16bit* KS = &this->get_DK()[0];
diff --git a/src/block/idea_sse2/idea_sse2.h b/src/block/idea_sse2/idea_sse2.h
index 1f6e063d0..8e475568e 100644
--- a/src/block/idea_sse2/idea_sse2.h
+++ b/src/block/idea_sse2/idea_sse2.h
@@ -20,8 +20,8 @@ class BOTAN_DLL IDEA_SSE2 : public IDEA
public:
size_t parallelism() const { return 8; }
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
BlockCipher* clone() const { return new IDEA_SSE2; }
};
diff --git a/src/block/kasumi/kasumi.cpp b/src/block/kasumi/kasumi.cpp
index 023a7a503..15d6a24fc 100644
--- a/src/block/kasumi/kasumi.cpp
+++ b/src/block/kasumi/kasumi.cpp
@@ -109,16 +109,16 @@ u16bit FI(u16bit I, u16bit K)
/*
* KASUMI Encryption
*/
-void KASUMI::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void KASUMI::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit B0 = load_be<u16bit>(in, 0);
u16bit B1 = load_be<u16bit>(in, 1);
u16bit B2 = load_be<u16bit>(in, 2);
u16bit B3 = load_be<u16bit>(in, 3);
- for(u32bit j = 0; j != 8; j += 2)
+ for(size_t j = 0; j != 8; j += 2)
{
const u16bit* K = &EK[8*j];
@@ -153,16 +153,16 @@ void KASUMI::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* KASUMI Decryption
*/
-void KASUMI::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void KASUMI::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit B0 = load_be<u16bit>(in, 0);
u16bit B1 = load_be<u16bit>(in, 1);
u16bit B2 = load_be<u16bit>(in, 2);
u16bit B3 = load_be<u16bit>(in, 3);
- for(u32bit j = 0; j != 8; j += 2)
+ for(size_t j = 0; j != 8; j += 2)
{
const u16bit* K = &EK[8*(6-j)];
@@ -205,22 +205,22 @@ void KASUMI::key_schedule(const byte key[], u32bit)
0xFEDC, 0xBA98, 0x7654, 0x3210 };
SecureVector<u16bit> K(16);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t i = 0; i != 8; ++i)
{
- K[j] = load_be<u16bit>(key, j);
- K[j+8] = K[j] ^ RC[j];
+ K[i] = load_be<u16bit>(key, i);
+ K[i+8] = K[i] ^ RC[i];
}
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t i = 0; i != 8; ++i)
{
- EK[8*j ] = rotate_left(K[(j+0) % 8 ], 2);
- EK[8*j+1] = rotate_left(K[(j+2) % 8 + 8], 1);
- EK[8*j+2] = rotate_left(K[(j+1) % 8 ], 5);
- EK[8*j+3] = K[(j+4) % 8 + 8];
- EK[8*j+4] = rotate_left(K[(j+5) % 8 ], 8);
- EK[8*j+5] = K[(j+3) % 8 + 8];
- EK[8*j+6] = rotate_left(K[(j+6) % 8 ], 13);
- EK[8*j+7] = K[(j+7) % 8 + 8];
+ EK[8*i ] = rotate_left(K[(i+0) % 8 ], 2);
+ EK[8*i+1] = rotate_left(K[(i+2) % 8 + 8], 1);
+ EK[8*i+2] = rotate_left(K[(i+1) % 8 ], 5);
+ EK[8*i+3] = K[(i+4) % 8 + 8];
+ EK[8*i+4] = rotate_left(K[(i+5) % 8 ], 8);
+ EK[8*i+5] = K[(i+3) % 8 + 8];
+ EK[8*i+6] = rotate_left(K[(i+6) % 8 ], 13);
+ EK[8*i+7] = K[(i+7) % 8 + 8];
}
}
diff --git a/src/block/kasumi/kasumi.h b/src/block/kasumi/kasumi.h
index 51727dd4d..8589af79b 100644
--- a/src/block/kasumi/kasumi.h
+++ b/src/block/kasumi/kasumi.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL KASUMI : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); }
std::string name() const { return "KASUMI"; }
diff --git a/src/block/lion/lion.cpp b/src/block/lion/lion.cpp
index 9d0dff297..b4a00ebee 100644
--- a/src/block/lion/lion.cpp
+++ b/src/block/lion/lion.cpp
@@ -14,12 +14,12 @@ namespace Botan {
/*
* Lion Encryption
*/
-void Lion::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Lion::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
SecureVector<byte> buffer_vec(LEFT_SIZE);
byte* buffer = &buffer_vec[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
xor_buf(buffer, in, &key1[0], LEFT_SIZE);
cipher->set_key(buffer, LEFT_SIZE);
@@ -41,12 +41,12 @@ void Lion::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Lion Decryption
*/
-void Lion::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Lion::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
SecureVector<byte> buffer_vec(LEFT_SIZE);
byte* buffer = &buffer_vec[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
xor_buf(buffer, in, &key2[0], LEFT_SIZE);
cipher->set_key(buffer, LEFT_SIZE);
@@ -108,8 +108,8 @@ void Lion::clear()
/*
* Lion Constructor
*/
-Lion::Lion(HashFunction* hash_in, StreamCipher* sc_in, u32bit block_len) :
- BlockCipher(std::max<u32bit>(2*hash_in->OUTPUT_LENGTH + 1, block_len),
+Lion::Lion(HashFunction* hash_in, StreamCipher* sc_in, size_t block_len) :
+ BlockCipher(std::max<size_t>(2*hash_in->OUTPUT_LENGTH + 1, block_len),
2, 2*hash_in->OUTPUT_LENGTH, 2),
LEFT_SIZE(hash_in->OUTPUT_LENGTH),
RIGHT_SIZE(BLOCK_SIZE - LEFT_SIZE),
diff --git a/src/block/lion/lion.h b/src/block/lion/lion.h
index bba4e6f30..5d4d374b9 100644
--- a/src/block/lion/lion.h
+++ b/src/block/lion/lion.h
@@ -25,8 +25,8 @@ namespace Botan {
class BOTAN_DLL Lion : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const;
@@ -39,13 +39,13 @@ class BOTAN_DLL Lion : public BlockCipher
*/
Lion(HashFunction* hash,
StreamCipher* cipher,
- u32bit block_size);
+ size_t block_size);
~Lion() { delete hash; delete cipher; }
private:
void key_schedule(const byte[], u32bit);
- const u32bit LEFT_SIZE, RIGHT_SIZE;
+ const size_t LEFT_SIZE, RIGHT_SIZE;
HashFunction* hash;
StreamCipher* cipher;
diff --git a/src/block/lubyrack/lubyrack.cpp b/src/block/lubyrack/lubyrack.cpp
index cdaff1b1e..0b7ec7bf4 100644
--- a/src/block/lubyrack/lubyrack.cpp
+++ b/src/block/lubyrack/lubyrack.cpp
@@ -13,14 +13,14 @@ namespace Botan {
/*
* Luby-Rackoff Encryption
*/
-void LubyRackoff::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void LubyRackoff::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- const u32bit len = hash->OUTPUT_LENGTH;
+ const size_t len = hash->OUTPUT_LENGTH;
SecureVector<byte> buffer_vec(len);
byte* buffer = &buffer_vec[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
hash->update(K1);
hash->update(in, len);
@@ -50,14 +50,14 @@ void LubyRackoff::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Luby-Rackoff Decryption
*/
-void LubyRackoff::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void LubyRackoff::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- const u32bit len = hash->OUTPUT_LENGTH;
+ const size_t len = hash->OUTPUT_LENGTH;
SecureVector<byte> buffer_vec(len);
byte* buffer = &buffer_vec[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
hash->update(K2);
hash->update(in + len, len);
diff --git a/src/block/lubyrack/lubyrack.h b/src/block/lubyrack/lubyrack.h
index a69d2302f..c20af950d 100644
--- a/src/block/lubyrack/lubyrack.h
+++ b/src/block/lubyrack/lubyrack.h
@@ -19,8 +19,8 @@ namespace Botan {
class BOTAN_DLL LubyRackoff : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const;
diff --git a/src/block/mars/mars.cpp b/src/block/mars/mars.cpp
index 71cef3ee8..9445ab576 100644
--- a/src/block/mars/mars.cpp
+++ b/src/block/mars/mars.cpp
@@ -232,9 +232,9 @@ u32bit gen_mask(u32bit input)
/*
* MARS Encryption
*/
-void MARS::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void MARS::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_le<u32bit>(in, 0) + EK[0];
u32bit B = load_le<u32bit>(in, 1) + EK[1];
@@ -275,9 +275,9 @@ void MARS::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* MARS Decryption
*/
-void MARS::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void MARS::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_le<u32bit>(in, 3) + EK[39];
u32bit B = load_le<u32bit>(in, 2) + EK[38];
@@ -321,30 +321,30 @@ void MARS::decrypt_n(const byte in[], byte out[], u32bit blocks) const
void MARS::key_schedule(const byte key[], u32bit length)
{
SecureVector<u32bit> T(15);
- for(u32bit j = 0; j != length / 4; ++j)
+ for(size_t j = 0; j != length / 4; ++j)
T[j] = load_le<u32bit>(key, j);
T[length / 4] = length / 4;
- for(u32bit j = 0; j != 4; ++j)
+ for(u32bit i = 0; i != 4; ++i)
{
- T[ 0] ^= rotate_left(T[ 8] ^ T[13], 3) ^ (j );
- T[ 1] ^= rotate_left(T[ 9] ^ T[14], 3) ^ (j + 4);
- T[ 2] ^= rotate_left(T[10] ^ T[ 0], 3) ^ (j + 8);
- T[ 3] ^= rotate_left(T[11] ^ T[ 1], 3) ^ (j + 12);
- T[ 4] ^= rotate_left(T[12] ^ T[ 2], 3) ^ (j + 16);
- T[ 5] ^= rotate_left(T[13] ^ T[ 3], 3) ^ (j + 20);
- T[ 6] ^= rotate_left(T[14] ^ T[ 4], 3) ^ (j + 24);
- T[ 7] ^= rotate_left(T[ 0] ^ T[ 5], 3) ^ (j + 28);
- T[ 8] ^= rotate_left(T[ 1] ^ T[ 6], 3) ^ (j + 32);
- T[ 9] ^= rotate_left(T[ 2] ^ T[ 7], 3) ^ (j + 36);
- T[10] ^= rotate_left(T[ 3] ^ T[ 8], 3) ^ (j + 40);
- T[11] ^= rotate_left(T[ 4] ^ T[ 9], 3) ^ (j + 44);
- T[12] ^= rotate_left(T[ 5] ^ T[10], 3) ^ (j + 48);
- T[13] ^= rotate_left(T[ 6] ^ T[11], 3) ^ (j + 52);
- T[14] ^= rotate_left(T[ 7] ^ T[12], 3) ^ (j + 56);
-
- for(u32bit k = 0; k != 4; ++k)
+ T[ 0] ^= rotate_left(T[ 8] ^ T[13], 3) ^ (i );
+ T[ 1] ^= rotate_left(T[ 9] ^ T[14], 3) ^ (i + 4);
+ T[ 2] ^= rotate_left(T[10] ^ T[ 0], 3) ^ (i + 8);
+ T[ 3] ^= rotate_left(T[11] ^ T[ 1], 3) ^ (i + 12);
+ T[ 4] ^= rotate_left(T[12] ^ T[ 2], 3) ^ (i + 16);
+ T[ 5] ^= rotate_left(T[13] ^ T[ 3], 3) ^ (i + 20);
+ T[ 6] ^= rotate_left(T[14] ^ T[ 4], 3) ^ (i + 24);
+ T[ 7] ^= rotate_left(T[ 0] ^ T[ 5], 3) ^ (i + 28);
+ T[ 8] ^= rotate_left(T[ 1] ^ T[ 6], 3) ^ (i + 32);
+ T[ 9] ^= rotate_left(T[ 2] ^ T[ 7], 3) ^ (i + 36);
+ T[10] ^= rotate_left(T[ 3] ^ T[ 8], 3) ^ (i + 40);
+ T[11] ^= rotate_left(T[ 4] ^ T[ 9], 3) ^ (i + 44);
+ T[12] ^= rotate_left(T[ 5] ^ T[10], 3) ^ (i + 48);
+ T[13] ^= rotate_left(T[ 6] ^ T[11], 3) ^ (i + 52);
+ T[14] ^= rotate_left(T[ 7] ^ T[12], 3) ^ (i + 56);
+
+ for(size_t j = 0; j != 4; ++j)
{
T[ 0] = rotate_left(T[ 0] + SBOX[T[14] % 512], 9);
T[ 1] = rotate_left(T[ 1] + SBOX[T[ 0] % 512], 9);
@@ -363,17 +363,23 @@ void MARS::key_schedule(const byte key[], u32bit length)
T[14] = rotate_left(T[14] + SBOX[T[13] % 512], 9);
}
- EK[10*j + 0] = T[ 0]; EK[10*j + 1] = T[ 4]; EK[10*j + 2] = T[ 8];
- EK[10*j + 3] = T[12]; EK[10*j + 4] = T[ 1]; EK[10*j + 5] = T[ 5];
- EK[10*j + 6] = T[ 9]; EK[10*j + 7] = T[13]; EK[10*j + 8] = T[ 2];
- EK[10*j + 9] = T[ 6];
+ EK[10*i + 0] = T[ 0];
+ EK[10*i + 1] = T[ 4];
+ EK[10*i + 2] = T[ 8];
+ EK[10*i + 3] = T[12];
+ EK[10*i + 4] = T[ 1];
+ EK[10*i + 5] = T[ 5];
+ EK[10*i + 6] = T[ 9];
+ EK[10*i + 7] = T[13];
+ EK[10*i + 8] = T[ 2];
+ EK[10*i + 9] = T[ 6];
}
- for(u32bit j = 5; j != 37; j += 2)
+ for(size_t i = 5; i != 37; i += 2)
{
- u32bit key3 = EK[j] & 3;
- EK[j] |= 3;
- EK[j] ^= rotate_left(SBOX[265 + key3], EK[j-1] % 32) & gen_mask(EK[j]);
+ u32bit key3 = EK[i] & 3;
+ EK[i] |= 3;
+ EK[i] ^= rotate_left(SBOX[265 + key3], EK[i-1] % 32) & gen_mask(EK[i]);
}
}
diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h
index 84a9a21f7..0b98d3c25 100644
--- a/src/block/mars/mars.h
+++ b/src/block/mars/mars.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL MARS : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); }
std::string name() const { return "MARS"; }
diff --git a/src/block/misty1/misty1.cpp b/src/block/misty1/misty1.cpp
index 1d032172d..891abf49f 100644
--- a/src/block/misty1/misty1.cpp
+++ b/src/block/misty1/misty1.cpp
@@ -102,16 +102,16 @@ u16bit FI(u16bit input, u16bit key7, u16bit key9)
/*
* MISTY1 Encryption
*/
-void MISTY1::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void MISTY1::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit B0 = load_be<u16bit>(in, 0);
u16bit B1 = load_be<u16bit>(in, 1);
u16bit B2 = load_be<u16bit>(in, 2);
u16bit B3 = load_be<u16bit>(in, 3);
- for(u32bit j = 0; j != 12; j += 3)
+ for(size_t j = 0; j != 12; j += 3)
{
const u16bit* RK = &EK[8 * j];
@@ -152,16 +152,16 @@ void MISTY1::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* MISTY1 Decryption
*/
-void MISTY1::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit B0 = load_be<u16bit>(in, 2);
u16bit B1 = load_be<u16bit>(in, 3);
u16bit B2 = load_be<u16bit>(in, 0);
u16bit B3 = load_be<u16bit>(in, 1);
- for(u32bit j = 0; j != 12; j += 3)
+ for(size_t j = 0; j != 12; j += 3)
{
const u16bit* RK = &DK[8 * j];
@@ -205,14 +205,14 @@ void MISTY1::decrypt_n(const byte in[], byte out[], u32bit blocks) const
void MISTY1::key_schedule(const byte key[], u32bit length)
{
SecureVector<u16bit> KS(32);
- for(u32bit j = 0; j != length / 2; ++j)
- KS[j] = load_be<u16bit>(key, j);
+ for(size_t i = 0; i != length / 2; ++i)
+ KS[i] = load_be<u16bit>(key, i);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t i = 0; i != 8; ++i)
{
- KS[j+ 8] = FI(KS[j], KS[(j+1) % 8] >> 9, KS[(j+1) % 8] & 0x1FF);
- KS[j+16] = KS[j+8] >> 9;
- KS[j+24] = KS[j+8] & 0x1FF;
+ KS[i+ 8] = FI(KS[i], KS[(i+1) % 8] >> 9, KS[(i+1) % 8] & 0x1FF);
+ KS[i+16] = KS[i+8] >> 9;
+ KS[i+24] = KS[i+8] & 0x1FF;
}
/*
@@ -241,17 +241,17 @@ void MISTY1::key_schedule(const byte key[], u32bit length)
0x1C, 0x05, 0x00, 0x15, 0x1D, 0x02, 0x11, 0x19, 0x07, 0x13, 0x1B, 0x04,
0x04, 0x0A, 0x0E, 0x00 };
- for(u32bit j = 0; j != 100; ++j)
+ for(size_t i = 0; i != 100; ++i)
{
- EK[j] = KS[EK_ORDER[j]];
- DK[j] = KS[DK_ORDER[j]];
+ EK[i] = KS[EK_ORDER[i]];
+ DK[i] = KS[DK_ORDER[i]];
}
}
/*
* MISTY1 Constructor
*/
-MISTY1::MISTY1(u32bit rounds) : BlockCipher(8, 16), EK(100), DK(100)
+MISTY1::MISTY1(size_t rounds) : BlockCipher(8, 16), EK(100), DK(100)
{
if(rounds != 8)
throw Invalid_Argument("MISTY1: Invalid number of rounds: "
diff --git a/src/block/misty1/misty1.h b/src/block/misty1/misty1.h
index 7a9f1f9d9..bb948cb07 100644
--- a/src/block/misty1/misty1.h
+++ b/src/block/misty1/misty1.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL MISTY1 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); zeroise(DK); }
std::string name() const { return "MISTY1"; }
@@ -29,7 +29,7 @@ class BOTAN_DLL MISTY1 : public BlockCipher
* @param rounds the number of rounds. Must be 8 with the current
* implementation
*/
- MISTY1(u32bit rounds = 8);
+ MISTY1(size_t rounds = 8);
private:
void key_schedule(const byte[], u32bit);
diff --git a/src/block/noekeon/noekeon.cpp b/src/block/noekeon/noekeon.cpp
index a24153a29..f9a54482b 100644
--- a/src/block/noekeon/noekeon.cpp
+++ b/src/block/noekeon/noekeon.cpp
@@ -84,16 +84,16 @@ const byte Noekeon::RC[] = {
/*
* Noekeon Encryption
*/
-void Noekeon::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A0 = load_be<u32bit>(in, 0);
u32bit A1 = load_be<u32bit>(in, 1);
u32bit A2 = load_be<u32bit>(in, 2);
u32bit A3 = load_be<u32bit>(in, 3);
- for(u32bit j = 0; j != 16; ++j)
+ for(size_t j = 0; j != 16; ++j)
{
A0 ^= RC[j];
theta(A0, A1, A2, A3, &EK[0]);
@@ -122,16 +122,16 @@ void Noekeon::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Noekeon Encryption
*/
-void Noekeon::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A0 = load_be<u32bit>(in, 0);
u32bit A1 = load_be<u32bit>(in, 1);
u32bit A2 = load_be<u32bit>(in, 2);
u32bit A3 = load_be<u32bit>(in, 3);
- for(u32bit j = 16; j != 0; --j)
+ for(size_t j = 16; j != 0; --j)
{
theta(A0, A1, A2, A3, &DK[0]);
A0 ^= RC[j];
@@ -167,7 +167,7 @@ void Noekeon::key_schedule(const byte key[], u32bit)
u32bit A2 = load_be<u32bit>(key, 2);
u32bit A3 = load_be<u32bit>(key, 3);
- for(u32bit j = 0; j != 16; ++j)
+ for(size_t j = 0; j != 16; ++j)
{
A0 ^= RC[j];
theta(A0, A1, A2, A3);
diff --git a/src/block/noekeon/noekeon.h b/src/block/noekeon/noekeon.h
index ee3d32c80..65d3474c7 100644
--- a/src/block/noekeon/noekeon.h
+++ b/src/block/noekeon/noekeon.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Noekeon : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const { return "Noekeon"; }
diff --git a/src/block/noekeon_simd/noekeon_simd.cpp b/src/block/noekeon_simd/noekeon_simd.cpp
index a7fb66f98..97158593a 100644
--- a/src/block/noekeon_simd/noekeon_simd.cpp
+++ b/src/block/noekeon_simd/noekeon_simd.cpp
@@ -53,7 +53,7 @@ namespace Botan {
/*
* Noekeon Encryption
*/
-void Noekeon_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Noekeon_SIMD::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const SecureVector<u32bit>& EK = this->get_EK();
@@ -71,7 +71,7 @@ void Noekeon_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
SIMD_32::transpose(A0, A1, A2, A3);
- for(u32bit i = 0; i != 16; ++i)
+ for(size_t i = 0; i != 16; ++i)
{
A0 ^= SIMD_32(RC[i]);
@@ -110,7 +110,7 @@ void Noekeon_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Noekeon Encryption
*/
-void Noekeon_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Noekeon_SIMD::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const SecureVector<u32bit>& DK = this->get_DK();
@@ -128,7 +128,7 @@ void Noekeon_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const
SIMD_32::transpose(A0, A1, A2, A3);
- for(u32bit i = 0; i != 16; ++i)
+ for(size_t i = 0; i != 16; ++i)
{
NOK_SIMD_THETA(A0, A1, A2, A3, K0, K1, K2, K3);
diff --git a/src/block/noekeon_simd/noekeon_simd.h b/src/block/noekeon_simd/noekeon_simd.h
index c583aa85b..5cc2d8b09 100644
--- a/src/block/noekeon_simd/noekeon_simd.h
+++ b/src/block/noekeon_simd/noekeon_simd.h
@@ -20,8 +20,8 @@ class BOTAN_DLL Noekeon_SIMD : public Noekeon
public:
size_t parallelism() const { return 4; }
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
BlockCipher* clone() const { return new Noekeon_SIMD; }
};
diff --git a/src/block/rc2/rc2.cpp b/src/block/rc2/rc2.cpp
index 8a939ecae..6cfe8c202 100644
--- a/src/block/rc2/rc2.cpp
+++ b/src/block/rc2/rc2.cpp
@@ -14,16 +14,16 @@ namespace Botan {
/*
* RC2 Encryption
*/
-void RC2::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void RC2::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit R0 = load_le<u16bit>(in, 0);
u16bit R1 = load_le<u16bit>(in, 1);
u16bit R2 = load_le<u16bit>(in, 2);
u16bit R3 = load_le<u16bit>(in, 3);
- for(u32bit j = 0; j != 16; ++j)
+ for(size_t j = 0; j != 16; ++j)
{
R0 += (R1 & ~R3) + (R2 & R3) + K[4*j];
R0 = rotate_left(R0, 1);
@@ -56,16 +56,16 @@ void RC2::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* RC2 Decryption
*/
-void RC2::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void RC2::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit R0 = load_le<u16bit>(in, 0);
u16bit R1 = load_le<u16bit>(in, 1);
u16bit R2 = load_le<u16bit>(in, 2);
u16bit R3 = load_le<u16bit>(in, 3);
- for(u32bit j = 0; j != 16; ++j)
+ for(size_t j = 0; j != 16; ++j)
{
R3 = rotate_right(R3, 5);
R3 -= (R0 & ~R2) + (R1 & R2) + K[63 - (4*j + 0)];
@@ -127,11 +127,13 @@ void RC2::key_schedule(const byte key[], u32bit length)
SecureVector<byte> L(128);
L.copy(key, length);
- for(u32bit j = length; j != 128; ++j)
- L[j] = TABLE[(L[j-1] + L[j-length]) % 256];
+ for(size_t i = length; i != 128; ++i)
+ L[i] = TABLE[(L[i-1] + L[i-length]) % 256];
+
L[128-length] = TABLE[L[128-length]];
- for(s32bit j = 127-length; j >= 0; --j)
- L[j] = TABLE[L[j+1] ^ L[j+length]];
+
+ for(s32bit i = 127-length; i >= 0; --i)
+ L[i] = TABLE[L[i+1] ^ L[i+length]];
load_le<u16bit>(&K[0], &L[0], 64);
}
@@ -139,7 +141,7 @@ void RC2::key_schedule(const byte key[], u32bit length)
/*
* Return the code of the effective key bits
*/
-byte RC2::EKB_code(u32bit ekb)
+byte RC2::EKB_code(size_t ekb)
{
const byte EKB[256] = {
0xBD, 0x56, 0xEA, 0xF2, 0xA2, 0xF1, 0xAC, 0x2A, 0xB0, 0x93, 0xD1, 0x9C,
diff --git a/src/block/rc2/rc2.h b/src/block/rc2/rc2.h
index 7e1953441..b8c1e069a 100644
--- a/src/block/rc2/rc2.h
+++ b/src/block/rc2/rc2.h
@@ -18,15 +18,15 @@ namespace Botan {
class BOTAN_DLL RC2 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
/**
* Return the code of the effective key bits
* @param bits key length
* @return EKB code
*/
- static byte EKB_code(u32bit bits);
+ static byte EKB_code(size_t bits);
void clear() { zeroise(K); }
std::string name() const { return "RC2"; }
diff --git a/src/block/rc5/rc5.cpp b/src/block/rc5/rc5.cpp
index ff0250d32..3b288d328 100644
--- a/src/block/rc5/rc5.cpp
+++ b/src/block/rc5/rc5.cpp
@@ -16,14 +16,15 @@ namespace Botan {
/*
* RC5 Encryption
*/
-void RC5::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void RC5::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit A = load_le<u32bit>(in, 0), B = load_le<u32bit>(in, 1);
+ u32bit A = load_le<u32bit>(in, 0);
+ u32bit B = load_le<u32bit>(in, 1);
A += S[0]; B += S[1];
- for(u32bit j = 0; j != ROUNDS; j += 4)
+ for(size_t j = 0; j != ROUNDS; j += 4)
{
A = rotate_left(A ^ B, B % 32) + S[2*j+2];
B = rotate_left(B ^ A, A % 32) + S[2*j+3];
@@ -45,13 +46,14 @@ void RC5::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* RC5 Decryption
*/
-void RC5::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void RC5::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit A = load_le<u32bit>(in, 0), B = load_le<u32bit>(in, 1);
+ u32bit A = load_le<u32bit>(in, 0);
+ u32bit B = load_le<u32bit>(in, 1);
- for(u32bit j = ROUNDS; j != 0; j -= 4)
+ for(size_t j = ROUNDS; j != 0; j -= 4)
{
B = rotate_right(B - S[2*j+1], A % 32) ^ A;
A = rotate_right(A - S[2*j ], B % 32) ^ B;
@@ -76,24 +78,26 @@ void RC5::decrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void RC5::key_schedule(const byte key[], u32bit length)
{
- const u32bit WORD_KEYLENGTH = (((length - 1) / 4) + 1),
- MIX_ROUNDS = 3*std::max<u32bit>(WORD_KEYLENGTH, S.size());
+ const size_t WORD_KEYLENGTH = (((length - 1) / 4) + 1);
+ const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, S.size());
S[0] = 0xB7E15163;
- for(u32bit j = 1; j != S.size(); ++j)
- S[j] = S[j-1] + 0x9E3779B9;
+ for(size_t i = 1; i != S.size(); ++i)
+ S[i] = S[i-1] + 0x9E3779B9;
SecureVector<u32bit> K(8);
- for(s32bit j = length-1; j >= 0; --j)
- K[j/4] = (K[j/4] << 8) + key[j];
+ for(s32bit i = length-1; i >= 0; --i)
+ K[i/4] = (K[i/4] << 8) + key[i];
- for(u32bit j = 0, A = 0, B = 0; j != MIX_ROUNDS; ++j)
+ u32bit A = 0, B = 0;
+
+ for(size_t i = 0; i != MIX_ROUNDS; ++i)
{
- A = rotate_left(S[j % S.size()] + A + B, 3);
- B = rotate_left(K[j % WORD_KEYLENGTH] + A + B, (A + B) % 32);
- S[j % S.size()] = A;
- K[j % WORD_KEYLENGTH] = B;
+ A = rotate_left(S[i % S.size()] + A + B, 3);
+ B = rotate_left(K[i % WORD_KEYLENGTH] + A + B, (A + B) % 32);
+ S[i % S.size()] = A;
+ K[i % WORD_KEYLENGTH] = B;
}
}
@@ -108,7 +112,7 @@ std::string RC5::name() const
/*
* RC5 Constructor
*/
-RC5::RC5(u32bit r) : BlockCipher(8, 1, 32), ROUNDS(r)
+RC5::RC5(size_t r) : BlockCipher(8, 1, 32), ROUNDS(r)
{
if(ROUNDS < 8 || ROUNDS > 32 || (ROUNDS % 4 != 0))
throw Invalid_Argument(name() + ": Invalid number of rounds");
diff --git a/src/block/rc5/rc5.h b/src/block/rc5/rc5.h
index 9a794d248..f15230a00 100644
--- a/src/block/rc5/rc5.h
+++ b/src/block/rc5/rc5.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL RC5 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(S); }
std::string name() const;
@@ -29,11 +29,11 @@ class BOTAN_DLL RC5 : public BlockCipher
* @param rounds the number of RC5 rounds to run. Must be between
* 8 and 32 and a multiple of 4.
*/
- RC5(u32bit rounds);
+ RC5(size_t rounds);
private:
void key_schedule(const byte[], u32bit);
SecureVector<u32bit> S;
- const u32bit ROUNDS;
+ const size_t ROUNDS;
};
}
diff --git a/src/block/rc6/rc6.cpp b/src/block/rc6/rc6.cpp
index 291d3b97e..f81f25efd 100644
--- a/src/block/rc6/rc6.cpp
+++ b/src/block/rc6/rc6.cpp
@@ -15,9 +15,9 @@ namespace Botan {
/*
* RC6 Encryption
*/
-void RC6::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void RC6::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_le<u32bit>(in, 0);
u32bit B = load_le<u32bit>(in, 1);
@@ -26,7 +26,7 @@ void RC6::encrypt_n(const byte in[], byte out[], u32bit blocks) const
B += S[0]; D += S[1];
- for(u32bit j = 0; j != 20; j += 4)
+ for(size_t j = 0; j != 20; j += 4)
{
u32bit T1, T2;
@@ -63,9 +63,9 @@ void RC6::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* RC6 Decryption
*/
-void RC6::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void RC6::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_le<u32bit>(in, 0);
u32bit B = load_le<u32bit>(in, 1);
@@ -74,7 +74,7 @@ void RC6::decrypt_n(const byte in[], byte out[], u32bit blocks) const
C -= S[43]; A -= S[42];
- for(u32bit j = 0; j != 20; j += 4)
+ for(size_t j = 0; j != 20; j += 4)
{
u32bit T1, T2;
@@ -113,10 +113,11 @@ void RC6::decrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void RC6::key_schedule(const byte key[], u32bit length)
{
- const u32bit WORD_KEYLENGTH = (((length - 1) / 4) + 1),
- MIX_ROUNDS = 3*std::max<u32bit>(WORD_KEYLENGTH, S.size());
+ const size_t WORD_KEYLENGTH = (((length - 1) / 4) + 1);
+ const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, S.size());
+
S[0] = 0xB7E15163;
- for(u32bit j = 1; j != S.size(); ++j)
+ for(size_t j = 1; j != S.size(); ++j)
S[j] = S[j-1] + 0x9E3779B9;
SecureVector<u32bit> K(8);
@@ -124,7 +125,8 @@ void RC6::key_schedule(const byte key[], u32bit length)
for(s32bit j = length-1; j >= 0; --j)
K[j/4] = (K[j/4] << 8) + key[j];
- for(u32bit j = 0, A = 0, B = 0; j != MIX_ROUNDS; ++j)
+ u32bit A = 0, B = 0;
+ for(u32bit j = 0; j != MIX_ROUNDS; ++j)
{
A = rotate_left(S[j % S.size()] + A + B, 3);
B = rotate_left(K[j % WORD_KEYLENGTH] + A + B, (A + B) % 32);
diff --git a/src/block/rc6/rc6.h b/src/block/rc6/rc6.h
index 55a9d412e..ada7e9610 100644
--- a/src/block/rc6/rc6.h
+++ b/src/block/rc6/rc6.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL RC6 : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(S); }
std::string name() const { return "RC6"; }
diff --git a/src/block/safer/safer_sk.cpp b/src/block/safer/safer_sk.cpp
index aebb770d7..d64c37f00 100644
--- a/src/block/safer/safer_sk.cpp
+++ b/src/block/safer/safer_sk.cpp
@@ -15,14 +15,14 @@ namespace Botan {
/*
* SAFER-SK Encryption
*/
-void SAFER_SK::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void SAFER_SK::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
byte A = in[0], B = in[1], C = in[2], D = in[3],
E = in[4], F = in[5], G = in[6], H = in[7], X, Y;
- for(u32bit j = 0; j != 16*ROUNDS; j += 16)
+ for(size_t j = 0; j != 16*ROUNDS; j += 16)
{
A = EXP[A ^ EK[j ]]; B = LOG[B + EK[j+1]];
C = LOG[C + EK[j+2]]; D = EXP[D ^ EK[j+3]];
@@ -51,9 +51,9 @@ void SAFER_SK::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* SAFER-SK Decryption
*/
-void SAFER_SK::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void SAFER_SK::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
byte A = in[0], B = in[1], C = in[2], D = in[3],
E = in[4], F = in[5], G = in[6], H = in[7];
@@ -93,17 +93,18 @@ void SAFER_SK::key_schedule(const byte key[], u32bit)
{
SecureVector<byte> KB(18);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t i = 0; i != 8; ++i)
{
- KB[ 8] ^= KB[j] = rotate_left(key[j], 5);
- KB[17] ^= KB[j+9] = EK[j] = key[j+8];
+ KB[ 8] ^= KB[i] = rotate_left(key[i], 5);
+ KB[17] ^= KB[i+9] = EK[i] = key[i+8];
}
- for(u32bit j = 0; j != ROUNDS; ++j)
+
+ for(size_t i = 0; i != ROUNDS; ++i)
{
- for(u32bit k = 0; k != 18; ++k)
- KB[k] = rotate_left(KB[k], 6);
- for(u32bit k = 0; k != 16; ++k)
- EK[16*j+k+8] = KB[KEY_INDEX[16*j+k]] + BIAS[16*j+k];
+ for(size_t j = 0; j != 18; ++j)
+ KB[j] = rotate_left(KB[j], 6);
+ for(size_t j = 0; j != 16; ++j)
+ EK[16*i+j+8] = KB[KEY_INDEX[16*i+j]] + BIAS[16*i+j];
}
}
@@ -126,7 +127,7 @@ BlockCipher* SAFER_SK::clone() const
/*
* SAFER-SK Constructor
*/
-SAFER_SK::SAFER_SK(u32bit rounds) : BlockCipher(8, 16),
+SAFER_SK::SAFER_SK(size_t rounds) : BlockCipher(8, 16),
EK(16 * rounds + 8), ROUNDS(rounds)
{
if(ROUNDS > 13 || ROUNDS == 0)
diff --git a/src/block/safer/safer_sk.h b/src/block/safer/safer_sk.h
index 26875c97b..b68cb5363 100644
--- a/src/block/safer/safer_sk.h
+++ b/src/block/safer/safer_sk.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL SAFER_SK : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); }
std::string name() const;
@@ -29,7 +29,7 @@ class BOTAN_DLL SAFER_SK : public BlockCipher
* @param rounds the number of rounds to use - must be between 1
* and 13
*/
- SAFER_SK(u32bit rounds);
+ SAFER_SK(size_t rounds);
private:
void key_schedule(const byte[], u32bit);
@@ -39,7 +39,7 @@ class BOTAN_DLL SAFER_SK : public BlockCipher
static const byte KEY_INDEX[208];
SecureVector<byte> EK;
- const u32bit ROUNDS;
+ const size_t ROUNDS;
};
}
diff --git a/src/block/seed/seed.cpp b/src/block/seed/seed.cpp
index ca09937e8..a253f27b8 100644
--- a/src/block/seed/seed.cpp
+++ b/src/block/seed/seed.cpp
@@ -22,9 +22,9 @@ u32bit SEED::G_FUNC::operator()(u32bit X) const
/*
* SEED Encryption
*/
-void SEED::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void SEED::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit B0 = load_be<u32bit>(in, 0);
u32bit B1 = load_be<u32bit>(in, 1);
@@ -33,7 +33,7 @@ void SEED::encrypt_n(const byte in[], byte out[], u32bit blocks) const
G_FUNC G;
- for(u32bit j = 0; j != 16; j += 2)
+ for(size_t j = 0; j != 16; j += 2)
{
u32bit T0, T1;
@@ -62,9 +62,9 @@ void SEED::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* SEED Decryption
*/
-void SEED::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void SEED::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit B0 = load_be<u32bit>(in, 0);
u32bit B1 = load_be<u32bit>(in, 1);
@@ -73,7 +73,7 @@ void SEED::decrypt_n(const byte in[], byte out[], u32bit blocks) const
G_FUNC G;
- for(u32bit j = 0; j != 16; j += 2)
+ for(size_t j = 0; j != 16; j += 2)
{
u32bit T0, T1;
@@ -113,22 +113,22 @@ void SEED::key_schedule(const byte key[], u32bit)
SecureVector<u32bit> WK(4);
- for(u32bit j = 0; j != 4; ++j)
- WK[j] = load_be<u32bit>(key, j);
+ for(size_t i = 0; i != 4; ++i)
+ WK[i] = load_be<u32bit>(key, i);
G_FUNC G;
- for(u32bit j = 0; j != 16; j += 2)
+ for(size_t i = 0; i != 16; i += 2)
{
- K[2*j ] = G(WK[0] + WK[2] - RC[j]);
- K[2*j+1] = G(WK[1] - WK[3] + RC[j]) ^ K[2*j];
+ K[2*i ] = G(WK[0] + WK[2] - RC[i]);
+ K[2*i+1] = G(WK[1] - WK[3] + RC[i]) ^ K[2*i];
byte T = get_byte(3, WK[0]);
WK[0] = (WK[0] >> 8) | (get_byte(3, WK[1]) << 24);
WK[1] = (WK[1] >> 8) | (T << 24);
- K[2*j+2] = G(WK[0] + WK[2] - RC[j+1]);
- K[2*j+3] = G(WK[1] - WK[3] + RC[j+1]) ^ K[2*j+2];
+ K[2*i+2] = G(WK[0] + WK[2] - RC[i+1]);
+ K[2*i+3] = G(WK[1] - WK[3] + RC[i+1]) ^ K[2*i+2];
T = get_byte(0, WK[3]);
WK[3] = (WK[3] << 8) | get_byte(0, WK[2]);
diff --git a/src/block/seed/seed.h b/src/block/seed/seed.h
index 001743ada..e2b0862ae 100644
--- a/src/block/seed/seed.h
+++ b/src/block/seed/seed.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL SEED : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(K); }
std::string name() const { return "SEED"; }
diff --git a/src/block/serpent/serpent.cpp b/src/block/serpent/serpent.cpp
index 4133750ad..8ff35b900 100644
--- a/src/block/serpent/serpent.cpp
+++ b/src/block/serpent/serpent.cpp
@@ -243,9 +243,9 @@ inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
/*
* Serpent Encryption
*/
-void Serpent::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit B0 = load_le<u32bit>(in, 0);
u32bit B1 = load_le<u32bit>(in, 1);
@@ -295,9 +295,9 @@ void Serpent::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Serpent Decryption
*/
-void Serpent::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit B0 = load_le<u32bit>(in, 0);
u32bit B1 = load_le<u32bit>(in, 1);
@@ -356,12 +356,17 @@ void Serpent::key_schedule(const byte key[], u32bit length)
const u32bit PHI = 0x9E3779B9;
SecureVector<u32bit> W(140);
- for(u32bit j = 0; j != length / 4; ++j)
- W[j] = load_le<u32bit>(key, j);
+ for(size_t i = 0; i != length / 4; ++i)
+ W[i] = load_le<u32bit>(key, i);
W[length / 4] |= u32bit(1) << ((length%4)*8);
- for(u32bit j = 8; j != 140; ++j)
- W[j] = rotate_left(W[j-8] ^ W[j-5] ^ W[j-3] ^ W[j-1] ^ PHI ^ (j-8), 11);
+
+ for(size_t i = 8; i != 140; ++i)
+ {
+ u32bit wi = W[i-8] ^ W[i-5] ^ W[i-3] ^ W[i-1] ^ PHI ^ u32bit(i-8);
+ W[i] = rotate_left(wi, 11);
+ }
+
SBoxE4(W[ 8],W[ 9],W[ 10],W[ 11]); SBoxE3(W[ 12],W[ 13],W[ 14],W[ 15]);
SBoxE2(W[ 16],W[ 17],W[ 18],W[ 19]); SBoxE1(W[ 20],W[ 21],W[ 22],W[ 23]);
SBoxE8(W[ 24],W[ 25],W[ 26],W[ 27]); SBoxE7(W[ 28],W[ 29],W[ 30],W[ 31]);
diff --git a/src/block/serpent/serpent.h b/src/block/serpent/serpent.h
index f980c602e..a436c578a 100644
--- a/src/block/serpent/serpent.h
+++ b/src/block/serpent/serpent.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Serpent : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(round_key); }
std::string name() const { return "Serpent"; }
diff --git a/src/block/serpent_simd/serp_simd.cpp b/src/block/serpent_simd/serp_simd.cpp
index a4143804a..babe68d40 100644
--- a/src/block/serpent_simd/serp_simd.cpp
+++ b/src/block/serpent_simd/serp_simd.cpp
@@ -178,7 +178,7 @@ void serpent_decrypt_4(const byte in[64],
/*
* Serpent Encryption
*/
-void Serpent_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Serpent_SIMD::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* KS = &(this->get_round_keys()[0]);
@@ -197,7 +197,7 @@ void Serpent_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Serpent Decryption
*/
-void Serpent_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Serpent_SIMD::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* KS = &(this->get_round_keys()[0]);
diff --git a/src/block/serpent_simd/serp_simd.h b/src/block/serpent_simd/serp_simd.h
index 75a8434d1..b3c0b06c8 100644
--- a/src/block/serpent_simd/serp_simd.h
+++ b/src/block/serpent_simd/serp_simd.h
@@ -20,8 +20,8 @@ class BOTAN_DLL Serpent_SIMD : public Serpent
public:
size_t parallelism() const { return 4; }
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
BlockCipher* clone() const { return new Serpent_SIMD; }
};
diff --git a/src/block/skipjack/skipjack.cpp b/src/block/skipjack/skipjack.cpp
index 2a1901230..e3c8598ff 100644
--- a/src/block/skipjack/skipjack.cpp
+++ b/src/block/skipjack/skipjack.cpp
@@ -15,7 +15,7 @@ namespace {
/*
* Skipjack Stepping Rule 'A'
*/
-void step_A(u16bit& W1, u16bit& W4, u32bit round, const byte FTAB[])
+void step_A(u16bit& W1, u16bit& W4, size_t round, const byte FTAB[])
{
byte G1 = get_byte(0, W1), G2 = get_byte(1, W1), G3;
@@ -31,7 +31,7 @@ void step_A(u16bit& W1, u16bit& W4, u32bit round, const byte FTAB[])
/*
* Skipjack Stepping Rule 'B'
*/
-void step_B(u16bit& W1, u16bit& W2, u32bit round, const byte FTAB[])
+void step_B(u16bit& W1, u16bit& W2, size_t round, const byte FTAB[])
{
W2 ^= W1 ^ round;
byte G1 = get_byte(0, W1), G2 = get_byte(1, W1), G3;
@@ -45,7 +45,7 @@ void step_B(u16bit& W1, u16bit& W2, u32bit round, const byte FTAB[])
/*
* Skipjack Invserse Stepping Rule 'A'
*/
-void step_Ai(u16bit& W1, u16bit& W2, u32bit round, const byte FTAB[])
+void step_Ai(u16bit& W1, u16bit& W2, size_t round, const byte FTAB[])
{
W1 ^= W2 ^ round;
byte G1 = get_byte(1, W2), G2 = get_byte(0, W2), G3;
@@ -59,7 +59,7 @@ void step_Ai(u16bit& W1, u16bit& W2, u32bit round, const byte FTAB[])
/*
* Skipjack Invserse Stepping Rule 'B'
*/
-void step_Bi(u16bit& W2, u16bit& W3, u32bit round, const byte FTAB[])
+void step_Bi(u16bit& W2, u16bit& W3, size_t round, const byte FTAB[])
{
byte G1 = get_byte(1, W2), G2 = get_byte(0, W2), G3;
G3 = FTAB[((4 * round - 1) % 10)*256 + G2] ^ G1;
@@ -75,11 +75,11 @@ void step_Bi(u16bit& W2, u16bit& W3, u32bit round, const byte FTAB[])
/*
* Skipjack Encryption
*/
-void Skipjack::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Skipjack::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const byte* ftab = &FTAB[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit W1 = load_le<u16bit>(in, 3);
u16bit W2 = load_le<u16bit>(in, 2);
@@ -116,11 +116,11 @@ void Skipjack::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Skipjack Decryption
*/
-void Skipjack::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Skipjack::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const byte* ftab = &FTAB[0];
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u16bit W1 = load_le<u16bit>(in, 3);
u16bit W2 = load_le<u16bit>(in, 2);
@@ -183,8 +183,8 @@ void Skipjack::key_schedule(const byte key[], u32bit)
0x5E, 0x6C, 0xA9, 0x13, 0x57, 0x25, 0xB5, 0xE3, 0xBD, 0xA8, 0x3A, 0x01,
0x05, 0x59, 0x2A, 0x46 };
- for(u32bit i = 0; i != 10; ++i)
- for(u32bit j = 0; j != 256; ++j)
+ for(size_t i = 0; i != 10; ++i)
+ for(size_t j = 0; j != 256; ++j)
FTAB[256*i+j] = F[j ^ key[9-i]];
}
diff --git a/src/block/skipjack/skipjack.h b/src/block/skipjack/skipjack.h
index 123ab85ae..98cea7650 100644
--- a/src/block/skipjack/skipjack.h
+++ b/src/block/skipjack/skipjack.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Skipjack : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const { return "Skipjack"; }
diff --git a/src/block/square/square.cpp b/src/block/square/square.cpp
index 4b6709d50..601d66c15 100644
--- a/src/block/square/square.cpp
+++ b/src/block/square/square.cpp
@@ -14,9 +14,9 @@ namespace Botan {
/*
* Square Encryption
*/
-void Square::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Square::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit B0, B1, B2, B3;
@@ -29,7 +29,7 @@ void Square::encrypt_n(const byte in[], byte out[], u32bit blocks) const
B3 = TE0[in[ 3] ^ ME[ 3]] ^ TE1[in[ 7] ^ ME[ 7]] ^
TE2[in[11] ^ ME[11]] ^ TE3[in[15] ^ ME[15]] ^ EK[3];
- for(u32bit j = 1; j != 7; j += 2)
+ for(size_t j = 1; j != 7; j += 2)
{
u32bit T0, T1, T2, T3;
T0 = TE0[get_byte(0, B0)] ^ TE1[get_byte(0, B1)] ^
@@ -76,9 +76,9 @@ void Square::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Square Decryption
*/
-void Square::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Square::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit B0, B1, B2, B3;
@@ -91,7 +91,7 @@ void Square::decrypt_n(const byte in[], byte out[], u32bit blocks) const
B3 = TD0[in[ 3] ^ MD[ 3]] ^ TD1[in[ 7] ^ MD[ 7]] ^
TD2[in[11] ^ MD[11]] ^ TD3[in[15] ^ MD[15]] ^ DK[3];
- for(u32bit j = 1; j != 7; j += 2)
+ for(size_t j = 1; j != 7; j += 2)
{
u32bit T0, T1, T2, T3;
T0 = TD0[get_byte(0, B0)] ^ TD1[get_byte(0, B1)] ^
@@ -142,24 +142,24 @@ void Square::key_schedule(const byte key[], u32bit)
{
SecureVector<u32bit> XEK(36), XDK(36);
- for(u32bit i = 0; i != 4; ++i)
+ for(size_t i = 0; i != 4; ++i)
XEK[i] = load_be<u32bit>(key, i);
- for(u32bit i = 0; i != 8; ++i)
+ for(size_t i = 0; i != 8; ++i)
{
XEK[4*i+4] = XEK[4*i ] ^ rotate_left(XEK[4*i+3], 8) ^ (0x01000000 << i);
XEK[4*i+5] = XEK[4*i+1] ^ XEK[4*i+4];
XEK[4*i+6] = XEK[4*i+2] ^ XEK[4*i+5];
XEK[4*i+7] = XEK[4*i+3] ^ XEK[4*i+6];
- for(u32bit j = 0; j != 4; ++j)
+ for(size_t j = 0; j != 4; ++j)
XDK[28 - 4*i + j] = XEK[4*(i+1)+j];
transform(&XEK[4*i]);
}
- for(u32bit i = 0; i != 4; ++i)
- for(u32bit j = 0; j != 4; ++j)
+ for(size_t i = 0; i != 4; ++i)
+ for(size_t j = 0; j != 4; ++j)
{
ME[4*i+j ] = get_byte(j, XEK[i ]);
ME[4*i+j+16] = get_byte(j, XEK[i+32]);
@@ -182,14 +182,14 @@ void Square::transform(u32bit round_key[4])
{ 1, 3, 2, 1 },
{ 1, 1, 3, 2 } };
- for(u32bit i = 0; i != 4; ++i)
+ for(size_t i = 0; i != 4; ++i)
{
byte A[4] = { 0 }, B[4] = { 0 };
store_be(round_key[i], A);
- for(u32bit j = 0; j != 4; ++j)
- for(u32bit k = 0; k != 4; ++k)
+ for(size_t j = 0; j != 4; ++j)
+ for(size_t k = 0; k != 4; ++k)
{
const byte a = A[k];
const byte b = G[k][j];
diff --git a/src/block/square/square.h b/src/block/square/square.h
index 0c0cc871d..e3b07f24d 100644
--- a/src/block/square/square.h
+++ b/src/block/square/square.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Square : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const { return "Square"; }
diff --git a/src/block/tea/tea.cpp b/src/block/tea/tea.cpp
index de30858da..434c74ba6 100644
--- a/src/block/tea/tea.cpp
+++ b/src/block/tea/tea.cpp
@@ -13,14 +13,15 @@ namespace Botan {
/*
* TEA Encryption
*/
-void TEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void TEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit L = load_be<u32bit>(in, 0), R = load_be<u32bit>(in, 1);
+ u32bit L = load_be<u32bit>(in, 0);
+ u32bit R = load_be<u32bit>(in, 1);
u32bit S = 0;
- for(u32bit j = 0; j != 32; ++j)
+ for(size_t j = 0; j != 32; ++j)
{
S += 0x9E3779B9;
L += ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]);
@@ -37,14 +38,15 @@ void TEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* TEA Decryption
*/
-void TEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void TEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit L = load_be<u32bit>(in, 0), R = load_be<u32bit>(in, 1);
+ u32bit L = load_be<u32bit>(in, 0);
+ u32bit R = load_be<u32bit>(in, 1);
u32bit S = 0xC6EF3720;
- for(u32bit j = 0; j != 32; ++j)
+ for(size_t j = 0; j != 32; ++j)
{
R -= ((L << 4) + K[2]) ^ (L + S) ^ ((L >> 5) + K[3]);
L -= ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]);
@@ -63,8 +65,8 @@ void TEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void TEA::key_schedule(const byte key[], u32bit)
{
- for(u32bit j = 0; j != 4; ++j)
- K[j] = load_be<u32bit>(key, j);
+ for(size_t i = 0; i != 4; ++i)
+ K[i] = load_be<u32bit>(key, i);
}
}
diff --git a/src/block/tea/tea.h b/src/block/tea/tea.h
index dd03ec3c6..7cb18a4f8 100644
--- a/src/block/tea/tea.h
+++ b/src/block/tea/tea.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL TEA : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(K); }
std::string name() const { return "TEA"; }
diff --git a/src/block/twofish/twofish.cpp b/src/block/twofish/twofish.cpp
index b760de382..9c3d57500 100644
--- a/src/block/twofish/twofish.cpp
+++ b/src/block/twofish/twofish.cpp
@@ -14,16 +14,16 @@ namespace Botan {
/*
* Twofish Encryption
*/
-void Twofish::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_le<u32bit>(in, 0) ^ RK[0];
u32bit B = load_le<u32bit>(in, 1) ^ RK[1];
u32bit C = load_le<u32bit>(in, 2) ^ RK[2];
u32bit D = load_le<u32bit>(in, 3) ^ RK[3];
- for(u32bit j = 0; j != 16; j += 2)
+ for(size_t j = 0; j != 16; j += 2)
{
u32bit X, Y;
@@ -65,16 +65,16 @@ void Twofish::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* Twofish Decryption
*/
-void Twofish::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
u32bit A = load_le<u32bit>(in, 0) ^ RK[4];
u32bit B = load_le<u32bit>(in, 1) ^ RK[5];
u32bit C = load_le<u32bit>(in, 2) ^ RK[6];
u32bit D = load_le<u32bit>(in, 3) ^ RK[7];
- for(u32bit j = 0; j != 16; j += 2)
+ for(size_t j = 0; j != 16; j += 2)
{
u32bit X, Y;
@@ -120,12 +120,12 @@ void Twofish::key_schedule(const byte key[], u32bit length)
{
SecureVector<byte> S(16);
- for(u32bit i = 0; i != length; ++i)
+ for(size_t i = 0; i != length; ++i)
rs_mul(&S[4*(i/8)], key[i], i);
if(length == 16)
{
- for(u32bit i = 0; i != 256; ++i)
+ for(size_t i = 0; i != 256; ++i)
{
SB[ i] = MDS0[Q0[Q0[i]^S[ 0]]^S[ 4]];
SB[256+i] = MDS1[Q0[Q1[i]^S[ 1]]^S[ 5]];
@@ -133,7 +133,7 @@ void Twofish::key_schedule(const byte key[], u32bit length)
SB[768+i] = MDS3[Q1[Q1[i]^S[ 3]]^S[ 7]];
}
- for(u32bit i = 0; i != 40; i += 2)
+ for(size_t i = 0; i != 40; i += 2)
{
u32bit X = MDS0[Q0[Q0[i ]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[i ]^key[ 9]]^key[ 1]] ^
@@ -152,7 +152,7 @@ void Twofish::key_schedule(const byte key[], u32bit length)
}
else if(length == 24)
{
- for(u32bit i = 0; i != 256; ++i)
+ for(size_t i = 0; i != 256; ++i)
{
SB[ i] = MDS0[Q0[Q0[Q1[i]^S[ 0]]^S[ 4]]^S[ 8]];
SB[256+i] = MDS1[Q0[Q1[Q1[i]^S[ 1]]^S[ 5]]^S[ 9]];
@@ -160,7 +160,7 @@ void Twofish::key_schedule(const byte key[], u32bit length)
SB[768+i] = MDS3[Q1[Q1[Q0[i]^S[ 3]]^S[ 7]]^S[11]];
}
- for(u32bit i = 0; i != 40; i += 2)
+ for(size_t i = 0; i != 40; i += 2)
{
u32bit X = MDS0[Q0[Q0[Q1[i ]^key[16]]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[Q1[i ]^key[17]]^key[ 9]]^key[ 1]] ^
@@ -179,7 +179,7 @@ void Twofish::key_schedule(const byte key[], u32bit length)
}
else if(length == 32)
{
- for(u32bit i = 0; i != 256; ++i)
+ for(size_t i = 0; i != 256; ++i)
{
SB[ i] = MDS0[Q0[Q0[Q1[Q1[i]^S[ 0]]^S[ 4]]^S[ 8]]^S[12]];
SB[256+i] = MDS1[Q0[Q1[Q1[Q0[i]^S[ 1]]^S[ 5]]^S[ 9]]^S[13]];
@@ -187,7 +187,7 @@ void Twofish::key_schedule(const byte key[], u32bit length)
SB[768+i] = MDS3[Q1[Q1[Q0[Q1[i]^S[ 3]]^S[ 7]]^S[11]]^S[15]];
}
- for(u32bit i = 0; i != 40; i += 2)
+ for(size_t i = 0; i != 40; i += 2)
{
u32bit X = MDS0[Q0[Q0[Q1[Q1[i ]^key[24]]^key[16]]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[Q1[Q0[i ]^key[25]]^key[17]]^key[ 9]]^key[ 1]] ^
@@ -209,7 +209,7 @@ void Twofish::key_schedule(const byte key[], u32bit length)
/*
* Do one column of the RS matrix multiplcation
*/
-void Twofish::rs_mul(byte S[4], byte key, u32bit offset)
+void Twofish::rs_mul(byte S[4], byte key, size_t offset)
{
if(key)
{
diff --git a/src/block/twofish/twofish.h b/src/block/twofish/twofish.h
index eb4900ffa..b94c3adc3 100644
--- a/src/block/twofish/twofish.h
+++ b/src/block/twofish/twofish.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Twofish : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
std::string name() const { return "Twofish"; }
@@ -29,7 +29,7 @@ class BOTAN_DLL Twofish : public BlockCipher
private:
void key_schedule(const byte[], u32bit);
- static void rs_mul(byte[4], byte, u32bit);
+ static void rs_mul(byte[4], byte, size_t);
static const u32bit MDS0[256];
static const u32bit MDS1[256];
diff --git a/src/block/xtea/xtea.cpp b/src/block/xtea/xtea.cpp
index 9e47e5328..7acad2b6b 100644
--- a/src/block/xtea/xtea.cpp
+++ b/src/block/xtea/xtea.cpp
@@ -17,7 +17,7 @@ void xtea_encrypt_4(const byte in[32], byte out[32], const u32bit EK[64])
u32bit L0, R0, L1, R1, L2, R2, L3, R3;
load_be(in, L0, R0, L1, R1, L2, R2, L3, R3);
- for(u32bit i = 0; i != 32; ++i)
+ for(size_t i = 0; i != 32; ++i)
{
L0 += (((R0 << 4) ^ (R0 >> 5)) + R0) ^ EK[2*i];
L1 += (((R1 << 4) ^ (R1 >> 5)) + R1) ^ EK[2*i];
@@ -38,7 +38,7 @@ void xtea_decrypt_4(const byte in[32], byte out[32], const u32bit EK[64])
u32bit L0, R0, L1, R1, L2, R2, L3, R3;
load_be(in, L0, R0, L1, R1, L2, R2, L3, R3);
- for(u32bit i = 0; i != 32; ++i)
+ for(size_t i = 0; i != 32; ++i)
{
R0 -= (((L0 << 4) ^ (L0 >> 5)) + L0) ^ EK[63 - 2*i];
R1 -= (((L1 << 4) ^ (L1 >> 5)) + L1) ^ EK[63 - 2*i];
@@ -59,7 +59,7 @@ void xtea_decrypt_4(const byte in[32], byte out[32], const u32bit EK[64])
/*
* XTEA Encryption
*/
-void XTEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
while(blocks >= 4)
{
@@ -69,11 +69,12 @@ void XTEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const
blocks -= 4;
}
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit L = load_be<u32bit>(in, 0), R = load_be<u32bit>(in, 1);
+ u32bit L = load_be<u32bit>(in, 0);
+ u32bit R = load_be<u32bit>(in, 1);
- for(u32bit j = 0; j != 32; ++j)
+ for(size_t j = 0; j != 32; ++j)
{
L += (((R << 4) ^ (R >> 5)) + R) ^ EK[2*j];
R += (((L << 4) ^ (L >> 5)) + L) ^ EK[2*j+1];
@@ -89,7 +90,7 @@ void XTEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* XTEA Decryption
*/
-void XTEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
while(blocks >= 4)
{
@@ -99,11 +100,12 @@ void XTEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const
blocks -= 4;
}
- for(u32bit i = 0; i != blocks; ++i)
+ for(size_t i = 0; i != blocks; ++i)
{
- u32bit L = load_be<u32bit>(in, 0), R = load_be<u32bit>(in, 1);
+ u32bit L = load_be<u32bit>(in, 0);
+ u32bit R = load_be<u32bit>(in, 1);
- for(u32bit j = 0; j != 32; ++j)
+ for(size_t j = 0; j != 32; ++j)
{
R -= (((L << 4) ^ (L >> 5)) + L) ^ EK[63 - 2*j];
L -= (((R << 4) ^ (R >> 5)) + R) ^ EK[62 - 2*j];
@@ -122,11 +124,11 @@ void XTEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const
void XTEA::key_schedule(const byte key[], u32bit)
{
SecureVector<u32bit> UK(4);
- for(u32bit i = 0; i != 4; ++i)
+ for(size_t i = 0; i != 4; ++i)
UK[i] = load_be<u32bit>(key, i);
u32bit D = 0;
- for(u32bit i = 0; i != 64; i += 2)
+ for(size_t i = 0; i != 64; i += 2)
{
EK[i ] = D + UK[D % 4];
D += 0x9E3779B9;
diff --git a/src/block/xtea/xtea.h b/src/block/xtea/xtea.h
index 54c925df2..6a843e21f 100644
--- a/src/block/xtea/xtea.h
+++ b/src/block/xtea/xtea.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL XTEA : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear() { zeroise(EK); }
std::string name() const { return "XTEA"; }
diff --git a/src/block/xtea_simd/xtea_simd.cpp b/src/block/xtea_simd/xtea_simd.cpp
index b1c19aca3..831cc0359 100644
--- a/src/block/xtea_simd/xtea_simd.cpp
+++ b/src/block/xtea_simd/xtea_simd.cpp
@@ -92,7 +92,7 @@ void xtea_decrypt_8(const byte in[64], byte out[64], const u32bit EK[64])
/*
* XTEA Encryption
*/
-void XTEA_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
+void XTEA_SIMD::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* KS = &(this->get_EK()[0]);
@@ -111,7 +111,7 @@ void XTEA_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
/*
* XTEA Decryption
*/
-void XTEA_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const
+void XTEA_SIMD::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
const u32bit* KS = &(this->get_EK()[0]);
diff --git a/src/block/xtea_simd/xtea_simd.h b/src/block/xtea_simd/xtea_simd.h
index e68282539..ecfdf90a5 100644
--- a/src/block/xtea_simd/xtea_simd.h
+++ b/src/block/xtea_simd/xtea_simd.h
@@ -20,8 +20,8 @@ class BOTAN_DLL XTEA_SIMD : public XTEA
public:
size_t parallelism() const { return 8; }
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
BlockCipher* clone() const { return new XTEA_SIMD; }
};
diff --git a/src/engine/openssl/ossl_bc.cpp b/src/engine/openssl/ossl_bc.cpp
index 911d6088d..d1365d038 100644
--- a/src/engine/openssl/ossl_bc.cpp
+++ b/src/engine/openssl/ossl_bc.cpp
@@ -27,8 +27,8 @@ class EVP_BlockCipher : public BlockCipher
~EVP_BlockCipher();
private:
- void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
- void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void key_schedule(const byte[], u32bit);
std::string cipher_name;
mutable EVP_CIPHER_CTX encrypt, decrypt;
@@ -91,7 +91,7 @@ EVP_BlockCipher::~EVP_BlockCipher()
* Encrypt a block
*/
void EVP_BlockCipher::encrypt_n(const byte in[], byte out[],
- u32bit blocks) const
+ size_t blocks) const
{
int out_len = 0;
EVP_EncryptUpdate(&encrypt, out, &out_len, in, blocks * BLOCK_SIZE);
@@ -101,7 +101,7 @@ void EVP_BlockCipher::encrypt_n(const byte in[], byte out[],
* Decrypt a block
*/
void EVP_BlockCipher::decrypt_n(const byte in[], byte out[],
- u32bit blocks) const
+ size_t blocks) const
{
int out_len = 0;
EVP_DecryptUpdate(&decrypt, out, &out_len, in, blocks * BLOCK_SIZE);
@@ -214,7 +214,8 @@ OpenSSL_Engine::find_block_cipher(const SCAN_Name& request,
#if !defined(OPENSSL_NO_RC5)
if(request.algo_name() == "RC5")
if(request.arg_as_u32bit(0, 12) == 12)
- return new EVP_BlockCipher(EVP_rc5_32_12_16_ecb(), "RC5(12)", 1, 32, 1);
+ return new EVP_BlockCipher(EVP_rc5_32_12_16_ecb(),
+ "RC5(12)", 1, 32, 1);
#endif
#if !defined(OPENSSL_NO_IDEA)
diff --git a/src/filters/modes/ecb/ecb.cpp b/src/filters/modes/ecb/ecb.cpp
index 965212abf..d97fe4f49 100644
--- a/src/filters/modes/ecb/ecb.cpp
+++ b/src/filters/modes/ecb/ecb.cpp
@@ -87,7 +87,7 @@ void ECB_Encryption::buffered_block(const byte input[], u32bit input_length)
while(blocks)
{
- u32bit to_proc = std::min<u32bit>(blocks, blocks_in_temp);
+ u32bit to_proc = std::min(blocks, blocks_in_temp);
cipher->encrypt_n(input, &temp[0], to_proc);
@@ -178,7 +178,7 @@ void ECB_Decryption::buffered_block(const byte input[], u32bit length)
while(blocks)
{
- u32bit to_proc = std::min<u32bit>(blocks, blocks_in_temp);
+ u32bit to_proc = std::min(blocks, blocks_in_temp);
cipher->decrypt_n(input, &temp[0], to_proc);