diff options
author | lloyd <[email protected]> | 2010-10-12 19:41:37 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-12 19:41:37 +0000 |
commit | ff2210b035a1598bf99e18a578ff075bece8fbe5 (patch) | |
tree | 4efe3a23daac9e2cd8b9f2b794d95089ba4cdfb2 /src/block/rc6 | |
parent | e7e3af16a3540e1d7a84e085aa1ea7c55f627930 (diff) |
Use size_t rather than u32bit for the blocks argument of encrypt_n
Diffstat (limited to 'src/block/rc6')
-rw-r--r-- | src/block/rc6/rc6.cpp | 22 | ||||
-rw-r--r-- | src/block/rc6/rc6.h | 4 |
2 files changed, 14 insertions, 12 deletions
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"; } |