Support crypt parameters in login.conf
(also see D15713)
This is "traditional" crypt and caller might be expecting DES (see bug 192277).
What's the reasoning behind using Blowfish? (It's author, Bruce Schneier have advised to migrate to Twofish in ~2007 by the way)
style: avoid hardcoding.
Avoid strn*, use strl* instead.
In the Kitchener/Waterloo hackathon we discussed the plan as three parts
- Allan is working to port the improvements from OpenBSD bcrypt back to FreeBSD.
- (This patch) allow users to overwrite the default parameters through login.conf
- Work on importing Argon2 as an alternative (and maybe scrypt if there's interest)
Fair point do we need to default to MD5, because that isn't what the code was doing?
|26 ↗||(On Diff #57737)|
I'll restore this for this diff
But I think you are just changing the default here (which we can't do without breaking existing applications out there).
When DES is eventually removed, crypt() should return NULL to indicate an error (when salt was invalid), or use the then-default algorithm (as it's doing right now) should the salt was acceptable for the new algorithm, and with that, I think most of the change was unnecessary?
I think it's fine to change the fallback (when DES is not available) default to anything.
We only need the default be DES for legacy applications. POSIX says "The algorithm is implementation-defined." ( https://pubs.opengroup.org/onlinepubs/9699919799/functions/crypt.html ).
Is this needed?
Please keep the blank line per style(9).
Previously the switch was performed by modifying a pointer, which is typically atomic, and now it's being compared against a string. This made crypt_r no longer thread safe and we can't do this.
But can't one already use e.g. $6$rounds=100000$xxxxx$ as salt? Or are you talking about something different?
Good question (note that we do not set errno as POSIX suggested, and the crypt_* should probably be modified to support these).
By the way I think the current lib/libcrypt/crypt.3 can land independently because it matches the current behavior.
There is no way through the login_ functions in libutil nor in OpenPAM to select the parameters to crypt_*(). Arguably it doesn't make sense to expose the parameters in OpenPAM and the algorithm in login.conf.
Regarding the other stuff:
crypt_r() when the algorithm is set to DES is not re-entrant. The DES code is structured like the setkey/encrypt functions in the POSIX specification.
We should probably set the errno variable (OpenBSD does) to be inline with the POSIX spec.