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.

370 lines
10 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: kerbtick.h
  7. //
  8. // Contents: Structures for ticket request and creation
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 22-April-1996 Created MikeSw
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __KERBTICK_H__
  18. #define __KERBTICK_H__
  19. //
  20. // Macros used for building tickets
  21. //
  22. #define KERB_ENCRYPT_SIZE(_x_) (sizeof(KERB_ENCRYPTED_DATA) - 1 + (_x_))
  23. //
  24. // Structures used for AP (authentication protocol) exchanges with a server
  25. //
  26. //#define KERB_AP_INTEGRITY 0x80000000 // Integrity Request
  27. //#define KERB_AP_PRIVACY 0x40000000 // Privacy
  28. //#define KERB_AP_THREE_LEG 0x20000000 // Mutual Auth 3-leg
  29. //#define KERB_AP_RETURN_EE 0x10000000 // Return extended error info
  30. //#define KERB_AP_USE_SKEY 0x00000002 // Use session key
  31. //#define KERB_AP_MUTUAL_REQ 0x00000004
  32. //
  33. // Structure used to store GSS checksum
  34. //
  35. typedef struct _KERB_GSS_CHECKSUM {
  36. ULONG BindLength;
  37. ULONG BindHash[4];
  38. ULONG GssFlags;
  39. USHORT Delegation;
  40. USHORT DelegationLength;
  41. UCHAR DelegationInfo[ANYSIZE_ARRAY];
  42. } KERB_GSS_CHECKSUM, *PKERB_GSS_CHECKSUM;
  43. #define GSS_C_DELEG_FLAG 0x01
  44. #define GSS_C_MUTUAL_FLAG 0x02
  45. #define GSS_C_REPLAY_FLAG 0x04
  46. #define GSS_C_SEQUENCE_FLAG 0x08
  47. #define GSS_C_CONF_FLAG 0x10
  48. #define GSS_C_INTEG_FLAG 0x20
  49. #define GSS_C_ANON_FLAG 0x40
  50. #define GSS_C_DCE_STYLE 0x1000
  51. #define GSS_C_IDENTIFY_FLAG 0x2000
  52. #define GSS_C_EXTENDED_ERROR_FLAG 0x4000
  53. #define GSS_CHECKSUM_TYPE 0x8003
  54. #define GSS_CHECKSUM_SIZE 24
  55. // This was added due to sizeof() byte alignment issues on
  56. // the KREB_GSS_CHECKSUM structure.
  57. #define GSS_DELEGATE_CHECKSUM_SIZE 28
  58. //
  59. // KerbGetTgsTicket retry flags
  60. //
  61. #define KERB_MIT_NO_CANONICALIZE_RETRY 0x00000001 // for MIT no canonicalize retry case and usage of host to realm mappings
  62. #define KERB_RETRY_WITH_NEW_TGT 0x00000002
  63. #define KERB_RETRY_DISABLE_S4U 0x00000004 // Turn off S4U
  64. #define KERB_RETRY_NO_S4UMATCH 0x00000008 // cache this SPN as not avail. for S4U
  65. //
  66. // Default flags for use in ticket requests
  67. //
  68. #define KERB_DEFAULT_TICKET_FLAGS (KERB_KDC_OPTIONS_forwardable | \
  69. KERB_KDC_OPTIONS_renewable | \
  70. KERB_KDC_OPTIONS_renewable_ok | \
  71. KERB_KDC_OPTIONS_name_canonicalize )
  72. //
  73. // These flags don't have to be in the TGT in order to be honored. Reg.
  74. // configurable.
  75. //
  76. #define KERB_ADDITIONAL_KDC_OPTIONS (KERB_KDC_OPTIONS_name_canonicalize)
  77. NTSTATUS
  78. KerbGetReferralNames(
  79. IN PKERB_ENCRYPTED_KDC_REPLY KdcReply,
  80. IN PKERB_INTERNAL_NAME OriginalTargetName,
  81. OUT PUNICODE_STRING ReferralRealm
  82. );
  83. NTSTATUS
  84. KerbMITGetMachineDomain(
  85. IN PKERB_INTERNAL_NAME TargetName,
  86. IN OUT PUNICODE_STRING TargetDomainName,
  87. IN OUT PKERB_TICKET_CACHE_ENTRY *TicketGrantingTicket
  88. );
  89. NTSTATUS
  90. KerbGetTgtForService(
  91. IN PKERB_LOGON_SESSION LogonSession,
  92. IN PKERB_CREDENTIAL Credential,
  93. IN OPTIONAL PKERB_CREDMAN_CRED CredManCredentials,
  94. IN OPTIONAL PUNICODE_STRING SuppRealm,
  95. IN PUNICODE_STRING TargetDomain,
  96. IN ULONG TargetFlags,
  97. OUT PKERB_TICKET_CACHE_ENTRY * NewCacheEntry,
  98. OUT PBOOLEAN CrossRealm
  99. );
  100. NTSTATUS
  101. KerbGetTgsTicket(
  102. IN PUNICODE_STRING ClientRealm,
  103. IN PKERB_TICKET_CACHE_ENTRY TicketGrantingTicket,
  104. IN PKERB_INTERNAL_NAME TargetName,
  105. IN ULONG Flags,
  106. IN OPTIONAL ULONG TicketOptions,
  107. IN OPTIONAL ULONG EncryptionType,
  108. IN OPTIONAL PKERB_AUTHORIZATION_DATA AuthorizationData,
  109. IN OPTIONAL PKERB_PA_DATA_LIST PADataList,
  110. IN OPTIONAL PKERB_TGT_REPLY TgtReply,
  111. IN OPTIONAL PKERB_TICKET EvidenceTicket,
  112. IN OPTIONAL PTimeStamp OptionalEndTime,
  113. OUT PKERB_KDC_REPLY * KdcReply,
  114. OUT PKERB_ENCRYPTED_KDC_REPLY * ReplyBody,
  115. OUT PULONG pRetryFlags
  116. );
  117. NTSTATUS
  118. KerbGetServiceTicket(
  119. IN PKERB_LOGON_SESSION LogonSession,
  120. IN PKERB_CREDENTIAL Credential,
  121. IN OPTIONAL PKERB_CREDMAN_CRED CredManCredentials,
  122. IN PKERB_INTERNAL_NAME TargetName,
  123. IN PUNICODE_STRING TargetDomainName,
  124. IN OPTIONAL PKERB_SPN_CACHE_ENTRY SpnCacheEntry,
  125. IN ULONG Flags,
  126. IN OPTIONAL ULONG TicketOptions,
  127. IN OPTIONAL ULONG EncryptionType,
  128. IN OPTIONAL PKERB_ERROR ErrorMessage,
  129. IN OPTIONAL PKERB_AUTHORIZATION_DATA AuthorizationData,
  130. IN OPTIONAL PKERB_TGT_REPLY TgtReply,
  131. OUT PKERB_TICKET_CACHE_ENTRY * NewCacheEntry,
  132. OUT LPGUID pLogonGuid OPTIONAL
  133. );
  134. #define KERB_GET_TICKET_NO_CACHE 0x1
  135. #define KERB_GET_TICKET_NO_CANONICALIZE 0x2
  136. #define KERB_TARGET_DID_ALTNAME_LOOKUP 0x8
  137. #define KERB_TARGET_USED_SPN_CACHE 0x1000
  138. #define KERB_TARGET_UNKNOWN_SPN 0x2000
  139. #define KERB_MIT_REALM_USED 0x4000
  140. #define KERB_TARGET_REFERRAL 0x8000
  141. #define KERB_TARGET_SPN_NO_PROXY 0x10000
  142. BOOL
  143. KerbHaveKeyMaterials(
  144. IN OPTIONAL PKERB_LOGON_SESSION LogonSession,
  145. IN PKERB_PRIMARY_CREDENTIAL PrimaryCred
  146. );
  147. NTSTATUS
  148. KerbBuildApRequest(
  149. IN PKERB_LOGON_SESSION LogonSession,
  150. IN OPTIONAL PKERB_CREDENTIAL Credential,
  151. IN OPTIONAL PKERB_CREDMAN_CRED CredManCredentials,
  152. IN PKERB_TICKET_CACHE_ENTRY TicketCacheEntry,
  153. IN OPTIONAL PKERB_ERROR ErrorMessage,
  154. IN ULONG ContextAttributes,
  155. IN OUT PULONG ContextFlags,
  156. OUT PUCHAR * MarshalledApRequest,
  157. OUT PULONG ApRequestSize,
  158. OUT PULONG Nonce,
  159. OUT OPTIONAL PTimeStamp pAuthenticatorTime,
  160. OUT PKERB_ENCRYPTION_KEY SubSessionKey,
  161. IN PSEC_CHANNEL_BINDINGS pChannelBindings
  162. );
  163. NTSTATUS
  164. KerbBuildNullSessionApRequest(
  165. OUT PUCHAR * MarshalledApRequest,
  166. OUT PULONG ApRequestSize
  167. );
  168. KERBERR
  169. KerbCreateApRequest(
  170. IN PKERB_INTERNAL_NAME ClientName,
  171. IN PUNICODE_STRING ClientRealm,
  172. IN PKERB_ENCRYPTION_KEY SessionKey,
  173. IN PKERB_ENCRYPTION_KEY SubSessionKey,
  174. IN ULONG Nonce,
  175. OUT OPTIONAL PTimeStamp pAuthenticatorTime,
  176. IN PKERB_TICKET ServiceTicket,
  177. IN ULONG ApOptions,
  178. IN OPTIONAL PKERB_CHECKSUM GssChecksum,
  179. IN OPTIONAL PTimeStamp ServerSkewTime,
  180. IN BOOLEAN KdcRequest,
  181. OUT PULONG RequestSize,
  182. OUT PUCHAR * Request
  183. );
  184. NTSTATUS
  185. KerbVerifyApRequest(
  186. IN OPTIONAL PKERB_CONTEXT Context,
  187. IN PUCHAR RequestMessage,
  188. IN ULONG RequestSize,
  189. IN PKERB_LOGON_SESSION LogonSession,
  190. IN PKERB_CREDENTIAL Credential,
  191. IN BOOLEAN UseSuppliedCreds,
  192. IN BOOLEAN CheckForReplay,
  193. OUT PKERB_AP_REQUEST * ApRequest,
  194. OUT PKERB_ENCRYPTED_TICKET * NewTicket,
  195. OUT PKERB_AUTHENTICATOR * NewAuthenticator,
  196. OUT PKERB_ENCRYPTION_KEY SessionKey,
  197. OUT PKERB_ENCRYPTION_KEY TicketKey,
  198. OUT PKERB_ENCRYPTION_KEY ServerKey,
  199. OUT PULONG ContextFlags,
  200. OUT PULONG ContextAttributes,
  201. OUT PKERBERR KerbError,
  202. IN PSEC_CHANNEL_BINDINGS pChannelBindings
  203. );
  204. NTSTATUS
  205. KerbComputeGssBindHash(
  206. IN PSEC_CHANNEL_BINDINGS pChannelBindings,
  207. OUT PUCHAR HashBuffer
  208. );
  209. //
  210. // From credapi.cxx
  211. //
  212. NTSTATUS
  213. KerbCaptureSuppliedCreds(
  214. IN PKERB_LOGON_SESSION LogonSession,
  215. IN OPTIONAL PVOID AuthorizationData,
  216. IN OPTIONAL PUNICODE_STRING PrincipalName,
  217. OUT PKERB_PRIMARY_CREDENTIAL * SuppliedCreds,
  218. OUT PULONG Flags
  219. );
  220. NTSTATUS
  221. KerbBuildApReply(
  222. IN PKERB_AUTHENTICATOR InternalAuthenticator,
  223. IN PKERB_AP_REQUEST Request,
  224. IN ULONG ContextFlags,
  225. IN ULONG ContextAtributes,
  226. IN PKERB_ENCRYPTION_KEY TicketKey,
  227. IN OUT PKERB_ENCRYPTION_KEY SessionKey,
  228. OUT PULONG Nonce,
  229. OUT PUCHAR * NewReply,
  230. OUT PULONG NewReplySize
  231. );
  232. NTSTATUS
  233. KerbBuildThirdLegApReply(
  234. IN PKERB_CONTEXT Context,
  235. IN ULONG ReceiveNonce,
  236. OUT PUCHAR * NewReply,
  237. OUT PULONG NewReplySize
  238. );
  239. BOOLEAN
  240. KerbKerbTimeEqual(
  241. PKERB_TIME pt1,
  242. PKERB_TIME pt2
  243. );
  244. NTSTATUS
  245. KerbVerifyApReply(
  246. IN PKERB_CONTEXT Context,
  247. IN PUCHAR PackedReply,
  248. IN ULONG PackedReplySize,
  249. OUT PULONG ReceiveNonce
  250. );
  251. NTSTATUS
  252. KerbInitTicketHandling(
  253. VOID
  254. );
  255. NTSTATUS
  256. KerbInitGlobalVariables(
  257. VOID
  258. );
  259. VOID
  260. KerbCleanupTicketHandling(
  261. VOID
  262. );
  263. NTSTATUS
  264. KerbMakeSocketCall(
  265. IN PUNICODE_STRING RealmName,
  266. IN OPTIONAL PUNICODE_STRING AccountName,
  267. IN BOOLEAN CallPDC,
  268. IN BOOLEAN UseTcp,
  269. IN BOOLEAN CallKpasswd,
  270. IN PKERB_MESSAGE_BUFFER RequestMessage,
  271. IN PKERB_MESSAGE_BUFFER ReplyMessage,
  272. IN OPTIONAL PKERB_BINDING_CACHE_ENTRY OptionalBindingHandle,
  273. IN ULONG AdditionalFlags,
  274. OUT PBOOLEAN CalledPDC
  275. );
  276. NTSTATUS
  277. KerbHandleTgtRequest(
  278. IN PKERB_LOGON_SESSION LogonSession,
  279. IN PKERB_CREDENTIAL Credential,
  280. IN BOOLEAN UseSuppliedCreds,
  281. IN PUCHAR RequestMessage,
  282. IN ULONG RequestSize,
  283. IN ULONG ContextRequirements,
  284. IN PSecBuffer OutputToken,
  285. IN PLUID LogonId,
  286. OUT PULONG ContextAttributes,
  287. OUT PKERB_CONTEXT * Context,
  288. OUT PTimeStamp ContextLifetime,
  289. OUT PKERBERR ReturnedError
  290. );
  291. NTSTATUS
  292. KerbBuildTgtRequest(
  293. IN PKERB_INTERNAL_NAME TargetName,
  294. IN PUNICODE_STRING TargetRealm,
  295. OUT PULONG ContextAttributes,
  296. OUT PUCHAR * MarshalladTgtRequest,
  297. OUT PULONG TgtRequestSize
  298. );
  299. NTSTATUS
  300. KerbUnpackTgtReply(
  301. IN PKERB_CONTEXT Context,
  302. IN PUCHAR ReplyMessage,
  303. IN ULONG ReplySize,
  304. OUT PKERB_INTERNAL_NAME * TargetName,
  305. OUT PUNICODE_STRING TargetRealm,
  306. OUT PKERB_TGT_REPLY * Reply
  307. );
  308. NTSTATUS
  309. KerbBuildTgtErrorReply(
  310. IN PKERB_LOGON_SESSION LogonSession,
  311. IN PKERB_CREDENTIAL Credentials,
  312. IN BOOLEAN UseSuppliedCreds,
  313. IN OUT PKERB_CONTEXT Context,
  314. OUT PULONG ReplySize,
  315. OUT PBYTE * Reply
  316. );
  317. NTSTATUS
  318. KerbBuildKerbCred(
  319. IN OPTIONAL PKERB_TICKET_CACHE_ENTRY Ticket,
  320. IN PKERB_TICKET_CACHE_ENTRY DelegationTicket,
  321. OUT PUCHAR * MarshalledKerbCred,
  322. OUT PULONG KerbCredSize
  323. );
  324. #endif // __KERBTICK_H__