9
$\begingroup$

What is the maximum key size for AES 128, Will using a key greater than maximum gives extra security or error? Is there a minimum key size?

Suppose a key is 128 bit, does it means The key is of length 16characters

Suggest me a good password to key function.

$\endgroup$
3
  • 7
    $\begingroup$ 1. 128 bits is the largest 128 bit key. Conversely, the smallest 128 bit key is 128 bits. 2. Characters are not always 8 bits so there is no translation between key size and number of characters 3. The fastest function to transform a password into a key is to ignore the password and return the zero key. This is good if speed is the important measure. $\endgroup$ Feb 28, 2017 at 19:06
  • 2
    $\begingroup$ An AES-128 key consists of exactly 128 bits / 16 bytes, no more, no less. $\endgroup$ Feb 28, 2017 at 19:34
  • 3
    $\begingroup$ Q: Will using more than four wheels on my car give me more stability or error? A: the question is nonsense because my car doesn't even have a spot to put more than 4 wheels. I'd have to totally redesign the car. $\endgroup$
    – user253751
    Feb 28, 2017 at 23:14

2 Answers 2

17
$\begingroup$

Despite similarities, it is really important to understand that passwords and cryptographic keys should not be carelessly conflated. Some important contrasts:

  • Passwords are normally selected by human beings according to their whims. Cryptographic keys are meant to be randomly generated by an algorithm.
  • Passwords are usually intended to be memorized by human beings. A strong cryptographic key cannot generally be memorized—they're too random and complex—and thus generally stored in a secure device. In the parlance of multi-factor authentication, passwords are "something you know" while cryptographic keys are "something you have."
  • Passwords have to be text that human beings can manually input into their devices. Cryptographic keys are fundamentally binary data (despite being sometimes serialized and deserialized as text) and are generally not meant to input manually.

I say all this because your question really comes down to a lack of understanding of these differences. AES doesn't use passwords, it uses keys. AES-128 keys are fixed-length binary data; they don't really have "characters" because they're not text. As others have said, the maximum key size for AES-128 is the same as the minimum and only key size: 128 bits.


Many programs that use AES-128, however, do present a password-based user interface, and maybe you've encountered one of these. But what these programs are doing, behind the scenes, is internally transforming the user's password into a proper cryptographic key. In those programs your password can generally be any sensible length you like, but generally then the password is the weakest link—an attacker who can guess your password doesn't need to crack the AES encryption. So to achieve the full security strength of AES-128 in such a program you would need to choose an extremely strong password—something most users won't know how to do. In this case I recommend looking into Diceware and their FAQ, which has some useful advice on how complex of a password to choose.

$\endgroup$
11
$\begingroup$

AES-128 requires keys 128 bits in length, period.

As Thomas points out in his comment, the size of characters is encoding-dependent, so there is no well-defined "number of characters" in an AES key. AES cares about bits for its input, not characters.

Low-entropy passwords should be converted into key material with a password-stretching KDF with appropriate work factors. PBKDF2 (with a work factor of > 100,000) is fine, if aging. Better are scrypt or argon2, again with appropriately-sized work factors.

$\endgroup$
2
  • 1
    $\begingroup$ I'd also include bcrypt in that list. $\endgroup$ Feb 28, 2017 at 19:34
  • $\begingroup$ I'm open to that, but many (if not most) bcrypt APIs in practice don't seem oriented to getting out key material, instead just giving you an /etc/shadow-style encoded blob that you'd have to parse the key out of. $\endgroup$ Feb 28, 2017 at 19:43

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.