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