20#ifndef WINPR_SSPI_NTLM_PRIVATE_H
21#define WINPR_SSPI_NTLM_PRIVATE_H
23#include <winpr/sspi.h>
24#include <winpr/windows.h>
27#include <winpr/crypto.h>
28#include <winpr/sysinfo.h>
32#define MESSAGE_TYPE_NEGOTIATE 1
33#define MESSAGE_TYPE_CHALLENGE 2
34#define MESSAGE_TYPE_AUTHENTICATE 3
36#define NTLMSSP_NEGOTIATE_56 0x80000000
37#define NTLMSSP_NEGOTIATE_KEY_EXCH 0x40000000
38#define NTLMSSP_NEGOTIATE_128 0x20000000
39#define NTLMSSP_RESERVED1 0x10000000
40#define NTLMSSP_RESERVED2 0x08000000
41#define NTLMSSP_RESERVED3 0x04000000
42#define NTLMSSP_NEGOTIATE_VERSION 0x02000000
43#define NTLMSSP_RESERVED4 0x01000000
44#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
45#define NTLMSSP_REQUEST_NON_NT_SESSION_KEY 0x00400000
46#define NTLMSSP_RESERVED5 0x00200000
47#define NTLMSSP_NEGOTIATE_IDENTIFY 0x00100000
48#define NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY 0x00080000
49#define NTLMSSP_RESERVED6 0x00040000
50#define NTLMSSP_TARGET_TYPE_SERVER 0x00020000
51#define NTLMSSP_TARGET_TYPE_DOMAIN 0x00010000
52#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
53#define NTLMSSP_RESERVED7 0x00004000
54#define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x00002000
55#define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x00001000
56#define NTLMSSP_NEGOTIATE_ANONYMOUS 0x00000800
57#define NTLMSSP_RESERVED8 0x00000400
58#define NTLMSSP_NEGOTIATE_NTLM 0x00000200
59#define NTLMSSP_RESERVED9 0x00000100
60#define NTLMSSP_NEGOTIATE_LM_KEY 0x00000080
61#define NTLMSSP_NEGOTIATE_DATAGRAM 0x00000040
62#define NTLMSSP_NEGOTIATE_SEAL 0x00000020
63#define NTLMSSP_NEGOTIATE_SIGN 0x00000010
64#define NTLMSSP_RESERVED10 0x00000008
65#define NTLMSSP_REQUEST_TARGET 0x00000004
66#define NTLMSSP_NEGOTIATE_OEM 0x00000002
67#define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
74 NTLM_STATE_AUTHENTICATE,
79typedef MSV1_0_AVID NTLM_AV_ID;
81#if __MINGW64_VERSION_MAJOR < 9
84 MsvAvTimestamp = MsvAvFlags + 1,
88 MsvAvSingleHost = MsvAvRestrictions
92#ifndef MsvAvSingleHost
93#define MsvAvSingleHost MsvAvRestrictions
102 MsvAvDnsComputerName,
119#define MSV_AV_FLAGS_AUTHENTICATION_CONSTRAINED 0x00000001
120#define MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK 0x00000002
121#define MSV_AV_FLAGS_TARGET_SPN_UNTRUSTED_SOURCE 0x00000004
123#define WINDOWS_MAJOR_VERSION_5 0x05
124#define WINDOWS_MAJOR_VERSION_6 0x06
125#define WINDOWS_MINOR_VERSION_0 0x00
126#define WINDOWS_MINOR_VERSION_1 0x01
127#define WINDOWS_MINOR_VERSION_2 0x02
128#define NTLMSSP_REVISION_W2K3 0x0F
132 UINT8 ProductMajorVersion;
133 UINT8 ProductMinorVersion;
136 UINT8 NTLMRevisionCurrent;
160 BYTE ClientChallenge[8];
189 UINT32 NegotiateFlags;
198 UINT32 NegotiateFlags;
199 BYTE ServerChallenge[8];
209 UINT32 NegotiateFlags;
217 BYTE MessageIntegrityCheck[16];
232 BOOL SendVersionInfo;
233 BOOL confidentiality;
234 WINPR_RC4_CTX* SendRc4Seal;
235 WINPR_RC4_CTX* RecvRc4Seal;
236 BYTE* SendSigningKey;
237 BYTE* RecvSigningKey;
238 BYTE* SendSealingKey;
239 BYTE* RecvSealingKey;
240 UINT32 NegotiateFlags;
241 BOOL UseSamFileDatabase;
242 int LmCompatibilityLevel;
243 int SuppressExtendedProtection;
244 BOOL SendWorkstationName;
248 BYTE* ChannelBindingToken;
249 BYTE ChannelBindingsHash[16];
251 BOOL SendSingleHostData;
252 BOOL NegotiateKeyExchange;
257 size_t MessageIntegrityCheckOffset;
267 BYTE NtProofString[16];
269 BYTE ChallengeTimestamp[8];
270 BYTE ServerChallenge[8];
271 BYTE ClientChallenge[8];
272 BYTE SessionBaseKey[16];
273 BYTE KeyExchangeKey[16];
274 BYTE RandomSessionKey[16];
275 BYTE ExportedSessionKey[16];
276 BYTE EncryptedRandomSessionKey[16];
277 BYTE ClientSigningKey[16];
278 BYTE ClientSealingKey[16];
279 BYTE ServerSigningKey[16];
280 BYTE ServerSealingKey[16];
281 psSspiNtlmHashCallback HashCallback;
282 void* HashCallbackArg;
290char* ntlm_negotiate_flags_string(
char* buffer,
size_t size, UINT32 flags);
293const char* ntlm_message_type_string(UINT32 messageType);
296const char* ntlm_state_string(NTLM_STATE state);
298void ntlm_change_state(
NTLM_CONTEXT* ntlm, NTLM_STATE state);
304BOOL ntlm_reset_cipher_state(
PSecHandle phContext);
313SECURITY_STATUS ntlm_SetContextWorkstationX(
NTLM_CONTEXT* context, BOOL unicode,
const void* data,
317#define WITH_DEBUG_NTLM
328UNICODE_STRING ntlm_from_unicode_string_w(
const WCHAR* str,
size_t wcharlen);
331UNICODE_STRING ntlm_from_unicode_string_utf8(
const char* str,
size_t wcharlen);
337BOOL ntlm_SecBufferRealloc(
SecBuffer* buffer, ULONG len);