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.

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