/*
* NTLM message handling.
*
* Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
*
* This software is released under the MIT license.
*/
#include "lib.h"
#include "str.h"
#include "buffer.h"
#include "hostpid.h"
#include "randgen.h"
#include "ntlm.h"
#include "ntlm-message.h"
#include <stdarg.h>
#include <ctype.h>
bool unicode)
{
if (unicode)
while (len-- > 0) {
}
}
{
unsigned int length = 0;
if (unicode) {
buffer_append_c(buf, 0);
length++;
}
length++;
}
return length;
}
{
unsigned int length;
}
{
int type;
do {
const char *data;
switch (type) {
case NTPLMSSP_V2_TARGET_END:
break;
case NTPLMSSP_V2_TARGET_FQDN:
case NTPLMSSP_V2_TARGET_DNS:
sizeof(info);
break;
default:
i_panic("Invalid NTLM target info block type "
"%u", type);
}
total_length += length;
} while (type != NTPLMSSP_V2_TARGET_END);
}
{
if ((client_flags & NTLMSSP_NEGOTIATE_UNICODE) != 0)
else
if ((client_flags & NTLMSSP_NEGOTIATE_NTLM2) != 0)
if ((client_flags & NTLMSSP_REQUEST_TARGET) != 0)
return flags;
}
const struct ntlmssp_challenge *
{
struct ntlmssp_challenge c;
i_zero(&c);
buffer_write(buf, 0, &c, sizeof(c));
if ((flags & NTLMSSP_TARGET_TYPE_SERVER) != 0)
return buffer_free_without_data(&buf);
}
{
/* Empty buffer is ok */
return TRUE;
*error = "buffer offset out of bounds";
return FALSE;
}
*error = "buffer end out of bounds";
return FALSE;
}
return TRUE;
}
{
if (data_size < sizeof(struct ntlmssp_request)) {
*error = "request too short";
return FALSE;
}
*error = "signature mismatch";
return FALSE;
}
*error = "message type mismatch";
return FALSE;
}
if ((flags & NTLMSSP_NEGOTIATE_NTLM) == 0) {
*error = "client doesn't advertise NTLM support";
return FALSE;
}
return TRUE;
}
{
if (data_size < sizeof(struct ntlmssp_response)) {
*error = "response too short";
return FALSE;
}
*error = "signature mismatch";
return FALSE;
}
*error = "message type mismatch";
return FALSE;
}
return FALSE;
return TRUE;
}