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.

214 lines
5.2 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1992 - 1996
  6. //
  7. // File: kerblist.h
  8. //
  9. // Contents: types for Kerbers internal lists
  10. //
  11. //
  12. // History: 16-Apr-1996 MikeSw Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __KERBLIST_H__
  16. #define __KERBLIST_H__
  17. //
  18. // Generic list entry structure allowing common code for inserting
  19. // logon sessions, credentials, and contexts.
  20. //
  21. typedef struct _KERBEROS_LIST {
  22. LIST_ENTRY List;
  23. ERESOURCE Lock;
  24. } KERBEROS_LIST, *PKERBEROS_LIST;
  25. typedef struct _KERBEROS_LIST_ENTRY {
  26. LIST_ENTRY Next;
  27. ULONG ReferenceCount;
  28. } KERBEROS_LIST_ENTRY, *PKERBEROS_LIST_ENTRY;
  29. typedef enum _KERB_CONTEXT_STATE {
  30. IdleState,
  31. TgtRequestSentState,
  32. TgtReplySentState,
  33. ApRequestSentState,
  34. ApReplySentState,
  35. AuthenticatedState,
  36. ErrorMessageSentState,
  37. InvalidState
  38. } KERB_CONTEXT_STATE, *PKERB_CONTEXT_STATE;
  39. //
  40. // Guards - this structure is defined in krb5.h
  41. //
  42. #ifndef OSS_krb5
  43. typedef struct KERB_ENCRYPTION_KEY {
  44. int keytype;
  45. struct {
  46. unsigned int length;
  47. unsigned char *value;
  48. } keyvalue;
  49. } KERB_ENCRYPTION_KEY;
  50. #endif
  51. #define KERB_CONTEXT_SIGNATURE 'BREK'
  52. #define KERB_CONTEXT_DELETED_SIGNATURE 'XBRK'
  53. typedef struct _KERB_KERNEL_CONTEXT {
  54. KSEC_LIST_ENTRY List ;
  55. LARGE_INTEGER Lifetime; // end time/expiration time
  56. LARGE_INTEGER RenewTime; // time to renew until
  57. UNICODE_STRING FullName;
  58. LSA_SEC_HANDLE LsaContextHandle;
  59. PACCESS_TOKEN AccessToken;
  60. HANDLE TokenHandle;
  61. KERB_ENCRYPTION_KEY SessionKey;
  62. ULONG Nonce;
  63. ULONG ReceiveNonce;
  64. ULONG ContextFlags;
  65. ULONG ContextAttributes;
  66. ULONG EncryptionType;
  67. PUCHAR pbMarshalledTargetInfo;
  68. ULONG cbMarshalledTargetInfo;
  69. } KERB_KERNEL_CONTEXT, *PKERB_KERNEL_CONTEXT;
  70. typedef struct _KERB_CONTEXT {
  71. KERBEROS_LIST_ENTRY ListEntry;
  72. TimeStamp Lifetime; // end time/expiration time
  73. TimeStamp RenewTime; // time to renew until
  74. TimeStamp StartTime;
  75. UNICODE_STRING ClientName;
  76. UNICODE_STRING ClientRealm;
  77. union {
  78. ULONG ClientProcess;
  79. ULONG LsaContextHandle;
  80. };
  81. LUID LogonId;
  82. HANDLE TokenHandle;
  83. ULONG CredentialHandle;
  84. KERB_ENCRYPTION_KEY SessionKey;
  85. ULONG Nonce;
  86. ULONG ReceiveNonce;
  87. ULONG ContextFlags;
  88. ULONG ContextAttributes;
  89. ULONG EncryptionType;
  90. PSID UserSid;
  91. KERB_CONTEXT_STATE ContextState;
  92. ULONG Retries;
  93. KERB_ENCRYPTION_KEY TicketKey;
  94. PVOID TicketCacheEntry;
  95. //
  96. // marshalled target info for DFS/RDR.
  97. //
  98. PUCHAR pbMarshalledTargetInfo;
  99. ULONG cbMarshalledTargetInfo;
  100. } KERB_CONTEXT, *PKERB_CONTEXT;
  101. typedef struct _KERB_PACKED_CONTEXT {
  102. ULONG ContextType ; // Indicates the type of the context
  103. ULONG Pad; // Pad data
  104. TimeStamp Lifetime; // Matches basic context above
  105. TimeStamp RenewTime ;
  106. TimeStamp StartTime;
  107. UNICODE_STRING32 ClientName ;
  108. UNICODE_STRING32 ClientRealm ;
  109. ULONG LsaContextHandle ;
  110. LUID LogonId ;
  111. ULONG TokenHandle ;
  112. ULONG CredentialHandle ;
  113. ULONG SessionKeyType ;
  114. ULONG SessionKeyOffset ;
  115. ULONG SessionKeyLength ;
  116. ULONG Nonce ;
  117. ULONG ReceiveNonce ;
  118. ULONG ContextFlags ;
  119. ULONG ContextAttributes ;
  120. ULONG EncryptionType ;
  121. KERB_CONTEXT_STATE ContextState ;
  122. ULONG Retries ;
  123. ULONG MarshalledTargetInfo; // offset
  124. ULONG MarshalledTargetInfoLength;
  125. } KERB_PACKED_CONTEXT, * PKERB_PACKED_CONTEXT ;
  126. #define KERB_PACKED_CONTEXT_MAP 0
  127. #define KERB_PACKED_CONTEXT_EXPORT 1
  128. //
  129. // Functions for manipulating Kerberos lists
  130. //
  131. NTSTATUS
  132. KerbInitializeList(
  133. IN PKERBEROS_LIST List
  134. );
  135. VOID
  136. KerbFreeList(
  137. IN PKERBEROS_LIST List
  138. );
  139. VOID
  140. KerbInsertListEntry(
  141. IN PKERBEROS_LIST_ENTRY ListEntry,
  142. IN PKERBEROS_LIST List
  143. );
  144. VOID
  145. KerbReferenceListEntry(
  146. IN PKERBEROS_LIST List,
  147. IN PKERBEROS_LIST_ENTRY ListEntry,
  148. IN BOOLEAN RemoveFromList
  149. );
  150. BOOLEAN
  151. KerbDereferenceListEntry(
  152. IN PKERBEROS_LIST_ENTRY ListEntry,
  153. IN PKERBEROS_LIST List
  154. );
  155. VOID
  156. KerbInitializeListEntry(
  157. IN OUT PKERBEROS_LIST_ENTRY ListEntry
  158. );
  159. VOID
  160. KerbValidateListEx(
  161. IN PKERBEROS_LIST List
  162. );
  163. #if DBG
  164. #define KerbValidateList(_List_) KerbValidateListEx(_List_)
  165. #else
  166. #define KerbValidateList(_List_)
  167. #endif // DBG
  168. #define KerbLockList(_List_) \
  169. { \
  170. KeEnterCriticalRegion(); \
  171. ExAcquireResourceExclusiveLite(&(_List_)->Lock, TRUE ); \
  172. }
  173. #define KerbUnlockList(_List_) \
  174. { \
  175. ExReleaseResourceLite(&(_List_)->Lock); \
  176. KeLeaveCriticalRegion(); \
  177. }
  178. #endif // __KERBLIST_H_