test-libpassword.c revision 2437015089814f398b717725915009878b3f45aa
#include "test-lib.h"
#include "password-scheme.h"
static struct {
const char *scheme_generated;
const char *scheme_detected;
} known_non_aliases[] = {
{ "MD5", "CRYPT" },
{ "MD5-CRYPT", "CRYPT" },
{ "SKEY", "OTP" },
};
/* some algorithms are detected as something other, because they are compatible
but not considered aliases by dovecot. treat those here to avoid false errors. */
{
return TRUE;
}
return FALSE;
}
static void
const char *plaintext)
{
struct password_generate_params params = {
.user = "testuser1",
.rounds = 0,
};
const unsigned char *raw_password;
test_end();
}
static void test_password_failures(void)
{
const char *scheme = "PLAIN";
const char *crypted = "{PLAIN}invalid";
const char *plaintext = "test";
struct password_generate_params params = {
.user = "testuser1",
.rounds = 0,
};
const unsigned char *raw_password;
const char *error;
test_begin("password scheme failures");
/* wrong password */
/* unknown scheme */
crypted = "{INVALID}invalid";
/* crypt with empty value */
test_end();
}
static void test_password_schemes(void)
{
test_password_scheme("SHA512", "{SHA512}7iaw3Ur350mqGo7jwQrpkj9hiYB3Lkc/iBml1JQODbJ6wYX4oOHV+E+IvIh/1nsUNzLDBMxfqa2Ob1f1ACio/w==", "test");
test_password_scheme("PBKDF2", "{PBKDF2}$1$bUnT4Pl7yFtYX0KU$5000$50a83cafdc517b9f46519415e53c6a858908680a", "test");
test_password_scheme("CRAM-MD5", "{CRAM-MD5}e02d374fde0dc75a17a557039a3a5338c7743304777dccd376f332bee68d2cf6", "test");
test_password_scheme("SCRAM-SHA-1", "{SCRAM-SHA-1}4096,GetyLXdBuHzf1FWf8SLz2Q==,NA/OqmF4hhrsrB9KR7po+dliTGM=,QBiURvQaE6H6qYTmeghDHLANBFQ=", "test");
test_password_scheme("BLF-CRYPT", "{BLF-CRYPT}$2y$05$11ipvo5dR6CwkzwmhwM26OXgzXwhV2PyPuLV.Qi31ILcRcThQpEiW", "test");
#ifdef HAVE_LIBSODIUM
test_password_scheme("ARGON2I", "{ARGON2I}$argon2i$v=19$m=32768,t=4,p=1$f2iuP4aUeNMrgu34fhOkkg$1XSZZMWlIs0zmE+snlUIcLADO3GXbA2O/hsQmmc317k", "test");
#endif
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}