Search code examples
encryptionaes

When using AES, is there a way to tell if data was encrypted using 128 or 256 bit keys?


I was wondering if there is some way to tell if data was encrypted with a specific key size, without the source code of course. Is there any detectable differences with the data that you can check post encryption?


Solution

  • No there is not any way to do that. Both encrypt 16-byte chunks of data and the resulting blocks would "look" the same after the encryption is complete (they would have different values, but an analysis on only the encrypted data would not be able to determine the original key size). If the original data (plain text) is available, it may be possible to do some kind of analysis.

    A very simplistic "proof" is:

    • For a given input, the length of the output is the same regardless of the key size. It may, however, differ depending on the mode (CBC, CTR, etc.).
    • Since the encryption is reversible, it can be considered to be a one-to-one function. In other words, a different input results in a different output.
    • Therefore, it is possible to produce any given output (by changing the plain text) regardless of the key size.

    Thus, for a given password, you could end up with the same output by using the appropriate plain text regardless of the key size. This "proof" has a hole in that padding schemes can result in a longer output than input (so the function is not necessarily onto.) But I doubt this would make a difference in the end result.