0
$\begingroup$

I was recently trying to perform a AES-128 CTR Encryption and Decryption.

I had a observation that if a AES-CTR encrypted value is encrypted again (with same key and Iv) it results in the plain text that was in encrypted in first place.

Just want to the reason behind this and does any other AES scheme support this similar behaviour ?

Thanks!

$\endgroup$
1
  • 1
    $\begingroup$ "does any other AES scheme support this similar behaviour" - OFB mode (which also uses in the 'generate a keystream from the key/IV and xor it into the plaintext to form the ciphertext" paradigm) $\endgroup$
    – poncho
    Apr 11, 2023 at 19:13

1 Answer 1

1
$\begingroup$

It is correct, and reason is simple - CTR mode basically acts as stream cipher, meaning it creates keystream just from key and IV and then this keystream is bitewise XORed with plaintext.

When you do that same operation again, the first and second XOR counteracts each other and all that remains is plaintext.

first encryption:

ciphertext = plaintext XOR keystream

secound encryption (same key and IV):

ciphertext2 = ciphertext XOR keystream

ciphertext2 = (plaintext XOR keystream) XOR keystream

ciphertext2 = plaintext

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.