Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the difference between the keylength and the length of a password for AES-256?

share|improve this question

closed as unclear what you're asking by hunter, Thomas, D.W., minar, Ricky Demer Jul 24 '13 at 17:10

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

One is the length of a key, and one is the length of the password. $\:$ – Ricky Demer Jul 24 '13 at 17:10

AES is a block cipher, a cryptographic primitive that is meant to be used in a larger framework. Its sole purview is encrypting a single block of data given a certain-sized key. In the case of AES-256, the key size is 256 bits.

Notably, there is no password involved in AES. So, there is no password length to discuss. AES itself just uses keys.

If you are using a service which claims it uses AES-256, and you are forced to enter a password, what is likely happening is that your password is used to derive a key. This is often done using a key derivation function, like PBKDF2, which stands for "password-based key derivation function 2". (Some KDFs are meant to expand real, uniformly-random keys, while others are intended to have "human"-like passwords for inputs.)

So, in this hypothetical scenario, the direct key used for AES-256 is likely the output of the KDF given your password as an input. If this is the case, then your password can be whatever length you so desire, although longer passwords are more difficult to guess (i.e., stronger). The job of a KDF is take the input and produce a "good" key from it.

share|improve this answer
How about skipping the key derivation function, if the password length and keylength match? – user129789 Jul 22 '13 at 3:21
@user129789 If your password was provided by a user, it won't be uniformly distributed, which may open the door to related key attacks. Always feed it into the proper type of key derivation function. – Thomas Jul 22 '13 at 4:05

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