diff options
Diffstat (limited to 'src/block/des/des.cpp')
-rw-r--r-- | src/block/des/des.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/block/des/des.cpp b/src/block/des/des.cpp index bbe564827..7c61df3db 100644 --- a/src/block/des/des.cpp +++ b/src/block/des/des.cpp @@ -140,9 +140,9 @@ void des_decrypt(u32bit& L, u32bit& R, /* * DES Encryption */ -void DES::encrypt_n(const byte in[], byte out[], u32bit blocks) const +void DES::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) { u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | @@ -152,7 +152,7 @@ void DES::encrypt_n(const byte in[], byte out[], u32bit blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_encrypt(L, R, round_key); + des_encrypt(L, R, &round_key[0]); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -162,17 +162,17 @@ void DES::encrypt_n(const byte in[], byte out[], u32bit blocks) const store_be(T, out); - in += BLOCK_SIZE; - out += BLOCK_SIZE; + in += block_size(); + out += block_size(); } } /* * DES Decryption */ -void DES::decrypt_n(const byte in[], byte out[], u32bit blocks) const +void DES::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) { u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | @@ -182,7 +182,7 @@ void DES::decrypt_n(const byte in[], byte out[], u32bit blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_decrypt(L, R, round_key); + des_decrypt(L, R, &round_key[0]); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -193,25 +193,25 @@ void DES::decrypt_n(const byte in[], byte out[], u32bit blocks) const store_be(T, out); - in += BLOCK_SIZE; - out += BLOCK_SIZE; + in += block_size(); + out += block_size(); } } /* * DES Key Schedule */ -void DES::key_schedule(const byte key[], u32bit) +void DES::key_schedule(const byte key[], size_t) { - des_key_schedule(round_key.begin(), key); + des_key_schedule(&round_key[0], key); } /* * TripleDES Encryption */ -void TripleDES::encrypt_n(const byte in[], byte out[], u32bit blocks) const +void TripleDES::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) { u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | @@ -221,9 +221,9 @@ void TripleDES::encrypt_n(const byte in[], byte out[], u32bit blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_encrypt(L, R, round_key); - des_decrypt(R, L, round_key + 32); - des_encrypt(L, R, round_key + 64); + des_encrypt(L, R, &round_key[0]); + des_decrypt(R, L, &round_key[32]); + des_encrypt(L, R, &round_key[64]); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -234,17 +234,17 @@ void TripleDES::encrypt_n(const byte in[], byte out[], u32bit blocks) const store_be(T, out); - in += BLOCK_SIZE; - out += BLOCK_SIZE; + in += block_size(); + out += block_size(); } } /* * TripleDES Decryption */ -void TripleDES::decrypt_n(const byte in[], byte out[], u32bit blocks) const +void TripleDES::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) { u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | @@ -254,9 +254,9 @@ void TripleDES::decrypt_n(const byte in[], byte out[], u32bit blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_decrypt(L, R, round_key + 64); - des_encrypt(R, L, round_key + 32); - des_decrypt(L, R, round_key); + des_decrypt(L, R, &round_key[64]); + des_encrypt(R, L, &round_key[32]); + des_decrypt(L, R, &round_key[0]); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -267,15 +267,15 @@ void TripleDES::decrypt_n(const byte in[], byte out[], u32bit blocks) const store_be(T, out); - in += BLOCK_SIZE; - out += BLOCK_SIZE; + in += block_size(); + out += block_size(); } } /* * TripleDES Key Schedule */ -void TripleDES::key_schedule(const byte key[], u32bit length) +void TripleDES::key_schedule(const byte key[], size_t length) { des_key_schedule(&round_key[0], key); des_key_schedule(&round_key[32], key + 8); @@ -283,7 +283,7 @@ void TripleDES::key_schedule(const byte key[], u32bit length) if(length == 24) des_key_schedule(&round_key[64], key + 16); else - copy_mem(&round_key[64], round_key.begin(), 32); + copy_mem(&round_key[64], &round_key[0], 32); } } |