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/safer | |
parent | e7e3af16a3540e1d7a84e085aa1ea7c55f627930 (diff) |
Use size_t rather than u32bit for the blocks argument of encrypt_n
Diffstat (limited to 'src/block/safer')
-rw-r--r-- | src/block/safer/safer_sk.cpp | 29 | ||||
-rw-r--r-- | src/block/safer/safer_sk.h | 8 |
2 files changed, 19 insertions, 18 deletions
diff --git a/src/block/safer/safer_sk.cpp b/src/block/safer/safer_sk.cpp index aebb770d7..d64c37f00 100644 --- a/src/block/safer/safer_sk.cpp +++ b/src/block/safer/safer_sk.cpp @@ -15,14 +15,14 @@ namespace Botan { /* * SAFER-SK Encryption */ -void SAFER_SK::encrypt_n(const byte in[], byte out[], u32bit blocks) const +void SAFER_SK::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) { byte A = in[0], B = in[1], C = in[2], D = in[3], E = in[4], F = in[5], G = in[6], H = in[7], X, Y; - for(u32bit j = 0; j != 16*ROUNDS; j += 16) + for(size_t j = 0; j != 16*ROUNDS; j += 16) { A = EXP[A ^ EK[j ]]; B = LOG[B + EK[j+1]]; C = LOG[C + EK[j+2]]; D = EXP[D ^ EK[j+3]]; @@ -51,9 +51,9 @@ void SAFER_SK::encrypt_n(const byte in[], byte out[], u32bit blocks) const /* * SAFER-SK Decryption */ -void SAFER_SK::decrypt_n(const byte in[], byte out[], u32bit blocks) const +void SAFER_SK::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) { byte A = in[0], B = in[1], C = in[2], D = in[3], E = in[4], F = in[5], G = in[6], H = in[7]; @@ -93,17 +93,18 @@ void SAFER_SK::key_schedule(const byte key[], u32bit) { SecureVector<byte> KB(18); - for(u32bit j = 0; j != 8; ++j) + for(size_t i = 0; i != 8; ++i) { - KB[ 8] ^= KB[j] = rotate_left(key[j], 5); - KB[17] ^= KB[j+9] = EK[j] = key[j+8]; + KB[ 8] ^= KB[i] = rotate_left(key[i], 5); + KB[17] ^= KB[i+9] = EK[i] = key[i+8]; } - for(u32bit j = 0; j != ROUNDS; ++j) + + for(size_t i = 0; i != ROUNDS; ++i) { - for(u32bit k = 0; k != 18; ++k) - KB[k] = rotate_left(KB[k], 6); - for(u32bit k = 0; k != 16; ++k) - EK[16*j+k+8] = KB[KEY_INDEX[16*j+k]] + BIAS[16*j+k]; + for(size_t j = 0; j != 18; ++j) + KB[j] = rotate_left(KB[j], 6); + for(size_t j = 0; j != 16; ++j) + EK[16*i+j+8] = KB[KEY_INDEX[16*i+j]] + BIAS[16*i+j]; } } @@ -126,7 +127,7 @@ BlockCipher* SAFER_SK::clone() const /* * SAFER-SK Constructor */ -SAFER_SK::SAFER_SK(u32bit rounds) : BlockCipher(8, 16), +SAFER_SK::SAFER_SK(size_t rounds) : BlockCipher(8, 16), EK(16 * rounds + 8), ROUNDS(rounds) { if(ROUNDS > 13 || ROUNDS == 0) diff --git a/src/block/safer/safer_sk.h b/src/block/safer/safer_sk.h index 26875c97b..b68cb5363 100644 --- a/src/block/safer/safer_sk.h +++ b/src/block/safer/safer_sk.h @@ -18,8 +18,8 @@ namespace Botan { class BOTAN_DLL SAFER_SK : 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); } std::string name() const; @@ -29,7 +29,7 @@ class BOTAN_DLL SAFER_SK : public BlockCipher * @param rounds the number of rounds to use - must be between 1 * and 13 */ - SAFER_SK(u32bit rounds); + SAFER_SK(size_t rounds); private: void key_schedule(const byte[], u32bit); @@ -39,7 +39,7 @@ class BOTAN_DLL SAFER_SK : public BlockCipher static const byte KEY_INDEX[208]; SecureVector<byte> EK; - const u32bit ROUNDS; + const size_t ROUNDS; }; } |