password-scheme.c revision 21be4f711d3bab82a783273189a8bbca44a84c5d
/* Copyright (C) 2003 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "base64.h"
#include "hex-binary.h"
#include "md5.h"
#include "module-dir.h"
#include "mycrypt.h"
#include "randgen.h"
#include "sha1.h"
#include "str.h"
#include "password-scheme.h"
static const char salt_chars[] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static buffer_t *schemes_buf;
static const struct password_scheme *schemes;
#ifdef HAVE_MODULES
static struct module *scheme_modules;
#endif
{
const struct password_scheme *s;
return 0;
}
return -1;
}
{
return NULL;
}
}
const char *password_get_scheme(const char **password)
{
const char *p, *scheme;
return NULL;
/* skip the salt */
if (p != NULL) {
/* stop at next '$' */
if (p != NULL)
return "MD5";
}
}
if (**password != '{')
return NULL;
if (p == NULL)
return NULL;
*password = p + 1;
/* LDAP's RFC2307 specifies the MD5 scheme for what we call PLAIN-MD5,
only base64-encoded rather than hex-encoded.
We can detect this case - base64 doesn't use '$'. */
scheme = "LDAP-MD5";
}
return scheme;
}
const char *scheme)
{
const struct password_scheme *s;
}
return NULL;
}
const char *user __attr_unused__)
{
}
static const char *crypt_generate(const char *plaintext,
const char *user __attr_unused__)
{
char salt[9];
}
const char *user __attr_unused__)
{
const char *str;
}
static const char *md5_generate(const char *plaintext,
const char *user __attr_unused__)
{
char salt[9];
int i;
for (i = 0; i < 8; i++)
}
static const char *sha1_generate(const char *plaintext,
const char *user __attr_unused__)
{
unsigned char digest[SHA1_RESULTLEN];
}
const char *user __attr_unused__)
{
unsigned char sha1_digest[SHA1_RESULTLEN];
const char *data;
return 0;
}
if (size < SHA1_RESULTLEN) {
return 0;
}
}
static const char *ssha_generate(const char *plaintext,
const char *user __attr_unused__)
{
}
const char *user __attr_unused__)
{
unsigned char sha1_digest[SHA1_RESULTLEN];
const char *data;
/* format: base64-encoded MD5 hash and salt */
return 0;
}
if (size <= SHA1_RESULTLEN) {
return 0;
}
}
static const char *smd5_generate(const char *plaintext,
const char *user __attr_unused__)
{
unsigned char smd5_digest[20];
struct md5_context ctx;
}
const char *user __attr_unused__)
{
unsigned char md5_digest[16];
const char *data;
struct md5_context ctx;
/* format: base64-encoded MD5 hash and salt */
return 0;
}
if (size <= 16) {
return 0;
}
}
const char *user __attr_unused__)
{
}
static const char *plain_generate(const char *plaintext,
const char *user __attr_unused__)
{
return plaintext;
}
const char *user __attr_unused__)
{
}
static const char *hmac_md5_generate(const char *plaintext,
const char *user __attr_unused__)
{
return password_generate_cram_md5(plaintext);
}
const char *user)
{
unsigned char digest[16];
/* user:realm:passwd */
}
{
unsigned char digest[16];
/* user:realm:passwd */
}
const char *user __attr_unused__)
{
unsigned char digest[16];
const char *str;
}
static const char *plain_md5_generate(const char *plaintext,
const char *user __attr_unused__)
{
unsigned char digest[16];
}
static const char *ldap_md5_generate(const char *plaintext,
const char *user __attr_unused__)
{
unsigned char digest[16];
}
const char *user __attr_unused__)
{
unsigned char md5_digest[16];
const char *data;
i_error("ldap_md5_verify(%s): failed decoding MD5 base64",
user);
return 0;
}
if (size != 16) {
return 0;
}
}
const char *user __attr_unused__)
{
}
static const char *lm_generate(const char *plaintext,
const char *user __attr_unused__)
{
return password_generate_lm(plaintext);
}
const char *user __attr_unused__)
{
}
static const char *ntlm_generate(const char *plaintext,
const char *user __attr_unused__)
{
return password_generate_ntlm(plaintext);
}
static const struct password_scheme default_schemes[] = {
};
void password_schemes_init(void)
{
const struct password_scheme *s;
#ifdef HAVE_MODULES
const char *symbol;
#endif
buffer_append(schemes_buf, s, sizeof(*s));
#ifdef HAVE_MODULES
t_push();
if (s != NULL)
buffer_append(schemes_buf, s, sizeof(*s));
t_pop();
}
#endif
}
void password_schemes_deinit(void)
{
#ifdef HAVE_MODULES
#endif
}