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.

364 lines
9.4 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
  62. #define KERB_RETRY_WITH_NEW_TGT 0x00000002
  63. //
  64. // Default flags for use in ticket requests
  65. //
  66. #define KERB_DEFAULT_TICKET_FLAGS (KERB_KDC_OPTIONS_forwardable | \
  67. KERB_KDC_OPTIONS_renewable | \
  68. KERB_KDC_OPTIONS_renewable_ok | \
  69. KERB_KDC_OPTIONS_name_canonicalize )
  70. //
  71. // These flags don't have to be in the TGT in order to be honored. Reg.
  72. // configurable.
  73. //
  74. #define KERB_ADDITIONAL_KDC_OPTIONS (KERB_KDC_OPTIONS_name_canonicalize)
  75. NTSTATUS
  76. KerbGetReferralNames(
  77. IN PKERB_ENCRYPTED_KDC_REPLY KdcReply,
  78. IN PKERB_INTERNAL_NAME OriginalTargetName,
  79. OUT PUNICODE_STRING ReferralRealm
  80. );
  81. NTSTATUS
  82. KerbMITGetMachineDomain(
  83. IN PKERB_LOGON_SESSION LogonSession,
  84. IN PKERB_INTERNAL_NAME TargetName,
  85. IN OUT PUNICODE_STRING TargetDomainName,
  86. IN OUT PKERB_TICKET_CACHE_ENTRY *TicketGrantingTicket
  87. );
  88. NTSTATUS
  89. KerbGetTgtForService(
  90. IN PKERB_LOGON_SESSION LogonSession,
  91. IN PKERB_CREDENTIAL Credential,
  92. IN OPTIONAL PKERB_CREDMAN_CRED CredManCredentials,
  93. IN OPTIONAL PUNICODE_STRING SuppRealm,
  94. IN PUNICODE_STRING TargetDomain,
  95. IN ULONG TargetFlags,
  96. OUT PKERB_TICKET_CACHE_ENTRY * NewCacheEntry,
  97. OUT PBOOLEAN CrossRealm
  98. );
  99. NTSTATUS
  100. KerbGetTgsTicket(
  101. IN PUNICODE_STRING ClientRealm,
  102. IN PKERB_TICKET_CACHE_ENTRY TicketGrantingTicket,
  103. IN PKERB_INTERNAL_NAME TargetName,
  104. IN ULONG Flags,
  105. IN OPTIONAL ULONG TicketOptions,
  106. IN OPTIONAL ULONG EncryptionType,
  107. IN OPTIONAL PKERB_AUTHORIZATION_DATA AuthorizationData,
  108. IN OPTIONAL PKERB_PA_DATA_LIST PADataList,
  109. IN OPTIONAL PKERB_TGT_REPLY TgtReply,
  110. OUT PKERB_KDC_REPLY * KdcReply,
  111. OUT PKERB_ENCRYPTED_KDC_REPLY * ReplyBody,
  112. OUT PULONG pRetryFlags
  113. );
  114. NTSTATUS
  115. KerbGetServiceTicket(
  116. IN PKERB_LOGON_SESSION LogonSession,
  117. IN PKERB_CREDENTIAL Credential,
  118. IN OPTIONAL PKERB_CREDMAN_CRED CredManCredentials,
  119. IN PKERB_INTERNAL_NAME TargetName,
  120. IN PUNICODE_STRING TargetDomainName,
  121. IN OPTIONAL PKERB_SPN_CACHE_ENTRY SpnCacheEntry,
  122. IN ULONG Flags,
  123. IN OPTIONAL ULONG TicketOptions,
  124. IN OPTIONAL ULONG EncryptionType,
  125. IN OPTIONAL PKERB_ERROR ErrorMessage,
  126. IN OPTIONAL PKERB_AUTHORIZATION_DATA AuthorizationData,
  127. IN OPTIONAL PKERB_TGT_REPLY TgtReply,
  128. OUT PKERB_TICKET_CACHE_ENTRY * NewCacheEntry,
  129. OUT LPGUID pLogonGuid OPTIONAL
  130. );
  131. #define KERB_GET_TICKET_NO_CACHE 0x1
  132. #define KERB_GET_TICKET_NO_CANONICALIZE 0x2
  133. #define KERB_GET_TICKET_S4U 0x4
  134. #define KERB_TARGET_USED_SPN_CACHE 0x1000
  135. #define KERB_TARGET_UNKNOWN_SPN 0x2000
  136. #define KERB_MIT_REALM_USED 0x4000
  137. #define KERB_TARGET_REFERRAL 0x8000
  138. NTSTATUS
  139. KerbBuildApRequest(
  140. IN PKERB_LOGON_SESSION LogonSession,
  141. IN OPTIONAL PKERB_CREDENTIAL Credential,
  142. IN OPTIONAL PKERB_CREDMAN_CRED CredManCredentials,
  143. IN PKERB_TICKET_CACHE_ENTRY TicketCacheEntry,
  144. IN OPTIONAL PKERB_ERROR ErrorMessage,
  145. IN ULONG ContextAttributes,
  146. IN OUT PULONG ContextFlags,
  147. OUT PUCHAR * MarshalledApRequest,
  148. OUT PULONG ApRequestSize,
  149. OUT PULONG Nonce,
  150. OUT PKERB_ENCRYPTION_KEY SubSessionKey,
  151. IN PSEC_CHANNEL_BINDINGS pChannelBindings
  152. );
  153. NTSTATUS
  154. KerbBuildNullSessionApRequest(
  155. OUT PUCHAR * MarshalledApRequest,
  156. OUT PULONG ApRequestSize
  157. );
  158. NTSTATUS
  159. KerbVerifyApRequest(
  160. IN OPTIONAL PKERB_CONTEXT Context,
  161. IN PUCHAR RequestMessage,
  162. IN ULONG RequestSize,
  163. IN PKERB_LOGON_SESSION LogonSession,
  164. IN PKERB_CREDENTIAL Credential,
  165. IN BOOLEAN UseSuppliedCreds,
  166. IN BOOLEAN CheckForReplay,
  167. OUT PKERB_AP_REQUEST * ApRequest,
  168. OUT PKERB_ENCRYPTED_TICKET * NewTicket,
  169. OUT PKERB_AUTHENTICATOR * NewAuthenticator,
  170. OUT PKERB_ENCRYPTION_KEY SessionKey,
  171. OUT PKERB_ENCRYPTION_KEY TicketKey,
  172. OUT PKERB_ENCRYPTION_KEY ServerKey,
  173. OUT PULONG ContextFlags,
  174. OUT PULONG ContextAttributes,
  175. OUT PKERBERR KerbError,
  176. IN PSEC_CHANNEL_BINDINGS pChannelBindings
  177. );
  178. NTSTATUS
  179. KerbComputeGssBindHash(
  180. IN PSEC_CHANNEL_BINDINGS pChannelBindings,
  181. OUT PUCHAR HashBuffer
  182. );
  183. //
  184. // From credapi.cxx
  185. //
  186. NTSTATUS
  187. KerbCaptureSuppliedCreds(
  188. IN PKERB_LOGON_SESSION LogonSession,
  189. IN OPTIONAL PVOID AuthorizationData,
  190. IN OPTIONAL PUNICODE_STRING PrincipalName,
  191. OUT PKERB_PRIMARY_CREDENTIAL * SuppliedCreds,
  192. OUT PULONG Flags
  193. );
  194. NTSTATUS
  195. KerbBuildApReply(
  196. IN PKERB_AUTHENTICATOR InternalAuthenticator,
  197. IN PKERB_AP_REQUEST Request,
  198. IN ULONG ContextFlags,
  199. IN ULONG ContextAtributes,
  200. IN PKERB_ENCRYPTION_KEY TicketKey,
  201. IN OUT PKERB_ENCRYPTION_KEY SessionKey,
  202. OUT PULONG Nonce,
  203. OUT PUCHAR * NewReply,
  204. OUT PULONG NewReplySize
  205. );
  206. NTSTATUS
  207. KerbBuildThirdLegApReply(
  208. IN PKERB_CONTEXT Context,
  209. IN ULONG ReceiveNonce,
  210. OUT PUCHAR * NewReply,
  211. OUT PULONG NewReplySize
  212. );
  213. NTSTATUS
  214. KerbVerifyApReply(
  215. IN PKERB_CONTEXT Context,
  216. IN PUCHAR PackedReply,
  217. IN ULONG PackedReplySize,
  218. OUT PULONG ReceiveNonce
  219. );
  220. NTSTATUS
  221. KerbInitTicketHandling(
  222. VOID
  223. );
  224. VOID
  225. KerbCleanupTicketHandling(
  226. VOID
  227. );
  228. NTSTATUS
  229. KerbMakeSocketCall(
  230. IN PUNICODE_STRING RealmName,
  231. IN OPTIONAL PUNICODE_STRING AccountName,
  232. IN BOOLEAN CallPDC,
  233. IN BOOLEAN UseTcp,
  234. IN BOOLEAN CallKpasswd,
  235. IN PKERB_MESSAGE_BUFFER RequestMessage,
  236. IN PKERB_MESSAGE_BUFFER ReplyMessage,
  237. IN OPTIONAL PKERB_BINDING_CACHE_ENTRY OptionalBindingHandle,
  238. IN ULONG AdditionalFlags,
  239. OUT PBOOLEAN CalledPDC
  240. );
  241. NTSTATUS
  242. KerbRenewTicket(
  243. IN PKERB_LOGON_SESSION LogonSession,
  244. IN OPTIONAL PKERB_CREDENTIAL Credentials,
  245. IN OPTIONAL PKERB_PRIMARY_CREDENTIAL CredManCredentials,
  246. IN PKERB_TICKET_CACHE_ENTRY Ticket,
  247. IN BOOLEAN IsTgt,
  248. OUT PKERB_TICKET_CACHE_ENTRY *NewTicket
  249. );
  250. NTSTATUS
  251. KerbRefreshPrimaryTgt(
  252. IN PKERB_LOGON_SESSION LogonSession,
  253. IN OPTIONAL PKERB_CREDENTIAL Credentials,
  254. IN OPTIONAL PKERB_CREDMAN_CRED CredManCredentials,
  255. IN OPTIONAL PUNICODE_STRING SuppRealm,
  256. IN OPTIONAL PKERB_TICKET_CACHE_ENTRY OldTgt
  257. );
  258. NTSTATUS
  259. KerbHandleTgtRequest(
  260. IN PKERB_LOGON_SESSION LogonSession,
  261. IN PKERB_CREDENTIAL Credential,
  262. IN BOOLEAN UseSuppliedCreds,
  263. IN PUCHAR RequestMessage,
  264. IN ULONG RequestSize,
  265. IN ULONG ContextRequirements,
  266. IN PSecBuffer OutputToken,
  267. IN PLUID LogonId,
  268. OUT PULONG ContextAttributes,
  269. OUT PKERB_CONTEXT * Context,
  270. OUT PTimeStamp ContextLifetime,
  271. OUT PKERBERR ReturnedError
  272. );
  273. NTSTATUS
  274. KerbBuildTgtRequest(
  275. IN PKERB_INTERNAL_NAME TargetName,
  276. IN PUNICODE_STRING TargetRealm,
  277. OUT PULONG ContextAttributes,
  278. OUT PUCHAR * MarshalladTgtRequest,
  279. OUT PULONG TgtRequestSize
  280. );
  281. NTSTATUS
  282. KerbUnpackTgtReply(
  283. IN PKERB_CONTEXT Context,
  284. IN PUCHAR ReplyMessage,
  285. IN ULONG ReplySize,
  286. OUT PKERB_INTERNAL_NAME * TargetName,
  287. OUT PUNICODE_STRING TargetRealm,
  288. OUT PKERB_TGT_REPLY * Reply
  289. );
  290. NTSTATUS
  291. KerbBuildTgtErrorReply(
  292. IN PKERB_LOGON_SESSION LogonSession,
  293. IN PKERB_CREDENTIAL Credentials,
  294. IN BOOLEAN UseSuppliedCreds,
  295. IN OUT PKERB_CONTEXT Context,
  296. OUT PULONG ReplySize,
  297. OUT PBYTE * Reply
  298. );
  299. NTSTATUS
  300. KerbBuildKerbCred(
  301. IN OPTIONAL PKERB_TICKET_CACHE_ENTRY Ticket,
  302. IN PKERB_TICKET_CACHE_ENTRY DelegationTicket,
  303. OUT PUCHAR * MarshalledKerbCred,
  304. OUT PULONG KerbCredSize
  305. );
  306. #endif // __KERBTICK_H__