mech-ntlm.c revision e80203675151ef9d4f3f850cf02041042eb13096
/*
* NTLM and NTLMv2 authentication mechanism.
*
* Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
*
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "common.h"
#include "mech.h"
#include "passdb.h"
#include "str.h"
#include "buffer.h"
#include "hex-binary.h"
#include "safe-memset.h"
#include "ntlm.h"
struct ntlm_auth_request {
struct auth_request auth_request;
/* requested: */
int ntlm2_negotiated;
int unicode_negotiated;
const unsigned char *challenge;
/* received: */
struct ntlmssp_response *response;
};
const char *credentials)
{
const unsigned char *client_response;
unsigned char lm_response[LM_RESPONSE_SIZE];
unsigned char hash[LM_HASH_SIZE];
unsigned int response_length;
if (response_length < LM_RESPONSE_SIZE) {
i_error("ntlm(%s): passdb credentials' length is too small",
return FALSE;
}
i_error("ntlm(%s): passdb credentials are not in hex",
return FALSE;
}
}
static void
const char *credentials,
struct auth_request *auth_request)
{
struct ntlm_auth_request *request =
(struct ntlm_auth_request *)auth_request;
switch (result) {
case PASSDB_RESULT_OK:
else
break;
break;
default:
break;
}
}
const char *credentials)
{
const unsigned char *client_response;
unsigned char hash[NTLMSSP_HASH_SIZE];
unsigned int response_length;
if (response_length == 0) {
/* try LM authentication unless NTLM2 was negotiated */
}
if (response_length > NTLMSSP_RESPONSE_SIZE) {
unsigned char ntlm_v2_response[NTLMSSP_V2_RESPONSE_SIZE];
const unsigned char *blob =
/*
* Authentication target == NULL because we are acting
* as a standalone server, not as NT domain member.
*/
} else {
unsigned char ntlm_response[NTLMSSP_RESPONSE_SIZE];
const unsigned char *client_lm_response =
if (request->ntlm2_negotiated)
else
}
}
static void
const char *credentials,
struct auth_request *auth_request)
{
struct ntlm_auth_request *request =
(struct ntlm_auth_request *)auth_request;
int ret;
switch (result) {
case PASSDB_RESULT_OK:
if (ret > 0) {
return;
}
if (ret < 0) {
return;
}
break;
return;
default:
break;
}
/* NTLM credentials not found or didn't want to use them,
try with LM credentials */
}
static void
{
struct ntlm_auth_request *request =
(struct ntlm_auth_request *)auth_request;
const char *error;
const struct ntlmssp_request *ntlm_request =
(struct ntlmssp_request *)data;
const struct ntlmssp_challenge *message;
if (verbose) {
i_info("ntlm(%s): invalid NTLM request, %s",
error);
}
return;
}
&message_size);
} else {
const struct ntlmssp_response *response =
(struct ntlmssp_response *)data;
char *username;
if (verbose) {
i_info("ntlm(%s): invalid NTLM response, %s",
error);
}
return;
}
if (verbose) {
i_info("ntlm(%s): %s",
}
return;
}
}
}
static void
{
if (data_size == 0)
else
}
static void
{
}
static struct auth_request *mech_ntlm_auth_new(void)
{
struct ntlm_auth_request *request;
return &request->auth_request;
}
const struct mech_module mech_ntlm = {
"NTLM",
};