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.

298 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1991 - 1999 Microsoft Corporation
  3. Module Name:
  4. nlpcache.h
  5. Abstract:
  6. Structures and prototypes for nlpcache.c
  7. Author:
  8. Richard L Firth (rfirth) 17-Mar-1992
  9. Revision History:
  10. Chandana Surlu 21-Jul-96 Stolen from \\kernel\razzle3\src\security\msv1_0\nlpcache.h
  11. --*/
  12. #define CACHE_NAME L"\\Registry\\Machine\\Security\\Cache"
  13. #define CACHE_NAME_SIZE (sizeof(CACHE_NAME) - sizeof(L""))
  14. #define CACHE_TITLE_INDEX 100 // ?
  15. //
  16. // CACHE_PASSWORDS - passwords are stored (in secret storage) as two encrypted
  17. // one way function (OWF) passwords concatenated together. They must be fixed
  18. // length
  19. //
  20. typedef struct _CACHE_PASSWORDS {
  21. USER_INTERNAL1_INFORMATION SecretPasswords;
  22. } CACHE_PASSWORDS, *PCACHE_PASSWORDS;
  23. //
  24. // LOGON_CACHE_ENTRY - this is what we store in the cache. We don't need to
  25. // cache all the fields from the NETLOGON_VALIDATION_SAM_INFO - just the ones
  26. // we can't easily invent.
  27. //
  28. // There is additional data following the end of the structure: There are
  29. // <GroupCount> GROUP_MEMBERSHIP structures, followed by a SID which is the
  30. // LogonDomainId. The rest of the data in the entry is the buffer areas for
  31. // the UNICODE_STRING fields
  32. //
  33. typedef struct _LOGON_CACHE_ENTRY {
  34. USHORT UserNameLength;
  35. USHORT DomainNameLength;
  36. USHORT EffectiveNameLength;
  37. USHORT FullNameLength;
  38. USHORT LogonScriptLength;
  39. USHORT ProfilePathLength;
  40. USHORT HomeDirectoryLength;
  41. USHORT HomeDirectoryDriveLength;
  42. ULONG UserId;
  43. ULONG PrimaryGroupId;
  44. ULONG GroupCount;
  45. USHORT LogonDomainNameLength;
  46. //
  47. // The following fields are present in NT1.0A release and later
  48. // systems.
  49. //
  50. USHORT LogonDomainIdLength; // was Unused1
  51. LARGE_INTEGER Time;
  52. ULONG Revision;
  53. ULONG SidCount; // was Unused2
  54. BOOLEAN Valid;
  55. //
  56. // The following fields are present for NT 3.51 since build 622
  57. //
  58. CHAR Unused[3];
  59. ULONG SidLength;
  60. //
  61. // The following fields have been present (but zero) since NT 3.51.
  62. // We started filling it in in NT 5.0
  63. //
  64. ULONG LogonPackage; // The RPC ID of the package doing the logon.
  65. USHORT DnsDomainNameLength;
  66. USHORT UpnLength;
  67. //
  68. // The following fields were added for NT5.0 build 2053.
  69. //
  70. //
  71. // define a 128bit random key for this cache entry. This is used
  72. // in conjunction with a per-machine LSA secret to derive an encryption
  73. // key used to encrypt CachePasswords & Opaque data.
  74. //
  75. CHAR RandomKey[ 16 ];
  76. CHAR MAC[ 16 ]; // encrypted data integrity check.
  77. //
  78. // store the CACHE_PASSWORDS with the cache entry, encrypted using
  79. // the RandomKey & per-machine LSA secret.
  80. // this improves performance and eliminates problems with storing data
  81. // in 2 locations.
  82. //
  83. // note: data from this point forward is encrypted and protected from
  84. // tampering via HMAC. This includes the data marshalled beyond the
  85. // structure.
  86. //
  87. CACHE_PASSWORDS CachePasswords;
  88. //
  89. // Length of opaque supplemental cache data.
  90. //
  91. ULONG SupplementalCacheDataLength;
  92. //
  93. // offset from LOGON_CACHE_ENTRY to SupplementalCacheData.
  94. //
  95. ULONG SupplementalCacheDataOffset;
  96. //
  97. // Used for special cache properties, e.g. MIT cached logon.
  98. //
  99. ULONG CacheFlags;
  100. //
  101. // LogonServer that satisfied the logon.
  102. //
  103. ULONG LogonServerLength; // was Spare2
  104. //
  105. // spare slots for future data, to potentially avoid revising the structure
  106. //
  107. ULONG Spare3;
  108. ULONG Spare4;
  109. ULONG Spare5;
  110. ULONG Spare6;
  111. } LOGON_CACHE_ENTRY, *PLOGON_CACHE_ENTRY;
  112. //
  113. // pre-NT5 versions of the LOGON_CACHE_ENTRY structure, for sizing and
  114. // field mapping purposes for backwards compatibility.
  115. //
  116. typedef struct _LOGON_CACHE_ENTRY_NT_4_SP4 {
  117. USHORT UserNameLength;
  118. USHORT DomainNameLength;
  119. USHORT EffectiveNameLength;
  120. USHORT FullNameLength;
  121. USHORT LogonScriptLength;
  122. USHORT ProfilePathLength;
  123. USHORT HomeDirectoryLength;
  124. USHORT HomeDirectoryDriveLength;
  125. ULONG UserId;
  126. ULONG PrimaryGroupId;
  127. ULONG GroupCount;
  128. USHORT LogonDomainNameLength;
  129. //
  130. // The following fields are present in NT1.0A release and later
  131. // systems.
  132. //
  133. USHORT LogonDomainIdLength; // was Unused1
  134. LARGE_INTEGER Time;
  135. ULONG Revision;
  136. ULONG SidCount; // was Unused2
  137. BOOLEAN Valid;
  138. //
  139. // The following fields are present for NT 3.51 since build 622
  140. //
  141. CHAR Unused[3];
  142. ULONG SidLength;
  143. //
  144. // The following fields have been present (but zero) since NT 3.51.
  145. // We started filling it in in NT 5.0
  146. //
  147. ULONG LogonPackage; // The RPC ID of the package doing the logon.
  148. USHORT DnsDomainNameLength;
  149. USHORT UpnLength;
  150. } LOGON_CACHE_ENTRY_NT_4_SP4, *PLOGON_CACHE_ENTRY_NT_4_SP4;
  151. #if 0
  152. //
  153. // NT1.0 logon structure. left here for reference only.
  154. //
  155. typedef struct _LOGON_CACHE_ENTRY_1_0 {
  156. USHORT UserNameLength;
  157. USHORT DomainNameLength;
  158. USHORT EffectiveNameLength;
  159. USHORT FullNameLength;
  160. USHORT LogonScriptLength;
  161. USHORT ProfilePathLength;
  162. USHORT HomeDirectoryLength;
  163. USHORT HomeDirectoryDriveLength;
  164. ULONG UserId;
  165. ULONG PrimaryGroupId;
  166. ULONG GroupCount;
  167. USHORT LogonDomainNameLength;
  168. } LOGON_CACHE_ENTRY_1_0, *PLOGON_CACHE_ENTRY_1_0;
  169. #endif
  170. //
  171. // Windows2000 cached logon request structs
  172. // Updated version in NTLMSV1_0.h
  173. //
  174. typedef struct _MSV1_0_CACHE_LOGON_REQUEST_OLD {
  175. MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  176. PVOID LogonInformation;
  177. PVOID ValidationInformation;
  178. } MSV1_0_CACHE_LOGON_REQUEST_OLD, *PMSV1_0_CACHE_LOGON_REQUEST_OLD;
  179. typedef struct _MSV1_0_CACHE_LOGON_REQUEST_W2K {
  180. MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  181. PVOID LogonInformation;
  182. PVOID ValidationInformation;
  183. PVOID SupplementalCacheData;
  184. ULONG SupplementalCacheDataLength;
  185. } MSV1_0_CACHE_LOGON_REQUEST_W2K, *PMSV1_0_CACHE_LOGON_REQUEST_W2K;
  186. //
  187. // net logon cache prototypes
  188. //
  189. NTSTATUS
  190. NlpCacheInitialize(
  191. VOID
  192. );
  193. NTSTATUS
  194. NlpCacheTerminate(
  195. VOID
  196. );
  197. NTSTATUS
  198. NlpAddCacheEntry(
  199. IN PNETLOGON_INTERACTIVE_INFO LogonInfo,
  200. IN PNETLOGON_VALIDATION_SAM_INFO4 AccountInfo,
  201. IN PVOID SupplementalCacheData,
  202. IN ULONG SupplementalCacheDataLength,
  203. IN ULONG CacheFlags
  204. );
  205. NTSTATUS
  206. NlpGetCacheEntry(
  207. IN PNETLOGON_LOGON_IDENTITY_INFO LogonInfo,
  208. OUT PNETLOGON_VALIDATION_SAM_INFO4* AccountInfo,
  209. OUT PCACHE_PASSWORDS Passwords,
  210. OUT PVOID *ppSupplementalCacheData OPTIONAL ,
  211. OUT PULONG SupplementalCacheDataLength OPTIONAL
  212. );
  213. NTSTATUS
  214. NlpDeleteCacheEntry(
  215. IN PNETLOGON_INTERACTIVE_INFO LogonInfo
  216. );
  217. VOID
  218. NlpChangeCachePassword(
  219. IN PUNICODE_STRING DomainName,
  220. IN PUNICODE_STRING UserName,
  221. IN PLM_OWF_PASSWORD LmOwfPassword,
  222. IN PNT_OWF_PASSWORD NtOwfPassword
  223. );
  224. NTSTATUS
  225. NlpComputeSaltedHashedPassword(
  226. OUT PNT_OWF_PASSWORD SaltedOwfPassword,
  227. IN PNT_OWF_PASSWORD OwfPassword,
  228. IN PUNICODE_STRING UserName
  229. );