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>
31 #define MESSAGE_TYPE_NEGOTIATE 1
32 #define MESSAGE_TYPE_CHALLENGE 2
33 #define MESSAGE_TYPE_AUTHENTICATE 3
35 #define NTLMSSP_NEGOTIATE_56 0x80000000
36 #define NTLMSSP_NEGOTIATE_KEY_EXCH 0x40000000
37 #define NTLMSSP_NEGOTIATE_128 0x20000000
38 #define NTLMSSP_RESERVED1 0x10000000
39 #define NTLMSSP_RESERVED2 0x08000000
40 #define NTLMSSP_RESERVED3 0x04000000
41 #define NTLMSSP_NEGOTIATE_VERSION 0x02000000
42 #define NTLMSSP_RESERVED4 0x01000000
43 #define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
44 #define NTLMSSP_REQUEST_NON_NT_SESSION_KEY 0x00400000
45 #define NTLMSSP_RESERVED5 0x00200000
46 #define NTLMSSP_NEGOTIATE_IDENTIFY 0x00100000
47 #define NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY 0x00080000
48 #define NTLMSSP_RESERVED6 0x00040000
49 #define NTLMSSP_TARGET_TYPE_SERVER 0x00020000
50 #define NTLMSSP_TARGET_TYPE_DOMAIN 0x00010000
51 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
52 #define NTLMSSP_RESERVED7 0x00004000
53 #define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x00002000
54 #define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x00001000
55 #define NTLMSSP_NEGOTIATE_ANONYMOUS 0x00000800
56 #define NTLMSSP_RESERVED8 0x00000400
57 #define NTLMSSP_NEGOTIATE_NTLM 0x00000200
58 #define NTLMSSP_RESERVED9 0x00000100
59 #define NTLMSSP_NEGOTIATE_LM_KEY 0x00000080
60 #define NTLMSSP_NEGOTIATE_DATAGRAM 0x00000040
61 #define NTLMSSP_NEGOTIATE_SEAL 0x00000020
62 #define NTLMSSP_NEGOTIATE_SIGN 0x00000010
63 #define NTLMSSP_RESERVED10 0x00000008
64 #define NTLMSSP_REQUEST_TARGET 0x00000004
65 #define NTLMSSP_NEGOTIATE_OEM 0x00000002
66 #define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
73 NTLM_STATE_AUTHENTICATE,
78 typedef MSV1_0_AVID NTLM_AV_ID;
80 #if __MINGW64_VERSION_MAJOR < 9
83 MsvAvTimestamp = MsvAvFlags + 1,
87 MsvAvSingleHost = MsvAvRestrictions
91 #ifndef MsvAvSingleHost
92 #define MsvAvSingleHost MsvAvRestrictions
101 MsvAvDnsComputerName,
118 #define MSV_AV_FLAGS_AUTHENTICATION_CONSTRAINED 0x00000001
119 #define MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK 0x00000002
120 #define MSV_AV_FLAGS_TARGET_SPN_UNTRUSTED_SOURCE 0x00000004
122 #define WINDOWS_MAJOR_VERSION_5 0x05
123 #define WINDOWS_MAJOR_VERSION_6 0x06
124 #define WINDOWS_MINOR_VERSION_0 0x00
125 #define WINDOWS_MINOR_VERSION_1 0x01
126 #define WINDOWS_MINOR_VERSION_2 0x02
127 #define NTLMSSP_REVISION_W2K3 0x0F
131 UINT8 ProductMajorVersion;
132 UINT8 ProductMinorVersion;
135 UINT8 NTLMRevisionCurrent;
159 BYTE ClientChallenge[8];
188 UINT32 NegotiateFlags;
197 UINT32 NegotiateFlags;
198 BYTE ServerChallenge[8];
208 UINT32 NegotiateFlags;
216 BYTE MessageIntegrityCheck[16];
231 BOOL SendVersionInfo;
232 BOOL confidentiality;
233 WINPR_RC4_CTX* SendRc4Seal;
234 WINPR_RC4_CTX* RecvRc4Seal;
235 BYTE* SendSigningKey;
236 BYTE* RecvSigningKey;
237 BYTE* SendSealingKey;
238 BYTE* RecvSealingKey;
239 UINT32 NegotiateFlags;
240 BOOL UseSamFileDatabase;
241 int LmCompatibilityLevel;
242 int SuppressExtendedProtection;
243 BOOL SendWorkstationName;
247 BYTE* ChannelBindingToken;
248 BYTE ChannelBindingsHash[16];
250 BOOL SendSingleHostData;
251 BOOL NegotiateKeyExchange;
256 size_t MessageIntegrityCheckOffset;
266 BYTE NtProofString[16];
268 BYTE ChallengeTimestamp[8];
269 BYTE ServerChallenge[8];
270 BYTE ClientChallenge[8];
271 BYTE SessionBaseKey[16];
272 BYTE KeyExchangeKey[16];
273 BYTE RandomSessionKey[16];
274 BYTE ExportedSessionKey[16];
275 BYTE EncryptedRandomSessionKey[16];
276 BYTE ClientSigningKey[16];
277 BYTE ClientSealingKey[16];
278 BYTE ServerSigningKey[16];
279 BYTE ServerSealingKey[16];
280 psSspiNtlmHashCallback HashCallback;
281 void* HashCallbackArg;
284 char* ntlm_negotiate_flags_string(
char* buffer,
size_t size, UINT32 flags);
285 const char* ntlm_message_type_string(UINT32 messageType);
287 const char* ntlm_state_string(NTLM_STATE state);
288 void ntlm_change_state(
NTLM_CONTEXT* ntlm, NTLM_STATE state);
290 BOOL ntlm_reset_cipher_state(
PSecHandle phContext);
295 #ifdef WITH_DEBUG_NLA
296 #define WITH_DEBUG_NTLM
299 BOOL NTLM_init(
void);