I'm playing around with openssl command line to verify my understanding on block cipher mode.
I read that ECB block cipher mode always encrypt the same text to the same output. AES operates on 16 bytes block, independently on the key length while DES operates on 8 byte blocks.
So I tried the following examples expecting the same block in the output to be repeated twice, but that's not the case.
➜ echo -n "1234567890abcdef1234567890abcdef" | openssl enc -e -aes-256-ecb | hexdump enter aes-256-ecb encryption password: Verifying - enter aes-256-ecb encryption password: 0000000 53 61 6c 74 65 64 5f 5f 03 9a 3d 27 b9 9b f2 c6 0000010 c5 e3 3d 77 ca 4f df aa 90 aa d1 b8 22 04 43 c3 * 0000030 75 c8 72 0c 54 33 30 73 0a f1 8d 5a 17 f2 64 de 0000040 ➜ echo -n "12345678123456781234567812345678" | openssl enc -e -des-ecb | hexdump enter des-ecb encryption password: Verifying - enter des-ecb encryption password: 0000000 53 61 6c 74 65 64 5f 5f 64 00 a6 ee 5c f5 a0 b8 0000010 c3 3c 57 65 4a 0c 37 81 c3 3c 57 65 4a 0c 37 81 * 0000030 9e 37 2c cf f9 27 74 fb 0000038
In the first example, the input is 32 bytes, and the first 16 bytes are the same as the last 16 bytes, which is the block size of AES. Given that I'm using ECB, I'd expect the same ciphertext in the output twice.
In the second example, the input also 32 bytes, and it's composed of the same 8 bytes (1-8), which is the block size of DES. Same assumption here
Not only I don't see a repetition, but I noticed that the first 8 bytes are the same between AES and DES.
Also, why does openssl asks for a password? It that used to generate the key?
Thanks a lot.
EDIT: clarified the example