What is the difference between the keylength and the length of a password for AES-256?
1 Answer
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.
-
$\begingroup$ How about skipping the key derivation function, if the password length and keylength match? $\endgroup$ Commented Jul 22, 2013 at 3:21
-
1$\begingroup$ @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. $\endgroup$– ThomasCommented Jul 22, 2013 at 4:05