Leaked source code of windows server 2003
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.

307 lines
9.2 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1992 - 1996
  6. //
  7. // File: kerbdefs.h
  8. //
  9. // Contents: defines for all internal Kerberos lists
  10. //
  11. //
  12. // History: 03-May-1999 ChandanS Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __KERBDEFS_H__
  16. #define __KERBDEFS_H__
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include <safelock.h>
  21. #ifdef __cplusplus
  22. }
  23. #endif
  24. //
  25. // All Kerberos list structures are defined here
  26. //
  27. typedef struct _KERBEROS_LIST {
  28. LIST_ENTRY List;
  29. SAFE_CRITICAL_SECTION Lock;
  30. } KERBEROS_LIST, *PKERBEROS_LIST;
  31. typedef struct _KERBEROS_LIST_ENTRY {
  32. LIST_ENTRY Next;
  33. ULONG ReferenceCount;
  34. } KERBEROS_LIST_ENTRY, *PKERBEROS_LIST_ENTRY;
  35. //
  36. // NOTE: If you add members to this struct, be sure to
  37. // modify KerbDuplicateTicketCacheEntry!!!!
  38. //
  39. typedef struct _KERB_TICKET_CACHE_ENTRY {
  40. KERBEROS_LIST_ENTRY ListEntry;
  41. volatile LONG Linked;
  42. PKERB_INTERNAL_NAME ServiceName;
  43. PKERB_INTERNAL_NAME TargetName;
  44. UNICODE_STRING DomainName;
  45. UNICODE_STRING TargetDomainName;
  46. UNICODE_STRING AltTargetDomainName;
  47. UNICODE_STRING ClientDomainName;
  48. PKERB_INTERNAL_NAME ClientName;
  49. PKERB_INTERNAL_NAME AltClientName;
  50. ULONG TicketFlags;
  51. ULONG CacheFlags;
  52. KERB_ENCRYPTION_KEY SessionKey;
  53. KERB_ENCRYPTION_KEY CredentialKey; // used for pkiint only.
  54. TimeStamp StartTime;
  55. TimeStamp EndTime;
  56. TimeStamp RenewUntil;
  57. KERB_TICKET Ticket;
  58. TimeStamp TimeSkew;
  59. LUID EvidenceLogonId;
  60. void * ScavengerHandle;
  61. #if DBG
  62. LIST_ENTRY GlobalListEntry;
  63. #endif
  64. } KERB_TICKET_CACHE_ENTRY, *PKERB_TICKET_CACHE_ENTRY;
  65. typedef struct _KERB_TICKET_CACHE {
  66. LIST_ENTRY CacheEntries;
  67. TimeStamp LastCleanup;
  68. } KERB_TICKET_CACHE, *PKERB_TICKET_CACHE;
  69. //
  70. // Smartcard flags
  71. //
  72. #define CSP_DATA_INITIALIZED 0x01
  73. #define CSP_DATA_REUSED 0x02
  74. //
  75. // Context flags used to determine pin caching behavior.
  76. //
  77. #define CONTEXT_INITIALIZED_WITH_CRED_MAN_CREDS 0x10
  78. #define CONTEXT_INITIALIZED_WITH_ACH 0x20
  79. typedef struct _KERB_PUBLIC_KEY_CREDENTIALS {
  80. UNICODE_STRING Pin;
  81. UNICODE_STRING AlternateDomainName;
  82. PCCERT_CONTEXT CertContext;
  83. ULONG_PTR KerbHProv;
  84. ULONG InitializationInfo;
  85. ULONG CspDataLength;
  86. BYTE CspData[1];
  87. } KERB_PUBLIC_KEY_CREDENTIALS, *PKERB_PUBLIC_KEY_CREDENTIALS;
  88. typedef struct _KERB_PRIMARY_CREDENTIAL {
  89. UNICODE_STRING UserName;
  90. UNICODE_STRING DomainName;
  91. UNICODE_STRING ClearPassword; // this is only present until a ticket has been obtained.
  92. UNICODE_STRING OldUserName; // original user name in explicit
  93. UNICODE_STRING OldDomainName; // original domain name in explicit cred
  94. NT_OWF_PASSWORD OldHashPassword; // hash of encrypted ClearPassword
  95. PKERB_STORED_CREDENTIAL Passwords;
  96. PKERB_STORED_CREDENTIAL OldPasswords;
  97. KERB_TICKET_CACHE ServerTicketCache;
  98. KERB_TICKET_CACHE S4UTicketCache;
  99. KERB_TICKET_CACHE AuthenticationTicketCache;
  100. PKERB_PUBLIC_KEY_CREDENTIALS PublicKeyCreds;
  101. } KERB_PRIMARY_CREDENTIAL, *PKERB_PRIMARY_CREDENTIAL;
  102. typedef struct _KERB_EXTRA_CRED {
  103. KERBEROS_LIST_ENTRY ListEntry;
  104. volatile LONG Linked;
  105. UNICODE_STRING cName;
  106. UNICODE_STRING cRealm;
  107. PKERB_STORED_CREDENTIAL Passwords;
  108. PKERB_STORED_CREDENTIAL OldPasswords;
  109. } KERB_EXTRA_CRED, *PKERB_EXTRA_CRED;
  110. typedef struct _EXTRA_CRED_LIST {
  111. KERBEROS_LIST CredList;
  112. ULONG Count;
  113. } EXTRA_CRED_LIST, *PEXTRA_CRED_LIST;
  114. typedef struct _KERB_LOGON_SESSION {
  115. KERBEROS_LIST_ENTRY ListEntry;
  116. KERBEROS_LIST CredmanCredentials;
  117. LUID LogonId; // constant
  118. TimeStamp Lifetime;
  119. SAFE_CRITICAL_SECTION Lock;
  120. KERB_PRIMARY_CREDENTIAL PrimaryCredentials;
  121. EXTRA_CRED_LIST ExtraCredentials;
  122. ULONG LogonSessionFlags;
  123. void* TaskHandle;
  124. } KERB_LOGON_SESSION, *PKERB_LOGON_SESSION;
  125. #define KERB_CREDENTIAL_TAG_ACTIVE (ULONG)'AdrC'
  126. #define KERB_CREDENTIAL_TAG_DELETE (ULONG)'DdrC'
  127. typedef struct _KERB_CREDENTIAL {
  128. KERBEROS_LIST_ENTRY ListEntry;
  129. ULONG HandleCount;
  130. LUID LogonId; // constant
  131. TimeStamp Lifetime;
  132. UNICODE_STRING CredentialName;
  133. ULONG CredentialFlags;
  134. ULONG ClientProcess; // constant
  135. PKERB_PRIMARY_CREDENTIAL SuppliedCredentials;
  136. PKERB_AUTHORIZATION_DATA AuthData;
  137. ULONG CredentialTag;
  138. } KERB_CREDENTIAL, *PKERB_CREDENTIAL;
  139. typedef struct _KERB_CREDMAN_CRED {
  140. KERBEROS_LIST_ENTRY ListEntry;
  141. ULONG CredentialFlags;
  142. UNICODE_STRING CredmanUserName; // added since TGT information can overwrite primary credentials...
  143. UNICODE_STRING CredmanDomainName;
  144. PKERB_PRIMARY_CREDENTIAL SuppliedCredentials;
  145. } KERB_CREDMAN_CRED, *PKERB_CREDMAN_CRED;
  146. typedef enum _KERB_CONTEXT_STATE {
  147. IdleState,
  148. TgtRequestSentState,
  149. TgtReplySentState,
  150. ApRequestSentState,
  151. ApReplySentState,
  152. AuthenticatedState,
  153. ErrorMessageSentState,
  154. InvalidState
  155. } KERB_CONTEXT_STATE, *PKERB_CONTEXT_STATE;
  156. #define KERB_CONTEXT_TAG_ACTIVE (ULONG)'AxtC'
  157. #define KERB_CONTEXT_TAG_DELETE (ULONG)'DxtC'
  158. typedef struct _KERB_CONTEXT {
  159. KERBEROS_LIST_ENTRY ListEntry;
  160. TimeStamp Lifetime; // end time/expiration time
  161. TimeStamp RenewTime; // time to renew until
  162. TimeStamp StartTime;
  163. UNICODE_STRING ClientName;
  164. UNICODE_STRING ClientRealm;
  165. UNICODE_STRING ClientDnsRealm;
  166. union {
  167. ULONG ClientProcess;
  168. LSA_SEC_HANDLE LsaContextHandle;
  169. };
  170. LUID LogonId;
  171. HANDLE TokenHandle;
  172. ULONG_PTR CredentialHandle;
  173. KERB_ENCRYPTION_KEY SessionKey;
  174. ULONG Nonce;
  175. ULONG ReceiveNonce;
  176. ULONG ContextFlags;
  177. ULONG ContextAttributes;
  178. ULONG NegotiationInfo;
  179. ULONG EncryptionType;
  180. PSID UserSid;
  181. KERB_CONTEXT_STATE ContextState;
  182. ULONG Retries;
  183. KERB_ENCRYPTION_KEY TicketKey;
  184. PKERB_TICKET_CACHE_ENTRY TicketCacheEntry; // for clients, is ticket to server, for servers, is TGT used in user-to-user
  185. UNICODE_STRING ClientPrincipalName;
  186. UNICODE_STRING ServerPrincipalName;
  187. PKERB_CREDMAN_CRED CredManCredentials;
  188. //
  189. // marshalled target info for DFS/RDR.
  190. //
  191. PBYTE pbMarshalledTargetInfo;
  192. ULONG cbMarshalledTargetInfo;
  193. TimeStamp AuthenticatorTime;
  194. ULONG ContextTag;
  195. } KERB_CONTEXT, *PKERB_CONTEXT;
  196. typedef struct _KERB_PACKED_CONTEXT {
  197. ULONG ContextType ; // Indicates the type of the context
  198. ULONG Pad; // Pad data
  199. TimeStamp Lifetime; // Matches basic context above
  200. TimeStamp RenewTime ;
  201. TimeStamp StartTime;
  202. UNICODE_STRING32 ClientName ;
  203. UNICODE_STRING32 ClientRealm ;
  204. ULONG LsaContextHandle ;
  205. LUID LogonId ;
  206. ULONG TokenHandle ;
  207. ULONG CredentialHandle ;
  208. ULONG SessionKeyType ;
  209. ULONG SessionKeyOffset ;
  210. ULONG SessionKeyLength ;
  211. ULONG Nonce ;
  212. ULONG ReceiveNonce ;
  213. ULONG ContextFlags ;
  214. ULONG ContextAttributes ;
  215. ULONG EncryptionType ;
  216. KERB_CONTEXT_STATE ContextState ;
  217. ULONG Retries ;
  218. ULONG MarshalledTargetInfo; // offset
  219. ULONG MarshalledTargetInfoLength;
  220. } KERB_PACKED_CONTEXT, * PKERB_PACKED_CONTEXT;
  221. typedef struct _KERB_SESSION_KEY_ENTRY {
  222. LIST_ENTRY ListEntry;
  223. KERB_ENCRYPTION_KEY SessionKey;
  224. FILETIME ExpireTime; // time when SessionKey expires
  225. } KERB_SESSION_KEY_ENTRY, * PKERB_SESSION_KEY_ENTRY;
  226. #define KERB_PACKED_CONTEXT_MAP 0
  227. #define KERB_PACKED_CONTEXT_EXPORT 1
  228. //
  229. // The order of this enum is the order in which locks
  230. // must be acquired. Violating this order will result
  231. // in asserts firing in debug builds.
  232. //
  233. // Do not change the order of this enum without first verifying
  234. // thoroughly that the change is safe.
  235. //
  236. typedef enum {
  237. //
  238. // No-dependency locks
  239. //
  240. LS_LIST_LOCK_ENUM = 0, // (LSLS)
  241. LOCAL_LOOPBACK_SKEY_LOCK = 0, // (LLBK)
  242. HOST_2_REALM_LIST_LOCK = 0, // (H2RL)
  243. //
  244. // Locks with dependencies
  245. //
  246. CRED_MGR_LOCK_ENUM = 1, // (CRED)
  247. LOGON_SESSION_LOCK_ENUM, // (LOGO)
  248. CONTEXT_LIST_LOCK_ENUM, // (CLIS) --- LOGO
  249. LS_EXTRACRED_LOCK_ENUM, // (LSXC) --- LOGO
  250. LS_CREDMAN_LOCK_ENUM, // (LSCM) --- LOGO
  251. TICKET_CACHE_LOCK_ENUM, // (TICK) --- CRED LOGO CLIS LSXC LSCM
  252. GLOBAL_RESOURCE_LOCK_ENUM, // (GLOB) --- LOGO
  253. MIT_REALM_LIST_LOCK_ENUM, // (MITR) --- GLOB
  254. BINDING_CACHE_LOCK_ENUM, // (BNDC) --- GLOB
  255. SPN_CACHE_LOCK_ENUM, // (SPNC) --- GLOB
  256. CONTEXT_RESOURCE_LOCK_ENUM, // (CRES) --- TICK LSXC
  257. S4U_CACHE_LOCK_ENUM, // (S4UC) --- TICK
  258. DISABLED_SPNS_LOCK_ENUM, // (DISA) --- TICK
  259. KERB_SKEW_STATE_LOCK_ENUM, // (SKEW) --- TICK
  260. KDC_DATA_LOCK_ENUM, // (KDLK) --- LOGO LSCM
  261. KERB_MAX_LOCK_ENUM,
  262. } KERB_LOCK_ENUM;
  263. #endif // __KERBDEFS_H_