diff options
Diffstat (limited to 'src/block/tea/tea.cpp')
-rw-r--r-- | src/block/tea/tea.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
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); } } |