Join GitHub today
Is this really AES-CBC? #2
I tried using your gem to decrypt data, which was encrypted by another application using 128 bit AES-CBC. However, only the first 16 bytes were decrypted correctly. Since this is exactly one block, and because of the fact that I can't specify an IV, I was wondering if maybe fast-aes implements ECB, rather than CBC.
As I understand it, the advantage of CBC is that two blocks with the same plaintext should not result in identical ciphertext. This is an easy way to verify the my assumption, by creating a file with e.g. 2x 128 bytes identical random data (i.e. 8 16 byte blocks with random data, and the same 8 blocks again) and encrypting it:
dd if=/dev/urandom bs=1 count=128 of=random-test-data
data = f.read()
aes = FastAES.new('0123456789abcdef')
encrypted_data = aes.encrypt(data)
As the blocks 0-7 are identical to blocks 8-15, I assume that fast-aes indeed implements aes-ecb, rather than cbc.