shared/libcrypt-util: do not refuse passwords if some other hash is unsupported
This commit is contained in:
parent
9de324c3c9
commit
35e22827a9
|
@ -182,8 +182,12 @@ int test_password_one(const char *hashed_password, const char *password) {
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
k = crypt_ra(password, hashed_password, &cd_data, &cd_size);
|
k = crypt_ra(password, hashed_password, &cd_data, &cd_size);
|
||||||
if (!k)
|
if (!k) {
|
||||||
return errno_or_else(EINVAL);
|
if (errno == ENOMEM)
|
||||||
|
return -ENOMEM;
|
||||||
|
/* Unknown or unavailable hashing method or string too short */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return streq(k, hashed_password);
|
return streq(k, hashed_password);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,18 @@ static void test_hash_password_full(void) {
|
||||||
hashed,
|
hashed,
|
||||||
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||||
i) == true);
|
i) == true);
|
||||||
|
assert_se(test_password_many(STRV_MAKE("$W$j9T$dlCXwkX0GC5L6B8Gf.4PN/$VCyEH", /* no such method exists... */
|
||||||
|
hashed,
|
||||||
|
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||||
|
i) == true);
|
||||||
assert_se(test_password_many(STRV_MAKE("$y$j9T$dlCXwkX0GC5L6B8Gf.4PN/$VCyEH",
|
assert_se(test_password_many(STRV_MAKE("$y$j9T$dlCXwkX0GC5L6B8Gf.4PN/$VCyEH",
|
||||||
hashed,
|
hashed,
|
||||||
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||||
"") == false);
|
"") == false);
|
||||||
|
assert_se(test_password_many(STRV_MAKE("$W$j9T$dlCXwkX0GC5L6B8Gf.4PN/$VCyEH", /* no such method exists... */
|
||||||
|
hashed,
|
||||||
|
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||||
|
"") == false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue