/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "mycrypt.h"
#include "password-scheme.h"
#include "crypt-blowfish.h"
#include "randgen.h"
/* Lengths and limits for some crypt() algorithms. */
static void
crypt_generate_des(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
{
*raw_password_r = (const unsigned char *)password;
}
static void
{
if (rounds == 0)
else if (rounds < CRYPT_BLF_ROUNDS_MIN)
else if (rounds > CRYPT_BLF_ROUNDS_MAX)
i_fatal("crypt_gensalt_blowfish_rn failed: %m");
CRYPT_BLF_BUFFER_LEN) == NULL)
i_fatal("crypt_blowfish_rn failed: %m");
}
static int
crypt_verify_blowfish(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
const char **error_r)
{
const char *password;
const char *salt;
if (size == 0) {
/* the default mycrypt() handler would return match */
return 0;
}
if (size < CRYPT_BLF_PREFIX_LEN ||
*error_r = "Password is not blowfish password";
return -1;
}
/* really shouldn't happen unless the system is broken */
return -1;
}
}
static void
{
if (rounds == 0)
else if (rounds < CRYPT_SHA2_ROUNDS_MIN)
else if (rounds > CRYPT_SHA2_ROUNDS_MAX)
if (rounds == CRYPT_SHA2_ROUNDS_DEFAULT)
else
*raw_password_r = (const unsigned char *)password;
}
static void
{
if (rounds == 0)
else if (rounds < CRYPT_SHA2_ROUNDS_MIN)
else if (rounds > CRYPT_SHA2_ROUNDS_MAX)
if (rounds == CRYPT_SHA2_ROUNDS_DEFAULT)
else
*raw_password_r = (const unsigned char *)password;
}
/* keep in sync with the crypt_schemes struct below */
static const struct {
const char *key;
const char *salt;
const char *expected;
} sample[] = {
{ "08/15!test~4711", "JB", "JBOZ0DgmtucwE" },
{ "08/15!test~4711", "$5$rounds=1000$0123456789abcdef",
"$5$rounds=1000$0123456789abcdef$K/DksR0DT01hGc8g/kt"
"9McEgrbFMKi9qrb1jehe7hn4" },
{ "08/15!test~4711", "$6$rounds=1000$0123456789abcdef",
"$6$rounds=1000$0123456789abcdef$ZIAd5WqfyLkpvsVCVUU1GrvqaZTq"
"vhJoouxdSqJO71l9Ld3tVrfOatEjarhghvEYADkq//LpDnTeO90tcbtHR1" }
};
/* keep in sync with the sample struct above */
};
};
};
void password_scheme_register_crypt(void)
{
unsigned int i;
const char *crypted;
for (i = 0; i < N_ELEMENTS(crypt_schemes); i++) {
}
}