/*
* NTLM and NTLMv2 authentication mechanism.
*
* Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
*
* This software is released under the MIT license.
*/
#include "auth-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 {
/* requested: */
bool ntlm2_negotiated;
bool unicode_negotiated;
const unsigned char *challenge;
/* received: */
};
{
const unsigned char *client_response;
unsigned int response_length;
if (size != LM_HASH_SIZE) {
"invalid LM credentials length");
return FALSE;
}
if (response_length < LM_RESPONSE_SIZE) {
"LM response length is too small");
return FALSE;
}
}
static void
struct auth_request *auth_request)
{
(struct ntlm_auth_request *)auth_request;
switch (result) {
case PASSDB_RESULT_OK:
else
break;
break;
default:
break;
}
}
static int
{
const unsigned char *client_response;
unsigned int response_length;
if (response_length == 0) {
/* try LM authentication unless NTLM2 was negotiated */
}
if (size != NTLMSSP_HASH_SIZE) {
"invalid NTLM credentials length");
return -1;
}
if (response_length > NTLMSSP_RESPONSE_SIZE) {
const unsigned char *blob =
/*
* Authentication target == NULL because we are acting
* as a standalone server, not as NT domain member.
*/
} else {
const unsigned char *client_lm_response =
if (request->ntlm2_negotiated)
else
}
}
static void
struct auth_request *auth_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 *)auth_request;
const char *error;
(const struct ntlmssp_request *)data;
"invalid NTLM request: %s", error);
return;
}
&message_size);
} else {
(const struct ntlmssp_response *)data;
const char *username;
"invalid NTLM response: %s", error);
return;
}
"%s", error);
return;
}
}
}
{
return &request->auth_request;
}
"NTLM",
};