Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
7.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1993 Microsoft Corporation
  4. //
  5. // File: ntlmsspi.h
  6. //
  7. // Contents: Header file describing the interface to code common to the NT
  8. // Lanman Security Support Provider (NtLmSsp) Service and the DLL.
  9. //
  10. // History: SudK Created 6/22/95
  11. //
  12. //----------------------------------------------------------------------------
  13. #ifndef _SICILY_NTLMSSPI_INCLUDED_
  14. #define _SICILY_NTLMSSPI_INCLUDED_
  15. #define MSV1_0_CHALLENGE_LENGTH 8
  16. //
  17. // Maximum lifetime of a context
  18. //
  19. #define NTLMSSP_MAX_LIFETIME (2L*60L*1000L) // 2 minutes
  20. ////////////////////////////////////////////////////////////////////////
  21. //
  22. // Opaque Messages passed between client and server
  23. //
  24. ////////////////////////////////////////////////////////////////////////
  25. #define NTLMSSP_SIGNATURE "NTLMSSP"
  26. #define NTLMSSP_SIGN_VERSION 1
  27. //
  28. // MessageType for the following messages.
  29. //
  30. #ifndef WIN16_BUILD
  31. typedef enum {
  32. NtLmNegotiate = 1,
  33. NtLmChallenge,
  34. NtLmAuthenticate,
  35. NtLmRedirect
  36. } NTLM_MESSAGE_TYPE;
  37. #else
  38. #define NtLmNegotiate 1
  39. #define NtLmChallenge 2
  40. #define NtLmAuthenticate 3
  41. #define NtLmRedirect 4
  42. typedef long NTLM_MESSAGE_TYPE;
  43. #endif // WIN16_BUILD
  44. //
  45. // Valid values of NegotiateFlags
  46. //
  47. #define NTLMSSP_NEGOTIATE_UNICODE 0x0001 // Text strings are in unicode
  48. #define NTLMSSP_NEGOTIATE_OEM 0x0002 // Text strings are in OEM
  49. #define NTLMSSP_REQUEST_TARGET 0x0004 // Server should return its
  50. // authentication realm
  51. #define NTLMSSP_NEGOTIATE_SIGN 0x0010 // Request signature capability
  52. #define NTLMSSP_NEGOTIATE_SEAL 0x0020 // Request confidentiality
  53. #define NTLMSSP_RESERVED 0x0040 // reserved for past use
  54. #define NTLMSSP_NEGOTIATE_LM_KEY 0x0080 // Use LM session key for sign/seal
  55. #define NTLMSSP_NEGOTIATE_NETWARE 0x0100 // NetWare authentication
  56. #define NTLMSSP_NEGOTIATE_NTLM 0x0200 // NTLM authentication
  57. #define NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED 0x1000 // Domain Name supplied on negotiate
  58. #define NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED 0x2000 // Workstation Name supplied on negotiate
  59. #define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x4000 // Indicates client/server are same machine
  60. #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x8000 // Sign for all security levels
  61. //
  62. // Valid target types returned by the server in Negotiate Flags
  63. //
  64. #define NTLMSSP_TARGET_TYPE_DOMAIN 0x10000 // TargetName is a domain name
  65. #define NTLMSSP_TARGET_TYPE_SERVER 0x20000 // TargetName is a server name
  66. #define NTLMSSP_TARGET_TYPE_SHARE 0x40000 // TargetName is a share name
  67. //
  68. // Opaque message returned from first call to InitializeSecurityContext
  69. //
  70. #define SIC_MIN_STR_SIZE sizeof(ULONG)
  71. #define MSAP_EXTRA_STR_SIZE(nn) \
  72. ((nn > SIC_MIN_STR_SIZE) ? nn - SIC_MIN_STR_SIZE : 0)
  73. // New Sicily 2.0 Negotiate message
  74. //
  75. typedef struct _SIC20_NEGOTIATE_MSG {
  76. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  77. NTLM_MESSAGE_TYPE MessageType;
  78. ULONG NegotiateFlags;
  79. STRING OemDomainName;
  80. STRING OemWorkstationName;
  81. // Reserved for future Sicily enhancement
  82. ULONG Reserved1; // for future multiple realm support
  83. ULONG Reserved2; // for future multiple realm support
  84. CHAR Reserved3[SIC_MIN_STR_SIZE]; // for future multiple realm support
  85. } SIC20_NEGOTIATE_MSG, *PSIC20_NEGOTIATE_MSG;
  86. typedef struct _NEGOTIATE_MESSAGE {
  87. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  88. NTLM_MESSAGE_TYPE MessageType;
  89. ULONG NegotiateFlags;
  90. STRING OemDomainName;
  91. STRING OemWorkstationName;
  92. } NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE;
  93. //
  94. // Old version of the message, for old clients
  95. //
  96. typedef struct _OLD_NEGOTIATE_MESSAGE {
  97. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  98. NTLM_MESSAGE_TYPE MessageType;
  99. ULONG NegotiateFlags;
  100. } OLD_NEGOTIATE_MESSAGE, *POLD_NEGOTIATE_MESSAGE;
  101. //
  102. // Opaque message returned from first call to AcceptSecurityContext
  103. //
  104. typedef struct _SIC20_CHALLENGE_MSG {
  105. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  106. NTLM_MESSAGE_TYPE MessageType;
  107. STRING TargetName;
  108. ULONG NegotiateFlags;
  109. UCHAR Challenge[MSV1_0_CHALLENGE_LENGTH];
  110. ULONG ServerContextHandleLower;
  111. ULONG ServerContextHandleUpper;
  112. // Reserved for future Sicily enhancement
  113. ULONG Reserved1; // for future multiple realm support
  114. ULONG Reserved2; // for future multiple realm support
  115. ULONG RealmListSize; // list of comma seperated realms which server has
  116. // ServerRealms consists of multiple Null terminated strings, each
  117. // represent a realm. This list is terminated by 2 Null characters.
  118. // For now, this only has one realm
  119. //
  120. CHAR ServerRealms[SIC_MIN_STR_SIZE];
  121. } SIC20_CHALLENGE_MSG, *PSIC20_CHALLENGE_MSG;
  122. typedef struct _CHALLENGE_MESSAGE {
  123. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  124. NTLM_MESSAGE_TYPE MessageType;
  125. STRING TargetName;
  126. ULONG NegotiateFlags;
  127. UCHAR Challenge[MSV1_0_CHALLENGE_LENGTH];
  128. ULONG ServerContextHandleLower;
  129. ULONG ServerContextHandleUpper;
  130. } CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE;
  131. //
  132. // Old version of the challenge message
  133. //
  134. typedef struct _OLD_CHALLENGE_MESSAGE {
  135. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  136. NTLM_MESSAGE_TYPE MessageType;
  137. STRING TargetName;
  138. ULONG NegotiateFlags;
  139. UCHAR Challenge[MSV1_0_CHALLENGE_LENGTH];
  140. } OLD_CHALLENGE_MESSAGE, *POLD_CHALLENGE_MESSAGE;
  141. //
  142. // Opaque message returned from second call to InitializeSecurityContext
  143. //
  144. typedef struct SIC20_AUTHENTICATE_MSG {
  145. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  146. NTLM_MESSAGE_TYPE MessageType;
  147. STRING LmChallengeResponse;
  148. STRING NtChallengeResponse;
  149. STRING DomainName;
  150. STRING UserName;
  151. STRING Workstation;
  152. STRING Challenge; // This must be the last field for ease of
  153. // backward compatibility
  154. } SIC20_AUTHENTICATE_MSG, *PSIC20_AUTHENTICATE_MSG;
  155. typedef struct _AUTHENTICATE_MESSAGE {
  156. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  157. NTLM_MESSAGE_TYPE MessageType;
  158. STRING LmChallengeResponse;
  159. STRING NtChallengeResponse;
  160. STRING DomainName;
  161. STRING UserName;
  162. STRING Workstation;
  163. } AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE;
  164. //
  165. // Opaque message sent by SSL ISAPI extension which forces the SSPI to
  166. // reuse the supplied credential handle, which was previously created
  167. // through the accept security context API's.
  168. //
  169. typedef struct _REDIRECT_MESSAGE {
  170. UCHAR Signature[sizeof(NTLMSSP_SIGNATURE)];
  171. NTLM_MESSAGE_TYPE MessageType;
  172. BYTE KeyData[4];
  173. CredHandle OriginalHandle;
  174. } REDIRECT_MESSAGE, *PREDIRECT_MESSAGE;
  175. //
  176. // Size of the largest message
  177. // (The largest message is the AUTHENTICATE_MESSAGE)
  178. //
  179. #define DNLEN_SICILY 15
  180. #define NTLMSSP_MAX_MESSAGE_SIZE (sizeof(AUTHENTICATE_MESSAGE) + \
  181. LM_RESPONSE_LENGTH + \
  182. NT_RESPONSE_LENGTH + \
  183. (DNLEN_SICILY + 1) * sizeof(WCHAR) + \
  184. (MAX_PATH + 1) * sizeof(WCHAR) + \
  185. (MAX_PATH + 1) * sizeof(WCHAR))
  186. #ifdef MAC
  187. #define swaplongtype(Value,Type) \
  188. Value = (Type)( ((((long)Value) & 0xFF000000) >> 24) \
  189. | ((((long)Value) & 0x00FF0000) >> 8) \
  190. | ((((long)Value) & 0x0000FF00) << 8) \
  191. | ((((long)Value) & 0x000000FF) << 24))
  192. #else
  193. #define swaplongtype(value,type)
  194. #endif
  195. #ifdef MAC
  196. #define swaplong(Value) \
  197. Value = ( (((Value) & 0xFF000000) >> 24) \
  198. | (((Value) & 0x00FF0000) >> 8) \
  199. | (((Value) & 0x0000FF00) << 8) \
  200. | (((Value) & 0x000000FF) << 24))
  201. #else
  202. #define swaplong(Value)
  203. #endif
  204. #ifdef MAC
  205. #define swapshort(Value) \
  206. Value = ( (((Value) & 0x00FF) << 8) \
  207. | (((Value) & 0xFF00) >> 8))
  208. #else
  209. #define swapshort(Value)
  210. #endif
  211. #endif // ifndef _SICILY_NTLMSSPI_INCLUDED_