diff options
Diffstat (limited to 'src/block')
58 files changed, 131 insertions, 132 deletions
diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp index 66f9c5eb1..cfd490e1d 100644 --- a/src/block/aes/aes.cpp +++ b/src/block/aes/aes.cpp @@ -619,7 +619,7 @@ void AES::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * AES Key Schedule */ -void AES::key_schedule(const byte key[], u32bit length) +void AES::key_schedule(const byte key[], size_t length) { static const u32bit RC[10] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, @@ -629,40 +629,40 @@ void AES::key_schedule(const byte key[], u32bit length) SecureVector<u32bit> XEK(64), XDK(64); - const u32bit X = length / 4; - for(u32bit j = 0; j != X; ++j) - XEK[j] = load_be<u32bit>(key, j); + const size_t X = length / 4; + for(size_t i = 0; i != X; ++i) + XEK[i] = load_be<u32bit>(key, i); - for(u32bit j = X; j < 4*(ROUNDS+1); j += X) + for(size_t i = X; i < 4*(ROUNDS+1); i += X) { - XEK[j] = XEK[j-X] ^ S(rotate_left(XEK[j-1], 8)) ^ RC[(j-X)/X]; - for(u32bit k = 1; k != X; ++k) + XEK[i] = XEK[i-X] ^ S(rotate_left(XEK[i-1], 8)) ^ RC[(i-X)/X]; + for(size_t j = 1; j != X; ++j) { - if(X == 8 && k == 4) - XEK[j+k] = XEK[j+k-X] ^ S(XEK[j+k-1]); + if(X == 8 && j == 4) + XEK[i+j] = XEK[i+j-X] ^ S(XEK[i+j-1]); else - XEK[j+k] = XEK[j+k-X] ^ XEK[j+k-1]; + XEK[i+j] = XEK[i+j-X] ^ XEK[i+j-1]; } } - for(u32bit j = 0; j != 4*(ROUNDS+1); j += 4) + for(size_t i = 0; i != 4*(ROUNDS+1); i += 4) { - XDK[j ] = XEK[4*ROUNDS-j ]; - XDK[j+1] = XEK[4*ROUNDS-j+1]; - XDK[j+2] = XEK[4*ROUNDS-j+2]; - XDK[j+3] = XEK[4*ROUNDS-j+3]; + XDK[i ] = XEK[4*ROUNDS-i ]; + XDK[i+1] = XEK[4*ROUNDS-i+1]; + XDK[i+2] = XEK[4*ROUNDS-i+2]; + XDK[i+3] = XEK[4*ROUNDS-i+3]; } - for(u32bit j = 4; j != length + 24; ++j) - XDK[j] = TD[SE[get_byte(0, XDK[j])] + 0] ^ - TD[SE[get_byte(1, XDK[j])] + 256] ^ - TD[SE[get_byte(2, XDK[j])] + 512] ^ - TD[SE[get_byte(3, XDK[j])] + 768]; + for(size_t i = 4; i != length + 24; ++i) + XDK[i] = TD[SE[get_byte(0, XDK[i])] + 0] ^ + TD[SE[get_byte(1, XDK[i])] + 256] ^ + TD[SE[get_byte(2, XDK[i])] + 512] ^ + TD[SE[get_byte(3, XDK[i])] + 768]; - for(u32bit j = 0; j != 4; ++j) + for(size_t i = 0; i != 4; ++i) { - store_be(XEK[j+4*ROUNDS], &ME[4*j]); - store_be(XEK[j], &MD[4*j]); + store_be(XEK[i+4*ROUNDS], &ME[4*i]); + store_be(XEK[i], &MD[4*i]); } EK.copy(&XEK[0], length + 24); diff --git a/src/block/aes/aes.h b/src/block/aes/aes.h index 6bc1f44b4..d62413f5b 100644 --- a/src/block/aes/aes.h +++ b/src/block/aes/aes.h @@ -25,7 +25,8 @@ class BOTAN_DLL AES : public BlockCipher std::string name() const { return "AES"; } BlockCipher* clone() const { return new AES; } - AES() : BlockCipher(16, 16, 32, 8), EK(56), ME(16), DK(56), MD(16) { ROUNDS = 14; } + AES() : BlockCipher(16, 16, 32, 8), EK(56), ME(16), DK(56), MD(16) + { ROUNDS = 14; } /** * AES fixed to a particular key_size (16, 24, or 32 bytes) @@ -33,7 +34,7 @@ class BOTAN_DLL AES : public BlockCipher */ AES(u32bit key_size); private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); static u32bit S(u32bit); u32bit ROUNDS; @@ -41,7 +42,7 @@ class BOTAN_DLL AES : public BlockCipher SecureVector<u32bit> EK; SecureVector<byte> ME; - SecureVector<u32bit> DK; + SecureVector<u32bit > DK; SecureVector<byte> MD; }; diff --git a/src/block/aes_intel/aes_intel.cpp b/src/block/aes_intel/aes_intel.cpp index d03767e72..a2e660f2c 100644 --- a/src/block/aes_intel/aes_intel.cpp +++ b/src/block/aes_intel/aes_intel.cpp @@ -255,7 +255,7 @@ void AES_128_Intel::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * AES-128 Key Schedule */ -void AES_128_Intel::key_schedule(const byte key[], u32bit) +void AES_128_Intel::key_schedule(const byte key[], size_t) { #define AES_128_key_exp(K, RCON) \ aes_128_key_expansion(K, _mm_aeskeygenassist_si128(K, RCON)) @@ -477,7 +477,7 @@ void AES_192_Intel::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * AES-192 Key Schedule */ -void AES_192_Intel::key_schedule(const byte key[], u32bit) +void AES_192_Intel::key_schedule(const byte key[], size_t) { __m128i K0 = _mm_loadu_si128((const __m128i*)(key)); __m128i K1 = _mm_loadu_si128((const __m128i*)(key + 8)); @@ -705,7 +705,7 @@ void AES_256_Intel::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * AES-256 Key Schedule */ -void AES_256_Intel::key_schedule(const byte key[], u32bit) +void AES_256_Intel::key_schedule(const byte key[], size_t) { __m128i K0 = _mm_loadu_si128((const __m128i*)(key)); __m128i K1 = _mm_loadu_si128((const __m128i*)(key + 16)); diff --git a/src/block/aes_intel/aes_intel.h b/src/block/aes_intel/aes_intel.h index 43e8f2f0e..1d8a68389 100644 --- a/src/block/aes_intel/aes_intel.h +++ b/src/block/aes_intel/aes_intel.h @@ -29,7 +29,7 @@ class BOTAN_DLL AES_128_Intel : public BlockCipher AES_128_Intel() : BlockCipher(16, 16) { } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit, 44> EK, DK; }; @@ -51,7 +51,7 @@ class BOTAN_DLL AES_192_Intel : public BlockCipher AES_192_Intel() : BlockCipher(16, 24) { } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit, 52> EK, DK; }; @@ -73,7 +73,7 @@ class BOTAN_DLL AES_256_Intel : public BlockCipher AES_256_Intel() : BlockCipher(16, 32) { } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit, 60> EK, DK; }; diff --git a/src/block/aes_ssse3/aes_ssse3.cpp b/src/block/aes_ssse3/aes_ssse3.cpp index dda5941b7..c5869f899 100644 --- a/src/block/aes_ssse3/aes_ssse3.cpp +++ b/src/block/aes_ssse3/aes_ssse3.cpp @@ -371,7 +371,7 @@ void AES_128_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * AES-128 Key Schedule */ -void AES_128_SSSE3::key_schedule(const byte keyb[], u32bit) +void AES_128_SSSE3::key_schedule(const byte keyb[], size_t) { __m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81, 0x1F8391B9, 0xAF9DEEB6); @@ -440,7 +440,7 @@ void AES_192_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * AES-192 Key Schedule */ -void AES_192_SSSE3::key_schedule(const byte keyb[], u32bit) +void AES_192_SSSE3::key_schedule(const byte keyb[], size_t) { __m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81, 0x1F8391B9, 0xAF9DEEB6); @@ -539,7 +539,7 @@ void AES_256_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * AES-256 Key Schedule */ -void AES_256_SSSE3::key_schedule(const byte keyb[], u32bit) +void AES_256_SSSE3::key_schedule(const byte keyb[], size_t) { __m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81, 0x1F8391B9, 0xAF9DEEB6); diff --git a/src/block/aes_ssse3/aes_ssse3.h b/src/block/aes_ssse3/aes_ssse3.h index 7b2a43cb7..0cdb5f4de 100644 --- a/src/block/aes_ssse3/aes_ssse3.h +++ b/src/block/aes_ssse3/aes_ssse3.h @@ -27,7 +27,7 @@ class BOTAN_DLL AES_128_SSSE3 : public BlockCipher AES_128_SSSE3() : BlockCipher(16, 16), EK(44), DK(44) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> EK, DK; }; @@ -47,7 +47,7 @@ class BOTAN_DLL AES_192_SSSE3 : public BlockCipher AES_192_SSSE3() : BlockCipher(16, 24), EK(52), DK(52) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> EK, DK; }; @@ -67,7 +67,7 @@ class BOTAN_DLL AES_256_SSSE3 : public BlockCipher AES_256_SSSE3() : BlockCipher(16, 32), EK(60), DK(60) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> EK, DK; }; diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp index e72dbb2ae..ea227e93e 100644 --- a/src/block/blowfish/blowfish.cpp +++ b/src/block/blowfish/blowfish.cpp @@ -83,13 +83,13 @@ void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Blowfish Key Schedule */ -void Blowfish::key_schedule(const byte key[], u32bit length) +void Blowfish::key_schedule(const byte key[], size_t length) { clear(); - 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]); + for(size_t i = 0, j = 0; i != 18; ++i, j += 4) + P[i] ^= make_u32bit(key[(j ) % length], key[(j+1) % length], + key[(j+2) % length], key[(j+3) % length]); u32bit L = 0, R = 0; generate_sbox(P, L, R); @@ -107,22 +107,22 @@ void Blowfish::generate_sbox(MemoryRegion<u32bit>& box, const u32bit* S3 = &S[512]; const u32bit* S4 = &S[768]; - for(size_t j = 0; j != box.size(); j += 2) + for(size_t i = 0; i != box.size(); i += 2) { - for(size_t k = 0; k != 16; k += 2) + for(size_t j = 0; j != 16; j += 2) { - L ^= P[k]; + L ^= P[j]; R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ S3[get_byte(2, L)]) + S4[get_byte(3, L)]; - R ^= P[k+1]; + R ^= P[j+1]; L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ S3[get_byte(2, R)]) + S4[get_byte(3, R)]; } u32bit T = R; R = L ^ P[16]; L = T ^ P[17]; - box[j] = L; - box[j+1] = R; + box[i] = L; + box[i+1] = R; } } @@ -133,8 +133,6 @@ void Blowfish::clear() { std::copy(P_INIT, P_INIT + 18, P.begin()); std::copy(S_INIT, S_INIT + 1024, S.begin()); - //P.copy(P_INIT, 18); - //S.copy(S_INIT, 1024); } } diff --git a/src/block/blowfish/blowfish.h b/src/block/blowfish/blowfish.h index 32fb4cbd4..4d39e9e58 100644 --- a/src/block/blowfish/blowfish.h +++ b/src/block/blowfish/blowfish.h @@ -27,7 +27,7 @@ class BOTAN_DLL Blowfish : public BlockCipher Blowfish() : BlockCipher(8, 1, 56), S(1024), P(18) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); void generate_sbox(MemoryRegion<u32bit>& box, u32bit& L, u32bit& R) const; diff --git a/src/block/cascade/cascade.cpp b/src/block/cascade/cascade.cpp index e93e81d33..54c33bc68 100644 --- a/src/block/cascade/cascade.cpp +++ b/src/block/cascade/cascade.cpp @@ -29,7 +29,7 @@ void Cascade_Cipher::decrypt_n(const byte in[], byte out[], cipher1->decrypt_n(out, out, c1_blocks); } -void Cascade_Cipher::key_schedule(const byte key[], u32bit) +void Cascade_Cipher::key_schedule(const byte key[], size_t) { const byte* key2 = key + cipher1->MAXIMUM_KEYLENGTH; diff --git a/src/block/cascade/cascade.h b/src/block/cascade/cascade.h index 6e9d43cf7..5e1989cb6 100644 --- a/src/block/cascade/cascade.h +++ b/src/block/cascade/cascade.h @@ -34,7 +34,7 @@ class BOTAN_DLL Cascade_Cipher : public BlockCipher ~Cascade_Cipher(); private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); BlockCipher* cipher1; BlockCipher* cipher2; diff --git a/src/block/cast/cast128.cpp b/src/block/cast/cast128.cpp index 538c1bd5b..24469e025 100644 --- a/src/block/cast/cast128.cpp +++ b/src/block/cast/cast128.cpp @@ -116,7 +116,7 @@ void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * CAST-128 Key Schedule */ -void CAST_128::key_schedule(const byte key[], u32bit length) +void CAST_128::key_schedule(const byte key[], size_t length) { clear(); SecureVector<u32bit> X(4); diff --git a/src/block/cast/cast128.h b/src/block/cast/cast128.h index 18c0c1868..edccf04b3 100644 --- a/src/block/cast/cast128.h +++ b/src/block/cast/cast128.h @@ -27,7 +27,7 @@ class BOTAN_DLL CAST_128 : public BlockCipher CAST_128() : BlockCipher(8, 11, 16), MK(16), RK(16) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); static void cast_ks(MemoryRegion<u32bit>& ks, MemoryRegion<u32bit>& user_key); diff --git a/src/block/cast/cast256.cpp b/src/block/cast/cast256.cpp index 6567ffbd4..8be0a8dd6 100644 --- a/src/block/cast/cast256.cpp +++ b/src/block/cast/cast256.cpp @@ -136,7 +136,7 @@ void CAST_256::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * CAST-256 Key Schedule */ -void CAST_256::key_schedule(const byte key[], u32bit length) +void CAST_256::key_schedule(const byte key[], size_t length) { SecureVector<u32bit> K(8); for(size_t j = 0; j != length; ++j) diff --git a/src/block/cast/cast256.h b/src/block/cast/cast256.h index ef73fbf94..74e38face 100644 --- a/src/block/cast/cast256.h +++ b/src/block/cast/cast256.h @@ -27,7 +27,7 @@ class BOTAN_DLL CAST_256 : public BlockCipher CAST_256() : BlockCipher(16, 4, 32, 4), MK(48), RK(48) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); static const u32bit KEY_MASK[192]; static const byte KEY_ROT[32]; diff --git a/src/block/des/des.cpp b/src/block/des/des.cpp index 043391938..15c771bda 100644 --- a/src/block/des/des.cpp +++ b/src/block/des/des.cpp @@ -201,7 +201,7 @@ void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * DES Key Schedule */ -void DES::key_schedule(const byte key[], u32bit) +void DES::key_schedule(const byte key[], size_t) { des_key_schedule(&round_key[0], key); } @@ -275,7 +275,7 @@ void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * TripleDES Key Schedule */ -void TripleDES::key_schedule(const byte key[], u32bit length) +void TripleDES::key_schedule(const byte key[], size_t length) { des_key_schedule(&round_key[0], key); des_key_schedule(&round_key[32], key + 8); diff --git a/src/block/des/des.h b/src/block/des/des.h index dbca8ddfd..03641ba40 100644 --- a/src/block/des/des.h +++ b/src/block/des/des.h @@ -27,7 +27,7 @@ class BOTAN_DLL DES : public BlockCipher DES() : BlockCipher(8, 8), round_key(32) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> round_key; }; @@ -47,7 +47,7 @@ class BOTAN_DLL TripleDES : public BlockCipher TripleDES() : BlockCipher(8, 16, 24, 8), round_key(96) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> round_key; }; diff --git a/src/block/des/desx.cpp b/src/block/des/desx.cpp index cb53448b4..b92011e56 100644 --- a/src/block/des/desx.cpp +++ b/src/block/des/desx.cpp @@ -45,7 +45,7 @@ void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * DESX Key Schedule */ -void DESX::key_schedule(const byte key[], u32bit) +void DESX::key_schedule(const byte key[], size_t) { K1.copy(key, 8); des.set_key(key + 8, 8); diff --git a/src/block/des/desx.h b/src/block/des/desx.h index 5b7f10281..b61ea3cf9 100644 --- a/src/block/des/desx.h +++ b/src/block/des/desx.h @@ -27,7 +27,7 @@ class BOTAN_DLL DESX : public BlockCipher DESX() : BlockCipher(8, 24), K1(8), K2(8) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<byte> K1, K2; DES des; }; diff --git a/src/block/gost_28147/gost_28147.cpp b/src/block/gost_28147/gost_28147.cpp index c23c31dfb..4b4b83dcc 100644 --- a/src/block/gost_28147/gost_28147.cpp +++ b/src/block/gost_28147/gost_28147.cpp @@ -144,7 +144,7 @@ void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * GOST Key Schedule */ -void GOST_28147_89::key_schedule(const byte key[], u32bit) +void GOST_28147_89::key_schedule(const byte key[], size_t) { 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 f70c6650f..d06b63228 100644 --- a/src/block/gost_28147/gost_28147.h +++ b/src/block/gost_28147/gost_28147.h @@ -68,7 +68,7 @@ class BOTAN_DLL GOST_28147_89 : public BlockCipher GOST_28147_89(const SecureVector<u32bit>& other_SBOX) : BlockCipher(8, 32), SBOX(other_SBOX), EK(8) {} - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> SBOX; SecureVector<u32bit> EK; diff --git a/src/block/idea/idea.cpp b/src/block/idea/idea.cpp index 8201c9193..be7680b2c 100644 --- a/src/block/idea/idea.cpp +++ b/src/block/idea/idea.cpp @@ -122,16 +122,16 @@ void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * IDEA Key Schedule */ -void IDEA::key_schedule(const byte key[], u32bit) +void IDEA::key_schedule(const byte key[], size_t) { - for(size_t j = 0; j != 8; ++j) - EK[j] = load_be<u16bit>(key, j); + for(size_t i = 0; i != 8; ++i) + EK[i] = load_be<u16bit>(key, i); - for(size_t j = 1, k = 8, offset = 0; k != 52; j %= 8, ++j, ++k) + for(size_t i = 1, j = 8, offset = 0; j != 52; i %= 8, ++i, ++j) { - EK[j+7+offset] = static_cast<u16bit>((EK[(j % 8) + offset] << 9) | - (EK[((j+1) % 8) + offset] >> 7)); - offset += (j == 8) ? 8 : 0; + EK[i+7+offset] = static_cast<u16bit>((EK[(i % 8) + offset] << 9) | + (EK[((i+1) % 8) + offset] >> 7)); + offset += (i == 8) ? 8 : 0; } DK[51] = mul_inv(EK[3]); @@ -139,14 +139,14 @@ void IDEA::key_schedule(const byte key[], u32bit) DK[49] = -EK[1]; DK[48] = mul_inv(EK[0]); - for(size_t j = 1, k = 4, counter = 47; j != 8; ++j, k += 6) + for(size_t i = 1, j = 4, counter = 47; i != 8; ++i, j += 6) { - DK[counter--] = EK[k+1]; - DK[counter--] = EK[k]; - DK[counter--] = mul_inv(EK[k+5]); - DK[counter--] = -EK[k+3]; - DK[counter--] = -EK[k+4]; - DK[counter--] = mul_inv(EK[k+2]); + DK[counter--] = EK[j+1]; + DK[counter--] = EK[j]; + DK[counter--] = mul_inv(EK[j+5]); + DK[counter--] = -EK[j+3]; + DK[counter--] = -EK[j+4]; + DK[counter--] = mul_inv(EK[j+2]); } DK[5] = EK[47]; diff --git a/src/block/idea/idea.h b/src/block/idea/idea.h index 566d9afd4..c0af38ad6 100644 --- a/src/block/idea/idea.h +++ b/src/block/idea/idea.h @@ -38,7 +38,7 @@ class BOTAN_DLL IDEA : public BlockCipher const SecureVector<u16bit>& get_DK() const { return DK; } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u16bit> EK, DK; }; diff --git a/src/block/kasumi/kasumi.cpp b/src/block/kasumi/kasumi.cpp index 15d6a24fc..a57c0396a 100644 --- a/src/block/kasumi/kasumi.cpp +++ b/src/block/kasumi/kasumi.cpp @@ -199,7 +199,7 @@ void KASUMI::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * KASUMI Key Schedule */ -void KASUMI::key_schedule(const byte key[], u32bit) +void KASUMI::key_schedule(const byte key[], size_t) { static const u16bit RC[] = { 0x0123, 0x4567, 0x89AB, 0xCDEF, 0xFEDC, 0xBA98, 0x7654, 0x3210 }; diff --git a/src/block/kasumi/kasumi.h b/src/block/kasumi/kasumi.h index 8589af79b..c6b3c4351 100644 --- a/src/block/kasumi/kasumi.h +++ b/src/block/kasumi/kasumi.h @@ -27,7 +27,7 @@ class BOTAN_DLL KASUMI : public BlockCipher KASUMI() : BlockCipher(8, 16), EK(64) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u16bit> EK; }; diff --git a/src/block/lion/lion.cpp b/src/block/lion/lion.cpp index b4a00ebee..daf00da81 100644 --- a/src/block/lion/lion.cpp +++ b/src/block/lion/lion.cpp @@ -68,7 +68,7 @@ void Lion::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Lion Key Schedule */ -void Lion::key_schedule(const byte key[], u32bit length) +void Lion::key_schedule(const byte key[], size_t length) { clear(); diff --git a/src/block/lion/lion.h b/src/block/lion/lion.h index 5d4d374b9..9beb68ca6 100644 --- a/src/block/lion/lion.h +++ b/src/block/lion/lion.h @@ -43,7 +43,7 @@ class BOTAN_DLL Lion : public BlockCipher ~Lion() { delete hash; delete cipher; } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); const size_t LEFT_SIZE, RIGHT_SIZE; diff --git a/src/block/lubyrack/lubyrack.cpp b/src/block/lubyrack/lubyrack.cpp index 0b7ec7bf4..383e9131b 100644 --- a/src/block/lubyrack/lubyrack.cpp +++ b/src/block/lubyrack/lubyrack.cpp @@ -87,7 +87,7 @@ void LubyRackoff::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Luby-Rackoff Key Schedule */ -void LubyRackoff::key_schedule(const byte key[], u32bit length) +void LubyRackoff::key_schedule(const byte key[], size_t length) { K1.set(key, length / 2); K2.set(key + length / 2, length / 2); diff --git a/src/block/lubyrack/lubyrack.h b/src/block/lubyrack/lubyrack.h index c20af950d..4567215e1 100644 --- a/src/block/lubyrack/lubyrack.h +++ b/src/block/lubyrack/lubyrack.h @@ -32,7 +32,7 @@ class BOTAN_DLL LubyRackoff : public BlockCipher LubyRackoff(HashFunction* hash); ~LubyRackoff() { delete hash; } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); HashFunction* hash; SecureVector<byte> K1, K2; diff --git a/src/block/mars/mars.cpp b/src/block/mars/mars.cpp index 9445ab576..fa73e564f 100644 --- a/src/block/mars/mars.cpp +++ b/src/block/mars/mars.cpp @@ -149,7 +149,7 @@ inline void decrypt_round(u32bit& A, u32bit& B, u32bit& C, u32bit& D, */ void forward_mix(u32bit& A, u32bit& B, u32bit& C, u32bit& D) { - for(u32bit j = 0; j != 2; ++j) + for(size_t j = 0; j != 2; ++j) { B ^= SBOX[get_byte(3, A)]; B += SBOX[get_byte(2, A) + 256]; C += SBOX[get_byte(1, A)]; D ^= SBOX[get_byte(0, A) + 256]; @@ -174,7 +174,7 @@ void forward_mix(u32bit& A, u32bit& B, u32bit& C, u32bit& D) */ void reverse_mix(u32bit& A, u32bit& B, u32bit& C, u32bit& D) { - for(u32bit j = 0; j != 2; ++j) + for(size_t j = 0; j != 2; ++j) { B ^= SBOX[get_byte(3, A) + 256]; C -= SBOX[get_byte(0, A)]; D -= SBOX[get_byte(1, A) + 256]; D ^= SBOX[get_byte(2, A)]; @@ -202,7 +202,7 @@ u32bit gen_mask(u32bit input) { u32bit mask = 0; - for(u32bit j = 2; j != 31; ++j) + for(size_t j = 2; j != 31; ++j) { u32bit region = (input >> (j-1)) & 0x07; @@ -318,11 +318,11 @@ void MARS::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * MARS Key Schedule */ -void MARS::key_schedule(const byte key[], u32bit length) +void MARS::key_schedule(const byte key[], size_t length) { SecureVector<u32bit> T(15); - for(size_t j = 0; j != length / 4; ++j) - T[j] = load_le<u32bit>(key, j); + for(size_t i = 0; i != length / 4; ++i) + T[i] = load_le<u32bit>(key, i); T[length / 4] = length / 4; diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h index 0b98d3c25..a61f475f2 100644 --- a/src/block/mars/mars.h +++ b/src/block/mars/mars.h @@ -27,7 +27,7 @@ class BOTAN_DLL MARS : public BlockCipher MARS() : BlockCipher(16, 16, 32, 4), EK(40) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> EK; }; diff --git a/src/block/misty1/misty1.cpp b/src/block/misty1/misty1.cpp index 891abf49f..2f82e18e8 100644 --- a/src/block/misty1/misty1.cpp +++ b/src/block/misty1/misty1.cpp @@ -202,7 +202,7 @@ void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * MISTY1 Key Schedule */ -void MISTY1::key_schedule(const byte key[], u32bit length) +void MISTY1::key_schedule(const byte key[], size_t length) { SecureVector<u16bit> KS(32); for(size_t i = 0; i != length / 2; ++i) diff --git a/src/block/misty1/misty1.h b/src/block/misty1/misty1.h index bb948cb07..318e63b7d 100644 --- a/src/block/misty1/misty1.h +++ b/src/block/misty1/misty1.h @@ -31,7 +31,7 @@ class BOTAN_DLL MISTY1 : public BlockCipher */ MISTY1(size_t rounds = 8); private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u16bit> EK, DK; }; diff --git a/src/block/noekeon/noekeon.cpp b/src/block/noekeon/noekeon.cpp index f9a54482b..06c415be9 100644 --- a/src/block/noekeon/noekeon.cpp +++ b/src/block/noekeon/noekeon.cpp @@ -160,16 +160,16 @@ void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Noekeon Key Schedule */ -void Noekeon::key_schedule(const byte key[], u32bit) +void Noekeon::key_schedule(const byte key[], size_t) { u32bit A0 = load_be<u32bit>(key, 0); u32bit A1 = load_be<u32bit>(key, 1); u32bit A2 = load_be<u32bit>(key, 2); u32bit A3 = load_be<u32bit>(key, 3); - for(size_t j = 0; j != 16; ++j) + for(size_t i = 0; i != 16; ++i) { - A0 ^= RC[j]; + A0 ^= RC[i]; theta(A0, A1, A2, A3); A1 = rotate_left(A1, 1); diff --git a/src/block/noekeon/noekeon.h b/src/block/noekeon/noekeon.h index 65d3474c7..593afa634 100644 --- a/src/block/noekeon/noekeon.h +++ b/src/block/noekeon/noekeon.h @@ -43,7 +43,7 @@ class BOTAN_DLL Noekeon : public BlockCipher const SecureVector<u32bit>& get_DK() const { return DK; } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> EK, DK; }; diff --git a/src/block/rc2/rc2.cpp b/src/block/rc2/rc2.cpp index 6cfe8c202..97ca5d577 100644 --- a/src/block/rc2/rc2.cpp +++ b/src/block/rc2/rc2.cpp @@ -98,7 +98,7 @@ void RC2::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * RC2 Key Schedule */ -void RC2::key_schedule(const byte key[], u32bit length) +void RC2::key_schedule(const byte key[], size_t length) { static const byte TABLE[256] = { 0xD9, 0x78, 0xF9, 0xC4, 0x19, 0xDD, 0xB5, 0xED, 0x28, 0xE9, 0xFD, 0x79, diff --git a/src/block/rc2/rc2.h b/src/block/rc2/rc2.h index b8c1e069a..4addf22ed 100644 --- a/src/block/rc2/rc2.h +++ b/src/block/rc2/rc2.h @@ -34,7 +34,7 @@ class BOTAN_DLL RC2 : public BlockCipher RC2() : BlockCipher(8, 1, 32), K(64) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u16bit> K; }; diff --git a/src/block/rc5/rc5.cpp b/src/block/rc5/rc5.cpp index 3b288d328..519735967 100644 --- a/src/block/rc5/rc5.cpp +++ b/src/block/rc5/rc5.cpp @@ -76,7 +76,7 @@ void RC5::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * RC5 Key Schedule */ -void RC5::key_schedule(const byte key[], u32bit length) +void RC5::key_schedule(const byte key[], size_t length) { const size_t WORD_KEYLENGTH = (((length - 1) / 4) + 1); const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, S.size()); diff --git a/src/block/rc5/rc5.h b/src/block/rc5/rc5.h index f15230a00..11a62badb 100644 --- a/src/block/rc5/rc5.h +++ b/src/block/rc5/rc5.h @@ -31,7 +31,7 @@ class BOTAN_DLL RC5 : public BlockCipher */ RC5(size_t rounds); private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> S; const size_t ROUNDS; }; diff --git a/src/block/rc6/rc6.cpp b/src/block/rc6/rc6.cpp index f81f25efd..53ca5a7a2 100644 --- a/src/block/rc6/rc6.cpp +++ b/src/block/rc6/rc6.cpp @@ -111,27 +111,27 @@ void RC6::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * RC6 Key Schedule */ -void RC6::key_schedule(const byte key[], u32bit length) +void RC6::key_schedule(const byte key[], size_t length) { 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(size_t 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]; u32bit A = 0, B = 0; - for(u32bit j = 0; j != MIX_ROUNDS; ++j) + 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; } } diff --git a/src/block/rc6/rc6.h b/src/block/rc6/rc6.h index ada7e9610..307834a8c 100644 --- a/src/block/rc6/rc6.h +++ b/src/block/rc6/rc6.h @@ -27,7 +27,7 @@ class BOTAN_DLL RC6 : public BlockCipher RC6() : BlockCipher(16, 1, 32), S(44) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> S; }; diff --git a/src/block/safer/safer_sk.cpp b/src/block/safer/safer_sk.cpp index d64c37f00..f78e326e4 100644 --- a/src/block/safer/safer_sk.cpp +++ b/src/block/safer/safer_sk.cpp @@ -89,7 +89,7 @@ void SAFER_SK::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * SAFER-SK Key Schedule */ -void SAFER_SK::key_schedule(const byte key[], u32bit) +void SAFER_SK::key_schedule(const byte key[], size_t) { SecureVector<byte> KB(18); diff --git a/src/block/safer/safer_sk.h b/src/block/safer/safer_sk.h index b68cb5363..a64d09fb7 100644 --- a/src/block/safer/safer_sk.h +++ b/src/block/safer/safer_sk.h @@ -31,7 +31,7 @@ class BOTAN_DLL SAFER_SK : public BlockCipher */ SAFER_SK(size_t rounds); private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); static const byte EXP[256]; static const byte LOG[512]; diff --git a/src/block/seed/seed.cpp b/src/block/seed/seed.cpp index a253f27b8..408220013 100644 --- a/src/block/seed/seed.cpp +++ b/src/block/seed/seed.cpp @@ -102,7 +102,7 @@ void SEED::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * SEED Key Schedule */ -void SEED::key_schedule(const byte key[], u32bit) +void SEED::key_schedule(const byte key[], size_t) { const u32bit RC[16] = { 0x9E3779B9, 0x3C6EF373, 0x78DDE6E6, 0xF1BBCDCC, diff --git a/src/block/seed/seed.h b/src/block/seed/seed.h index e2b0862ae..48fefc9b0 100644 --- a/src/block/seed/seed.h +++ b/src/block/seed/seed.h @@ -27,7 +27,7 @@ class BOTAN_DLL SEED : public BlockCipher SEED() : BlockCipher(16, 16), K(32) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); class G_FUNC { diff --git a/src/block/serpent/serpent.cpp b/src/block/serpent/serpent.cpp index 8ff35b900..1d940cf39 100644 --- a/src/block/serpent/serpent.cpp +++ b/src/block/serpent/serpent.cpp @@ -351,7 +351,7 @@ void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Serpent Key Schedule */ -void Serpent::key_schedule(const byte key[], u32bit length) +void Serpent::key_schedule(const byte key[], size_t length) { const u32bit PHI = 0x9E3779B9; diff --git a/src/block/serpent/serpent.h b/src/block/serpent/serpent.h index a436c578a..515a90407 100644 --- a/src/block/serpent/serpent.h +++ b/src/block/serpent/serpent.h @@ -41,7 +41,7 @@ class BOTAN_DLL Serpent : public BlockCipher { round_key.set(ks, 132); } private: - void key_schedule(const byte key[], u32bit length); + void key_schedule(const byte key[], size_t length); SecureVector<u32bit> round_key; }; diff --git a/src/block/serpent_ia32/serp_ia32.cpp b/src/block/serpent_ia32/serp_ia32.cpp index 6e409b580..d2f8adb62 100644 --- a/src/block/serpent_ia32/serp_ia32.cpp +++ b/src/block/serpent_ia32/serp_ia32.cpp @@ -70,7 +70,7 @@ void Serpent_IA32::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Serpent Key Schedule */ -void Serpent_IA32::key_schedule(const byte key[], u32bit length) +void Serpent_IA32::key_schedule(const byte key[], size_t length) { SecureVector<u32bit> W(140); for(size_t i = 0; i != length / 4; ++i) diff --git a/src/block/serpent_ia32/serp_ia32.h b/src/block/serpent_ia32/serp_ia32.h index cd103c130..d7b5bedc7 100644 --- a/src/block/serpent_ia32/serp_ia32.h +++ b/src/block/serpent_ia32/serp_ia32.h @@ -23,7 +23,7 @@ class BOTAN_DLL Serpent_IA32 : public Serpent BlockCipher* clone() const { return new Serpent_IA32; } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); }; } diff --git a/src/block/skipjack/skipjack.cpp b/src/block/skipjack/skipjack.cpp index e3c8598ff..b73972b59 100644 --- a/src/block/skipjack/skipjack.cpp +++ b/src/block/skipjack/skipjack.cpp @@ -157,7 +157,7 @@ void Skipjack::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Skipjack Key Schedule */ -void Skipjack::key_schedule(const byte key[], u32bit) +void Skipjack::key_schedule(const byte key[], size_t) { static const byte F[256] = { 0xA3, 0xD7, 0x09, 0x83, 0xF8, 0x48, 0xF6, 0xF4, 0xB3, 0x21, 0x15, 0x78, diff --git a/src/block/skipjack/skipjack.h b/src/block/skipjack/skipjack.h index 98cea7650..dff85df6c 100644 --- a/src/block/skipjack/skipjack.h +++ b/src/block/skipjack/skipjack.h @@ -27,7 +27,7 @@ class BOTAN_DLL Skipjack : public BlockCipher Skipjack() : BlockCipher(8, 10), FTAB(2560) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<byte> FTAB; }; diff --git a/src/block/square/square.cpp b/src/block/square/square.cpp index 601d66c15..b1517b990 100644 --- a/src/block/square/square.cpp +++ b/src/block/square/square.cpp @@ -138,7 +138,7 @@ void Square::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Square Key Schedule */ -void Square::key_schedule(const byte key[], u32bit) +void Square::key_schedule(const byte key[], size_t) { SecureVector<u32bit> XEK(36), XDK(36); diff --git a/src/block/square/square.h b/src/block/square/square.h index e3b07f24d..0a134bcb5 100644 --- a/src/block/square/square.h +++ b/src/block/square/square.h @@ -27,7 +27,7 @@ class BOTAN_DLL Square : public BlockCipher Square() : BlockCipher(16, 16), EK(28), DK(28), ME(32), MD(32) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); static void transform(u32bit[4]); diff --git a/src/block/tea/tea.cpp b/src/block/tea/tea.cpp index 434c74ba6..4ef995a7c 100644 --- a/src/block/tea/tea.cpp +++ b/src/block/tea/tea.cpp @@ -63,7 +63,7 @@ void TEA::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * TEA Key Schedule */ -void TEA::key_schedule(const byte key[], u32bit) +void TEA::key_schedule(const byte key[], size_t) { 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 7cb18a4f8..eeab13cbc 100644 --- a/src/block/tea/tea.h +++ b/src/block/tea/tea.h @@ -27,7 +27,7 @@ class BOTAN_DLL TEA : public BlockCipher TEA() : BlockCipher(8, 16), K(4) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> K; }; diff --git a/src/block/twofish/twofish.cpp b/src/block/twofish/twofish.cpp index 9c3d57500..41bc7ca1c 100644 --- a/src/block/twofish/twofish.cpp +++ b/src/block/twofish/twofish.cpp @@ -116,7 +116,7 @@ void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * Twofish Key Schedule */ -void Twofish::key_schedule(const byte key[], u32bit length) +void Twofish::key_schedule(const byte key[], size_t length) { SecureVector<byte> S(16); diff --git a/src/block/twofish/twofish.h b/src/block/twofish/twofish.h index b94c3adc3..38263af98 100644 --- a/src/block/twofish/twofish.h +++ b/src/block/twofish/twofish.h @@ -27,7 +27,7 @@ class BOTAN_DLL Twofish : public BlockCipher Twofish() : BlockCipher(16, 16, 32, 8), SB(1024), RK(40) {} private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); static void rs_mul(byte[4], byte, size_t); diff --git a/src/block/xtea/xtea.cpp b/src/block/xtea/xtea.cpp index 7acad2b6b..597eedd07 100644 --- a/src/block/xtea/xtea.cpp +++ b/src/block/xtea/xtea.cpp @@ -121,7 +121,7 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const /* * XTEA Key Schedule */ -void XTEA::key_schedule(const byte key[], u32bit) +void XTEA::key_schedule(const byte key[], size_t) { SecureVector<u32bit> UK(4); for(size_t i = 0; i != 4; ++i) diff --git a/src/block/xtea/xtea.h b/src/block/xtea/xtea.h index 6a843e21f..c870f588a 100644 --- a/src/block/xtea/xtea.h +++ b/src/block/xtea/xtea.h @@ -33,7 +33,7 @@ class BOTAN_DLL XTEA : public BlockCipher const SecureVector<u32bit>& get_EK() const { return EK; } private: - void key_schedule(const byte[], u32bit); + void key_schedule(const byte[], size_t); SecureVector<u32bit> EK; }; |