I need to construct an AES key from an array of bytes (in Java), but I first I have to check if the key created from these bytes would be weak.

Java can check for weakness for DES, but not for AES. What are the criteria for an AES key to be considered weak?

  • 6
    $\begingroup$ It has no (known) weak keys. And even with DES, rejecting "weak" keys is silly. $\endgroup$ – CodesInChaos Mar 22 '16 at 19:26
  • 3
    $\begingroup$ Just make sure the array of bytes is the output of a cryptographically-secure random number generator. $\endgroup$ – Stephen Touset Mar 22 '16 at 19:42
  • $\begingroup$ Some hints on generating keys for Java here $\endgroup$ – Maarten Bodewes Mar 22 '16 at 20:58
  • 2
    $\begingroup$ Ironically, DES's weak keys are now weak because they're well known (i.e. the same reason 01:23:45:67:89:AB:CD is "weak"), perhaps more so than because of their mathematical properties. I.e. if you think something was encrypted with a weak key, then instead of trying to exploit their properties, you may as well just try decrypting it with all 16 of them! $\endgroup$ – user253751 Mar 22 '16 at 23:56

The comments already have covered the two main points, but let me try to put it in the form of an answer. There are not (that we know) weak keys in AES, in the sense that you cannot formulate a routine $isWeak(key)$. However, there are weak ways to generate an AES key (i.e. bad randomness).

An AES key is just a bit string of length $n$. That means that there are $2^n$ possible keys. If the key is generated by a properly seeded CSPRNG, AES is (computationally) secure. If you don't know about the origins of the key, or it is generated by a less secure RNG (such as Java's Math.random), the key shouldn't be used.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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