#ifndef PASSWORD_SCHEME_H
#define PASSWORD_SCHEME_H
enum password_encoding {
};
struct password_generate_params {
const char *user;
unsigned int rounds;
};
struct password_scheme {
const char *name;
/* If non-zero, this is the expected raw password length.
It can be used to automatically detect encoding between
hex and base64 encoded passwords. */
unsigned int raw_password_len;
const char **error_r);
const unsigned char **raw_password_r,
};
extern unsigned int password_scheme_encryption_rounds;
/* Returns 1 = matched, 0 = didn't match, -1 = unknown scheme or invalid
raw_password */
const char **error_r);
/* Extracts scheme from password, or returns NULL if it isn't found.
If auth_request is given, it's used for debug logging. */
const char *password_get_scheme(const char **password);
0 if scheme is unknown, -1 if password is invalid. */
const char **error_r);
/* Create password with wanted scheme out of plaintext password and username.
the scheme is unknown. */
const char *scheme,
specified in the scheme, the default encoding for the scheme is used.
Returns FALSE if the scheme is unknown. */
bool password_generate_encoded(const char *plaintext, const struct password_generate_params *params,
const char *scheme, const char **password_r);
/* Returns TRUE if schemes are equivalent. */
/* Try to detect in which scheme crypted password is. Returns the scheme name
or NULL if nothing was found. */
const char *
const struct password_generate_params *params);
void password_schemes_init(void);
void password_schemes_deinit(void);
/* some password schemes/algorithms supports a variable number of
encryption rounds. */
void password_set_encryption_rounds(unsigned int rounds);
/* INTERNAL: */
ATTR_NULL(2);
const char **error_r);
unsigned int *iter_count_r, const char **salt_r,
unsigned char stored_key_r[],
unsigned char server_key_r[], const char **error_r);
int scram_sha1_verify(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
const char **error_r ATTR_UNUSED);
void scram_sha1_generate(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
void pbkdf2_generate(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
const char **error_r);
/* check which of the algorithms Blowfish, SHA-256 and SHA-512 are
void password_scheme_register_crypt(void);
#ifdef HAVE_LIBSODIUM
void password_scheme_register_sodium(void);
#endif
#endif