/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "password-scheme.h"
#ifdef HAVE_LIBSODIUM
#include <sodium.h>
#endif
static struct {
const char *scheme_generated;
const char *scheme_detected;
} known_non_aliases[] = {
{ "MD5", "DES-CRYPT" },
{ "MD5-CRYPT", "DES-CRYPT" },
{ "SKEY", "OTP" },
{ "ARGON2ID", "ARGON2I" },
};
/* 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)
{
.user = "testuser1",
.rounds = 0,
};
const unsigned char *raw_password;
test_end();
}
static void test_password_failures(void)
{
.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");
#ifdef crypto_pwhash_ALG_ARGON2ID13
test_password_scheme("ARGON2ID", "{ARGON2ID}$argon2id$v=19$m=65536,t=3,p=1$vBb99oJ12p3WAdYlaMHz1A$jtFOtbo/sYV9OSlTxDo/nVNq3uArHd5GJSEx0ty85Cc", "test");
#endif
#endif
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}