I have an AES encrypted data and the key, but I am not able to tell the block cipher mode [ECB|CBC|CTR] used in encryption or know the key length.

Below is the encrypted data output in java.


Need help identifying the mode and key length used in the encryption.

  • $\begingroup$ Not telling the context (software used, standard..) does not help. $\endgroup$
    – fgrieu
    Mar 23, 2023 at 13:07

1 Answer 1


No, we cannot. The reason is that the AES key is encrypted (or "wrapped"), probably using RSA as it is now 2048 bits in size rather than 128, 192 or 256 bits - the key size of AES. So basically you - or at least we - don't have the key.

It could be another mode, but CBC is really the only padded mode that is CPA secure and used regularly. So it is probably CBC because the output is a multiple of 16 bytes. CTR doesn't pad, so for a random message size there is only a 1/16 chance of it being a multiple of 16 bytes. ECB is insecure, so it is unlikely to be used for generic encryption.

  • $\begingroup$ Perhaps worth adding that if we know the size of the input we can probably distinguish the modes: input of 33-48 bytes would have to be ECB, input of 16-31 bytes would be CBC , input of 32 bytes would be CTR. $\endgroup$
    – Daniel S
    Mar 23, 2023 at 11:17
  • $\begingroup$ Not 100% sure if CBC is used with a prefixed IV, but otherwise, yes, that would give a good hint. There is PCBC, CFB, OFB or even authenticated modes that could also fit though. The question is about ECB/CBC or CTR, but I'm not sure that Aviril knows that there are other modes as well. $\endgroup$
    – Maarten Bodewes
    Mar 23, 2023 at 11:24

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.