Many advice against using AES in ECB mode as it always produces same cipher text for a given plain text.

That shortcoming can be addressed by using salt appended to original message so that the resulting cipher text is different each time , the receiver can then decyrpt the cipher text and discard the salt keeping the original message

However this is susceptible to replay attacks, but that can be mitigated further by using a frame counter in the plain text message so that the receiver knows if the message is being replayed by a unauthorized sender.

So the result would be

Encrypt[Counter + Message + Salt] ===> CipherText ==> Decrypt[CipherText] ===> Counter + Message + Salt.

That strategy seems sound to me , are there any known flaws that advise against using it ?

  • $\begingroup$ How many blocks do you plan to encrypt with this scheme? Is it one block per salt? $\endgroup$
    – kelalaka
    Jun 23, 2020 at 10:53
  • $\begingroup$ If your data EVER causes you to send two or more blocks, then @Thomas's answer absolutely holds and your scheme doesn't help -- you're better off using something other than ECB. If your data plus the counter and salt ALWAYS fit in a single block so that the block is the ENTIRETY of what you're sending, then all modes essentially devolve to ECB... and your idea would improve your security. $\endgroup$
    – Forbin
    Nov 19, 2021 at 23:47

1 Answer 1


The point of producing different ciphertexts for the same plaintext is so that an attacker, given two identical ciphertexts, could not conclude that the plaintexts must be the same. This is indeed a weakness, but is not the main problem of ECB, which is that each block is encrypted completely independently, leaking huge amounts of information about the plaintext to even a passive observer.

Your strategy does not help with that, as the attacker could simply ignore all the ECB blocks belonging to the counter and salt and simply pick out blocks belonging to the messages, and we're back to standard ECB.

  • $\begingroup$ If the counter, salt and message are all one single block of message fed to ECB how'd he separate the message part of it? The salt is not enough to give different cipher text for same message? $\endgroup$
    – Allahjane
    Dec 3, 2021 at 11:24

Your Answer

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

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