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/cast | |
parent | e7e3af16a3540e1d7a84e085aa1ea7c55f627930 (diff) |
Use size_t rather than u32bit for the blocks argument of encrypt_n
Diffstat (limited to 'src/block/cast')
-rw-r--r-- | src/block/cast/cast128.cpp | 14 | ||||
-rw-r--r-- | src/block/cast/cast128.h | 4 | ||||
-rw-r--r-- | src/block/cast/cast256.cpp | 12 | ||||
-rw-r--r-- | src/block/cast/cast256.h | 4 |
4 files changed, 17 insertions, 17 deletions
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"; } |