/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
/* CRAM-MD5 SASL authentication, see RFC-2195
Joshua Goodall <joshua@roughtrade.net> */
#include "auth-common.h"
#include "ioloop.h"
#include "buffer.h"
#include "hex-binary.h"
#include "hmac-cram-md5.h"
#include "hmac.h"
#include "md5.h"
#include "randgen.h"
#include "mech.h"
#include "passdb.h"
#include "hostpid.h"
#include <time.h>
struct cram_auth_request {
/* requested: */
char *challenge;
/* received: */
char *username;
char *response;
unsigned long maxbuf;
};
static const char *get_cram_challenge(void)
{
size_t i;
for (i = 0; i < sizeof(buf)-1; i++)
}
{
const char *response_hex;
if (size != CRAM_MD5_CONTEXTLEN) {
"invalid credentials length");
return FALSE;
}
return FALSE;
}
return TRUE;
}
const char **error_r)
{
/* <username> SPACE <response>. Username may contain spaces, so assume
the rightmost space is the response separator. */
if (data[i] == '\0') {
*error_r = "NULs in response";
return FALSE;
}
if (data[i] == ' ')
space = i;
}
if (space == 0) {
*error_r = "missing digest";
return FALSE;
}
space++;
return TRUE;
}
struct auth_request *auth_request)
{
(struct cram_auth_request *)auth_request;
switch (result) {
case PASSDB_RESULT_OK:
else
break;
break;
default:
break;
}
}
static void
{
(struct cram_auth_request *)auth_request;
const char *error;
&error)) {
"CRAM-MD5", credentials_callback);
return;
}
}
error = "authentication failed";
}
static void
const unsigned char *data ATTR_UNUSED,
{
(struct cram_auth_request *)auth_request;
}
{
return &request->auth_request;
}
"CRAM-MD5",
};