diff options
author | lloyd <[email protected]> | 2010-10-13 15:58:22 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-13 15:58:22 +0000 |
commit | 12617c8a0942a5af35ffe72891f3cd63c8b7fe18 (patch) | |
tree | 9d11b199a58521544d17a3af1c13b994366f27ab /src/block | |
parent | 79d7cf0a42368db93f1641cc4daea37cd6d02f86 (diff) |
More size_t
Diffstat (limited to 'src/block')
-rw-r--r-- | src/block/des/des.cpp | 30 | ||||
-rw-r--r-- | src/block/idea/idea.cpp | 2 | ||||
-rw-r--r-- | src/block/xtea_simd/xtea_simd.cpp | 4 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/block/des/des.cpp b/src/block/des/des.cpp index 15c771bda..739dfe87c 100644 --- a/src/block/des/des.cpp +++ b/src/block/des/des.cpp @@ -50,11 +50,11 @@ void des_key_schedule(u32bit round_key[32], const byte key[8]) ((key[3] & 0x10) >> 1) | ((key[2] & 0x10) >> 2) | ((key[1] & 0x10) >> 3) | ((key[0] & 0x10) >> 4); - for(u32bit j = 0; j != 16; ++j) + for(size_t i = 0; i != 16; ++i) { - C = ((C << ROT[j]) | (C >> (28-ROT[j]))) & 0x0FFFFFFF; - D = ((D << ROT[j]) | (D >> (28-ROT[j]))) & 0x0FFFFFFF; - round_key[2*j ] = ((C & 0x00000010) << 22) | ((C & 0x00000800) << 17) | + C = ((C << ROT[i]) | (C >> (28-ROT[i]))) & 0x0FFFFFFF; + D = ((D << ROT[i]) | (D >> (28-ROT[i]))) & 0x0FFFFFFF; + round_key[2*i ] = ((C & 0x00000010) << 22) | ((C & 0x00000800) << 17) | ((C & 0x00000020) << 16) | ((C & 0x00004004) << 15) | ((C & 0x00000200) << 11) | ((C & 0x00020000) << 10) | ((C & 0x01000000) >> 6) | ((C & 0x00100000) >> 4) | @@ -65,7 +65,7 @@ void des_key_schedule(u32bit round_key[32], const byte key[8]) ((D & 0x00000088) >> 3) | ((D & 0x00001000) >> 7) | ((D & 0x00080000) >> 9) | ((D & 0x02020000) >> 14) | ((D & 0x00400000) >> 21); - round_key[2*j+1] = ((C & 0x00000001) << 28) | ((C & 0x00000082) << 18) | + round_key[2*i+1] = ((C & 0x00000001) << 28) | ((C & 0x00000082) << 18) | ((C & 0x00002000) << 14) | ((C & 0x00000100) << 10) | ((C & 0x00001000) << 9) | ((C & 0x00040000) << 6) | ((C & 0x02400000) << 4) | ((C & 0x00008000) << 2) | @@ -85,20 +85,20 @@ void des_key_schedule(u32bit round_key[32], const byte key[8]) void des_encrypt(u32bit& L, u32bit& R, const u32bit round_key[32]) { - for(u32bit j = 0; j != 16; j += 2) + for(size_t i = 0; i != 16; i += 2) { u32bit T0, T1; - T0 = rotate_right(R, 4) ^ round_key[2*j]; - T1 = R ^ round_key[2*j + 1]; + T0 = rotate_right(R, 4) ^ round_key[2*i]; + T1 = R ^ round_key[2*i + 1]; L ^= DES_SPBOX1[get_byte(0, T0)] ^ DES_SPBOX2[get_byte(0, T1)] ^ DES_SPBOX3[get_byte(1, T0)] ^ DES_SPBOX4[get_byte(1, T1)] ^ DES_SPBOX5[get_byte(2, T0)] ^ DES_SPBOX6[get_byte(2, T1)] ^ DES_SPBOX7[get_byte(3, T0)] ^ DES_SPBOX8[get_byte(3, T1)]; - T0 = rotate_right(L, 4) ^ round_key[2*j + 2]; - T1 = L ^ round_key[2*j + 3]; + T0 = rotate_right(L, 4) ^ round_key[2*i + 2]; + T1 = L ^ round_key[2*i + 3]; R ^= DES_SPBOX1[get_byte(0, T0)] ^ DES_SPBOX2[get_byte(0, T1)] ^ DES_SPBOX3[get_byte(1, T0)] ^ DES_SPBOX4[get_byte(1, T1)] ^ @@ -113,20 +113,20 @@ void des_encrypt(u32bit& L, u32bit& R, void des_decrypt(u32bit& L, u32bit& R, const u32bit round_key[32]) { - for(u32bit j = 16; j != 0; j -= 2) + for(size_t i = 16; i != 0; i -= 2) { u32bit T0, T1; - T0 = rotate_right(R, 4) ^ round_key[2*j - 2]; - T1 = R ^ round_key[2*j - 1]; + T0 = rotate_right(R, 4) ^ round_key[2*i - 2]; + T1 = R ^ round_key[2*i - 1]; L ^= DES_SPBOX1[get_byte(0, T0)] ^ DES_SPBOX2[get_byte(0, T1)] ^ DES_SPBOX3[get_byte(1, T0)] ^ DES_SPBOX4[get_byte(1, T1)] ^ DES_SPBOX5[get_byte(2, T0)] ^ DES_SPBOX6[get_byte(2, T1)] ^ DES_SPBOX7[get_byte(3, T0)] ^ DES_SPBOX8[get_byte(3, T1)]; - T0 = rotate_right(L, 4) ^ round_key[2*j - 4]; - T1 = L ^ round_key[2*j - 3]; + T0 = rotate_right(L, 4) ^ round_key[2*i - 4]; + T1 = L ^ round_key[2*i - 3]; R ^= DES_SPBOX1[get_byte(0, T0)] ^ DES_SPBOX2[get_byte(0, T1)] ^ DES_SPBOX3[get_byte(1, T0)] ^ DES_SPBOX4[get_byte(1, T1)] ^ diff --git a/src/block/idea/idea.cpp b/src/block/idea/idea.cpp index be7680b2c..f9b6cc874 100644 --- a/src/block/idea/idea.cpp +++ b/src/block/idea/idea.cpp @@ -60,7 +60,7 @@ u16bit mul_inv(u16bit x) */ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52]) { - const u32bit BLOCK_SIZE = 8; + const size_t BLOCK_SIZE = 8; for(size_t i = 0; i != blocks; ++i) { diff --git a/src/block/xtea_simd/xtea_simd.cpp b/src/block/xtea_simd/xtea_simd.cpp index 831cc0359..d684eca5a 100644 --- a/src/block/xtea_simd/xtea_simd.cpp +++ b/src/block/xtea_simd/xtea_simd.cpp @@ -22,7 +22,7 @@ void xtea_encrypt_8(const byte in[64], byte out[64], const u32bit EK[64]) SIMD_32::transpose(L0, R0, L1, R1); - for(u32bit i = 0; i != 32; i += 2) + for(size_t i = 0; i != 32; i += 2) { SIMD_32 K0(EK[2*i ]); SIMD_32 K1(EK[2*i+1]); @@ -59,7 +59,7 @@ void xtea_decrypt_8(const byte in[64], byte out[64], const u32bit EK[64]) SIMD_32::transpose(L0, R0, L1, R1); - for(u32bit i = 0; i != 32; i += 2) + for(size_t i = 0; i != 32; i += 2) { SIMD_32 K0(EK[63 - 2*i]); SIMD_32 K1(EK[62 - 2*i]); |