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.

1807 lines
42 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // File: kerbcomm.h
  4. //
  5. // Contents: prototypes for common kerberos routines
  6. //
  7. //
  8. // History: 15-May-1996 Created MikeSw
  9. //
  10. //------------------------------------------------------------------------
  11. #ifndef _KERBCOMM_H_
  12. #define _KERBCOMM_H_
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif // __cplusplus
  17. #include <rpc.h>
  18. #include <rpcndr.h>
  19. #ifndef WIN32_CHICAGO
  20. #include <ntsam.h>
  21. #endif // WIN32_CHICAGO
  22. #include <windef.h>
  23. #include <stdio.h>
  24. #include <limits.h>
  25. #include <winbase.h>
  26. #include <krb5.h>
  27. #include <cryptdll.h>
  28. #include <align.h>
  29. #ifdef __cplusplus
  30. }
  31. #endif // _cplusplus
  32. #include <krb5p.h>
  33. #include <kerberr.h>
  34. #include <exterr.h>
  35. #include <kerbcred.h>
  36. #ifndef WIN32_CHICAGO
  37. // SECURITY_WIN32 is already defined
  38. #include <security.h>
  39. #endif // WIN32_CHICAGO
  40. //
  41. // HACK HACK HACK on xp sp1, we can not have STATUS_USER2USER_REQUIRED in ntstatus.mc!
  42. //
  43. //
  44. // MessageId: STATUS_USER2USER_REQUIRED
  45. //
  46. // MessageText:
  47. //
  48. // Kerberos sub-protocol User2User is required.
  49. //
  50. #define STATUS_USER2USER_REQUIRED ((NTSTATUS)0xC0000408L)
  51. //////////////////////////////////////////////////////////////////////////
  52. //
  53. // Definitions (for lack of a better place)
  54. //
  55. //////////////////////////////////////////////////////////////////////////
  56. //
  57. // Message types
  58. //
  59. #define KRB_AS_REQ 10 // Request for initial authentication
  60. #define KRB_AS_REP 11 // Response to KRB_AS_REQ request
  61. #define KRB_TGS_REQ 12 // Request for authentication based on TGT
  62. #define KRB_TGS_REP 13 // Response to KRB_TGS_REQ request
  63. #define KRB_AP_REQ 14 // application request to server
  64. #define KRB_AP_REP 15 // Response to KRB_AP_REQ_MUTUAL
  65. #define KRB_TGT_REQ 16 // Request for TGT for user-to-user
  66. #define KRB_TGT_REP 17 // Reply to TGT request
  67. #define KRB_SAFE 20 // Safe (checksummed) application message
  68. #define KRB_PRIV 21 // Private (encrypted) application message
  69. #define KRB_CRED 22 // Private (encrypted) message to forward
  70. // credentials
  71. #define KRB_ERROR 30 // Error response
  72. //
  73. // Pre-auth data types
  74. #define KRB5_PADATA_NONE 0
  75. #define KRB5_PADATA_AP_REQ 1
  76. #define KRB5_PADATA_TGS_REQ KRB5_PADATA_AP_REQ
  77. #define KRB5_PADATA_ENC_TIMESTAMP 2
  78. #define KRB5_PADATA_PW_SALT 3
  79. #define KRB5_PADATA_ENC_UNIX_TIME 5 /* timestamp encrypted in key */
  80. #define KRB5_PADATA_ENC_SANDIA_SECURID 6 /* SecurId passcode */
  81. #define KRB5_PADATA_SESAME 7 /* Sesame project */
  82. #define KRB5_PADATA_OSF_DCE 8 /* OSF DCE */
  83. #define KRB5_CYBERSAFE_SECUREID 9 /* Cybersafe */
  84. #define KRB5_PADATA_AFS3_SALT 10 /* Cygnus */
  85. #define KRB5_PADATA_ETYPE_INFO 11 /* Etype info for preauth */
  86. #define KRB5_PADATA_SAM_CHALLENGE 12 /* draft challenge system */
  87. #define KRB5_PADATA_SAM_RESPONSE 13 /* draft challenge system response */
  88. #define KRB5_PADATA_PK_AS_REQ 14 /* pkinit */
  89. #define KRB5_PADATA_PK_AS_REP 15 /* pkinit */
  90. #define KRB5_PADATA_PK_AS_SIGN 16 /* pkinit */
  91. #define KRB5_PADATA_PK_KEY_REQ 17 /* pkinit */
  92. #define KRB5_PADATA_PK_KEY_REP 18 /* pkinit */
  93. #define KRB5_PADATA_REFERRAL_INFO 20 /* referral names for canonicalization */
  94. #define KRB5_PADATA_S4U 21
  95. #define KRB5_PADATA_PAC_REQUEST 128 /* allow client do request or ignore PAC */
  96. //
  97. // Authorization data types
  98. //
  99. #define KERB_AUTH_OSF_DCE 64
  100. #define KERB_AUTH_SESAME 65
  101. //
  102. // NT authorization data type definitions
  103. //
  104. #define KERB_AUTH_DATA_PAC 128 // entry id for a PAC in authorization data
  105. #define KERB_AUTH_PROXY_ANNOTATION 139 // entry id for a proxy logon annotation string
  106. #define KERB_AUTH_DATA_IF_RELEVANT 1 // entry id for optional auth data
  107. #define KERB_AUTH_DATA_KDC_ISSUED 4 // entry id for data generated & signed by KDC
  108. #define KERB_AUTH_DATA_TOKEN_RESTRICTIONS 141 // entry id for token restrictions
  109. //
  110. // Transited realm compression types:
  111. //
  112. #define DOMAIN_X500_COMPRESS 1
  113. //
  114. // Certificate types for PKINIT
  115. //
  116. #define KERB_CERTIFICATE_TYPE_X509 1
  117. #define KERB_CERTIFICATE_TYPE_PGP 2
  118. //
  119. // Signature & seal types used by PKINIT
  120. //
  121. #define KERB_PKINIT_SIGNATURE_ALG CALG_MD5
  122. #define KERB_PKINIT_EXPORT_SEAL_OID szOID_RSA_RC2CBC
  123. #define KERB_PKINIT_EXPORT_SEAL_ETYPE KERB_ETYPE_RC2_CBC_ENV
  124. #define KERB_PKINIT_SEAL_ETYPE KERB_ETYPE_DES_EDE3_CBC_ENV
  125. #define KERB_PKINIT_SEAL_OID szOID_RSA_DES_EDE3_CBC
  126. #define KERB_PKINIT_SIGNATURE_OID szOID_RSA_MD5RSA
  127. #define KERB_PKINIT_KDC_CERT_TYPE szOID_PKIX_KP_SERVER_AUTH
  128. #ifdef szOID_KP_SMARTCARD_LOGON
  129. #define KERB_PKINIT_CLIENT_CERT_TYPE szOID_KP_SMARTCARD_LOGON
  130. #else
  131. #define KERB_PKINIT_CLIENT_CERT_TYPE "1.3.6.1.4.1.311.20.2.2"
  132. #endif
  133. //
  134. // Transport information
  135. //
  136. #define KERB_KDC_PORT 88
  137. #define KERB_KPASSWD_PORT 464
  138. //
  139. // KDC service principal
  140. //
  141. #define KDC_PRINCIPAL_NAME L"krbtgt"
  142. #define KDC_PRINCIPAL_NAME_A "krbtgt"
  143. #define KERB_HOST_STRING_A "host"
  144. #define KERB_HOST_STRING L"host"
  145. #define KERB_KPASSWD_FIRST_NAME L"kadmin"
  146. #define KERB_KPASSWD_SECOND_NAME L"changepw"
  147. //
  148. // address types - corresponds to GSS types
  149. //
  150. #define KERB_ADDRTYPE_UNSPEC 0x0
  151. #define KERB_ADDRTYPE_LOCAL 0x1
  152. #define KERB_ADDRTYPE_INET 0x2
  153. #define KERB_ADDRTYPE_IMPLINK 0x3
  154. #define KERB_ADDRTYPE_PUP 0x4
  155. #define KERB_ADDRTYPE_CHAOS 0x5
  156. #define KERB_ADDRTYPE_NS 0x6
  157. #define KERB_ADDRTYPE_NBS 0x7
  158. #define KERB_ADDRTYPE_ECMA 0x8
  159. #define KERB_ADDRTYPE_DATAKIT 0x9
  160. #define KERB_ADDRTYPE_CCITT 0xA
  161. #define KERB_ADDRTYPE_SNA 0xB
  162. #define KERB_ADDRTYPE_DECnet 0xC
  163. #define KERB_ADDRTYPE_DLI 0xD
  164. #define KERB_ADDRTYPE_LAT 0xE
  165. #define KERB_ADDRTYPE_HYLINK 0xF
  166. #define KERB_ADDRTYPE_APPLETALK 0x10
  167. #define KERB_ADDRTYPE_BSC 0x11
  168. #define KERB_ADDRTYPE_DSS 0x12
  169. #define KERB_ADDRTYPE_OSI 0x13
  170. #define KERB_ADDRTYPE_NETBIOS 0x14
  171. #define KERB_ADDRTYPE_X25 0x15
  172. //
  173. // Misc. Flags
  174. //
  175. #define KERB_EXPORT_KEY_FLAG 0x20000000
  176. //
  177. // SALT flags for encryption, from rfc1510 update 3des enctype
  178. //
  179. #define KERB_ENC_TIMESTAMP_SALT 1
  180. #define KERB_TICKET_SALT 2
  181. #define KERB_AS_REP_SALT 3
  182. #define KERB_TGS_REQ_SESSKEY_SALT 4
  183. #define KERB_TGS_REQ_SUBKEY_SALT 5
  184. #define KERB_TGS_REQ_AP_REQ_AUTH_CKSUM_SALT 6
  185. #define KERB_TGS_REQ_AP_REQ_AUTH_SALT 7
  186. #define KERB_TGS_REP_SALT 8
  187. #define KERB_TGS_REP_SUBKEY_SALT 9
  188. #define KERB_AP_REQ_AUTH_CKSUM_SALT 10
  189. #define KERB_AP_REQ_AUTH_SALT 11
  190. #define KERB_AP_REP_SALT 12
  191. #define KERB_PRIV_SALT 13
  192. #define KERB_CRED_SALT 14
  193. #define KERB_SAFE_SALT 15
  194. #define KERB_NON_KERB_SALT 16
  195. #define KERB_NON_KERB_CKSUM_SALT 17
  196. #define KERB_KERB_ERROR_SALT 18
  197. #define KERB_KDC_ISSUED_CKSUM_SALT 19
  198. #define KERB_MANDATORY_TKT_EXT_CKSUM_SALT 20
  199. #define KERB_AUTH_DATA_TKT_EXT_CKSUM_SALT 21
  200. //
  201. // Types for AP error data
  202. //
  203. #define KERB_AP_ERR_TYPE_NTSTATUS 1
  204. #define KERB_AP_ERR_TYPE_SKEW_RECOVERY 2
  205. //
  206. // Types for extended errors
  207. //
  208. #define KERB_ERR_TYPE_EXTENDED 3
  209. #define TD_MUST_USE_USER2USER -128
  210. #define TD_EXTENDED_ERROR -129
  211. //
  212. // PKINIT method errors
  213. //
  214. #define KERB_PKINIT_UNSPEC_ERROR 0 // not specified
  215. #define KERB_PKINIT_BAD_PUBLIC_KEY 1 // cannot verify public key
  216. #define KERB_PKINIT_INVALID_CERT 2 // invalid certificate
  217. #define KERB_PKINIT_REVOKED_CERT 3 // revoked certificate
  218. #define KERB_PKINIT_INVALID_KDC_NAME 4 // invalid KDC name
  219. #define KERB_PKINIT_CLIENT_NAME_MISMATCH 5 // client name mismatch
  220. //
  221. // Flag bit defines for use with the LogonRestrictionsFlag parameter
  222. // passed to the KerbCheckLogonRestrictions function
  223. //
  224. #define KDC_RESTRICT_PKINIT_USED 1
  225. #define KDC_RESTRICT_IGNORE_PW_EXPIRATION 2
  226. //
  227. // HACK for MAX_UNICODE_STRING, as KerbDuplicateString & others add a NULL
  228. // terminator when doing the duplication
  229. //
  230. #define KERB_MAX_UNICODE_STRING (UNICODE_STRING_MAX_BYTES - sizeof(WCHAR))
  231. #define KERB_MAX_STRING (UNICODE_STRING_MAX_BYTES - sizeof(CHAR))
  232. //////////////////////////////////////////////////////////////////////////
  233. //
  234. // Structures
  235. //
  236. //////////////////////////////////////////////////////////////////////////
  237. typedef struct _KERB_PREAUTH_DATA {
  238. ULONG Flags;
  239. } KERB_PREAUTH_DATA, *PKERB_PREAUTH_DATA;
  240. #define KERBFLAG_LOGON 0x1
  241. #define KERBFLAG_INTERACTIVE 0x2
  242. //
  243. // KDC-Kerberos interaction
  244. //
  245. #define KDC_START_EVENT L"\\Security\\KdcStartEvent"
  246. #define KERB_MAX_CRYPTO_SYSTEMS 20
  247. #define KERB_MAX_CRYPTO_SYSTEMS_SLOWBUFF 100
  248. #define KERB_DEFAULT_AP_REQ_CSUM KERB_CHECKSUM_MD5
  249. #define KERB_DEFAULT_PREAUTH_TYPE 0
  250. //
  251. // Registry parameters
  252. //
  253. #define KERB_PARAMETER_PATH L"System\\CurrentControlSet\\Control\\Lsa\\Kerberos"
  254. #define KERB_PARAMETER_SKEWTIME L"SkewTime"
  255. #define KERB_PARAMETER_MAX_UDP_PACKET L"MaxPacketSize"
  256. #define KERB_PARAMETER_START_TIME L"StartupTime"
  257. #define KERB_PARAMETER_KDC_CALL_TIMEOUT L"KdcWaitTime"
  258. #define KERB_PARAMETER_KDC_BACKOFF_TIME L"KdcBackoffTime"
  259. #define KERB_PARAMETER_KDC_SEND_RETRIES L"KdcSendRetries"
  260. #define KERB_PARAMETER_USE_SID_CACHE L"UseSidCache"
  261. #define KERB_PARAMETER_LOG_LEVEL L"LogLevel"
  262. #define KERB_PARAMETER_DEFAULT_ETYPE L"DefaultEncryptionType"
  263. #define KERB_PARAMETER_FAR_KDC_TIMEOUT L"FarKdcTimeout"
  264. #define KERB_PARAMETER_NEAR_KDC_TIMEOUT L"NearKdcTimeout"
  265. #define KERB_PARAMETER_STRONG_ENC_DG L"StronglyEncryptDatagram"
  266. #define KERB_PARAMETER_MAX_REFERRAL_COUNT L"MaxReferralCount"
  267. #define KERB_PARAMETER_MAX_TOKEN_SIZE L"MaxTokenSize"
  268. #define KERB_PARAMETER_SPN_CACHE_TIMEOUT L"SpnCacheTimeout"
  269. #define KERB_PARAMETER_RETRY_PDC L"RetryPDC"
  270. #define KERB_PARAMETER_REQUEST_OPTIONS L"RequestOptions"
  271. #define KERB_PARAMETER_CLIENT_IP_ADDRESSES L"ClientIpAddresses"
  272. #define KERB_PARAMETER_TGT_RENEWAL_INTERVAL L"TgtRenewalInterval"
  273. //
  274. // Registry defaults
  275. //
  276. #define KERB_DEFAULT_LOGLEVEL 0
  277. #define KERB_DEFAULT_USE_SIDCACHE FALSE
  278. #define KERB_DEFAULT_USE_STRONG_ENC_DG FALSE
  279. #define KERB_DEFAULT_CLIENT_IP_ADDRESSES 0
  280. #define KERB_DEFAULT_TGT_RENEWAL_INTERVAL ( 10 * 60 - 5 )
  281. //
  282. // These are arbitrary sizes for max request and responses sizes for datagram
  283. // requests.
  284. //
  285. #define KERB_MAX_KDC_RESPONSE_SIZE 4000
  286. #define KERB_MAX_KDC_REQUEST_SIZE 4000
  287. #define KERB_MAX_DATAGRAM_SIZE 2000
  288. #define KERB_MAX_RETRIES 3
  289. #define KERB_MAX_REFERRAL_COUNT 10
  290. //
  291. // timeout values in minutes
  292. //
  293. #define KERB_BINDING_FAR_DC_TIMEOUT 10
  294. #define KERB_BINDING_NEAR_DC_TIMEOUT 30
  295. #define KERB_SPN_CACHE_TIMEOUT 15
  296. #define KERB_DEFAULT_SKEWTIME 5
  297. //
  298. // Network service session timer callback frequency
  299. //
  300. #define KERB_SKLIST_CALLBACK_FEQ 10
  301. //
  302. // timeout values in seconds
  303. //
  304. #define KERB_KDC_CALL_TIMEOUT 5
  305. #define KERB_KDC_CALL_TIMEOUT_BACKOFF 5
  306. #define KERB_KDC_WAIT_TIME 120
  307. //
  308. // BER encoding values
  309. //
  310. #define KERB_BER_APPLICATION_TAG 0xc0
  311. #define KERB_BER_APPLICATION_MASK 0x1f
  312. #define KERB_TGS_REQ_TAG 12
  313. #define KERB_AS_REQ_TAG 10
  314. #define KERB_TGS_REP_TAG 13
  315. #define KERB_AS_REP_TAG 11
  316. #define KERB_ERROR_TAG 30
  317. //
  318. // Common types
  319. //
  320. typedef struct _KERB_MESSAGE_BUFFER {
  321. ULONG BufferSize;
  322. PUCHAR Buffer;
  323. } KERB_MESSAGE_BUFFER, *PKERB_MESSAGE_BUFFER;
  324. typedef enum _KERB_ACCOUNT_TYPE {
  325. UserAccount,
  326. MachineAccount,
  327. DomainTrustAccount,
  328. UnknownAccount
  329. } KERB_ACCOUNT_TYPE, *PKERB_ACCOUNT_TYPE;
  330. //
  331. // This is the maximum number of elements in a KERB_INTERNAL_NAME
  332. //
  333. #define MAX_NAME_ELEMENTS 20
  334. typedef struct _KERB_INTERNAL_NAME {
  335. SHORT NameType;
  336. USHORT NameCount;
  337. UNICODE_STRING Names[ANYSIZE_ARRAY];
  338. } KERB_INTERNAL_NAME, *PKERB_INTERNAL_NAME;
  339. //
  340. // Prototypes
  341. //
  342. #ifdef __cplusplus
  343. class CAuthenticatorList;
  344. KERBERR NTAPI
  345. KerbCheckTicket(
  346. IN PKERB_TICKET PackedTicket,
  347. IN PKERB_ENCRYPTED_DATA EncryptedAuthenticator,
  348. IN PKERB_ENCRYPTION_KEY pkKey,
  349. IN OUT CAuthenticatorList * AuthenticatorList,
  350. IN PTimeStamp SkewTime,
  351. IN ULONG ServiceNameCount,
  352. IN OPTIONAL PUNICODE_STRING ServiceName,
  353. IN OPTIONAL PUNICODE_STRING ServiceRealm,
  354. IN BOOLEAN CheckForReplay,
  355. IN BOOLEAN KdcRequest,
  356. OUT PKERB_ENCRYPTED_TICKET * EncryptTicket,
  357. OUT PKERB_AUTHENTICATOR * Authenticator,
  358. OUT PKERB_ENCRYPTION_KEY pkSessionKey,
  359. OUT OPTIONAL PKERB_ENCRYPTION_KEY pkTicketKey,
  360. OUT PBOOLEAN UseSubKey
  361. );
  362. extern "C" {
  363. #endif // __cplusplus
  364. KERBERR
  365. KerbVerifyTicket(
  366. IN PKERB_TICKET PackedTicket,
  367. IN ULONG NameCount,
  368. IN OPTIONAL PUNICODE_STRING ServiceNames,
  369. IN OPTIONAL PUNICODE_STRING ServiceRealm,
  370. IN PKERB_ENCRYPTION_KEY ServiceKey,
  371. IN OPTIONAL PTimeStamp SkewTime,
  372. OUT PKERB_ENCRYPTED_TICKET * DecryptedTicket
  373. );
  374. KERBERR NTAPI
  375. KerbPackTicket(
  376. IN PKERB_TICKET InternalTicket,
  377. IN PKERB_ENCRYPTION_KEY pkKey,
  378. IN ULONG EncryptionType,
  379. OUT PKERB_TICKET PackedTicket
  380. );
  381. KERBERR NTAPI
  382. KerbUnpackTicket(
  383. IN PKERB_TICKET PackedTicket,
  384. IN PKERB_ENCRYPTION_KEY pkKey,
  385. OUT PKERB_ENCRYPTED_TICKET * InternalTicket
  386. );
  387. // VOID NTAPI
  388. // KerbFreeTicket(
  389. // IN PKERB_ENCRYPTED_TICKET Ticket
  390. // );
  391. #define KerbFreeTicket( Ticket ) \
  392. KerbFreeData( \
  393. KERB_ENCRYPTED_TICKET_PDU, \
  394. (Ticket) \
  395. )
  396. KERBERR NTAPI
  397. KerbDuplicateTicket(
  398. OUT PKERB_TICKET DestinationTicket,
  399. IN PKERB_TICKET SourceTicket
  400. );
  401. VOID
  402. KerbFreeDuplicatedTicket(
  403. IN PKERB_TICKET Ticket
  404. );
  405. VOID
  406. CheckForOutsideStringToKey();
  407. KERBERR NTAPI
  408. KerbHashPassword(
  409. IN PUNICODE_STRING Password,
  410. IN ULONG EncryptionType,
  411. OUT PKERB_ENCRYPTION_KEY Key
  412. );
  413. KERBERR NTAPI
  414. KerbHashPasswordEx(
  415. IN PUNICODE_STRING Password,
  416. IN PUNICODE_STRING PrincipalName,
  417. IN ULONG EncryptionType,
  418. OUT PKERB_ENCRYPTION_KEY Key
  419. );
  420. KERBERR NTAPI
  421. KerbMakeKey(
  422. IN ULONG EncryptionType,
  423. OUT PKERB_ENCRYPTION_KEY NewKey
  424. );
  425. BOOLEAN
  426. KerbIsKeyExportable(
  427. IN PKERB_ENCRYPTION_KEY Key
  428. );
  429. KERBERR
  430. KerbMakeExportableKey(
  431. IN ULONG KeyType,
  432. OUT PKERB_ENCRYPTION_KEY NewKey
  433. );
  434. KERBERR NTAPI
  435. KerbCreateKeyFromBuffer(
  436. OUT PKERB_ENCRYPTION_KEY NewKey,
  437. IN PUCHAR Buffer,
  438. IN ULONG BufferSize,
  439. IN ULONG EncryptionType
  440. );
  441. KERBERR NTAPI
  442. KerbDuplicateKey(
  443. OUT PKERB_ENCRYPTION_KEY NewKey,
  444. IN PKERB_ENCRYPTION_KEY Key
  445. );
  446. VOID
  447. KerbFreeKey(
  448. IN PKERB_ENCRYPTION_KEY Key
  449. );
  450. PKERB_ENCRYPTION_KEY
  451. KerbGetKeyFromList(
  452. IN PKERB_STORED_CREDENTIAL Passwords,
  453. IN ULONG EncryptionType
  454. );
  455. KERBERR
  456. KerbFindCommonCryptSystem(
  457. IN PKERB_CRYPT_LIST CryptList,
  458. IN PKERB_STORED_CREDENTIAL Passwords,
  459. IN OPTIONAL PKERB_STORED_CREDENTIAL MorePasswords,
  460. OUT PULONG CommonCryptSystem,
  461. OUT PKERB_ENCRYPTION_KEY * Key
  462. );
  463. KERBERR NTAPI
  464. KerbRandomFill(
  465. IN OUT PUCHAR pbBuffer,
  466. IN ULONG cbBuffer
  467. );
  468. KERBERR NTAPI
  469. KerbCreateAuthenticator(
  470. IN PKERB_ENCRYPTION_KEY pkKey,
  471. IN ULONG EncryptionType,
  472. IN ULONG SequenceNumber,
  473. IN PUNICODE_STRING ClientName,
  474. IN PUNICODE_STRING ClientRealm,
  475. IN PTimeStamp ptsTime,
  476. IN PKERB_ENCRYPTION_KEY pkSubKey,
  477. IN OPTIONAL PKERB_CHECKSUM GssChecksum,
  478. IN BOOLEAN KdcRequest,
  479. OUT PKERB_ENCRYPTED_DATA Authenticator
  480. );
  481. KERBERR NTAPI
  482. KerbUnpackAuthenticator(
  483. IN PKERB_ENCRYPTION_KEY Key,
  484. IN PKERB_ENCRYPTED_DATA EncryptedAuthenticator,
  485. IN BOOLEAN KdcRequest,
  486. OUT PKERB_AUTHENTICATOR * Authenticator
  487. );
  488. // VOID NTAPI
  489. // KerbFreeAuthenticator(
  490. // IN PKERB_AUTHENTICATOR Authenticator
  491. // );
  492. #define KerbFreeAuthenticator( Authenticator ) \
  493. KerbFreeData( \
  494. KERB_AUTHENTICATOR_PDU, \
  495. (Authenticator) \
  496. )
  497. KERBERR NTAPI
  498. KerbPackKdcReplyBody(
  499. IN PKERB_ENCRYPTED_KDC_REPLY ReplyBody,
  500. IN PKERB_ENCRYPTION_KEY Key,
  501. IN ULONG EncryptionType,
  502. IN ULONG Pdu,
  503. OUT PKERB_ENCRYPTED_DATA EncryptedReply
  504. );
  505. KERBERR NTAPI
  506. KerbUnpackKdcReplyBody(
  507. IN PKERB_ENCRYPTED_DATA EncryptedReplyBody,
  508. IN PKERB_ENCRYPTION_KEY Key,
  509. IN ULONG Pdu,
  510. OUT PKERB_ENCRYPTED_KDC_REPLY * ReplyBody
  511. );
  512. KERBERR NTAPI
  513. KerbPackData(
  514. IN PVOID Data,
  515. IN ULONG PduValue,
  516. OUT PULONG DataSize,
  517. OUT PUCHAR * MarshalledData
  518. );
  519. KERBERR NTAPI
  520. KerbUnpackData(
  521. IN PUCHAR Data,
  522. IN ULONG DataSize,
  523. IN ULONG PduValue,
  524. OUT PVOID * DecodedData
  525. );
  526. VOID
  527. KerbFreeData(
  528. IN ULONG PduValue,
  529. IN PVOID Data
  530. );
  531. // KERBERR NTAPI
  532. // KerbPackAsReply(
  533. // IN PKERB_KDC_REPLY ReplyMessage,
  534. // OUT PULONG ReplySize,
  535. // OUT PUCHAR * MarshalledReply
  536. // );
  537. #define KerbPackAsReply( ReplyMessage, ReplySize, MarshalledReply ) \
  538. KerbPackData( \
  539. (PVOID) (ReplyMessage), \
  540. KERB_AS_REPLY_PDU, \
  541. (ReplySize), \
  542. (MarshalledReply) \
  543. )
  544. // KERBERR NTAPI
  545. // KerbUnpackAsReply(
  546. // IN PUCHAR ReplyMessage,
  547. // IN ULONG ReplySize,
  548. // OUT PKERB_KDC_REPLY * Reply
  549. // );
  550. #define KerbUnpackAsReply( ReplyMessage, ReplySize, Reply ) \
  551. KerbUnpackData( \
  552. (ReplyMessage), \
  553. (ReplySize), \
  554. KERB_AS_REPLY_PDU, \
  555. (PVOID *) (Reply) \
  556. )
  557. // VOID
  558. // KerbFreeAsReply(
  559. // IN PKERB_KDC_REPLY Request
  560. // );
  561. #define KerbFreeAsReply( Request) \
  562. KerbFreeData( \
  563. KERB_AS_REPLY_PDU, \
  564. (PVOID) (Request) \
  565. )
  566. // KERBERR NTAPI
  567. // KerbPackTgsReply(
  568. // IN PKERB_KDC_REPLY ReplyMessage,
  569. // OUT PULONG ReplySize,
  570. // OUT PUCHAR * MarshalledReply
  571. // );
  572. #define KerbPackTgsReply( ReplyMessage, ReplySize, MarshalledReply ) \
  573. KerbPackData( \
  574. (PVOID) (ReplyMessage), \
  575. KERB_TGS_REPLY_PDU, \
  576. (ReplySize), \
  577. (MarshalledReply) \
  578. )
  579. // KERBERR NTAPI
  580. // KerbUnpackTgsReply(
  581. // IN PUCHAR ReplyMessage,
  582. // IN ULONG ReplySize,
  583. // OUT PKERB_KDC_REPLY * Reply
  584. // );
  585. #define KerbUnpackTgsReply( ReplyMessage, ReplySize, Reply ) \
  586. KerbUnpackData( \
  587. (ReplyMessage), \
  588. (ReplySize), \
  589. KERB_TGS_REPLY_PDU, \
  590. (PVOID *) (Reply) \
  591. )
  592. // VOID
  593. // KerbFreeTgsReply(
  594. // IN PKERB_KDC_REPLY Request
  595. // );
  596. #define KerbFreeTgsReply( Request) \
  597. KerbFreeData( \
  598. KERB_TGS_REPLY_PDU, \
  599. (PVOID) (Request) \
  600. )
  601. // VOID
  602. // KerbFreeKdcReplyBody(
  603. // IN PKERB_ENCRYPTED_KDC_REPLY Request
  604. // );
  605. #define KerbFreeKdcReplyBody( Request) \
  606. KerbFreeData( \
  607. KERB_ENCRYPTED_TGS_REPLY_PDU, \
  608. (PVOID) (Request) \
  609. )
  610. // KERBERR NTAPI
  611. // KerbPackAsRequest(
  612. // IN PKERB_KDC_REQUEST RequestMessage,
  613. // OUT PULONG RequestSize,
  614. // OUT PUCHAR * MarshalledRequest
  615. // );
  616. #define KerbPackAsRequest( RequestMessage, RequestSize, MarshalledRequest )\
  617. KerbPackData( \
  618. (PVOID) (RequestMessage), \
  619. KERB_AS_REQUEST_PDU, \
  620. (RequestSize), \
  621. (MarshalledRequest) \
  622. )
  623. // KERBERR NTAPI
  624. // KerbUnpackAsRequest(
  625. // IN PUCHAR RequestMessage,
  626. // IN ULONG RequestSize,
  627. // OUT PKERB_KDC_REQUEST * Request
  628. // );
  629. #define KerbUnpackAsRequest( RequestMessage, RequestSize, Request ) \
  630. KerbUnpackData( \
  631. (RequestMessage), \
  632. (RequestSize), \
  633. KERB_AS_REQUEST_PDU, \
  634. (PVOID *) (Request) \
  635. )
  636. // VOID
  637. // KerbFreeAsRequest(
  638. // IN PKERB_KDC_REQUEST Request
  639. // );
  640. #define KerbFreeAsRequest( Request) \
  641. KerbFreeData( \
  642. KERB_TGS_REQUEST_PDU, \
  643. (PVOID) (Request) \
  644. )
  645. // KERBERR NTAPI
  646. // KerbPackTgsRequest(
  647. // IN PKERB_KDC_REQUEST RequestMessage,
  648. // OUT PULONG RequestSize,
  649. // OUT PUCHAR * MarshalledRequest
  650. // );
  651. #define KerbPackTgsRequest( RequestMessage, RequestSize, MarshalledRequest )\
  652. KerbPackData( \
  653. (PVOID) (RequestMessage), \
  654. KERB_TGS_REQUEST_PDU, \
  655. (RequestSize), \
  656. (MarshalledRequest) \
  657. )
  658. // KERBERR NTAPI
  659. // KerbUnpackTgsRequest(
  660. // IN PUCHAR RequestMessage,
  661. // IN ULONG RequestSize,
  662. // OUT PKERB_KDC_REQUEST * Request
  663. // );
  664. #define KerbUnpackTgsRequest( RequestMessage, RequestSize, Request ) \
  665. KerbUnpackData( \
  666. (RequestMessage), \
  667. (RequestSize), \
  668. KERB_TGS_REQUEST_PDU, \
  669. (PVOID *) (Request) \
  670. )
  671. // VOID
  672. // KerbFreeTgsRequest(
  673. // IN PKERB_KDC_REQUEST Request
  674. // );
  675. #define KerbFreeTgsRequest( Request) \
  676. KerbFreeData( \
  677. KERB_TGS_REQUEST_PDU, \
  678. (PVOID) (Request) \
  679. )
  680. // KERBERR NTAPI
  681. // KerbPackEncryptedData(
  682. // IN PKERB_ENCRYPTED_DATA EncryptedData,
  683. // OUT PULONG DataSize,
  684. // OUT PUCHAR * MarshalledData
  685. // );
  686. #define KerbPackEncryptedData( EncryptedData, DataSize, MarshalledData ) \
  687. KerbPackData( \
  688. (PVOID) (EncryptedData), \
  689. KERB_ENCRYPTED_DATA_PDU, \
  690. (DataSize), \
  691. (PUCHAR *) (MarshalledData) \
  692. )
  693. // KERBERR NTAPI
  694. // KerbUnpackEncryptedData(
  695. // IN PUCHAR EncryptedData,
  696. // IN ULONG DataSize,
  697. // OUT PKERB_ENCRYPTED_DATA * Data
  698. // );
  699. #define KerbUnpackEncryptedData( EncryptedData,DataSize,Data ) \
  700. KerbUnpackData( \
  701. (EncryptedData), \
  702. (DataSize), \
  703. KERB_ENCRYPTED_DATA_PDU, \
  704. (PVOID *) (Data) \
  705. )
  706. // VOID
  707. // KerbFreeEncryptedData(
  708. // IN PKERB_ENCRYPTED_DATA EncryptedData
  709. // );
  710. #define KerbFreeEncryptedData( EncryptedData) \
  711. KerbFreeData( \
  712. KERB_ENCRYPTED_DATA_PDU, \
  713. (PVOID) (EncryptedData) \
  714. )
  715. #ifdef notdef
  716. // KERBERR NTAPI
  717. // KerbPackAuthData(
  718. // IN PKERB_AUTHORIZATION_DATA AuthData,
  719. // OUT PULONG AuthDataSize,
  720. // OUT PUCHAR * MarshalledAuthData
  721. // );
  722. #define KerbPackAuthData( AuthData, AuthDataSize, MarshalledAuthData ) \
  723. KerbPackData( \
  724. (PVOID) (AuthData), \
  725. KERB_AUTHORIZATION_DATA_PDU, \
  726. (AuthDataSize), \
  727. (MarshalledAuthData) \
  728. )
  729. // KERBERR NTAPI
  730. // KerbUnpackAuthData(
  731. // IN PUCHAR PackedAuthData,
  732. // IN ULONG AuthDataSize,
  733. // OUT PKERB_AUTHORIZATION_DATA * AuthData
  734. // );
  735. #define KerbUnpackAuthData( PackedAuthData, AuthDataSize, AuthData ) \
  736. KerbUnpackData( \
  737. (PackedAuthData), \
  738. (AuthDataSize), \
  739. KERB_AUTHORIZATION_DATA_PDU, \
  740. (PVOID *) (AuthData) \
  741. )
  742. // VOID
  743. // KerbFreeAuthData(
  744. // IN PKERB_AUTH_DATA AuthData
  745. // );
  746. #define KerbFreeAuthData( AuthData) \
  747. KerbFreeData( \
  748. KERB_AUTHORIZATION_DATA_PDU, \
  749. (PVOID) (AuthData) \
  750. )
  751. #endif // notdef
  752. VOID
  753. KerbFreeAuthData(
  754. IN PKERB_AUTHORIZATION_DATA AuthData
  755. );
  756. // KERBERR NTAPI
  757. // KerbPackApRequest(
  758. // IN PKERB_AP_REQUEST ApRequestMessage,
  759. // OUT PULONG ApRequestSize,
  760. // OUT PUCHAR * MarshalledApRequest
  761. // );
  762. #define KerbPackApRequest( ApRequestMessage, ApRequestSize, MarshalledApRequest ) \
  763. KerbPackData( \
  764. (PVOID) (ApRequestMessage), \
  765. KERB_AP_REQUEST_PDU, \
  766. (ApRequestSize), \
  767. (MarshalledApRequest) \
  768. )
  769. // KERBERR NTAPI
  770. // KerbUnpackApRequest(
  771. // IN PUCHAR ApRequestMessage,
  772. // IN ULONG ApRequestSize,
  773. // OUT PKERB_AP_REQUEST * ApRequest
  774. // );
  775. #define KerbUnpackApRequest( ApRequestMessage,ApRequestSize, ApRequest) \
  776. KerbUnpackData( \
  777. (ApRequestMessage), \
  778. (ApRequestSize), \
  779. KERB_AP_REQUEST_PDU, \
  780. (PVOID *) (ApRequest) \
  781. )
  782. // VOID
  783. // KerbFreeApRequest(
  784. // IN PKERB_AP_REQUEST Request
  785. // );
  786. #define KerbFreeApRequest( Request) \
  787. KerbFreeData( \
  788. KERB_AP_REQUEST_PDU, \
  789. (PVOID) (Request) \
  790. )
  791. // KERBERR NTAPI
  792. // KerbPackApReply(
  793. // IN PKERB_AP_REPLY ApReplyMessage,
  794. // OUT PULONG ApReplySize,
  795. // OUT PUCHAR * MarshalledApReply
  796. // );
  797. #define KerbPackApReply( ApReplyMessage, ApReplySize, MarshalledApReply ) \
  798. KerbPackData( \
  799. (PVOID) (ApReplyMessage), \
  800. KERB_AP_REPLY_PDU, \
  801. (ApReplySize), \
  802. (MarshalledApReply) \
  803. )
  804. // KERBERR NTAPI
  805. // KerbUnpackApReply(
  806. // IN PUCHAR ApReplyMessage,
  807. // IN ULONG ApReplySize,
  808. // OUT PKERB_AP_REPLY * ApReply
  809. // );
  810. #define KerbUnpackApReply( ApReplyMessage,ApReplySize, ApReply) \
  811. KerbUnpackData( \
  812. (ApReplyMessage), \
  813. (ApReplySize), \
  814. KERB_AP_REPLY_PDU, \
  815. (PVOID *) (ApReply) \
  816. )
  817. // VOID
  818. // KerbFreeApReply(
  819. // IN PKERB_AP_REPLY Reply
  820. // );
  821. #define KerbFreeApReply( Reply) \
  822. KerbFreeData( \
  823. KERB_AP_REPLY_PDU, \
  824. (PVOID) (Reply) \
  825. )
  826. // KERBERR NTAPI
  827. // KerbPackApReplyBody(
  828. // IN PKERB_ENCRYPTED_AP_REPLY ApReplyBodyMessage,
  829. // OUT PULONG ApReplyBodySize,
  830. // OUT PUCHAR * MarshalledApReplyBody
  831. // );
  832. #define KerbPackApReplyBody( ApReplyBodyMessage, ApReplyBodySize, MarshalledApReplyBody ) \
  833. KerbPackData( \
  834. (PVOID) (ApReplyBodyMessage), \
  835. KERB_ENCRYPTED_AP_REPLY_PDU, \
  836. (ApReplyBodySize), \
  837. (MarshalledApReplyBody) \
  838. )
  839. // KERBERR NTAPI
  840. // KerbUnpackApReplyBody(
  841. // IN PUCHAR ApReplyBodyMessage,
  842. // IN ULONG ApReplyBodySize,
  843. // OUT PKERB_ENCRYPTED_AP_REPLY * ApReplyBody
  844. // );
  845. #define KerbUnpackApReplyBody( ApReplyBodyMessage,ApReplyBodySize, ApReplyBody) \
  846. KerbUnpackData( \
  847. (ApReplyBodyMessage), \
  848. (ApReplyBodySize), \
  849. KERB_ENCRYPTED_AP_REPLY_PDU, \
  850. (PVOID *) (ApReplyBody) \
  851. )
  852. // VOID
  853. // KerbFreeApReplyBody(
  854. // IN PKERB_ENCRYPTED_AP_REPLY ReplyBody
  855. // );
  856. #define KerbFreeApReplyBody( ReplyBody) \
  857. KerbFreeData( \
  858. KERB_ENCRYPTED_AP_REPLY_PDU, \
  859. (PVOID) (ReplyBody) \
  860. )
  861. // KERBERR NTAPI
  862. // KerbUnmarshallTicket(
  863. // IN PUCHAR TicketMessage,
  864. // IN ULONG TicketSize,
  865. // OUT PKERB_ENCRYPTED_TICKET * Ticket
  866. // );
  867. #define KerbUnmarshallTicket( TicketMessage, TicketSize, Ticket ) \
  868. KerbUnpackData( \
  869. (TicketMessage), \
  870. (TicketSize), \
  871. KERB_ENCRYPTED_TICKET_PDU, \
  872. (PVOID *) (Ticket) \
  873. )
  874. // KERBERR NTAPI
  875. // KerbPackEncryptedCred(
  876. // IN PKERB_ENCRYPTED_CRED EncryptedCred,
  877. // OUT PULONG CredSize,
  878. // OUT PUCHAR * MarshalledCred
  879. // );
  880. #define KerbPackEncryptedCred( EncryptedCred, CredSize, MarshalledCred ) \
  881. KerbPackData( \
  882. (PVOID) (EncryptedCred), \
  883. KERB_ENCRYPTED_CRED_PDU, \
  884. (CredSize), \
  885. (MarshalledCred) \
  886. )
  887. // KERBERR NTAPI
  888. // KerbUnpackEncryptedCred(
  889. // IN PUCHAR EncryptedCred,
  890. // IN ULONG CredSize,
  891. // OUT PKERB_ENCRYPTED_CRED * Cred
  892. // );
  893. #define KerbUnpackEncryptedCred( EncryptedCred,CredSize,Cred ) \
  894. KerbUnpackData( \
  895. (EncryptedCred), \
  896. (CredSize), \
  897. KERB_ENCRYPTED_CRED_PDU, \
  898. (PVOID *) (Cred) \
  899. )
  900. // VOID
  901. // KerbFreeEncryptedCred(
  902. // IN PKERB_ENCRYPTED_CRED EncryptedCred
  903. // );
  904. #define KerbFreeEncryptedCred( EncryptedCred) \
  905. KerbFreeData( \
  906. KERB_ENCRYPTED_CRED_PDU, \
  907. (PVOID) (EncryptedCred) \
  908. )
  909. // KERBERR NTAPI
  910. // KerbPackKerbCred(
  911. // IN PKERB_CRED KerbCred,
  912. // OUT PULONG KerbCredSize,
  913. // OUT PUCHAR * MarshalledKerbCred
  914. // );
  915. #define KerbPackKerbCred( KerbCred, KerbCredSize, MarshalledKerbCred ) \
  916. KerbPackData( \
  917. (PVOID) (KerbCred), \
  918. KERB_CRED_PDU, \
  919. (KerbCredSize), \
  920. (MarshalledKerbCred) \
  921. )
  922. // KERBERR NTAPI
  923. // KerbUnpackKerbCred(
  924. // IN PUCHAR MarshalledKerbCred,
  925. // IN ULONG KerbCredSize,
  926. // OUT PKERB_CRED * KerbCred
  927. // );
  928. #define KerbUnpackKerbCred( MarshalledKerbCred,KerbCredSize,KerbCred ) \
  929. KerbUnpackData( \
  930. (MarshalledKerbCred), \
  931. (KerbCredSize), \
  932. KERB_CRED_PDU, \
  933. (PVOID *) (KerbCred) \
  934. )
  935. // VOID
  936. // KerbFreeKerbCred(
  937. // IN PKERB_CRED KerbCred
  938. // );
  939. #define KerbFreeKerbCred( KerbCred) \
  940. KerbFreeData( \
  941. KERB_CRED_PDU, \
  942. (PVOID) (KerbCred) \
  943. )
  944. // KERBERR NTAPI
  945. // KerbPackKerbError(
  946. // IN PKERB_ERROR ErrorMessage,
  947. // OUT PULONG ErrorSize,
  948. // OUT PUCHAR * MarshalledError
  949. // );
  950. #define KerbPackKerbError( ErrorMessage, ErrorSize, MarshalledError ) \
  951. KerbPackData( \
  952. (PVOID) (ErrorMessage), \
  953. KERB_ERROR_PDU, \
  954. (ErrorSize), \
  955. (MarshalledError) \
  956. )
  957. // KERBERR NTAPI
  958. // KerbUnpackKerbError(
  959. // IN PUCHAR ErrorMessage,
  960. // IN ULONG ErrorSize,
  961. // OUT PKERB_ERROR * Error
  962. // );
  963. #define KerbUnpackKerbError( ErrorMessage, ErrorSize, Error ) \
  964. KerbUnpackData( \
  965. (ErrorMessage), \
  966. (ErrorSize), \
  967. KERB_ERROR_PDU, \
  968. (PVOID *) (Error) \
  969. )
  970. // VOID
  971. // KerbFreeKerbError(
  972. // IN PKERB_ERROR Request
  973. // );
  974. #define KerbFreeKerbError( Error ) \
  975. KerbFreeData( \
  976. KERB_ERROR_PDU, \
  977. (PVOID) (Error) \
  978. )
  979. // KERBERR NTAPI
  980. // KerbPackEncryptedTime(
  981. // IN PKERB_ENCRYPTED_TIMESTAMP EncryptedTimeMessage,
  982. // OUT PULONG EncryptedTimeSize,
  983. // OUT PUCHAR * MarshalledEncryptedTime
  984. // );
  985. #define KerbPackEncryptedTime( EncryptedTimeMessage, EncryptedTimeSize, MarshalledEncryptedTime ) \
  986. KerbPackData( \
  987. (PVOID) (EncryptedTimeMessage), \
  988. KERB_ENCRYPTED_TIMESTAMP_PDU, \
  989. (EncryptedTimeSize), \
  990. (MarshalledEncryptedTime) \
  991. )
  992. // KERBERR NTAPI
  993. // KerbUnpackEncryptedTime(
  994. // IN PUCHAR EncryptedTimeMessage,
  995. // IN ULONG EncryptedTimeSize,
  996. // OUT PKERB_ENCRYPTED_TIMESTAMP * EncryptedTime
  997. // );
  998. #define KerbUnpackEncryptedTime( EncryptedTimeMessage, EncryptedTimeSize, EncryptedTime ) \
  999. KerbUnpackData( \
  1000. (EncryptedTimeMessage), \
  1001. (EncryptedTimeSize), \
  1002. KERB_ENCRYPTED_TIMESTAMP_PDU, \
  1003. (PVOID *) (EncryptedTime) \
  1004. )
  1005. // VOID
  1006. // KerbFreeEncryptedTime(
  1007. // IN PKERB_ENCRYPTED_TIMESTAMP EncryptedTime
  1008. // );
  1009. #define KerbFreeEncryptedTime( EncryptedTime ) \
  1010. KerbFreeData( \
  1011. KERB_ENCRYPTED_TIMESTAMP_PDU, \
  1012. (PVOID) (EncryptedTime) \
  1013. )
  1014. KERBERR
  1015. KerbAllocateEncryptionBuffer(
  1016. IN ULONG EncryptionType,
  1017. IN ULONG BufferSize,
  1018. OUT PUINT EncryptionBufferSize,
  1019. OUT PBYTE * EncryptionBuffer
  1020. );
  1021. KERBERR
  1022. KerbAllocateEncryptionBufferWrapper(
  1023. IN ULONG EncryptionType,
  1024. IN ULONG BufferSize,
  1025. OUT unsigned long * EncryptionBufferSize,
  1026. OUT PBYTE * EncryptionBuffer
  1027. );
  1028. KERBERR NTAPI
  1029. KerbEncryptData(
  1030. OUT PKERB_ENCRYPTED_DATA EncryptedData,
  1031. IN ULONG DataSize,
  1032. IN PUCHAR Data,
  1033. IN ULONG Algorithm,
  1034. IN PKERB_ENCRYPTION_KEY Key
  1035. );
  1036. KERBERR NTAPI
  1037. KerbDecryptData(
  1038. IN PKERB_ENCRYPTED_DATA EncryptedData,
  1039. IN PKERB_ENCRYPTION_KEY pkKey,
  1040. OUT PULONG DataSize,
  1041. OUT PUCHAR Data
  1042. );
  1043. KERBERR NTAPI
  1044. KerbEncryptDataEx(
  1045. OUT PKERB_ENCRYPTED_DATA EncryptedData,
  1046. IN ULONG DataSize,
  1047. IN PUCHAR Data,
  1048. IN ULONG Algorithm,
  1049. IN ULONG UsageFlags,
  1050. IN PKERB_ENCRYPTION_KEY Key
  1051. );
  1052. KERBERR NTAPI
  1053. KerbDecryptDataEx(
  1054. IN PKERB_ENCRYPTED_DATA EncryptedData,
  1055. IN PKERB_ENCRYPTION_KEY pkKey,
  1056. IN ULONG UsageFlags,
  1057. OUT PULONG DataSize,
  1058. OUT PUCHAR Data
  1059. );
  1060. #ifndef WIN32_CHICAGO
  1061. KERBERR NTAPI
  1062. KerbCheckSumVerify(
  1063. IN PUCHAR pbBuffer,
  1064. IN ULONG cbBuffer,
  1065. OUT PKERB_CHECKSUM pcsCheck
  1066. );
  1067. KERBERR NTAPI
  1068. KerbCheckSum(
  1069. PUCHAR pbData,
  1070. ULONG cbData,
  1071. PCHECKSUM_FUNCTION pcsfSum,
  1072. PKERB_CHECKSUM pcsCheckSum
  1073. );
  1074. #endif // WIN32_CHICAGO
  1075. KERBERR
  1076. KerbGetEncryptionOverhead(
  1077. IN ULONG Algorithm,
  1078. OUT PULONG Overhead,
  1079. OUT OPTIONAL PULONG BlockSize
  1080. );
  1081. NTSTATUS
  1082. KerbDuplicateSid(
  1083. OUT PSID * DestinationSid,
  1084. IN PSID SourceSid
  1085. );
  1086. NTSTATUS
  1087. KerbConvertStringToSid(
  1088. IN PUNICODE_STRING String,
  1089. OUT PSID * Sid
  1090. );
  1091. NTSTATUS
  1092. KerbConvertSidToString(
  1093. IN PSID Sid,
  1094. OUT PUNICODE_STRING String,
  1095. IN BOOLEAN AllocateDestination
  1096. );
  1097. KERBERR
  1098. KerbExtractSidFromKdcName(
  1099. IN OUT PKERB_INTERNAL_NAME Name,
  1100. OUT PSID * Sid
  1101. );
  1102. KERBERR
  1103. KerbBuildFullServiceKdcNameWithSid(
  1104. IN PUNICODE_STRING DomainName,
  1105. IN PUNICODE_STRING ServiceName,
  1106. IN OPTIONAL PSID Sid,
  1107. IN ULONG NameType,
  1108. OUT PKERB_INTERNAL_NAME * FullServiceName
  1109. );
  1110. NTSTATUS
  1111. KerbDuplicateString(
  1112. OUT PUNICODE_STRING DestinationString,
  1113. IN OPTIONAL PUNICODE_STRING SourceString
  1114. );
  1115. LPWSTR
  1116. KerbBuildNullTerminatedString(
  1117. IN PUNICODE_STRING String
  1118. );
  1119. VOID
  1120. KerbFreeString(
  1121. IN OPTIONAL PUNICODE_STRING String
  1122. );
  1123. VOID
  1124. KerbFreeRealm(
  1125. IN PKERB_REALM Realm
  1126. );
  1127. VOID
  1128. KerbFreePrincipalName(
  1129. IN PKERB_PRINCIPAL_NAME Name
  1130. );
  1131. #ifndef WIN32_CHICAGO
  1132. KERBERR
  1133. KerbCheckLogonRestrictions(
  1134. IN PVOID UserHandle,
  1135. IN PUNICODE_STRING Workstation,
  1136. IN PUSER_ALL_INFORMATION UserAll,
  1137. IN ULONG LogonRestrictionsFlags,
  1138. OUT PTimeStamp LogoffTime,
  1139. OUT PNTSTATUS RetStatus
  1140. );
  1141. #include <pacndr.h>
  1142. NTSTATUS
  1143. PAC_EncodeTokenRestrictions(
  1144. IN PKERB_TOKEN_RESTRICTIONS TokenRestrictions,
  1145. OUT PBYTE * EncodedData,
  1146. OUT PULONG DataSize
  1147. );
  1148. NTSTATUS
  1149. PAC_DecodeTokenRestrictions(
  1150. IN PBYTE EncodedData,
  1151. IN ULONG DataSize,
  1152. OUT PKERB_TOKEN_RESTRICTIONS * TokenRestrictions
  1153. );
  1154. #define KERB_TOKEN_RESTRICTION_DISABLE_GROUPS 1
  1155. #define KERB_TOKEN_RESTRICTION_RESTRICT_SIDS 2
  1156. #define KERB_TOKEN_RESTRICTION_DELETE_PRIVS 4
  1157. #endif // WIN32_CHICAGO
  1158. KERBERR
  1159. KerbConvertStringToPrincipalName(
  1160. OUT PKERB_PRINCIPAL_NAME PrincipalName,
  1161. IN PUNICODE_STRING String,
  1162. IN ULONG NameType
  1163. );
  1164. KERBERR
  1165. KerbDuplicatePrincipalName(
  1166. OUT PKERB_PRINCIPAL_NAME PrincipalName,
  1167. IN PKERB_PRINCIPAL_NAME SourcePrincipalName
  1168. );
  1169. KERBERR
  1170. KerbConvertPrincipalNameToString(
  1171. OUT PUNICODE_STRING String,
  1172. OUT PULONG NameType,
  1173. IN PKERB_PRINCIPAL_NAME PrincipalName
  1174. );
  1175. KERBERR
  1176. KerbConvertPrincipalNameToFullServiceString(
  1177. OUT PUNICODE_STRING String,
  1178. IN PKERB_PRINCIPAL_NAME PrincipalName,
  1179. IN KERB_REALM RealmName
  1180. );
  1181. BOOLEAN
  1182. KerbComparePrincipalNames(
  1183. IN PKERB_PRINCIPAL_NAME Name1,
  1184. IN PKERB_PRINCIPAL_NAME Name2
  1185. );
  1186. KERBERR
  1187. KerbConvertUnicodeStringToRealm(
  1188. OUT PKERB_REALM Realm,
  1189. IN PUNICODE_STRING String
  1190. );
  1191. KERBERR
  1192. KerbConvertRealmToUnicodeString(
  1193. OUT PUNICODE_STRING String,
  1194. IN PKERB_REALM Realm
  1195. );
  1196. KERBERR
  1197. KerbDuplicateRealm(
  1198. OUT PKERB_REALM Realm,
  1199. IN KERB_REALM SourceRealm
  1200. );
  1201. BOOLEAN
  1202. KerbCompareRealmNames(
  1203. IN PKERB_REALM Realm1,
  1204. IN PKERB_REALM Realm2
  1205. );
  1206. BOOLEAN
  1207. KerbCompareUnicodeRealmNames(
  1208. IN PUNICODE_STRING Domain1,
  1209. IN PUNICODE_STRING Domain2
  1210. );
  1211. BOOLEAN
  1212. KerbCompareStringToPrincipalName(
  1213. IN PKERB_PRINCIPAL_NAME PrincipalName,
  1214. IN PUNICODE_STRING String
  1215. );
  1216. VOID
  1217. KerbConvertLargeIntToGeneralizedTime(
  1218. OUT PKERB_TIME ClientTime,
  1219. OUT OPTIONAL int * ClientUsec,
  1220. IN PTimeStamp TimeStamp
  1221. );
  1222. VOID
  1223. KerbConvertLargeIntToGeneralizedTimeWrapper(
  1224. OUT PKERB_TIME ClientTime,
  1225. OUT OPTIONAL long * ClientUsec,
  1226. IN PTimeStamp TimeStamp
  1227. );
  1228. VOID
  1229. KerbConvertGeneralizedTimeToLargeInt(
  1230. OUT PTimeStamp TimeStamp,
  1231. IN PKERB_TIME ClientTime,
  1232. IN int ClientUsec
  1233. );
  1234. BOOLEAN
  1235. KerbCheckTimeSkew(
  1236. IN PTimeStamp CurrentTime,
  1237. IN PTimeStamp ClientTime,
  1238. IN PTimeStamp AllowedSkew
  1239. );
  1240. KERBERR
  1241. KerbConvertArrayToCryptList(
  1242. OUT PKERB_CRYPT_LIST * CryptList,
  1243. IN PULONG ETypeArray,
  1244. IN ULONG ETypeCount
  1245. );
  1246. KERBERR
  1247. KerbConvertKeysToCryptList(
  1248. OUT PKERB_CRYPT_LIST * CryptList,
  1249. IN PKERB_STORED_CREDENTIAL Keys
  1250. );
  1251. KERBERR
  1252. KerbConvertCryptListToArray(
  1253. OUT PULONG * ETypeArray,
  1254. OUT PULONG ETypeCount,
  1255. IN PKERB_CRYPT_LIST CryptList
  1256. );
  1257. VOID
  1258. KerbFreeCryptList(
  1259. IN PKERB_CRYPT_LIST CryptList
  1260. );
  1261. PKERB_AUTHORIZATION_DATA
  1262. KerbFindAuthDataEntry(
  1263. IN ULONG EntryId,
  1264. IN PKERB_AUTHORIZATION_DATA AuthData
  1265. );
  1266. PKERB_PA_DATA
  1267. KerbFindPreAuthDataEntry(
  1268. IN ULONG EntryId,
  1269. IN PKERB_PA_DATA_LIST AuthData
  1270. );
  1271. VOID
  1272. KerbFreePreAuthData(
  1273. IN OPTIONAL PKERB_PA_DATA_LIST PreAuthData
  1274. );
  1275. KERBERR
  1276. KerbCopyAndAppendAuthData(
  1277. OUT PKERB_AUTHORIZATION_DATA * OutputAuthData,
  1278. IN PKERB_AUTHORIZATION_DATA InputAuthData
  1279. );
  1280. KERBERR
  1281. KerbGetPacFromAuthData(
  1282. IN PKERB_AUTHORIZATION_DATA AuthData,
  1283. OUT PKERB_IF_RELEVANT_AUTH_DATA ** ReturnIfRelevantData,
  1284. OUT PKERB_AUTHORIZATION_DATA * Pac
  1285. );
  1286. KERBERR
  1287. KerbCreateApRequest(
  1288. IN PKERB_INTERNAL_NAME ClientName,
  1289. IN PUNICODE_STRING ClientRealm,
  1290. IN PKERB_ENCRYPTION_KEY SessionKey,
  1291. IN PKERB_ENCRYPTION_KEY SubSessionKey,
  1292. IN ULONG Nonce,
  1293. IN PKERB_TICKET ServiceTicket,
  1294. IN ULONG ApOptions,
  1295. IN OPTIONAL PKERB_CHECKSUM GssChecksum,
  1296. IN OPTIONAL PTimeStamp ServerSkewTime,
  1297. IN BOOLEAN KdcRequest,
  1298. OUT PULONG RequestSize,
  1299. OUT PUCHAR * Request
  1300. );
  1301. KERBERR
  1302. KerbBuildFullServiceName(
  1303. IN PUNICODE_STRING DomainName,
  1304. IN PUNICODE_STRING ServiceName,
  1305. OUT PUNICODE_STRING FullServiceName
  1306. );
  1307. KERBERR
  1308. KerbBuildUnicodeSpn(
  1309. IN PUNICODE_STRING DomainName,
  1310. IN PUNICODE_STRING ServiceName,
  1311. OUT PUNICODE_STRING UnicodeSpn
  1312. );
  1313. KERBERR
  1314. KerbBuildEmailName(
  1315. IN PUNICODE_STRING DomainName,
  1316. IN PUNICODE_STRING ServiceName,
  1317. OUT PUNICODE_STRING EmailName
  1318. );
  1319. KERBERR
  1320. KerbBuildFullServiceKdcName(
  1321. IN PUNICODE_STRING DomainName,
  1322. IN PUNICODE_STRING ServiceName,
  1323. IN ULONG NameType,
  1324. OUT PKERB_INTERNAL_NAME * FullServiceName
  1325. );
  1326. KERBERR
  1327. KerbBuildAltSecId(
  1328. OUT PUNICODE_STRING AlternateName,
  1329. IN PKERB_INTERNAL_NAME PrincipalName,
  1330. IN OPTIONAL PKERB_REALM Realm,
  1331. IN OPTIONAL PUNICODE_STRING UnicodeRealm
  1332. );
  1333. KERBERR
  1334. KerbBuildKeySalt(
  1335. IN PUNICODE_STRING DomainName,
  1336. IN PUNICODE_STRING ServiceName,
  1337. IN KERB_ACCOUNT_TYPE AccountType,
  1338. OUT PUNICODE_STRING KeySalt
  1339. );
  1340. KERBERR
  1341. KerbBuildKeySaltFromUpn(
  1342. IN PUNICODE_STRING Upn,
  1343. OUT PUNICODE_STRING Salt
  1344. );
  1345. KERBERR
  1346. KerbBuildErrorMessageEx(
  1347. IN KERBERR ErrorCode,
  1348. IN OPTIONAL PKERB_EXT_ERROR pExtendedError,
  1349. IN PUNICODE_STRING ServerRealm,
  1350. IN PKERB_INTERNAL_NAME ServerName,
  1351. IN OPTIONAL PUNICODE_STRING ClientRealm,
  1352. IN OPTIONAL PBYTE ErrorData,
  1353. IN ULONG ErrorDataSize,
  1354. OUT PULONG ErrorMessageSize,
  1355. OUT PUCHAR * ErrorMessage
  1356. );
  1357. KERBERR
  1358. KerbBuildExtendedError(
  1359. IN PKERB_EXT_ERROR pExtendedError,
  1360. OUT PULONG ExtErrorSize,
  1361. OUT PBYTE* ExtErrorData
  1362. );
  1363. #ifdef __cplusplus
  1364. } // extern "C"
  1365. #endif
  1366. //
  1367. // Socket functions
  1368. //
  1369. NTSTATUS
  1370. KerbInitializeSockets(
  1371. IN ULONG VersionRequired,
  1372. IN ULONG MinSockets,
  1373. OUT BOOLEAN *TcpNotInstalled
  1374. );
  1375. VOID
  1376. KerbCleanupSockets(
  1377. );
  1378. NTSTATUS
  1379. KerbCallKdc(
  1380. IN PUNICODE_STRING KdcAddress,
  1381. IN ULONG AddressType,
  1382. IN ULONG Timeout,
  1383. IN BOOLEAN UseDatagram,
  1384. IN USHORT PortNumber,
  1385. IN PKERB_MESSAGE_BUFFER Input,
  1386. OUT PKERB_MESSAGE_BUFFER Output
  1387. );
  1388. NTSTATUS
  1389. KerbMapKerbError(
  1390. IN KERBERR KerbError
  1391. );
  1392. VOID
  1393. KerbFreeHostAddresses(
  1394. IN PKERB_HOST_ADDRESSES Addresses
  1395. );
  1396. KERBERR
  1397. KerbDuplicateHostAddresses(
  1398. OUT PKERB_HOST_ADDRESSES * DestAddresses,
  1399. IN PKERB_HOST_ADDRESSES SourceAddresses
  1400. );
  1401. KERBERR
  1402. KerbUnicodeStringToKerbString(
  1403. OUT PSTRING KerbString,
  1404. IN PUNICODE_STRING String
  1405. );
  1406. KERBERR
  1407. KerbStringToUnicodeString(
  1408. OUT PUNICODE_STRING String,
  1409. IN PSTRING KerbString
  1410. );
  1411. BOOLEAN
  1412. KerbMbStringToUnicodeString(
  1413. PUNICODE_STRING pDest,
  1414. char * pszString
  1415. );
  1416. VOID
  1417. KerbFreeKdcName(
  1418. IN PKERB_INTERNAL_NAME * KdcName
  1419. );
  1420. KERBERR
  1421. KerbConvertPrincipalNameToKdcName(
  1422. OUT PKERB_INTERNAL_NAME * OutputName,
  1423. IN PKERB_PRINCIPAL_NAME PrincipalName
  1424. );
  1425. KERBERR
  1426. KerbConvertKdcNameToPrincipalName(
  1427. OUT PKERB_PRINCIPAL_NAME PrincipalName,
  1428. IN PKERB_INTERNAL_NAME KdcName
  1429. );
  1430. BOOLEAN
  1431. KerbEqualKdcNames(
  1432. IN PKERB_INTERNAL_NAME Name1,
  1433. IN PKERB_INTERNAL_NAME Name2
  1434. );
  1435. KERBERR
  1436. KerbCompareKdcNameToPrincipalName(
  1437. IN PKERB_PRINCIPAL_NAME PrincipalName,
  1438. IN PKERB_INTERNAL_NAME KdcName,
  1439. OUT PBOOLEAN Result
  1440. );
  1441. VOID
  1442. KerbPrintKdcNameEx(
  1443. IN ULONG DebugLevel,
  1444. IN ULONG InfoLevel,
  1445. IN PKERB_INTERNAL_NAME Name
  1446. );
  1447. #define KERB_INTERNAL_NAME_SIZE(NameCount) (sizeof(KERB_INTERNAL_NAME) + ((NameCount) - ANYSIZE_ARRAY) * sizeof(UNICODE_STRING))
  1448. KERBERR
  1449. KerbConvertStringToKdcName(
  1450. OUT PKERB_INTERNAL_NAME * PrincipalName,
  1451. IN PUNICODE_STRING String
  1452. );
  1453. NTSTATUS
  1454. KerbBuildKpasswdName(
  1455. OUT PKERB_INTERNAL_NAME * KpasswdName
  1456. );
  1457. KERBERR
  1458. KerbConvertKdcNameToString(
  1459. OUT PUNICODE_STRING String,
  1460. IN PKERB_INTERNAL_NAME PrincipalName,
  1461. IN PUNICODE_STRING Realm
  1462. );
  1463. NTSTATUS
  1464. KerbDuplicateKdcName(
  1465. OUT PKERB_INTERNAL_NAME * Destination,
  1466. IN PKERB_INTERNAL_NAME Source
  1467. );
  1468. PSID
  1469. KerbMakeDomainRelativeSid(
  1470. IN PSID DomainId,
  1471. IN ULONG RelativeId
  1472. );
  1473. ULONG
  1474. KerbConvertFlagsToUlong(
  1475. IN PVOID Flags
  1476. );
  1477. ULONG
  1478. KerbConvertUlongToFlagUlong(
  1479. IN ULONG Flag
  1480. );
  1481. BOOLEAN
  1482. KerbCompareObjectIds(
  1483. IN PKERB_OBJECT_ID Object1,
  1484. IN PKERB_OBJECT_ID Object2
  1485. );
  1486. KERBERR
  1487. KerbGetClientNetbiosAddress(
  1488. OUT PUNICODE_STRING ClientNetbiosAddress,
  1489. IN PKERB_HOST_ADDRESSES Addresses
  1490. );
  1491. #ifdef __WINCRYPT_H__
  1492. KERBERR
  1493. KerbCreateCertificateList(
  1494. OUT PKERB_CERTIFICATE_LIST * Certificates,
  1495. IN PCCERT_CONTEXT CertContext
  1496. );
  1497. VOID
  1498. KerbFreeCertificateList(
  1499. IN PKERB_CERTIFICATE_LIST Certificates
  1500. );
  1501. NTSTATUS
  1502. KerbGetPrincipalNameFromCertificate(
  1503. IN PCCERT_CONTEXT ClientCert,
  1504. OUT PUNICODE_STRING String
  1505. );
  1506. NTSTATUS
  1507. KerbDuplicateStringEx(
  1508. OUT PUNICODE_STRING DestinationString,
  1509. IN OPTIONAL PUNICODE_STRING SourceString,
  1510. IN BOOLEAN NullTerminate
  1511. );
  1512. #if DBG
  1513. void
  1514. DebugDisplayTime(
  1515. IN ULONG DebugLevel,
  1516. IN FILETIME *pFileTime
  1517. );
  1518. #endif
  1519. #endif // __WINCRYPT_H__
  1520. #endif // _KERBCOMM_H_