RFC 3414 (published 2002) specifies a method of generating keys based on password in its Appendix, which essentially takes any "passphrase", and keeps on repeating it until there is a 1MB string, at which point it takes either the SHA1 or MD5 of that data to use as the key:
/**********************************************/
/* Use while loop until we've done 1 Megabyte */
/**********************************************/
while (count < 1048576) {
cp = password_buf;
for (i = 0; i < 64; i++) {
/*************************************************/
/* Take the next octet of the password, wrapping */
/* to the beginning of the password as necessary.*/
/*************************************************/
*cp++ = password[password_index++ % passwordlen];
}
SHAUpdate (&SH, password_buf, 64);
count += 64;
}
SHAFinal (key, &SH); /* tell SHA we're done */
It also states a minimum length security requirement:
SNMP implementations (and SNMP configuration applications) must ensure that passwords are at least 8 characters in length.
And then makes the observation:
Please note that longer passwords with repetitive strings may result in exactly the same key. For example, a password 'bertbert' will result in exactly the same key as password 'bertbertbert'.
It seems to be a well known "workaround" to the 8 character minimum to just repeat your input: If you want to use the password a
, just enter aaaaaaaa
. In fact, in either case it will actually be converted to a
repeated 1048576 times (1MB), and then hashed. If you are trying to brute force the password, the passwords a
, aa
, aaa
and aaaaaa....aaaaaa
are all identical (and you don't need to try all of the variations).
Everything I understand about password security and hashing tells me this is not only a stupid design, but actually undermines the hash algorithm and lowers security. Is there actually a benefit to this method of key generation? How the heck did this get into an RFC explicitly concerned with security?