by AsyncAwait · 9y ago · 0 comments
In the interests of hewing closest to cryptographic reality, I design not to allow a password longer than the algorithm can usefully use.
Everyone's been saying "just use bcrypt", but bcrypt has too many gotchas to be the default choice. We really need to work on getting scrypt and argon2 into the most popular programming languages and frameworks a.s.a.p.
This has got to be the underlying problem of modern security. By the time a best practice is well known, it's no longer best practice.
I haven't looked deeply at this, but using "key stretching" that clips your output characters to such a small space smells very suspect to me.
Remember: there is only 32 bytes of actual output there, regardless of whether you represent it as hex or binary. And since bcrypt can't take more than 56 bytes of input, you are clipping that down to the equivalent of 23 bytes.
Or you could use a better KDF, e.g. scrypt (even PBKDF2 is better on this metric). Artificial password-length restrictions are symptomatic of poor design.
To upload 100s or even more than a few megs you need a multipart message, a password form won't accept MP http requests.
https://github.com/plataformatec/devise/blob/88724e10adaf9ff...
Requiring me to trust your code in order for you to decide whether or not to trust me is asking too much.