Skip to content

Commit

Permalink
pam_unix: read yescrypt rounds from login.defs
Browse files Browse the repository at this point in the history
Retrieves YESCRYPT_COST_FACTOR from /etc/login.defs for yescrypt
in a similar fashion to reading number of rounds for SHA-2.

Resolves #607.

Signed-off-by: Nathan Du <nathandu@outlook.com>
  • Loading branch information
mcendu committed Nov 27, 2023
1 parent 6619819 commit 8d082da
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/pam_unix/support.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ unsigned long long _set_ctrl(pam_handle_t *pamh, int flags, int *remember,
free (val);

/* read number of rounds for crypt algo */
if (rounds && (on(UNIX_SHA256_PASS, ctrl) || on(UNIX_SHA512_PASS, ctrl))) {
val = pam_modutil_search_key(pamh, LOGIN_DEFS, "SHA_CRYPT_MAX_ROUNDS");
if (rounds) {
val = NULL;
if (on(UNIX_SHA256_PASS, ctrl) || on(UNIX_SHA512_PASS, ctrl)) {
val = pam_modutil_search_key(pamh, LOGIN_DEFS, "SHA_CRYPT_MAX_ROUNDS");
} else if (on(UNIX_YESCRYPT_PASS, ctrl)) {
val = pam_modutil_search_key(pamh, LOGIN_DEFS, "YESCRYPT_COST_FACTOR");
}

if (val) {
*rounds = strtol(val, NULL, 10);
Expand Down

0 comments on commit 8d082da

Please sign in to comment.