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.

1828 lines
44 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. //
  197. // Types for extended errors
  198. //
  199. #define TD_MUST_USE_USER2USER -128
  200. #define TD_EXTENDED_ERROR -129
  201. //
  202. // PKINIT method errors
  203. //
  204. #define KERB_PKINIT_UNSPEC_ERROR 0 // not specified
  205. #define KERB_PKINIT_BAD_PUBLIC_KEY 1 // cannot verify public key
  206. #define KERB_PKINIT_INVALID_CERT 2 // invalid certificate
  207. #define KERB_PKINIT_REVOKED_CERT 3 // revoked certificate
  208. #define KERB_PKINIT_INVALID_KDC_NAME 4 // invalid KDC name
  209. #define KERB_PKINIT_CLIENT_NAME_MISMATCH 5 // client name mismatch
  210. //
  211. // HACK for MAX_UNICODE_STRING, as KerbDuplicateString & others add a NULL
  212. // terminator when doing the duplication
  213. //
  214. #define KERB_MAX_UNICODE_STRING (UNICODE_STRING_MAX_BYTES - sizeof(WCHAR))
  215. //////////////////////////////////////////////////////////////////////////
  216. //
  217. // Structures
  218. //
  219. //////////////////////////////////////////////////////////////////////////
  220. typedef struct _KERB_PREAUTH_DATA {
  221. ULONG Flags;
  222. } KERB_PREAUTH_DATA, *PKERB_PREAUTH_DATA;
  223. #define KERBFLAG_LOGON 0x1
  224. #define KERBFLAG_INTERACTIVE 0x2
  225. //
  226. // KDC-Kerberos interaction
  227. //
  228. #define KDC_START_EVENT L"\\Security\\KdcStartEvent"
  229. #define KERB_MAX_CRYPTO_SYSTEMS 20
  230. #define KERB_MAX_CRYPTO_SYSTEMS_SLOWBUFF 100
  231. #define KERB_DEFAULT_AP_REQ_CSUM KERB_CHECKSUM_MD5
  232. #define KERB_DEFAULT_PREAUTH_TYPE 0
  233. //
  234. // Registry parameters
  235. //
  236. #define KERB_PATH L"System\\CurrentControlSet\\Control\\Lsa\\Kerberos"
  237. #define KERB_PARAMETER_PATH L"System\\CurrentControlSet\\Control\\Lsa\\Kerberos\\Parameters"
  238. #define KERB_PARAMETER_SKEWTIME L"SkewTime"
  239. #define KERB_PARAMETER_MAX_UDP_PACKET L"MaxPacketSize"
  240. #define KERB_PARAMETER_START_TIME L"StartupTime"
  241. #define KERB_PARAMETER_KDC_CALL_TIMEOUT L"KdcWaitTime"
  242. #define KERB_PARAMETER_KDC_BACKOFF_TIME L"KdcBackoffTime"
  243. #define KERB_PARAMETER_KDC_SEND_RETRIES L"KdcSendRetries"
  244. #define KERB_PARAMETER_USE_SID_CACHE L"UseSidCache"
  245. #define KERB_PARAMETER_LOG_LEVEL L"LogLevel"
  246. #define KERB_PARAMETER_DEFAULT_ETYPE L"DefaultEncryptionType"
  247. #define KERB_PARAMETER_FAR_KDC_TIMEOUT L"FarKdcTimeout"
  248. #define KERB_PARAMETER_NEAR_KDC_TIMEOUT L"NearKdcTimeout"
  249. #define KERB_PARAMETER_STRONG_ENC_DG L"StronglyEncryptDatagram"
  250. #define KERB_PARAMETER_MAX_REFERRAL_COUNT L"MaxReferralCount"
  251. #define KERB_PARAMETER_MAX_TOKEN_SIZE L"MaxTokenSize"
  252. #define KERB_PARAMETER_SPN_CACHE_TIMEOUT L"SpnCacheTimeout"
  253. #define KERB_PARAMETER_S4UCACHE_TIMEOUT L"S4UCacheTimeout"
  254. #define KERB_PARAMETER_S4UTICKET_LIFETIME L"S4UTicketLifetime"
  255. #define KERB_PARAMETER_RETRY_PDC L"RetryPDC"
  256. #define KERB_PARAMETER_REQUEST_OPTIONS L"RequestOptions"
  257. #define KERB_PARAMETER_CLIENT_IP_ADDRESSES L"ClientIpAddresses"
  258. #define KERB_PARAMETER_TGT_RENEWAL_TIME L"TgtRenewalTime"
  259. #define KERB_PARAMETER_ALLOW_TGT_SESSION_KEY L"AllowTgtSessionKey"
  260. //
  261. // Registry defaults
  262. //
  263. #define KERB_DEFAULT_LOGLEVEL 0
  264. #define KERB_DEFAULT_USE_STRONG_ENC_DG FALSE
  265. #define KERB_DEFAULT_CLIENT_IP_ADDRESSES 0
  266. #define KERB_DEFAULT_TGT_RENEWAL_TIME 600
  267. #define KERB_DEFAULT_ALLOW_TGT_SESSION_KEY FALSE
  268. //
  269. // These are arbitrary sizes for max request and responses sizes for datagram
  270. // requests.
  271. //
  272. #define KERB_MAX_KDC_RESPONSE_SIZE 4000
  273. #define KERB_MAX_KDC_REQUEST_SIZE 4000
  274. #define KERB_MAX_DATAGRAM_SIZE 2000
  275. #define KERB_MAX_RETRIES 3
  276. #define KERB_MAX_REFERRAL_COUNT 3
  277. //
  278. // timeout values in minutes
  279. //
  280. #define KERB_BINDING_FAR_DC_TIMEOUT 10
  281. #define KERB_BINDING_NEAR_DC_TIMEOUT 30
  282. #define KERB_SPN_CACHE_TIMEOUT 15
  283. #define KERB_S4U_CACHE_TIMEOUT 15
  284. #define KERB_S4U_QUERY_INTERVAL 15
  285. #define KERB_S4U_TICKET_LIFETIME 15
  286. #define KERB_DEFAULT_SKEWTIME 5
  287. //
  288. // Network service session timer callback frequency
  289. //
  290. #define KERB_SKLIST_CALLBACK_FEQ 10
  291. //
  292. // timeout values in seconds
  293. //
  294. #define KERB_KDC_CALL_TIMEOUT 5
  295. #define KERB_KDC_CALL_TIMEOUT_BACKOFF 5
  296. #define KERB_KDC_WAIT_TIME 120
  297. //
  298. // BER encoding values
  299. //
  300. #define KERB_BER_APPLICATION_TAG 0xc0
  301. #define KERB_BER_APPLICATION_MASK 0x1f
  302. #define KERB_TGS_REQ_TAG 12
  303. #define KERB_AS_REQ_TAG 10
  304. #define KERB_TGS_REP_TAG 13
  305. #define KERB_AS_REP_TAG 11
  306. #define KERB_ERROR_TAG 30
  307. //
  308. // Common types
  309. //
  310. typedef struct _KERB_MESSAGE_BUFFER {
  311. ULONG BufferSize;
  312. PUCHAR Buffer;
  313. } KERB_MESSAGE_BUFFER, *PKERB_MESSAGE_BUFFER;
  314. typedef enum _KERB_ACCOUNT_TYPE {
  315. UserAccount,
  316. MachineAccount,
  317. DomainTrustAccount,
  318. UnknownAccount
  319. } KERB_ACCOUNT_TYPE, *PKERB_ACCOUNT_TYPE;
  320. //
  321. // This is the maximum number of elements in a KERB_INTERNAL_NAME
  322. //
  323. #define MAX_NAME_ELEMENTS 20
  324. typedef struct _KERB_INTERNAL_NAME {
  325. SHORT NameType;
  326. USHORT NameCount;
  327. UNICODE_STRING Names[ANYSIZE_ARRAY];
  328. } KERB_INTERNAL_NAME, *PKERB_INTERNAL_NAME;
  329. //
  330. // Prototypes
  331. //
  332. #ifdef __cplusplus
  333. class CAuthenticatorList;
  334. KERBERR NTAPI
  335. KerbCheckTicket(
  336. IN PKERB_TICKET PackedTicket,
  337. IN PKERB_ENCRYPTED_DATA EncryptedAuthenticator,
  338. IN PKERB_ENCRYPTION_KEY pkKey,
  339. IN OUT CAuthenticatorList * AuthenticatorList,
  340. IN PTimeStamp SkewTime,
  341. IN ULONG ServiceNameCount,
  342. IN OPTIONAL PUNICODE_STRING ServiceName,
  343. IN OPTIONAL PUNICODE_STRING ServiceRealm,
  344. IN BOOLEAN CheckForReplay,
  345. IN BOOLEAN KdcRequest,
  346. OUT PKERB_ENCRYPTED_TICKET * EncryptTicket,
  347. OUT PKERB_AUTHENTICATOR * Authenticator,
  348. OUT PKERB_ENCRYPTION_KEY pkSessionKey,
  349. OUT OPTIONAL PKERB_ENCRYPTION_KEY pkTicketKey,
  350. OUT PBOOLEAN UseSubKey
  351. );
  352. extern "C" {
  353. #endif // __cplusplus
  354. KERBERR
  355. KerbVerifyTicket(
  356. IN PKERB_TICKET PackedTicket,
  357. IN ULONG NameCount,
  358. IN OPTIONAL PUNICODE_STRING ServiceNames,
  359. IN OPTIONAL PUNICODE_STRING ServiceRealm,
  360. IN PKERB_ENCRYPTION_KEY ServiceKey,
  361. IN OPTIONAL PTimeStamp SkewTime,
  362. OUT PKERB_ENCRYPTED_TICKET * DecryptedTicket
  363. );
  364. BOOLEAN
  365. KerbVerifyClientAddress(
  366. IN SOCKADDR * ClientAddress,
  367. IN PKERB_HOST_ADDRESSES Addresses
  368. );
  369. KERBERR NTAPI
  370. KerbPackTicket(
  371. IN PKERB_TICKET InternalTicket,
  372. IN PKERB_ENCRYPTION_KEY pkKey,
  373. IN ULONG KeyVersion,
  374. OUT PKERB_TICKET PackedTicket
  375. );
  376. VOID
  377. KerbPrintPrincipalName(
  378. IN ULONG DebugLevel,
  379. IN PKERB_PRINCIPAL_NAME Name
  380. );
  381. NTSTATUS
  382. KerbHashS4UPreauth(
  383. IN PKERB_PA_FOR_USER S4UPreauth,
  384. IN PKERB_ENCRYPTION_KEY Key,
  385. IN LONG ChecksumType,
  386. IN OUT PKERB_CHECKSUM CheckSum
  387. );
  388. VOID KerbPrintKerbRealm(
  389. IN ULONG DebugLevel,
  390. IN PKERB_REALM Realm
  391. );
  392. KERBERR NTAPI
  393. KerbUnpackTicket(
  394. IN PKERB_TICKET PackedTicket,
  395. IN PKERB_ENCRYPTION_KEY pkKey,
  396. OUT PKERB_ENCRYPTED_TICKET * InternalTicket
  397. );
  398. // VOID NTAPI
  399. // KerbFreeTicket(
  400. // IN PKERB_ENCRYPTED_TICKET Ticket
  401. // );
  402. #define KerbFreeTicket( Ticket ) \
  403. KerbFreeData( \
  404. KERB_ENCRYPTED_TICKET_PDU, \
  405. (Ticket) \
  406. )
  407. KERBERR NTAPI
  408. KerbDuplicateTicket(
  409. OUT PKERB_TICKET DestinationTicket,
  410. IN PKERB_TICKET SourceTicket
  411. );
  412. VOID
  413. KerbFreeDuplicatedTicket(
  414. IN PKERB_TICKET Ticket
  415. );
  416. VOID
  417. CheckForOutsideStringToKey();
  418. KERBERR NTAPI
  419. KerbHashPassword(
  420. IN PUNICODE_STRING Password,
  421. IN ULONG EncryptionType,
  422. OUT PKERB_ENCRYPTION_KEY Key
  423. );
  424. KERBERR NTAPI
  425. KerbHashPasswordEx(
  426. IN PUNICODE_STRING Password,
  427. IN PUNICODE_STRING PrincipalName,
  428. IN ULONG EncryptionType,
  429. OUT PKERB_ENCRYPTION_KEY Key
  430. );
  431. KERBERR NTAPI
  432. KerbMakeKey(
  433. IN ULONG EncryptionType,
  434. OUT PKERB_ENCRYPTION_KEY NewKey
  435. );
  436. BOOLEAN
  437. KerbIsKeyExportable(
  438. IN PKERB_ENCRYPTION_KEY Key
  439. );
  440. KERBERR
  441. KerbMakeExportableKey(
  442. IN ULONG KeyType,
  443. OUT PKERB_ENCRYPTION_KEY NewKey
  444. );
  445. KERBERR NTAPI
  446. KerbCreateKeyFromBuffer(
  447. OUT PKERB_ENCRYPTION_KEY NewKey,
  448. IN PUCHAR Buffer,
  449. IN ULONG BufferSize,
  450. IN ULONG EncryptionType
  451. );
  452. KERBERR NTAPI
  453. KerbDuplicateKey(
  454. OUT PKERB_ENCRYPTION_KEY NewKey,
  455. IN PKERB_ENCRYPTION_KEY Key
  456. );
  457. VOID
  458. KerbFreeKey(
  459. IN PKERB_ENCRYPTION_KEY Key
  460. );
  461. PKERB_ENCRYPTION_KEY
  462. KerbGetKeyFromList(
  463. IN PKERB_STORED_CREDENTIAL Passwords,
  464. IN ULONG EncryptionType
  465. );
  466. PKERB_ENCRYPTION_KEY
  467. KerbGetKeyFromListByIndex(
  468. IN PKERB_STORED_CREDENTIAL Passwords,
  469. IN ULONG EncryptionType,
  470. OUT PULONG pIndex
  471. );
  472. KERBERR
  473. KerbFindCommonCryptSystem(
  474. IN PKERB_CRYPT_LIST CryptList,
  475. IN PKERB_STORED_CREDENTIAL Passwords,
  476. IN OPTIONAL PKERB_STORED_CREDENTIAL MorePasswords,
  477. OUT PKERB_ENCRYPTION_KEY * Key
  478. );
  479. KERBERR NTAPI
  480. KerbRandomFill(
  481. IN OUT PUCHAR pbBuffer,
  482. IN ULONG cbBuffer
  483. );
  484. KERBERR NTAPI
  485. KerbCreateAuthenticator(
  486. IN PKERB_ENCRYPTION_KEY pkKey,
  487. IN ULONG SequenceNumber,
  488. OUT OPTIONAL PTimeStamp pAuthenticatorTime,
  489. IN PKERB_INTERNAL_NAME ClientName,
  490. IN PUNICODE_STRING ClientRealm,
  491. IN PTimeStamp ptsTime,
  492. IN PKERB_ENCRYPTION_KEY pkSubKey,
  493. IN OPTIONAL PKERB_CHECKSUM GssChecksum,
  494. IN BOOLEAN KdcRequest,
  495. OUT PKERB_ENCRYPTED_DATA Authenticator
  496. );
  497. KERBERR NTAPI
  498. KerbUnpackAuthenticator(
  499. IN PKERB_ENCRYPTION_KEY Key,
  500. IN PKERB_ENCRYPTED_DATA EncryptedAuthenticator,
  501. IN BOOLEAN KdcRequest,
  502. OUT PKERB_AUTHENTICATOR * Authenticator
  503. );
  504. DWORD
  505. KerbCopyDomainRelativeSid(
  506. OUT PSID TargetSid,
  507. IN PSID DomainId,
  508. IN ULONG RelativeId
  509. );
  510. // VOID NTAPI
  511. // KerbFreeAuthenticator(
  512. // IN PKERB_AUTHENTICATOR Authenticator
  513. // );
  514. #define KerbFreeAuthenticator( Authenticator ) \
  515. KerbFreeData( \
  516. KERB_AUTHENTICATOR_PDU, \
  517. (Authenticator) \
  518. )
  519. KERBERR NTAPI
  520. KerbPackKdcReplyBody(
  521. IN PKERB_ENCRYPTED_KDC_REPLY ReplyBody,
  522. IN PKERB_ENCRYPTION_KEY Key,
  523. IN ULONG KeyVersion,
  524. IN ULONG KeySalt,
  525. IN ULONG Pdu,
  526. OUT PKERB_ENCRYPTED_DATA EncryptedReply
  527. );
  528. KERBERR NTAPI
  529. KerbUnpackKdcReplyBody(
  530. IN PKERB_ENCRYPTED_DATA EncryptedReplyBody,
  531. IN PKERB_ENCRYPTION_KEY Key,
  532. IN ULONG Pdu,
  533. OUT PKERB_ENCRYPTED_KDC_REPLY * ReplyBody
  534. );
  535. KERBERR NTAPI
  536. KerbPackData(
  537. IN PVOID Data,
  538. IN ULONG PduValue,
  539. OUT PULONG DataSize,
  540. OUT PUCHAR * MarshalledData
  541. );
  542. KERBERR NTAPI
  543. KerbUnpackData(
  544. IN PUCHAR Data,
  545. IN ULONG DataSize,
  546. IN ULONG PduValue,
  547. OUT PVOID * DecodedData
  548. );
  549. VOID
  550. KerbFreeData(
  551. IN ULONG PduValue,
  552. IN PVOID Data
  553. );
  554. // KERBERR NTAPI
  555. // KerbPackAsReply(
  556. // IN PKERB_KDC_REPLY ReplyMessage,
  557. // OUT PULONG ReplySize,
  558. // OUT PUCHAR * MarshalledReply
  559. // );
  560. #define KerbPackAsReply( ReplyMessage, ReplySize, MarshalledReply ) \
  561. KerbPackData( \
  562. (PVOID) (ReplyMessage), \
  563. KERB_AS_REPLY_PDU, \
  564. (ReplySize), \
  565. (MarshalledReply) \
  566. )
  567. // KERBERR NTAPI
  568. // KerbUnpackAsReply(
  569. // IN PUCHAR ReplyMessage,
  570. // IN ULONG ReplySize,
  571. // OUT PKERB_KDC_REPLY * Reply
  572. // );
  573. #define KerbUnpackAsReply( ReplyMessage, ReplySize, Reply ) \
  574. KerbUnpackData( \
  575. (ReplyMessage), \
  576. (ReplySize), \
  577. KERB_AS_REPLY_PDU, \
  578. (PVOID *) (Reply) \
  579. )
  580. // VOID
  581. // KerbFreeAsReply(
  582. // IN PKERB_KDC_REPLY Request
  583. // );
  584. #define KerbFreeAsReply( Request) \
  585. KerbFreeData( \
  586. KERB_AS_REPLY_PDU, \
  587. (PVOID) (Request) \
  588. )
  589. // KERBERR NTAPI
  590. // KerbPackTgsReply(
  591. // IN PKERB_KDC_REPLY ReplyMessage,
  592. // OUT PULONG ReplySize,
  593. // OUT PUCHAR * MarshalledReply
  594. // );
  595. #define KerbPackTgsReply( ReplyMessage, ReplySize, MarshalledReply ) \
  596. KerbPackData( \
  597. (PVOID) (ReplyMessage), \
  598. KERB_TGS_REPLY_PDU, \
  599. (ReplySize), \
  600. (MarshalledReply) \
  601. )
  602. // KERBERR NTAPI
  603. // KerbUnpackTgsReply(
  604. // IN PUCHAR ReplyMessage,
  605. // IN ULONG ReplySize,
  606. // OUT PKERB_KDC_REPLY * Reply
  607. // );
  608. #define KerbUnpackTgsReply( ReplyMessage, ReplySize, Reply ) \
  609. KerbUnpackData( \
  610. (ReplyMessage), \
  611. (ReplySize), \
  612. KERB_TGS_REPLY_PDU, \
  613. (PVOID *) (Reply) \
  614. )
  615. // VOID
  616. // KerbFreeTgsReply(
  617. // IN PKERB_KDC_REPLY Request
  618. // );
  619. #define KerbFreeTgsReply( Request) \
  620. KerbFreeData( \
  621. KERB_TGS_REPLY_PDU, \
  622. (PVOID) (Request) \
  623. )
  624. // VOID
  625. // KerbFreeKdcReplyBody(
  626. // IN PKERB_ENCRYPTED_KDC_REPLY Request
  627. // );
  628. #define KerbFreeKdcReplyBody( Request) \
  629. KerbFreeData( \
  630. KERB_ENCRYPTED_TGS_REPLY_PDU, \
  631. (PVOID) (Request) \
  632. )
  633. // KERBERR NTAPI
  634. // KerbPackAsRequest(
  635. // IN PKERB_KDC_REQUEST RequestMessage,
  636. // OUT PULONG RequestSize,
  637. // OUT PUCHAR * MarshalledRequest
  638. // );
  639. #define KerbPackAsRequest( RequestMessage, RequestSize, MarshalledRequest )\
  640. KerbPackData( \
  641. (PVOID) (RequestMessage), \
  642. KERB_AS_REQUEST_PDU, \
  643. (RequestSize), \
  644. (MarshalledRequest) \
  645. )
  646. // KERBERR NTAPI
  647. // KerbUnpackAsRequest(
  648. // IN PUCHAR RequestMessage,
  649. // IN ULONG RequestSize,
  650. // OUT PKERB_KDC_REQUEST * Request
  651. // );
  652. #define KerbUnpackAsRequest( RequestMessage, RequestSize, Request ) \
  653. KerbUnpackData( \
  654. (RequestMessage), \
  655. (RequestSize), \
  656. KERB_AS_REQUEST_PDU, \
  657. (PVOID *) (Request) \
  658. )
  659. // VOID
  660. // KerbFreeAsRequest(
  661. // IN PKERB_KDC_REQUEST Request
  662. // );
  663. #define KerbFreeAsRequest( Request) \
  664. KerbFreeData( \
  665. KERB_TGS_REQUEST_PDU, \
  666. (PVOID) (Request) \
  667. )
  668. // KERBERR NTAPI
  669. // KerbPackTgsRequest(
  670. // IN PKERB_KDC_REQUEST RequestMessage,
  671. // OUT PULONG RequestSize,
  672. // OUT PUCHAR * MarshalledRequest
  673. // );
  674. #define KerbPackTgsRequest( RequestMessage, RequestSize, MarshalledRequest )\
  675. KerbPackData( \
  676. (PVOID) (RequestMessage), \
  677. KERB_TGS_REQUEST_PDU, \
  678. (RequestSize), \
  679. (MarshalledRequest) \
  680. )
  681. // KERBERR NTAPI
  682. // KerbUnpackTgsRequest(
  683. // IN PUCHAR RequestMessage,
  684. // IN ULONG RequestSize,
  685. // OUT PKERB_KDC_REQUEST * Request
  686. // );
  687. #define KerbUnpackTgsRequest( RequestMessage, RequestSize, Request ) \
  688. KerbUnpackData( \
  689. (RequestMessage), \
  690. (RequestSize), \
  691. KERB_TGS_REQUEST_PDU, \
  692. (PVOID *) (Request) \
  693. )
  694. // VOID
  695. // KerbFreeTgsRequest(
  696. // IN PKERB_KDC_REQUEST Request
  697. // );
  698. #define KerbFreeTgsRequest( Request) \
  699. KerbFreeData( \
  700. KERB_TGS_REQUEST_PDU, \
  701. (PVOID) (Request) \
  702. )
  703. // KERBERR NTAPI
  704. // KerbPackEncryptedData(
  705. // IN PKERB_ENCRYPTED_DATA EncryptedData,
  706. // OUT PULONG DataSize,
  707. // OUT PUCHAR * MarshalledData
  708. // );
  709. #define KerbPackEncryptedData( EncryptedData, DataSize, MarshalledData ) \
  710. KerbPackData( \
  711. (PVOID) (EncryptedData), \
  712. KERB_ENCRYPTED_DATA_PDU, \
  713. (DataSize), \
  714. (PUCHAR *) (MarshalledData) \
  715. )
  716. // KERBERR NTAPI
  717. // KerbUnpackEncryptedData(
  718. // IN PUCHAR EncryptedData,
  719. // IN ULONG DataSize,
  720. // OUT PKERB_ENCRYPTED_DATA * Data
  721. // );
  722. #define KerbUnpackEncryptedData( EncryptedData,DataSize,Data ) \
  723. KerbUnpackData( \
  724. (EncryptedData), \
  725. (DataSize), \
  726. KERB_ENCRYPTED_DATA_PDU, \
  727. (PVOID *) (Data) \
  728. )
  729. // VOID
  730. // KerbFreeEncryptedData(
  731. // IN PKERB_ENCRYPTED_DATA EncryptedData
  732. // );
  733. #define KerbFreeEncryptedData( EncryptedData) \
  734. KerbFreeData( \
  735. KERB_ENCRYPTED_DATA_PDU, \
  736. (PVOID) (EncryptedData) \
  737. )
  738. #ifdef notdef
  739. // KERBERR NTAPI
  740. // KerbPackAuthData(
  741. // IN PKERB_AUTHORIZATION_DATA AuthData,
  742. // OUT PULONG AuthDataSize,
  743. // OUT PUCHAR * MarshalledAuthData
  744. // );
  745. #define KerbPackAuthData( AuthData, AuthDataSize, MarshalledAuthData ) \
  746. KerbPackData( \
  747. (PVOID) (AuthData), \
  748. KERB_AUTHORIZATION_DATA_PDU, \
  749. (AuthDataSize), \
  750. (MarshalledAuthData) \
  751. )
  752. // KERBERR NTAPI
  753. // KerbUnpackAuthData(
  754. // IN PUCHAR PackedAuthData,
  755. // IN ULONG AuthDataSize,
  756. // OUT PKERB_AUTHORIZATION_DATA * AuthData
  757. // );
  758. #define KerbUnpackAuthData( PackedAuthData, AuthDataSize, AuthData ) \
  759. KerbUnpackData( \
  760. (PackedAuthData), \
  761. (AuthDataSize), \
  762. KERB_AUTHORIZATION_DATA_PDU, \
  763. (PVOID *) (AuthData) \
  764. )
  765. // VOID
  766. // KerbFreeAuthData(
  767. // IN PKERB_AUTH_DATA AuthData
  768. // );
  769. #define KerbFreeAuthData( AuthData) \
  770. KerbFreeData( \
  771. KERB_AUTHORIZATION_DATA_PDU, \
  772. (PVOID) (AuthData) \
  773. )
  774. #endif // notdef
  775. VOID
  776. KerbFreeAuthData(
  777. IN PKERB_AUTHORIZATION_DATA AuthData
  778. );
  779. // KERBERR NTAPI
  780. // KerbPackApRequest(
  781. // IN PKERB_AP_REQUEST ApRequestMessage,
  782. // OUT PULONG ApRequestSize,
  783. // OUT PUCHAR * MarshalledApRequest
  784. // );
  785. #define KerbPackApRequest( ApRequestMessage, ApRequestSize, MarshalledApRequest ) \
  786. KerbPackData( \
  787. (PVOID) (ApRequestMessage), \
  788. KERB_AP_REQUEST_PDU, \
  789. (ApRequestSize), \
  790. (MarshalledApRequest) \
  791. )
  792. // KERBERR NTAPI
  793. // KerbUnpackApRequest(
  794. // IN PUCHAR ApRequestMessage,
  795. // IN ULONG ApRequestSize,
  796. // OUT PKERB_AP_REQUEST * ApRequest
  797. // );
  798. #define KerbUnpackApRequest( ApRequestMessage,ApRequestSize, ApRequest) \
  799. KerbUnpackData( \
  800. (ApRequestMessage), \
  801. (ApRequestSize), \
  802. KERB_AP_REQUEST_PDU, \
  803. (PVOID *) (ApRequest) \
  804. )
  805. // VOID
  806. // KerbFreeApRequest(
  807. // IN PKERB_AP_REQUEST Request
  808. // );
  809. #define KerbFreeApRequest( Request) \
  810. KerbFreeData( \
  811. KERB_AP_REQUEST_PDU, \
  812. (PVOID) (Request) \
  813. )
  814. // KERBERR NTAPI
  815. // KerbPackApReply(
  816. // IN PKERB_AP_REPLY ApReplyMessage,
  817. // OUT PULONG ApReplySize,
  818. // OUT PUCHAR * MarshalledApReply
  819. // );
  820. #define KerbPackApReply( ApReplyMessage, ApReplySize, MarshalledApReply ) \
  821. KerbPackData( \
  822. (PVOID) (ApReplyMessage), \
  823. KERB_AP_REPLY_PDU, \
  824. (ApReplySize), \
  825. (MarshalledApReply) \
  826. )
  827. // KERBERR NTAPI
  828. // KerbUnpackApReply(
  829. // IN PUCHAR ApReplyMessage,
  830. // IN ULONG ApReplySize,
  831. // OUT PKERB_AP_REPLY * ApReply
  832. // );
  833. #define KerbUnpackApReply( ApReplyMessage,ApReplySize, ApReply) \
  834. KerbUnpackData( \
  835. (ApReplyMessage), \
  836. (ApReplySize), \
  837. KERB_AP_REPLY_PDU, \
  838. (PVOID *) (ApReply) \
  839. )
  840. // VOID
  841. // KerbFreeApReply(
  842. // IN PKERB_AP_REPLY Reply
  843. // );
  844. #define KerbFreeApReply( Reply) \
  845. KerbFreeData( \
  846. KERB_AP_REPLY_PDU, \
  847. (PVOID) (Reply) \
  848. )
  849. // KERBERR NTAPI
  850. // KerbPackApReplyBody(
  851. // IN PKERB_ENCRYPTED_AP_REPLY ApReplyBodyMessage,
  852. // OUT PULONG ApReplyBodySize,
  853. // OUT PUCHAR * MarshalledApReplyBody
  854. // );
  855. #define KerbPackApReplyBody( ApReplyBodyMessage, ApReplyBodySize, MarshalledApReplyBody ) \
  856. KerbPackData( \
  857. (PVOID) (ApReplyBodyMessage), \
  858. KERB_ENCRYPTED_AP_REPLY_PDU, \
  859. (ApReplyBodySize), \
  860. (MarshalledApReplyBody) \
  861. )
  862. // KERBERR NTAPI
  863. // KerbUnpackApReplyBody(
  864. // IN PUCHAR ApReplyBodyMessage,
  865. // IN ULONG ApReplyBodySize,
  866. // OUT PKERB_ENCRYPTED_AP_REPLY * ApReplyBody
  867. // );
  868. #define KerbUnpackApReplyBody( ApReplyBodyMessage,ApReplyBodySize, ApReplyBody) \
  869. KerbUnpackData( \
  870. (ApReplyBodyMessage), \
  871. (ApReplyBodySize), \
  872. KERB_ENCRYPTED_AP_REPLY_PDU, \
  873. (PVOID *) (ApReplyBody) \
  874. )
  875. // VOID
  876. // KerbFreeApReplyBody(
  877. // IN PKERB_ENCRYPTED_AP_REPLY ReplyBody
  878. // );
  879. #define KerbFreeApReplyBody( ReplyBody) \
  880. KerbFreeData( \
  881. KERB_ENCRYPTED_AP_REPLY_PDU, \
  882. (PVOID) (ReplyBody) \
  883. )
  884. // KERBERR NTAPI
  885. // KerbUnmarshallTicket(
  886. // IN PUCHAR TicketMessage,
  887. // IN ULONG TicketSize,
  888. // OUT PKERB_ENCRYPTED_TICKET * Ticket
  889. // );
  890. #define KerbUnmarshallTicket( TicketMessage, TicketSize, Ticket ) \
  891. KerbUnpackData( \
  892. (TicketMessage), \
  893. (TicketSize), \
  894. KERB_ENCRYPTED_TICKET_PDU, \
  895. (PVOID *) (Ticket) \
  896. )
  897. // KERBERR NTAPI
  898. // KerbPackEncryptedCred(
  899. // IN PKERB_ENCRYPTED_CRED EncryptedCred,
  900. // OUT PULONG CredSize,
  901. // OUT PUCHAR * MarshalledCred
  902. // );
  903. #define KerbPackEncryptedCred( EncryptedCred, CredSize, MarshalledCred ) \
  904. KerbPackData( \
  905. (PVOID) (EncryptedCred), \
  906. KERB_ENCRYPTED_CRED_PDU, \
  907. (CredSize), \
  908. (MarshalledCred) \
  909. )
  910. // KERBERR NTAPI
  911. // KerbUnpackEncryptedCred(
  912. // IN PUCHAR EncryptedCred,
  913. // IN ULONG CredSize,
  914. // OUT PKERB_ENCRYPTED_CRED * Cred
  915. // );
  916. #define KerbUnpackEncryptedCred( EncryptedCred,CredSize,Cred ) \
  917. KerbUnpackData( \
  918. (EncryptedCred), \
  919. (CredSize), \
  920. KERB_ENCRYPTED_CRED_PDU, \
  921. (PVOID *) (Cred) \
  922. )
  923. // VOID
  924. // KerbFreeEncryptedCred(
  925. // IN PKERB_ENCRYPTED_CRED EncryptedCred
  926. // );
  927. #define KerbFreeEncryptedCred( EncryptedCred) \
  928. KerbFreeData( \
  929. KERB_ENCRYPTED_CRED_PDU, \
  930. (PVOID) (EncryptedCred) \
  931. )
  932. // KERBERR NTAPI
  933. // KerbPackKerbCred(
  934. // IN PKERB_CRED KerbCred,
  935. // OUT PULONG KerbCredSize,
  936. // OUT PUCHAR * MarshalledKerbCred
  937. // );
  938. #define KerbPackKerbCred( KerbCred, KerbCredSize, MarshalledKerbCred ) \
  939. KerbPackData( \
  940. (PVOID) (KerbCred), \
  941. KERB_CRED_PDU, \
  942. (KerbCredSize), \
  943. (MarshalledKerbCred) \
  944. )
  945. // KERBERR NTAPI
  946. // KerbUnpackKerbCred(
  947. // IN PUCHAR MarshalledKerbCred,
  948. // IN ULONG KerbCredSize,
  949. // OUT PKERB_CRED * KerbCred
  950. // );
  951. #define KerbUnpackKerbCred( MarshalledKerbCred,KerbCredSize,KerbCred ) \
  952. KerbUnpackData( \
  953. (MarshalledKerbCred), \
  954. (KerbCredSize), \
  955. KERB_CRED_PDU, \
  956. (PVOID *) (KerbCred) \
  957. )
  958. // VOID
  959. // KerbFreeKerbCred(
  960. // IN PKERB_CRED KerbCred
  961. // );
  962. #define KerbFreeKerbCred( KerbCred) \
  963. KerbFreeData( \
  964. KERB_CRED_PDU, \
  965. (PVOID) (KerbCred) \
  966. )
  967. // KERBERR NTAPI
  968. // KerbPackKerbError(
  969. // IN PKERB_ERROR ErrorMessage,
  970. // OUT PULONG ErrorSize,
  971. // OUT PUCHAR * MarshalledError
  972. // );
  973. #define KerbPackKerbError( ErrorMessage, ErrorSize, MarshalledError ) \
  974. KerbPackData( \
  975. (PVOID) (ErrorMessage), \
  976. KERB_ERROR_PDU, \
  977. (ErrorSize), \
  978. (MarshalledError) \
  979. )
  980. // KERBERR NTAPI
  981. // KerbUnpackKerbError(
  982. // IN PUCHAR ErrorMessage,
  983. // IN ULONG ErrorSize,
  984. // OUT PKERB_ERROR * Error
  985. // );
  986. #define KerbUnpackKerbError( ErrorMessage, ErrorSize, Error ) \
  987. KerbUnpackData( \
  988. (ErrorMessage), \
  989. (ErrorSize), \
  990. KERB_ERROR_PDU, \
  991. (PVOID *) (Error) \
  992. )
  993. // VOID
  994. // KerbFreeKerbError(
  995. // IN PKERB_ERROR Request
  996. // );
  997. #define KerbFreeKerbError( Error ) \
  998. KerbFreeData( \
  999. KERB_ERROR_PDU, \
  1000. (PVOID) (Error) \
  1001. )
  1002. // KERBERR NTAPI
  1003. // KerbPackEncryptedTime(
  1004. // IN PKERB_ENCRYPTED_TIMESTAMP EncryptedTimeMessage,
  1005. // OUT PULONG EncryptedTimeSize,
  1006. // OUT PUCHAR * MarshalledEncryptedTime
  1007. // );
  1008. #define KerbPackEncryptedTime( EncryptedTimeMessage, EncryptedTimeSize, MarshalledEncryptedTime ) \
  1009. KerbPackData( \
  1010. (PVOID) (EncryptedTimeMessage), \
  1011. KERB_ENCRYPTED_TIMESTAMP_PDU, \
  1012. (EncryptedTimeSize), \
  1013. (MarshalledEncryptedTime) \
  1014. )
  1015. // KERBERR NTAPI
  1016. // KerbUnpackEncryptedTime(
  1017. // IN PUCHAR EncryptedTimeMessage,
  1018. // IN ULONG EncryptedTimeSize,
  1019. // OUT PKERB_ENCRYPTED_TIMESTAMP * EncryptedTime
  1020. // );
  1021. #define KerbUnpackEncryptedTime( EncryptedTimeMessage, EncryptedTimeSize, EncryptedTime ) \
  1022. KerbUnpackData( \
  1023. (EncryptedTimeMessage), \
  1024. (EncryptedTimeSize), \
  1025. KERB_ENCRYPTED_TIMESTAMP_PDU, \
  1026. (PVOID *) (EncryptedTime) \
  1027. )
  1028. // VOID
  1029. // KerbFreeEncryptedTime(
  1030. // IN PKERB_ENCRYPTED_TIMESTAMP EncryptedTime
  1031. // );
  1032. #define KerbFreeEncryptedTime( EncryptedTime ) \
  1033. KerbFreeData( \
  1034. KERB_ENCRYPTED_TIMESTAMP_PDU, \
  1035. (PVOID) (EncryptedTime) \
  1036. )
  1037. KERBERR
  1038. KerbAllocateEncryptionBuffer(
  1039. IN ULONG EncryptionType,
  1040. IN ULONG BufferSize,
  1041. OUT PUINT EncryptionBufferSize,
  1042. OUT PBYTE * EncryptionBuffer
  1043. );
  1044. KERBERR
  1045. KerbAllocateEncryptionBufferWrapper(
  1046. IN ULONG EncryptionType,
  1047. IN ULONG BufferSize,
  1048. OUT unsigned long * EncryptionBufferSize,
  1049. OUT PBYTE * EncryptionBuffer
  1050. );
  1051. KERBERR NTAPI
  1052. KerbEncryptData(
  1053. OUT PKERB_ENCRYPTED_DATA EncryptedData,
  1054. IN ULONG DataSize,
  1055. IN PUCHAR Data,
  1056. IN ULONG Algorithm,
  1057. IN PKERB_ENCRYPTION_KEY Key
  1058. );
  1059. KERBERR NTAPI
  1060. KerbDecryptData(
  1061. IN PKERB_ENCRYPTED_DATA EncryptedData,
  1062. IN PKERB_ENCRYPTION_KEY pkKey,
  1063. OUT PULONG DataSize,
  1064. OUT PUCHAR Data
  1065. );
  1066. KERBERR NTAPI
  1067. KerbEncryptDataEx(
  1068. OUT PKERB_ENCRYPTED_DATA EncryptedData,
  1069. IN ULONG DataSize,
  1070. IN PUCHAR Data,
  1071. IN ULONG KeyVersion,
  1072. IN ULONG UsageFlags,
  1073. IN PKERB_ENCRYPTION_KEY Key
  1074. );
  1075. KERBERR NTAPI
  1076. KerbDecryptDataEx(
  1077. IN PKERB_ENCRYPTED_DATA EncryptedData,
  1078. IN PKERB_ENCRYPTION_KEY pkKey,
  1079. IN ULONG UsageFlags,
  1080. OUT PULONG DataSize,
  1081. OUT PUCHAR Data
  1082. );
  1083. #ifndef WIN32_CHICAGO
  1084. KERBERR NTAPI
  1085. KerbCheckSumVerify(
  1086. IN PUCHAR pbBuffer,
  1087. IN ULONG cbBuffer,
  1088. OUT PKERB_CHECKSUM pcsCheck
  1089. );
  1090. KERBERR NTAPI
  1091. KerbCheckSum(
  1092. PUCHAR pbData,
  1093. ULONG cbData,
  1094. PCHECKSUM_FUNCTION pcsfSum,
  1095. PKERB_CHECKSUM pcsCheckSum
  1096. );
  1097. #endif // WIN32_CHICAGO
  1098. KERBERR
  1099. KerbGetEncryptionOverhead(
  1100. IN ULONG Algorithm,
  1101. OUT PULONG Overhead,
  1102. OUT OPTIONAL PULONG BlockSize
  1103. );
  1104. NTSTATUS
  1105. KerbDuplicateSid(
  1106. OUT PSID * DestinationSid,
  1107. IN PSID SourceSid
  1108. );
  1109. NTSTATUS
  1110. KerbConvertStringToSid(
  1111. IN PUNICODE_STRING String,
  1112. OUT PSID * Sid
  1113. );
  1114. NTSTATUS
  1115. KerbConvertSidToString(
  1116. IN PSID Sid,
  1117. OUT PUNICODE_STRING String,
  1118. IN BOOLEAN AllocateDestination
  1119. );
  1120. KERBERR
  1121. KerbExtractSidFromKdcName(
  1122. IN OUT PKERB_INTERNAL_NAME Name,
  1123. OUT PSID * Sid
  1124. );
  1125. KERBERR
  1126. KerbBuildFullServiceKdcNameWithSid(
  1127. IN PUNICODE_STRING DomainName,
  1128. IN PUNICODE_STRING ServiceName,
  1129. IN OPTIONAL PSID Sid,
  1130. IN ULONG NameType,
  1131. OUT PKERB_INTERNAL_NAME * FullServiceName
  1132. );
  1133. NTSTATUS
  1134. KerbDuplicateString(
  1135. OUT PUNICODE_STRING DestinationString,
  1136. IN OPTIONAL PUNICODE_STRING SourceString
  1137. );
  1138. LPWSTR
  1139. KerbBuildNullTerminatedString(
  1140. IN PUNICODE_STRING String
  1141. );
  1142. VOID
  1143. KerbFreeString(
  1144. IN OPTIONAL PUNICODE_STRING String
  1145. );
  1146. VOID
  1147. KerbFreeRealm(
  1148. IN PKERB_REALM Realm
  1149. );
  1150. KERBERR
  1151. KerbCompareUnicodeRealmToKerbRealm(
  1152. IN PKERB_REALM KerbRealm,
  1153. IN PUNICODE_STRING UnicodeRealm,
  1154. OUT PBOOLEAN Result
  1155. );
  1156. VOID
  1157. KerbFreePrincipalName(
  1158. IN PKERB_PRINCIPAL_NAME Name
  1159. );
  1160. #ifndef WIN32_CHICAGO
  1161. KERBERR
  1162. KerbCheckLogonRestrictions(
  1163. IN PVOID UserHandle,
  1164. IN PUNICODE_STRING Workstation,
  1165. IN PUSER_ALL_INFORMATION UserAll,
  1166. IN ULONG LogonRestrictionsFlags,
  1167. OUT PTimeStamp LogoffTime,
  1168. OUT PNTSTATUS RetStatus
  1169. );
  1170. #include <pacndr.h>
  1171. NTSTATUS
  1172. PAC_EncodeTokenRestrictions(
  1173. IN PKERB_TOKEN_RESTRICTIONS TokenRestrictions,
  1174. OUT PBYTE * EncodedData,
  1175. OUT PULONG DataSize
  1176. );
  1177. NTSTATUS
  1178. PAC_DecodeTokenRestrictions(
  1179. IN PBYTE EncodedData,
  1180. IN ULONG DataSize,
  1181. OUT PKERB_TOKEN_RESTRICTIONS * TokenRestrictions
  1182. );
  1183. #define KERB_TOKEN_RESTRICTION_DISABLE_GROUPS 1
  1184. #define KERB_TOKEN_RESTRICTION_RESTRICT_SIDS 2
  1185. #define KERB_TOKEN_RESTRICTION_DELETE_PRIVS 4
  1186. #endif // WIN32_CHICAGO
  1187. KERBERR
  1188. KerbConvertStringToPrincipalName(
  1189. OUT PKERB_PRINCIPAL_NAME PrincipalName,
  1190. IN PUNICODE_STRING String,
  1191. IN ULONG NameType
  1192. );
  1193. KERBERR
  1194. KerbDuplicatePrincipalName(
  1195. OUT PKERB_PRINCIPAL_NAME PrincipalName,
  1196. IN PKERB_PRINCIPAL_NAME SourcePrincipalName
  1197. );
  1198. KERBERR
  1199. KerbConvertPrincipalNameToString(
  1200. OUT PUNICODE_STRING String,
  1201. OUT PULONG NameType,
  1202. IN PKERB_PRINCIPAL_NAME PrincipalName
  1203. );
  1204. KERBERR
  1205. KerbConvertPrincipalNameToFullServiceString(
  1206. OUT PUNICODE_STRING String,
  1207. IN PKERB_PRINCIPAL_NAME PrincipalName,
  1208. IN KERB_REALM RealmName
  1209. );
  1210. BOOLEAN
  1211. KerbComparePrincipalNames(
  1212. IN PKERB_PRINCIPAL_NAME Name1,
  1213. IN PKERB_PRINCIPAL_NAME Name2
  1214. );
  1215. KERBERR
  1216. KerbConvertUnicodeStringToRealm(
  1217. OUT PKERB_REALM Realm,
  1218. IN PUNICODE_STRING String
  1219. );
  1220. KERBERR
  1221. KerbConvertRealmToUnicodeString(
  1222. OUT PUNICODE_STRING String,
  1223. IN PKERB_REALM Realm
  1224. );
  1225. KERBERR
  1226. KerbDuplicateRealm(
  1227. OUT PKERB_REALM Realm,
  1228. IN KERB_REALM SourceRealm
  1229. );
  1230. BOOLEAN
  1231. KerbCompareRealmNames(
  1232. IN PKERB_REALM Realm1,
  1233. IN PKERB_REALM Realm2
  1234. );
  1235. BOOLEAN
  1236. KerbCompareUnicodeRealmNames(
  1237. IN PUNICODE_STRING Domain1,
  1238. IN PUNICODE_STRING Domain2
  1239. );
  1240. BOOLEAN
  1241. KerbCompareStringToPrincipalName(
  1242. IN PKERB_PRINCIPAL_NAME PrincipalName,
  1243. IN PUNICODE_STRING String
  1244. );
  1245. VOID
  1246. KerbConvertLargeIntToGeneralizedTime(
  1247. OUT PKERB_TIME ClientTime,
  1248. OUT OPTIONAL int * ClientUsec,
  1249. IN PTimeStamp TimeStamp
  1250. );
  1251. VOID
  1252. KerbConvertLargeIntToGeneralizedTimeWrapper(
  1253. OUT PKERB_TIME ClientTime,
  1254. OUT OPTIONAL long * ClientUsec,
  1255. IN PTimeStamp TimeStamp
  1256. );
  1257. VOID
  1258. KerbConvertGeneralizedTimeToLargeInt(
  1259. OUT PTimeStamp TimeStamp,
  1260. IN PKERB_TIME ClientTime,
  1261. IN int ClientUsec
  1262. );
  1263. BOOLEAN
  1264. KerbCheckTimeSkew(
  1265. IN PTimeStamp CurrentTime,
  1266. IN PTimeStamp ClientTime,
  1267. IN PTimeStamp AllowedSkew
  1268. );
  1269. KERBERR
  1270. KerbConvertArrayToCryptList(
  1271. OUT PKERB_CRYPT_LIST * CryptList,
  1272. IN PULONG ETypeArray,
  1273. IN ULONG ETypeCount,
  1274. IN BOOL bIncludeOldEtypes
  1275. );
  1276. KERBERR
  1277. KerbConvertKeysToCryptList(
  1278. OUT PKERB_CRYPT_LIST * CryptList,
  1279. IN PKERB_STORED_CREDENTIAL Keys
  1280. );
  1281. KERBERR
  1282. KerbConvertCryptListToArray(
  1283. OUT PULONG * ETypeArray,
  1284. OUT PULONG ETypeCount,
  1285. IN PKERB_CRYPT_LIST CryptList
  1286. );
  1287. VOID
  1288. KerbFreeCryptList(
  1289. IN PKERB_CRYPT_LIST CryptList
  1290. );
  1291. PKERB_AUTHORIZATION_DATA
  1292. KerbFindAuthDataEntry(
  1293. IN ULONG EntryId,
  1294. IN PKERB_AUTHORIZATION_DATA AuthData
  1295. );
  1296. PKERB_PA_DATA
  1297. KerbFindPreAuthDataEntry(
  1298. IN ULONG EntryId,
  1299. IN PKERB_PA_DATA_LIST AuthData
  1300. );
  1301. VOID
  1302. KerbFreePreAuthData(
  1303. IN OPTIONAL PKERB_PA_DATA_LIST PreAuthData
  1304. );
  1305. KERBERR
  1306. KerbCopyAndAppendAuthData(
  1307. OUT PKERB_AUTHORIZATION_DATA * OutputAuthData,
  1308. IN PKERB_AUTHORIZATION_DATA InputAuthData
  1309. );
  1310. KERBERR
  1311. KerbGetPacFromAuthData(
  1312. IN PKERB_AUTHORIZATION_DATA AuthData,
  1313. OUT PKERB_IF_RELEVANT_AUTH_DATA ** ReturnIfRelevantData,
  1314. OUT PKERB_AUTHORIZATION_DATA * Pac
  1315. );
  1316. KERBERR
  1317. KerbBuildFullServiceName(
  1318. IN PUNICODE_STRING DomainName,
  1319. IN PUNICODE_STRING ServiceName,
  1320. OUT PUNICODE_STRING FullServiceName
  1321. );
  1322. KERBERR
  1323. KerbBuildUnicodeSpn(
  1324. IN PUNICODE_STRING DomainName,
  1325. IN PUNICODE_STRING ServiceName,
  1326. OUT PUNICODE_STRING UnicodeSpn
  1327. );
  1328. KERBERR
  1329. KerbBuildEmailName(
  1330. IN PUNICODE_STRING DomainName,
  1331. IN PUNICODE_STRING ServiceName,
  1332. OUT PUNICODE_STRING EmailName
  1333. );
  1334. KERBERR
  1335. KerbBuildFullServiceKdcName(
  1336. IN PUNICODE_STRING DomainName,
  1337. IN PUNICODE_STRING ServiceName,
  1338. IN ULONG NameType,
  1339. OUT PKERB_INTERNAL_NAME * FullServiceName
  1340. );
  1341. KERBERR
  1342. KerbBuildAltSecId(
  1343. OUT PUNICODE_STRING AlternateName,
  1344. IN PKERB_INTERNAL_NAME PrincipalName,
  1345. IN OPTIONAL PKERB_REALM Realm,
  1346. IN OPTIONAL PUNICODE_STRING UnicodeRealm
  1347. );
  1348. KERBERR
  1349. KerbBuildKeySalt(
  1350. IN PUNICODE_STRING DomainName,
  1351. IN PUNICODE_STRING ServiceName,
  1352. IN KERB_ACCOUNT_TYPE AccountType,
  1353. OUT PUNICODE_STRING KeySalt
  1354. );
  1355. KERBERR
  1356. KerbBuildKeySaltFromUpn(
  1357. IN PUNICODE_STRING Upn,
  1358. OUT PUNICODE_STRING Salt
  1359. );
  1360. KERBERR
  1361. KerbBuildErrorMessageEx(
  1362. IN KERBERR ErrorCode,
  1363. IN OPTIONAL PKERB_EXT_ERROR pExtendedError,
  1364. IN PUNICODE_STRING ServerRealm,
  1365. IN PKERB_INTERNAL_NAME ServerName,
  1366. IN OPTIONAL PUNICODE_STRING ClientRealm,
  1367. IN OPTIONAL PBYTE ErrorData,
  1368. IN ULONG ErrorDataSize,
  1369. OUT PULONG ErrorMessageSize,
  1370. OUT PUCHAR * ErrorMessage
  1371. );
  1372. KERBERR
  1373. KerbBuildExtendedError(
  1374. IN PKERB_EXT_ERROR pExtendedError,
  1375. OUT PULONG ExtErrorSize,
  1376. OUT PBYTE* ExtErrorData
  1377. );
  1378. #ifdef __cplusplus
  1379. } // extern "C"
  1380. #endif
  1381. //
  1382. // Socket functions
  1383. //
  1384. NTSTATUS
  1385. KerbInitializeSockets(
  1386. IN WORD VersionRequired,
  1387. IN ULONG MinSockets,
  1388. OUT BOOLEAN *TcpNotInstalled
  1389. );
  1390. VOID
  1391. KerbCleanupSockets(
  1392. );
  1393. NTSTATUS
  1394. KerbCallKdc(
  1395. IN PUNICODE_STRING KdcAddress,
  1396. IN ULONG AddressType,
  1397. IN ULONG Timeout,
  1398. IN BOOLEAN UseDatagram,
  1399. IN USHORT PortNumber,
  1400. IN PKERB_MESSAGE_BUFFER Input,
  1401. OUT PKERB_MESSAGE_BUFFER Output
  1402. );
  1403. NTSTATUS
  1404. KerbMapKerbError(
  1405. IN KERBERR KerbError
  1406. );
  1407. VOID
  1408. KerbFreeHostAddresses(
  1409. IN PKERB_HOST_ADDRESSES Addresses
  1410. );
  1411. KERBERR
  1412. KerbDuplicateHostAddresses(
  1413. OUT PKERB_HOST_ADDRESSES * DestAddresses,
  1414. IN PKERB_HOST_ADDRESSES SourceAddresses
  1415. );
  1416. KERBERR
  1417. KerbUnicodeStringToKerbString(
  1418. OUT PSTRING KerbString,
  1419. IN PUNICODE_STRING String
  1420. );
  1421. KERBERR
  1422. KerbStringToUnicodeString(
  1423. OUT PUNICODE_STRING String,
  1424. IN PSTRING KerbString
  1425. );
  1426. BOOLEAN
  1427. KerbMbStringToUnicodeString(
  1428. PUNICODE_STRING pDest,
  1429. char * pszString
  1430. );
  1431. VOID
  1432. KerbFreeKdcName(
  1433. IN PKERB_INTERNAL_NAME * KdcName
  1434. );
  1435. KERBERR
  1436. KerbConvertPrincipalNameToKdcName(
  1437. OUT PKERB_INTERNAL_NAME * OutputName,
  1438. IN PKERB_PRINCIPAL_NAME PrincipalName
  1439. );
  1440. KERBERR
  1441. KerbConvertKdcNameToPrincipalName(
  1442. OUT PKERB_PRINCIPAL_NAME PrincipalName,
  1443. IN PKERB_INTERNAL_NAME KdcName
  1444. );
  1445. BOOLEAN
  1446. KerbEqualKdcNames(
  1447. IN PKERB_INTERNAL_NAME Name1,
  1448. IN PKERB_INTERNAL_NAME Name2
  1449. );
  1450. KERBERR
  1451. KerbCompareKdcNameToPrincipalName(
  1452. IN PKERB_PRINCIPAL_NAME PrincipalName,
  1453. IN PKERB_INTERNAL_NAME KdcName,
  1454. OUT PBOOLEAN Result
  1455. );
  1456. VOID
  1457. KerbPrintKdcNameEx(
  1458. IN ULONG DebugLevel,
  1459. IN ULONG InfoLevel,
  1460. IN PKERB_INTERNAL_NAME Name
  1461. );
  1462. #define KERB_INTERNAL_NAME_SIZE(NameCount) (sizeof(KERB_INTERNAL_NAME) + ((NameCount) - ANYSIZE_ARRAY) * sizeof(UNICODE_STRING))
  1463. KERBERR
  1464. KerbConvertStringToKdcName(
  1465. OUT PKERB_INTERNAL_NAME * PrincipalName,
  1466. IN PUNICODE_STRING String
  1467. );
  1468. NTSTATUS
  1469. KerbBuildKpasswdName(
  1470. OUT PKERB_INTERNAL_NAME * KpasswdName
  1471. );
  1472. KERBERR
  1473. KerbConvertKdcNameToString(
  1474. OUT PUNICODE_STRING String,
  1475. IN PKERB_INTERNAL_NAME PrincipalName,
  1476. IN PUNICODE_STRING Realm
  1477. );
  1478. NTSTATUS
  1479. KerbDuplicateKdcName(
  1480. OUT PKERB_INTERNAL_NAME * Destination,
  1481. IN PKERB_INTERNAL_NAME Source
  1482. );
  1483. PSID
  1484. KerbMakeDomainRelativeSid(
  1485. IN PSID DomainId,
  1486. IN ULONG RelativeId
  1487. );
  1488. ULONG
  1489. KerbConvertFlagsToUlong(
  1490. IN PVOID Flags
  1491. );
  1492. ULONG
  1493. KerbConvertUlongToFlagUlong(
  1494. IN ULONG Flag
  1495. );
  1496. BOOLEAN
  1497. KerbCompareObjectIds(
  1498. IN PKERB_OBJECT_ID Object1,
  1499. IN PKERB_OBJECT_ID Object2
  1500. );
  1501. KERBERR
  1502. KerbGetClientNetbiosAddress(
  1503. OUT PUNICODE_STRING ClientNetbiosAddress,
  1504. IN PKERB_HOST_ADDRESSES Addresses
  1505. );
  1506. #ifdef __WINCRYPT_H__
  1507. KERBERR
  1508. KerbCreateCertificateList(
  1509. OUT PKERB_CERTIFICATE_LIST * Certificates,
  1510. IN PCCERT_CONTEXT CertContext
  1511. );
  1512. VOID
  1513. KerbFreeCertificateList(
  1514. IN PKERB_CERTIFICATE_LIST Certificates
  1515. );
  1516. NTSTATUS
  1517. KerbGetPrincipalNameFromCertificate(
  1518. IN PCCERT_CONTEXT ClientCert,
  1519. OUT PUNICODE_STRING String
  1520. );
  1521. NTSTATUS
  1522. KerbDuplicateStringEx(
  1523. OUT PUNICODE_STRING DestinationString,
  1524. IN OPTIONAL PUNICODE_STRING SourceString,
  1525. IN BOOLEAN NullTerminate
  1526. );
  1527. #if DBG
  1528. void
  1529. DebugDisplayTime(
  1530. IN ULONG DebugLevel,
  1531. IN FILETIME *pFileTime
  1532. );
  1533. #endif
  1534. #endif // __WINCRYPT_H__
  1535. #endif // _KERBCOMM_H_