Photo by Markus Winkler on Unsplash

In AES, For The Same Plaintext, Will We Always Get Same Ciphertext (for the same IV and Key)?

--

You will perhaps know that in ECB (Electronic Code Book) mode in AES, you will always get the same ciphertext for the same key. As this is a block cipher, the padding will change the end characters, but as long as we have 16 bytes then the first block will be the same. But what about the modes that use an IV? Well, let’s look at a stream cipher mode: GCM, and see what happens when we use the same key and the same IV.

So we will create the following Golang code [here]:

In this case, we just convert a password into an encryption key, and then just set an IV to all zeros, along with the same salt used with the key generation. If we try “Testing 123” and a password of “qwerty123”, we get [here]:

Message:	Testing 123
Cipher: 80f8087e75d6875d56198a082820fb3dc6c0ba7e4bac4f697094e2
Key: 2f7ffec39904ee5b61a73d881f6d2f36c27d2a60a42d828b52b6409dc13d1318
Nonce: 000000000000000000000000
Decrypted: Testing 123

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.