diff options
author | Jesse Luehrs <doy@tozt.net> | 2015-03-26 23:24:14 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2015-03-26 23:24:14 -0400 |
commit | b466bae50a91da358f9e4264d312fb836c7cd829 (patch) | |
tree | f6861d286563d66a4b050580136cc86aae525ce2 /src | |
parent | fcdc3f0127fe841ecdf808d1941018f4fe7a2b85 (diff) | |
download | matasano-b466bae50a91da358f9e4264d312fb836c7cd829.tar.gz matasano-b466bae50a91da358f9e4264d312fb836c7cd829.zip |
no reason to repeatedly pad here
Diffstat (limited to 'src')
-rw-r--r-- | src/aes.rs | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -49,8 +49,8 @@ pub fn encrypt_aes_128_ecb (bytes: &[u8], key: &[u8]) -> Vec<u8> { pub fn encrypt_aes_128_cbc (bytes: &[u8], key: &[u8], iv: &[u8]) -> Vec<u8> { let mut prev = iv.to_vec(); let mut ciphertext = vec![]; - for block in bytes.chunks(16) { - let plaintext_block = fixed_xor(&pad_pkcs7(block, 16)[..], &prev[..]); + for block in pad_pkcs7(bytes, 16).chunks(16) { + let plaintext_block = fixed_xor(&block[..], &prev[..]); let mut ciphertext_block = encrypt_aes_128_ecb(&plaintext_block[..], key); ciphertext_block.truncate(16); for &c in ciphertext_block.iter() { |