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.

341 lines
8.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: tktutil.hxx
  7. //
  8. // Contents: prototypes for tktutil.cxx
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 05-Mar-94 wader Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __TKTUTIL_HXX__
  18. #define __TKTUTIL_HXX__
  19. #include <kdcsvr.hxx>
  20. #include <pac.hxx>
  21. #include <refer.h>
  22. #include <transit.h>
  23. #include <sockutil.h>
  24. extern "C"
  25. {
  26. #include <ntdsapi.h>
  27. #include <kdcexp.h>
  28. }
  29. //
  30. // Structures
  31. //
  32. #ifdef later
  33. typedef struct _KDC_PA_DATA_CONTEXT {
  34. struct _KDC_PA_DATA_CONTEXT * Next;
  35. ULONG PaDataType;
  36. ULONG ContextSize;
  37. PBYTE Context[ANYSIZE_ARRAY];
  38. } KDC_PA_DATA_CONTEXT, *PKDC_PA_DATA_CONTEXT;
  39. typedef NTSTATUS (*PKDC_PA_DATA_RESPONSE) (
  40. IN OUT PKDC_PA_DATA_CONTEXT * Context
  41. );
  42. typedef NTSTATUS (*PKDC_PA_DATA_CLEANUP) (
  43. IN PKDC_PA_DATA_CONTEXT Context
  44. );
  45. #endif // later
  46. typedef NTSTATUS (*PKDC_PA_DATA_REQUEST) (
  47. IN PKDC_TICKET_INFO ClientTicketInfo,
  48. IN SAMPR_HANDLE UserHandle,
  49. IN PKERB_PA_DATA_LIST PreAuthData,
  50. OUT PKERB_PA_DATA_LIST * OutputPreAuthData,
  51. OUT PBOOLEAN BuildPac,
  52. OUT PULONG Nonce,
  53. OUT PKERB_ENCRYPTION_KEY ReplyEncryptionKey
  54. );
  55. typedef struct _KDC_PA_DATA_HANDLER {
  56. ULONG PaDataType;
  57. PKDC_PA_DATA_REQUEST Request;
  58. } KDC_PA_DATA_HANDLER, *PKDC_PA_DATA_HANDLER;
  59. //
  60. // Flags for Normalize
  61. //
  62. #define KDC_NAME_CLIENT 0x1
  63. #define KDC_NAME_SERVER 0x2
  64. #define KDC_NAME_FOLLOW_REFERRALS 0x4
  65. #define KDC_NAME_INBOUND 0x8 // for trust, indicates name need not be outbound trust only
  66. #define KDC_NAME_CHECK_GC 0x10 // indicates that the client said this name should be canonicalized at the GC
  67. //
  68. // Prototypes.
  69. //
  70. KERBERR
  71. KdcGetTicketInfo(
  72. IN PUNICODE_STRING UserName,
  73. IN ULONG LookupFlags,
  74. IN OPTIONAL PKERB_INTERNAL_NAME PrincipalName,
  75. IN OPTIONAL PKERB_REALM Realm,
  76. OUT PKDC_TICKET_INFO TicketInfo,
  77. OUT PKERB_EXT_ERROR pExtendedError,
  78. OUT OPTIONAL SAMPR_HANDLE * UserHandle,
  79. IN OPTIONAL ULONG WhichFields,
  80. IN OPTIONAL ULONG ExtendedFields,
  81. OUT OPTIONAL PUSER_INTERNAL6_INFORMATION * RetUserInfo,
  82. OUT OPTIONAL PSID_AND_ATTRIBUTES_LIST GroupMembership
  83. );
  84. KERBERR
  85. GetTicketInfo(
  86. IN PUNICODE_STRING pwzName,
  87. IN OPTIONAL PKERB_INTERNAL_NAME PrincipalName,
  88. IN OPTIONAL PKERB_REALM Realm,
  89. IN OUT PKDC_TICKET_INFO ptiInfo,
  90. OUT OPTIONAL SAMPR_HANDLE * UserHandle,
  91. OUT OPTIONAL PUSER_INTERNAL6_INFORMATION * UserInfo,
  92. OUT OPTIONAL PSID_AND_ATTRIBUTES_LIST ReverseMembership
  93. );
  94. VOID
  95. FreeTicketInfo( IN PKDC_TICKET_INFO ptiInfo );
  96. KERBERR
  97. KdcDuplicateCredentials(
  98. OUT PKERB_STORED_CREDENTIAL * NewCredentials,
  99. OUT PULONG CredentialSize,
  100. IN PKERB_STORED_CREDENTIAL OldCredentials,
  101. IN BOOLEAN MarshallKeys
  102. );
  103. KERBERR
  104. BuildReply(
  105. IN OPTIONAL PKDC_TICKET_INFO ClientInfo,
  106. IN ULONG Nonce,
  107. IN PKERB_PRINCIPAL_NAME ServerName,
  108. IN KERB_REALM ServerRealm,
  109. IN OPTIONAL PKERB_HOST_ADDRESSES HostAddresses,
  110. IN PKERB_TICKET Ticket,
  111. OUT PKERB_ENCRYPTED_KDC_REPLY ReplyBody
  112. );
  113. KERBERR
  114. KdcNormalize(
  115. IN PKERB_INTERNAL_NAME PrincipalName,
  116. IN OPTIONAL PUNICODE_STRING PrincipalRealm,
  117. IN OPTIONAL PUNICODE_STRING RequestRealm,
  118. IN ULONG NameFlags,
  119. OUT PBOOLEAN Referral,
  120. OUT PUNICODE_STRING RealmName,
  121. OUT PKDC_TICKET_INFO TicketInfo,
  122. OUT PKERB_EXT_ERROR pExtendedError,
  123. OUT OPTIONAL SAMPR_HANDLE * UserHandle,
  124. IN OPTIONAL ULONG WhichFields,
  125. IN OPTIONAL ULONG ExtendedFields,
  126. OUT OPTIONAL PUSER_INTERNAL6_INFORMATION * UserInfo,
  127. OUT OPTIONAL PSID_AND_ATTRIBUTES_LIST GroupMembership
  128. );
  129. KERBERR
  130. KdcBuildTicketTimesAndFlags(
  131. IN ULONG ClientPolicyFlags,
  132. IN ULONG ServerPolicyFlags,
  133. IN PLARGE_INTEGER DomainTicketLifespan,
  134. IN PLARGE_INTEGER DomainTicketRenewspan,
  135. IN OPTIONAL PLARGE_INTEGER LogoffTime,
  136. IN OPTIONAL PLARGE_INTEGER AccountExpiry,
  137. IN PKERB_KDC_REQUEST_BODY RequestBody,
  138. IN OPTIONAL PKERB_ENCRYPTED_TICKET SourceTicket,
  139. IN OUT PKERB_ENCRYPTED_TICKET Ticket,
  140. IN OUT OPTIONAL PKERB_EXT_ERROR ExtendedError
  141. );
  142. KERBERR
  143. BuildTicketTimesAndFlags(
  144. IN ULONG ulMaxRenew,
  145. IN KERB_TICKET_FLAGS fAllowedFlags,
  146. IN PLARGE_INTEGER ptsMaxRenew,
  147. IN PLARGE_INTEGER ptsMaxLife,
  148. IN PKERB_KDC_REQUEST_BODY RequestBody,
  149. IN OUT PKERB_TICKET Ticket,
  150. IN OUT OPTIONAL PKERB_EXT_ERROR ExtendedError
  151. );
  152. KERBERR
  153. GetPacAndSuppCred(
  154. IN PUSER_INTERNAL6_INFORMATION UserInfo,
  155. IN PSID_AND_ATTRIBUTES_LIST GroupMembership,
  156. IN ULONG SignatureSize,
  157. IN OPTIONAL PKERB_ENCRYPTION_KEY CredentialKey,
  158. IN OPTIONAL PTimeStamp ClientId,
  159. IN OPTIONAL PUNICODE_STRING ClientName,
  160. OUT PPACTYPE * Pac,
  161. OUT PKERB_EXT_ERROR pExtendedError
  162. );
  163. KERBERR
  164. HandleTGSRequest(
  165. IN OPTIONAL SOCKADDR * ClientAddress,
  166. IN PKERB_TGS_REQUEST RequestMessage,
  167. IN PUNICODE_STRING RequestRealm,
  168. OUT PKERB_MESSAGE_BUFFER OutputMessage,
  169. OUT PKERB_EXT_ERROR pExtendedError
  170. );
  171. KERBERR
  172. KdcVerifyKdcRequest(
  173. IN PUCHAR RequestBuffer,
  174. IN ULONG RequestSize,
  175. IN OPTIONAL SOCKADDR * ClientAddress,
  176. IN BOOLEAN IsKdcRequest,
  177. OUT OPTIONAL PKERB_AP_REQUEST * UnmarshalledRequest,
  178. OUT OPTIONAL PKERB_AUTHENTICATOR * UnmarshalledAuthenticator,
  179. OUT PKERB_ENCRYPTED_TICKET *EncryptedTicket,
  180. OUT PKERB_ENCRYPTION_KEY SessionKey,
  181. OUT PKERB_ENCRYPTION_KEY ServerKey,
  182. OUT PKDC_TICKET_INFO ServerTicketInfo,
  183. OUT PBOOLEAN UseSubKey,
  184. OUT PKERB_EXT_ERROR pExtendedError
  185. );
  186. KERBERR
  187. KdcVerifyClientAddress(
  188. IN SOCKADDR * ClientAddress,
  189. IN PKERB_HOST_ADDRESSES Addresses
  190. );
  191. KERBERR
  192. KdcVerifyTgsChecksum(
  193. IN PKERB_KDC_REQUEST_BODY RequestBody,
  194. IN PKERB_ENCRYPTION_KEY Key,
  195. IN PKERB_CHECKSUM OldChecksum
  196. );
  197. NTSTATUS
  198. KdcBuildPasswordList(
  199. IN PUNICODE_STRING Password,
  200. IN PUNICODE_STRING PrincipalName,
  201. IN PUNICODE_STRING DnsDomainName,
  202. IN KERB_ACCOUNT_TYPE AccountType,
  203. IN PKERB_STORED_CREDENTIAL StoredCreds,
  204. IN ULONG StoredCredSize,
  205. IN BOOLEAN MarshallKeys,
  206. IN BOOLEAN IncludeBuiltinTypes,
  207. IN ULONG Flags,
  208. IN KDC_DOMAIN_INFO_DIRECTION Direction,
  209. OUT PKERB_STORED_CREDENTIAL * PasswordList,
  210. OUT PULONG PasswordListSize
  211. );
  212. #if DBG
  213. void
  214. PrintTicket( ULONG ulDebLevel,
  215. char * pszMessage,
  216. PKERB_TICKET pkitTicket );
  217. void
  218. PrintRequest( ULONG ulDebLevel,
  219. PKERB_KDC_REQUEST_BODY pktrRequest );
  220. #else
  221. #define PrintRequest(x,y)
  222. #define PrintTicket(w,x,y)
  223. #define PrintProxyReference(w,x,y)
  224. #define PrintProxyData(w,x,y)
  225. #endif
  226. VOID
  227. KdcFreeKdcReplyBody(
  228. IN PKERB_ENCRYPTED_KDC_REPLY ReplyBody
  229. );
  230. VOID
  231. KdcFreeInternalTicket(
  232. IN PKERB_TICKET Ticket
  233. );
  234. VOID
  235. KdcFreeKdcReply(
  236. IN PKERB_KDC_REPLY Reply
  237. );
  238. KERBERR
  239. KdcGetPacAuthData(
  240. IN PUSER_INTERNAL6_INFORMATION UserInfo,
  241. IN PSID_AND_ATTRIBUTES_LIST GroupMembership,
  242. IN PKERB_ENCRYPTION_KEY ServerKey,
  243. IN PKERB_ENCRYPTION_KEY CredentialKey,
  244. IN BOOLEAN AddResourceGroups,
  245. IN OPTIONAL PKERB_ENCRYPTED_TICKET EncryptedTicket,
  246. IN OPTIONAL PKERB_INTERNAL_NAME S4UClientName,
  247. OUT PKERB_AUTHORIZATION_DATA * PacAuthData,
  248. OUT PKERB_EXT_ERROR pExtendedError
  249. );
  250. KERBERR
  251. KdcVerifyAndResignPac(
  252. IN PKERB_ENCRYPTION_KEY OldKey,
  253. IN PKERB_ENCRYPTION_KEY NewKey,
  254. IN PKDC_TICKET_INFO OldServerInfo,
  255. IN BOOLEAN AddResouceGroups,
  256. IN OUT PKERB_AUTHORIZATION_DATA PacAuthData
  257. );
  258. KERBERR
  259. KdcGetPacFromAuthData(
  260. IN PKERB_AUTHORIZATION_DATA AuthData,
  261. OUT PKERB_IF_RELEVANT_AUTH_DATA *ReturnIfRelevantData,
  262. OUT PKERB_AUTHORIZATION_DATA * Pac
  263. );
  264. KERBERR
  265. KdcInsertPacIntoAuthData(
  266. IN PKERB_AUTHORIZATION_DATA AuthData,
  267. IN PKERB_IF_RELEVANT_AUTH_DATA IfRelevantData,
  268. IN PKERB_AUTHORIZATION_DATA PacAuthData,
  269. OUT PKERB_AUTHORIZATION_DATA * UpdatedAuthData
  270. );
  271. NTSTATUS
  272. EnterApiCall(
  273. VOID
  274. );
  275. VOID
  276. LeaveApiCall(
  277. VOID
  278. );
  279. #endif // __TKTUTIL_HXX__