SSPI.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:49k
源码类别:

Windows编程

开发平台:

Visual C++

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright (C) Microsoft Corporation, 1992-1997.
  5. //
  6. //  File:       sspi.h
  7. //
  8. //  Contents:   Security Support Provider Interface
  9. //              Prototypes and structure definitions
  10. //
  11. //  Functions:  Security Support Provider API
  12. //
  13. //  History:    11-24-93   RichardW   Created
  14. //
  15. //----------------------------------------------------------------------------
  16. #ifndef __SSPI_H__
  17. #define __SSPI_H__
  18. //
  19. // Determine environment:
  20. //
  21. #ifdef SECURITY_WIN32
  22. #define ISSP_LEVEL  32
  23. #define ISSP_MODE   1
  24. #endif // SECURITY_WIN32
  25. #ifdef SECURITY_WIN16
  26. #define ISSP_LEVEL  16
  27. #define ISSP_MODE   1
  28. #endif // SECURITY_WIN16
  29. #ifdef SECURITY_KERNEL
  30. #define ISSP_LEVEL  32
  31. //
  32. // SECURITY_KERNEL trumps SECURITY_WIN32.  Undefine ISSP_MODE so that
  33. // we don't get redefine errors.
  34. //
  35. #ifdef ISSP_MODE
  36. #undef ISSP_MODE
  37. #endif
  38. #define ISSP_MODE   0
  39. #endif // SECURITY_KERNEL
  40. #ifdef SECURITY_OS212
  41. #define ISSP_LEVEL  16
  42. #define ISSP_MODE   1
  43. #endif // SECURITY_OS212
  44. #ifdef SECURITY_DOS
  45. #define ISSP_LEVEL  16
  46. #define ISSP_MODE   1
  47. #endif // SECURITY_DOS
  48. #ifdef SECURITY_MAC
  49. #define ISSP_LEVEL  32
  50. #define ISSP_MODE   1
  51. #endif // SECURITY_MAC
  52. #ifndef ISSP_LEVEL
  53. #error  You must define one of SECURITY_WIN32, SECURITY_WIN16, SECURITY_KERNEL
  54. #error  SECURITY_DOS, SECURITY_MAC or SECURITY_OS212
  55. #endif // !ISSP_LEVEL
  56. //
  57. // Now, define platform specific mappings:
  58. //
  59. #if ISSP_LEVEL == 16
  60. typedef short SECURITY_STATUS;
  61. typedef unsigned short SEC_WCHAR;
  62. typedef char SEC_CHAR;
  63. #define SEC_TEXT(_x_) _x_
  64. #ifdef SECURITY_WIN16
  65. #define SEC_FAR __far
  66. #define SEC_ENTRY __pascal __far __export
  67. #else // SECURITY_WIN16
  68. #define SEC_FAR __far
  69. #define SEC_ENTRY __pascal __far __loadds
  70. #pragma warning(disable:4147)
  71. #endif // SECURITY_WIN16
  72. #elif defined(SECURITY_MAC)  // ISSP_LEVEL == 16
  73. #define SEC_ENTRY
  74. #define SEC_TEXT(_X_) _X_
  75. #define SEC_FAR
  76. typedef unsigned short SEC_WCHAR;
  77. typedef char SEC_CHAR;
  78. typedef long SECURITY_STATUS;
  79. // No Unicode on the Mac
  80. typedef SEC_CHAR SEC_FAR * SECURITY_PSTR;
  81. typedef SEC_CHAR SEC_FAR * SECURITY_PCSTR;
  82. #else // ISSP_LEVEL == 16
  83. //
  84. // For NT-2 and up, wtypes will define HRESULT to be long.
  85. //
  86. // begin_ntifs
  87. typedef WCHAR SEC_WCHAR;
  88. typedef CHAR SEC_CHAR;
  89. typedef LONG SECURITY_STATUS;
  90. #define SEC_TEXT TEXT
  91. #define SEC_FAR
  92. #define SEC_ENTRY __stdcall
  93. // end_ntifs
  94. //
  95. // Decide what a string - 32 bits only since for 16 bits it is clear.
  96. //
  97. #ifdef UNICODE
  98. typedef SEC_WCHAR SEC_FAR * SECURITY_PSTR;
  99. typedef CONST SEC_WCHAR SEC_FAR * SECURITY_PCSTR;
  100. #else // UNICODE
  101. typedef SEC_CHAR SEC_FAR * SECURITY_PSTR;
  102. typedef CONST SEC_CHAR SEC_FAR * SECURITY_PCSTR;
  103. #endif // UNICODE
  104. #endif // ISSP_LEVEL == 16
  105. //
  106. // Equivalent string for rpcrt:
  107. //
  108. #define __SEC_FAR SEC_FAR
  109. //
  110. // Okay, security specific types:
  111. //
  112. // begin_ntifs
  113. typedef struct _SecHandle
  114. {
  115.     unsigned long dwLower;
  116.     unsigned long dwUpper;
  117. } SecHandle, SEC_FAR * PSecHandle;
  118. typedef SecHandle CredHandle;
  119. typedef PSecHandle PCredHandle;
  120. typedef SecHandle CtxtHandle;
  121. typedef PSecHandle PCtxtHandle;
  122. // end_ntifs
  123. #if ISSP_LEVEL == 32
  124. #  ifdef WIN32_CHICAGO
  125. typedef unsigned __int64 QWORD;
  126. typedef QWORD SECURITY_INTEGER, *PSECURITY_INTEGER;
  127. #define SEC_SUCCESS(Status) ((Status) >= 0)
  128. #  elif defined(_NTDEF_) || defined(_WINNT_)
  129. typedef LARGE_INTEGER _SECURITY_INTEGER, SECURITY_INTEGER, *PSECURITY_INTEGER; // ntifs
  130. #  else // _NTDEF_ || _WINNT_
  131. // BUGBUG:  Alignment for axp
  132. typedef struct _SECURITY_INTEGER
  133. {
  134.     unsigned long LowPart;
  135.     long HighPart;
  136. } SECURITY_INTEGER, *PSECURITY_INTEGER;
  137. #  endif // _NTDEF_ || _WINNT_
  138. #  ifndef SECURITY_MAC
  139. typedef SECURITY_INTEGER TimeStamp;                 // ntifs
  140. typedef SECURITY_INTEGER SEC_FAR * PTimeStamp;      // ntifs
  141. #  else // SECURITY_MAC
  142. typedef unsigned long TimeStamp;
  143. typedef unsigned long * PTimeStamp;
  144. #  endif // SECUIRT_MAC
  145. #else // ISSP_LEVEL == 32
  146. typedef unsigned long TimeStamp;
  147. typedef unsigned long SEC_FAR * PTimeStamp;
  148. #  ifdef WIN32_CHICAGO
  149. typedef TimeStamp LARGE_INTEGER;
  150. #endif // WIN32_CHICAGO
  151. #endif // ISSP_LEVEL == 32
  152. //
  153. // If we are in 32 bit mode, define the SECURITY_STRING structure,
  154. // as a clone of the base UNICODE_STRING structure.  This is used
  155. // internally in security components, an as the string interface
  156. // for kernel components (e.g. FSPs)
  157. //
  158. #if ISSP_LEVEL == 32
  159. #  ifndef _NTDEF_
  160. typedef struct _SECURITY_STRING {
  161.     unsigned short      Length;
  162.     unsigned short      MaximumLength;
  163. #    ifdef MIDL_PASS
  164.     [size_is(MaximumLength / 2), length_is(Length / 2)]
  165. #    endif // MIDL_PASS
  166.     unsigned short *    Buffer;
  167. } SECURITY_STRING, * PSECURITY_STRING;
  168. #  else // _NTDEF_
  169. typedef UNICODE_STRING SECURITY_STRING, *PSECURITY_STRING;  // ntifs
  170. #  endif // _NTDEF_
  171. #endif // ISSP_LEVEL == 32
  172. // begin_ntifs
  173. //
  174. // SecPkgInfo structure
  175. //
  176. //  Provides general information about a security provider
  177. //
  178. typedef struct _SecPkgInfoW
  179. {
  180.     unsigned long fCapabilities;        // Capability bitmask
  181.     unsigned short wVersion;            // Version of driver
  182.     unsigned short wRPCID;              // ID for RPC Runtime
  183.     unsigned long cbMaxToken;           // Size of authentication token (max)
  184. #ifdef MIDL_PASS
  185.     [string]
  186. #endif
  187.     SEC_WCHAR SEC_FAR * Name;           // Text name
  188. #ifdef MIDL_PASS
  189.     [string]
  190. #endif
  191.     SEC_WCHAR SEC_FAR * Comment;        // Comment
  192. } SecPkgInfoW, SEC_FAR * PSecPkgInfoW;
  193. // end_ntifs
  194. typedef struct _SecPkgInfoA
  195. {
  196.     unsigned long fCapabilities;        // Capability bitmask
  197.     unsigned short wVersion;            // Version of driver
  198.     unsigned short wRPCID;              // ID for RPC Runtime
  199.     unsigned long cbMaxToken;           // Size of authentication token (max)
  200. #ifdef MIDL_PASS
  201.     [string]
  202. #endif
  203.     SEC_CHAR SEC_FAR * Name;            // Text name
  204. #ifdef MIDL_PASS
  205.     [string]
  206. #endif
  207.     SEC_CHAR SEC_FAR * Comment;         // Comment
  208. } SecPkgInfoA, SEC_FAR * PSecPkgInfoA;
  209. #ifdef UNICODE
  210. #  define SecPkgInfo SecPkgInfoW        // ntifs
  211. #  define PSecPkgInfo PSecPkgInfoW      // ntifs
  212. #else
  213. #  define SecPkgInfo SecPkgInfoA
  214. #  define PSecPkgInfo PSecPkgInfoA
  215. #endif // !UNICODE
  216. // begin_ntifs
  217. //
  218. //  Security Package Capabilities
  219. //
  220. #define SECPKG_FLAG_INTEGRITY       0x00000001  // Supports integrity on messages
  221. #define SECPKG_FLAG_PRIVACY         0x00000002  // Supports privacy (confidentiality)
  222. #define SECPKG_FLAG_TOKEN_ONLY      0x00000004  // Only security token needed
  223. #define SECPKG_FLAG_DATAGRAM        0x00000008  // Datagram RPC support
  224. #define SECPKG_FLAG_CONNECTION      0x00000010  // Connection oriented RPC support
  225. #define SECPKG_FLAG_MULTI_REQUIRED  0x00000020  // Full 3-leg required for re-auth.
  226. #define SECPKG_FLAG_CLIENT_ONLY     0x00000040  // Server side functionality not available
  227. #define SECPKG_FLAG_EXTENDED_ERROR  0x00000080  // Supports extended error msgs
  228. #define SECPKG_FLAG_IMPERSONATION   0x00000100  // Supports impersonation
  229. #define SECPKG_FLAG_ACCEPT_WIN32_NAME   0x00000200  // Accepts Win32 names
  230. #define SECPKG_FLAG_STREAM          0x00000400  // Supports stream semantics
  231. #define SECPKG_FLAG_NEGOTIABLE      0x00000800  // Can be used by the negotiate package
  232. #define SECPKG_FLAG_GSS_COMPATIBLE  0x00001000  // GSS Compatibility Available
  233. #define SECPKG_FLAG_LOGON           0x00002000  // Supports common LsaLogonUser
  234. #define SECPKG_ID_NONE      0xFFFF
  235. //
  236. // SecBuffer
  237. //
  238. //  Generic memory descriptors for buffers passed in to the security
  239. //  API
  240. //
  241. typedef struct _SecBuffer {
  242.     unsigned long cbBuffer;             // Size of the buffer, in bytes
  243.     unsigned long BufferType;           // Type of the buffer (below)
  244.     void SEC_FAR * pvBuffer;            // Pointer to the buffer
  245. } SecBuffer, SEC_FAR * PSecBuffer;
  246. typedef struct _SecBufferDesc {
  247.     unsigned long ulVersion;            // Version number
  248.     unsigned long cBuffers;             // Number of buffers
  249. #ifdef MIDL_PASS
  250.     [size_is(cBuffers)]
  251. #endif
  252.     PSecBuffer pBuffers;                // Pointer to array of buffers
  253. } SecBufferDesc, SEC_FAR * PSecBufferDesc;
  254. #define SECBUFFER_VERSION           0
  255. #define SECBUFFER_EMPTY             0   // Undefined, replaced by provider
  256. #define SECBUFFER_DATA              1   // Packet data
  257. #define SECBUFFER_TOKEN             2   // Security token
  258. #define SECBUFFER_PKG_PARAMS        3   // Package specific parameters
  259. #define SECBUFFER_MISSING           4   // Missing Data indicator
  260. #define SECBUFFER_EXTRA             5   // Extra data
  261. #define SECBUFFER_STREAM_TRAILER    6   // Security Trailer
  262. #define SECBUFFER_STREAM_HEADER     7   // Security Header
  263. #define SECBUFFER_NEGOTIATION_INFO  8   // Hints from the negotiation pkg
  264. #define SECBUFFER_ATTRMASK          0xF0000000
  265. #define SECBUFFER_READONLY          0x80000000  // Buffer is read-only
  266. #define SECBUFFER_RESERVED          0x40000000
  267. typedef struct _SEC_NEGOTIATION_INFO {
  268.     unsigned long       Size;           // Size of this structure
  269.     unsigned long       NameLength;     // Length of name hint
  270.     SEC_WCHAR SEC_FAR * Name;           // Name hint
  271.     void SEC_FAR *      Reserved;       // Reserved
  272. } SEC_NEGOTIATION_INFO, SEC_FAR * PSEC_NEGOTIATION_INFO ;
  273. //
  274. //  Data Representation Constant:
  275. //
  276. #define SECURITY_NATIVE_DREP        0x00000010
  277. #define SECURITY_NETWORK_DREP       0x00000000
  278. //
  279. //  Credential Use Flags
  280. //
  281. #define SECPKG_CRED_INBOUND         0x00000001
  282. #define SECPKG_CRED_OUTBOUND        0x00000002
  283. #define SECPKG_CRED_BOTH            0x00000003
  284. //
  285. //  InitializeSecurityContext Requirement and return flags:
  286. //
  287. #define ISC_REQ_DELEGATE                0x00000001
  288. #define ISC_REQ_MUTUAL_AUTH             0x00000002
  289. #define ISC_REQ_REPLAY_DETECT           0x00000004
  290. #define ISC_REQ_SEQUENCE_DETECT         0x00000008
  291. #define ISC_REQ_CONFIDENTIALITY         0x00000010
  292. #define ISC_REQ_USE_SESSION_KEY         0x00000020
  293. #define ISC_REQ_PROMPT_FOR_CREDS        0x00000040
  294. #define ISC_REQ_USE_SUPPLIED_CREDS      0x00000080
  295. #define ISC_REQ_ALLOCATE_MEMORY         0x00000100
  296. #define ISC_REQ_USE_DCE_STYLE           0x00000200
  297. #define ISC_REQ_DATAGRAM                0x00000400
  298. #define ISC_REQ_CONNECTION              0x00000800
  299. #define ISC_REQ_CALL_LEVEL              0x00001000
  300. #define ISC_REQ_EXTENDED_ERROR          0x00004000
  301. #define ISC_REQ_STREAM                  0x00008000
  302. #define ISC_REQ_INTEGRITY               0x00010000
  303. #define ISC_REQ_IDENTIFY                0x00020000
  304. #define ISC_REQ_NULL_SESSION            0x00040000
  305. #define ISC_RET_DELEGATE                0x00000001
  306. #define ISC_RET_MUTUAL_AUTH             0x00000002
  307. #define ISC_RET_REPLAY_DETECT           0x00000004
  308. #define ISC_RET_SEQUENCE_DETECT         0x00000008
  309. #define ISC_RET_CONFIDENTIALITY         0x00000010
  310. #define ISC_RET_USE_SESSION_KEY         0x00000020
  311. #define ISC_RET_USED_COLLECTED_CREDS    0x00000040
  312. #define ISC_RET_USED_SUPPLIED_CREDS     0x00000080
  313. #define ISC_RET_ALLOCATED_MEMORY        0x00000100
  314. #define ISC_RET_USED_DCE_STYLE          0x00000200
  315. #define ISC_RET_DATAGRAM                0x00000400
  316. #define ISC_RET_CONNECTION              0x00000800
  317. #define ISC_RET_INTERMEDIATE_RETURN     0x00001000
  318. #define ISC_RET_CALL_LEVEL              0x00002000
  319. #define ISC_RET_EXTENDED_ERROR          0x00004000
  320. #define ISC_RET_STREAM                  0x00008000
  321. #define ISC_RET_INTEGRITY               0x00010000
  322. #define ISC_RET_IDENTIFY                0x00020000
  323. #define ISC_RET_NULL_SESSION            0x00040000
  324. #define ASC_REQ_DELEGATE                0x00000001
  325. #define ASC_REQ_MUTUAL_AUTH             0x00000002
  326. #define ASC_REQ_REPLAY_DETECT           0x00000004
  327. #define ASC_REQ_SEQUENCE_DETECT         0x00000008
  328. #define ASC_REQ_CONFIDENTIALITY         0x00000010
  329. #define ASC_REQ_USE_SESSION_KEY         0x00000020
  330. #define ASC_REQ_ALLOCATE_MEMORY         0x00000100
  331. #define ASC_REQ_USE_DCE_STYLE           0x00000200
  332. #define ASC_REQ_DATAGRAM                0x00000400
  333. #define ASC_REQ_CONNECTION              0x00000800
  334. #define ASC_REQ_CALL_LEVEL              0x00001000
  335. #define ASC_REQ_EXTENDED_ERROR          0x00008000
  336. #define ASC_REQ_STREAM                  0x00010000
  337. #define ASC_REQ_INTEGRITY               0x00020000
  338. #define ASC_REQ_LICENSING               0x00040000
  339. #define ASC_REQ_IDENTIFY                0x00080000
  340. #define ASC_REQ_ALLOW_NULL_SESSION      0x00100000
  341. #define ASC_RET_DELEGATE                0x00000001
  342. #define ASC_RET_MUTUAL_AUTH             0x00000002
  343. #define ASC_RET_REPLAY_DETECT           0x00000004
  344. #define ASC_RET_SEQUENCE_DETECT         0x00000008
  345. #define ASC_RET_CONFIDENTIALITY         0x00000010
  346. #define ASC_RET_USE_SESSION_KEY         0x00000020
  347. #define ASC_RET_ALLOCATED_MEMORY        0x00000100
  348. #define ASC_RET_USED_DCE_STYLE          0x00000200
  349. #define ASC_RET_DATAGRAM                0x00000400
  350. #define ASC_RET_CONNECTION              0x00000800
  351. #define ASC_RET_CALL_LEVEL              0x00002000 // skipped 1000 to be like ISC_
  352. #define ASC_RET_THIRD_LEG_FAILED        0x00004000
  353. #define ASC_RET_EXTENDED_ERROR          0x00008000
  354. #define ASC_RET_STREAM                  0x00010000
  355. #define ASC_RET_INTEGRITY               0x00020000
  356. #define ASC_RET_LICENSING               0x00040000
  357. #define ASC_RET_IDENTIFY                0x00080000
  358. #define ASC_RET_NULL_SESSION            0x00100000
  359. //
  360. //  Security Credentials Attributes:
  361. //
  362. #define SECPKG_CRED_ATTR_NAMES 1
  363. typedef struct _SecPkgCredentials_NamesW
  364. {
  365.     SEC_WCHAR SEC_FAR * sUserName;
  366. } SecPkgCredentials_NamesW, SEC_FAR * PSecPkgCredentials_NamesW;
  367. // end_ntifs
  368. typedef struct _SecPkgCredentials_NamesA
  369. {
  370.     SEC_CHAR SEC_FAR * sUserName;
  371. } SecPkgCredentials_NamesA, SEC_FAR * PSecPkgCredentials_NamesA;
  372. #ifdef UNICODE
  373. #  define SecPkgCredentials_Names SecPkgCredentials_NamesW      // ntifs
  374. #  define PSecPkgCredentials_Names PSecPkgCredentials_NamesW    // ntifs
  375. #else
  376. #  define SecPkgCredentials_Names SecPkgCredentials_NamesA
  377. #  define PSecPkgCredentials_Names PSecPkgCredentials_NamesA
  378. #endif // !UNICODE
  379. // begin_ntifs
  380. //
  381. //  Security Context Attributes:
  382. //
  383. #define SECPKG_ATTR_SIZES           0
  384. #define SECPKG_ATTR_NAMES           1
  385. #define SECPKG_ATTR_LIFESPAN        2
  386. #define SECPKG_ATTR_DCE_INFO        3
  387. #define SECPKG_ATTR_STREAM_SIZES    4
  388. #define SECPKG_ATTR_KEY_INFO        5
  389. #define SECPKG_ATTR_AUTHORITY       6
  390. #define SECPKG_ATTR_PROTO_INFO      7
  391. #define SECPKG_ATTR_PASSWORD_EXPIRY 8
  392. #define SECPKG_ATTR_SESSION_KEY     9
  393. #define SECPKG_ATTR_PACKAGE_INFO    10
  394. typedef struct _SecPkgContext_Sizes
  395. {
  396.     unsigned long cbMaxToken;
  397.     unsigned long cbMaxSignature;
  398.     unsigned long cbBlockSize;
  399.     unsigned long cbSecurityTrailer;
  400. } SecPkgContext_Sizes, SEC_FAR * PSecPkgContext_Sizes;
  401. typedef struct _SecPkgContext_StreamSizes
  402. {
  403.     unsigned long   cbHeader;
  404.     unsigned long   cbTrailer;
  405.     unsigned long   cbMaximumMessage;
  406.     unsigned long   cBuffers;
  407.     unsigned long   cbBlockSize;
  408. } SecPkgContext_StreamSizes, * PSecPkgContext_StreamSizes;
  409. typedef struct _SecPkgContext_NamesW
  410. {
  411.     SEC_WCHAR SEC_FAR * sUserName;
  412. } SecPkgContext_NamesW, SEC_FAR * PSecPkgContext_NamesW;
  413. // end_ntifs
  414. typedef struct _SecPkgContext_NamesA
  415. {
  416.     SEC_CHAR SEC_FAR * sUserName;
  417. } SecPkgContext_NamesA, SEC_FAR * PSecPkgContext_NamesA;
  418. #ifdef UNICODE
  419. #  define SecPkgContext_Names SecPkgContext_NamesW          // ntifs
  420. #  define PSecPkgContext_Names PSecPkgContext_NamesW        // ntifs
  421. #else
  422. #  define SecPkgContext_Names SecPkgContext_NamesA
  423. #  define PSecPkgContext_Names PSecPkgContext_NamesA
  424. #endif // !UNICODE
  425. // begin_ntifs
  426. typedef struct _SecPkgContext_Lifespan
  427. {
  428.     TimeStamp tsStart;
  429.     TimeStamp tsExpiry;
  430. } SecPkgContext_Lifespan, SEC_FAR * PSecPkgContext_Lifespan;
  431. typedef struct _SecPkgContext_DceInfo
  432. {
  433.     unsigned long AuthzSvc;
  434.     void SEC_FAR * pPac;
  435. } SecPkgContext_DceInfo, SEC_FAR * PSecPkgContext_DceInfo;
  436. // end_ntifs
  437. typedef struct _SecPkgContext_KeyInfoA
  438. {
  439.     SEC_CHAR SEC_FAR *  sSignatureAlgorithmName;
  440.     SEC_CHAR SEC_FAR *  sEncryptAlgorithmName;
  441.     unsigned long       KeySize;
  442.     unsigned long       SignatureAlgorithm;
  443.     unsigned long       EncryptAlgorithm;
  444. } SecPkgContext_KeyInfoA, SEC_FAR * PSecPkgContext_KeyInfoA;
  445. // begin_ntifs
  446. typedef struct _SecPkgContext_KeyInfoW
  447. {
  448.     SEC_WCHAR SEC_FAR * sSignatureAlgorithmName;
  449.     SEC_WCHAR SEC_FAR * sEncryptAlgorithmName;
  450.     unsigned long       KeySize;
  451.     unsigned long       SignatureAlgorithm;
  452.     unsigned long       EncryptAlgorithm;
  453. } SecPkgContext_KeyInfoW, SEC_FAR * PSecPkgContext_KeyInfoW;
  454. // end_ntifs
  455. #ifdef UNICODE
  456. #define SecPkgContext_KeyInfo   SecPkgContext_KeyInfoW      // ntifs
  457. #define PSecPkgContext_KeyInfo  PSecPkgContext_KeyInfoW     // ntifs
  458. #else
  459. #define SecPkgContext_KeyInfo   SecPkgContext_KeyInfoA
  460. #define PSecPkgContext_KeyInfo  PSecPkgContext_KeyInfoA
  461. #endif
  462. typedef struct _SecPkgContext_AuthorityA
  463. {
  464.     SEC_CHAR SEC_FAR *  sAuthorityName;
  465. } SecPkgContext_AuthorityA, * PSecPkgContext_AuthorityA;
  466. // begin_ntifs
  467. typedef struct _SecPkgContext_AuthorityW
  468. {
  469.     SEC_WCHAR SEC_FAR * sAuthorityName;
  470. } SecPkgContext_AuthorityW, * PSecPkgContext_AuthorityW;
  471. // end_ntifs
  472. #ifdef UNICODE
  473. #define SecPkgContext_Authority SecPkgContext_AuthorityW        // ntifs
  474. #define PSecPkgContext_Authority    PSecPkgContext_AuthorityW   // ntifs
  475. #else
  476. #define SecPkgContext_Authority SecPkgContext_AuthorityA
  477. #define PSecPkgContext_Authority    PSecPkgContext_AuthorityA
  478. #endif
  479. typedef struct _SecPkgContext_ProtoInfoA
  480. {
  481.     SEC_CHAR SEC_FAR *  sProtocolName;
  482.     unsigned long       majorVersion;
  483.     unsigned long       minorVersion;
  484. } SecPkgContext_ProtoInfoA, SEC_FAR * PSecPkgContext_ProtoInfoA;
  485. // begin_ntifs
  486. typedef struct _SecPkgContext_ProtoInfoW
  487. {
  488.     SEC_WCHAR SEC_FAR * sProtocolName;
  489.     unsigned long       majorVersion;
  490.     unsigned long       minorVersion;
  491. } SecPkgContext_ProtoInfoW, SEC_FAR * PSecPkgContext_ProtoInfoW;
  492. // end_ntifs
  493. #ifdef UNICODE
  494. #define SecPkgContext_ProtoInfo   SecPkgContext_ProtoInfoW      // ntifs
  495. #define PSecPkgContext_ProtoInfo  PSecPkgContext_ProtoInfoW     // ntifs
  496. #else
  497. #define SecPkgContext_ProtoInfo   SecPkgContext_ProtoInfoA
  498. #define PSecPkgContext_ProtoInfo  PSecPkgContext_ProtoInfoA
  499. #endif
  500. // begin_ntifs
  501. typedef struct _SecPkgContext_PasswordExpiry
  502. {
  503.     TimeStamp tsPasswordExpires;
  504. } SecPkgContext_PasswordExpiry, SEC_FAR * PSecPkgContext_PasswordExpiry;
  505. typedef struct _SecPkgContext_SessionKey
  506. {
  507.     unsigned long SessionKeyLength;
  508.     unsigned char SEC_FAR * SessionKey;
  509. } SecPkgContext_SessionKey, *PSecPkgContext_SessionKey;
  510. // end_ntifs
  511. // begin_ntifs
  512. typedef struct _SecPkgContext_PackageInfoW
  513. {
  514.     PSecPkgInfoW PackageInfo;
  515. } SecPkgContext_PackageInfoW, SEC_FAR * PSecPkgContext_PackageInfoW;
  516. // end_ntifs
  517. typedef struct _SecPkgContext_PackageInfoA
  518. {
  519.     PSecPkgInfoA PackageInfo;
  520. } SecPkgContext_PackageInfoA, SEC_FAR * PSecPkgContext_PackageInfoA;
  521. #ifdef UNICODE
  522. #define SecPkgContext_PackageInfo   SecPkgContext_PackageInfoW      // ntifs
  523. #define PSecPkgContext_PackageInfo  PSecPkgContext_PackageInfoW     // ntifs
  524. #else
  525. #define SecPkgContext_PackageInfo   SecPkgContext_PackageInfoA
  526. #define PSecPkgContext_PackageInfo  PSecPkgContext_PackageInfoA
  527. #endif
  528. // begin_ntifs
  529. typedef void
  530. (SEC_ENTRY SEC_FAR * SEC_GET_KEY_FN) (
  531.     void SEC_FAR * Arg,                 // Argument passed in
  532.     void SEC_FAR * Principal,           // Principal ID
  533.     unsigned long KeyVer,               // Key Version
  534.     void SEC_FAR * SEC_FAR * Key,       // Returned ptr to key
  535.     SECURITY_STATUS SEC_FAR * Status    // returned status
  536.     );
  537. //
  538. // Flags for ExportSecurityContext
  539. //
  540. #define SECPKG_CONTEXT_EXPORT_RESET_NEW         0x00000001      // New context is reset to initial state
  541. #define SECPKG_CONTEXT_EXPORT_DELETE_OLD        0x00000002      // Old context is deleted during export
  542. SECURITY_STATUS SEC_ENTRY
  543. AcquireCredentialsHandleW(
  544. #if ISSP_MODE == 0                      // For Kernel mode
  545.     PSECURITY_STRING pPrincipal,
  546.     PSECURITY_STRING pPackage,
  547. #else
  548.     SEC_WCHAR SEC_FAR * pszPrincipal,   // Name of principal
  549.     SEC_WCHAR SEC_FAR * pszPackage,     // Name of package
  550. #endif
  551.     unsigned long fCredentialUse,       // Flags indicating use
  552.     void SEC_FAR * pvLogonId,           // Pointer to logon ID
  553.     void SEC_FAR * pAuthData,           // Package specific data
  554.     SEC_GET_KEY_FN pGetKeyFn,           // Pointer to GetKey() func
  555.     void SEC_FAR * pvGetKeyArgument,    // Value to pass to GetKey()
  556.     PCredHandle phCredential,           // (out) Cred Handle
  557.     PTimeStamp ptsExpiry                // (out) Lifetime (optional)
  558.     );
  559. typedef SECURITY_STATUS
  560. (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_W)(
  561. #if ISSP_MODE == 0
  562.     PSECURITY_STRING,
  563.     PSECURITY_STRING,
  564. #else
  565.     SEC_WCHAR SEC_FAR *,
  566.     SEC_WCHAR SEC_FAR *,
  567. #endif
  568.     unsigned long,
  569.     void SEC_FAR *,
  570.     void SEC_FAR *,
  571.     SEC_GET_KEY_FN,
  572.     void SEC_FAR *,
  573.     PCredHandle,
  574.     PTimeStamp);
  575. // end_ntifs
  576. SECURITY_STATUS SEC_ENTRY
  577. AcquireCredentialsHandleA(
  578.     SEC_CHAR SEC_FAR * pszPrincipal,    // Name of principal
  579.     SEC_CHAR SEC_FAR * pszPackage,      // Name of package
  580.     unsigned long fCredentialUse,       // Flags indicating use
  581.     void SEC_FAR * pvLogonId,           // Pointer to logon ID
  582.     void SEC_FAR * pAuthData,           // Package specific data
  583.     SEC_GET_KEY_FN pGetKeyFn,           // Pointer to GetKey() func
  584.     void SEC_FAR * pvGetKeyArgument,    // Value to pass to GetKey()
  585.     PCredHandle phCredential,           // (out) Cred Handle
  586.     PTimeStamp ptsExpiry                // (out) Lifetime (optional)
  587.     );
  588. typedef SECURITY_STATUS
  589. (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_A)(
  590.     SEC_CHAR SEC_FAR *,
  591.     SEC_CHAR SEC_FAR *,
  592.     unsigned long,
  593.     void SEC_FAR *,
  594.     void SEC_FAR *,
  595.     SEC_GET_KEY_FN,
  596.     void SEC_FAR *,
  597.     PCredHandle,
  598.     PTimeStamp);
  599. #ifdef UNICODE
  600. #  define AcquireCredentialsHandle AcquireCredentialsHandleW            // ntifs
  601. #  define ACQUIRE_CREDENTIALS_HANDLE_FN ACQUIRE_CREDENTIALS_HANDLE_FN_W // ntifs
  602. #else
  603. #  define AcquireCredentialsHandle AcquireCredentialsHandleA
  604. #  define ACQUIRE_CREDENTIALS_HANDLE_FN ACQUIRE_CREDENTIALS_HANDLE_FN_A
  605. #endif // !UNICODE
  606. // begin_ntifs
  607. SECURITY_STATUS SEC_ENTRY
  608. FreeCredentialsHandle(
  609.     PCredHandle phCredential            // Handle to free
  610.     );
  611. typedef SECURITY_STATUS
  612. (SEC_ENTRY * FREE_CREDENTIALS_HANDLE_FN)(
  613.     PCredHandle );
  614. #ifdef WIN32_CHICAGO
  615. SECURITY_STATUS SEC_ENTRY
  616. SspiLogonUserW(
  617.     SEC_WCHAR SEC_FAR * pszPackage,     // Name of package
  618.     SEC_WCHAR SEC_FAR * pszUserName,     // Name of package
  619.     SEC_WCHAR SEC_FAR * pszDomainName,     // Name of package
  620.     SEC_WCHAR SEC_FAR * pszPassword      // Name of package
  621.     );
  622. typedef SECURITY_STATUS
  623. (SEC_ENTRY * SSPI_LOGON_USER_FN_W)(
  624.     SEC_CHAR SEC_FAR *,
  625.     SEC_CHAR SEC_FAR *,
  626.     SEC_CHAR SEC_FAR *,
  627.     SEC_CHAR SEC_FAR *);
  628. SECURITY_STATUS SEC_ENTRY
  629. SspiLogonUserA(
  630.     SEC_CHAR SEC_FAR * pszPackage,     // Name of package
  631.     SEC_CHAR SEC_FAR * pszUserName,     // Name of package
  632.     SEC_CHAR SEC_FAR * pszDomainName,     // Name of package
  633.     SEC_CHAR SEC_FAR * pszPassword      // Name of package
  634.     );
  635. typedef SECURITY_STATUS
  636. (SEC_ENTRY * SSPI_LOGON_USER_FN_A)(
  637.     SEC_CHAR SEC_FAR *,
  638.     SEC_CHAR SEC_FAR *,
  639.     SEC_CHAR SEC_FAR *,
  640.     SEC_CHAR SEC_FAR *);
  641. #ifdef UNICODE
  642. #define SspiLogonUser SspiLogonUserW            // ntifs
  643. #define SSPI_LOGON_USER_FN SSPI_LOGON_USER_FN_W
  644. #else
  645. #define SspiLogonUser SspiLogonUserA
  646. #define SSPI_LOGON_USER_FN SSPI_LOGON_USER_FN_A
  647. #endif // !UNICODE
  648. #endif // WIN32_CHICAGO
  649. // end_ntifs
  650. // begin_ntifs
  651. ////////////////////////////////////////////////////////////////////////
  652. ///
  653. /// Context Management Functions
  654. ///
  655. ////////////////////////////////////////////////////////////////////////
  656. SECURITY_STATUS SEC_ENTRY
  657. InitializeSecurityContextW(
  658.     PCredHandle phCredential,               // Cred to base context
  659.     PCtxtHandle phContext,                  // Existing context (OPT)
  660. #if ISSP_MODE == 0
  661.     PSECURITY_STRING pTargetName,
  662. #else
  663.     SEC_WCHAR SEC_FAR * pszTargetName,      // Name of target
  664. #endif
  665.     unsigned long fContextReq,              // Context Requirements
  666.     unsigned long Reserved1,                // Reserved, MBZ
  667.     unsigned long TargetDataRep,            // Data rep of target
  668.     PSecBufferDesc pInput,                  // Input Buffers
  669.     unsigned long Reserved2,                // Reserved, MBZ
  670.     PCtxtHandle phNewContext,               // (out) New Context handle
  671.     PSecBufferDesc pOutput,                 // (inout) Output Buffers
  672.     unsigned long SEC_FAR * pfContextAttr,  // (out) Context attrs
  673.     PTimeStamp ptsExpiry                    // (out) Life span (OPT)
  674.     );
  675. typedef SECURITY_STATUS
  676. (SEC_ENTRY * INITIALIZE_SECURITY_CONTEXT_FN_W)(
  677.     PCredHandle,
  678.     PCtxtHandle,
  679. #if ISSP_MODE == 0
  680.     PSECURITY_STRING,
  681. #else
  682.     SEC_WCHAR SEC_FAR *,
  683. #endif
  684.     unsigned long,
  685.     unsigned long,
  686.     unsigned long,
  687.     PSecBufferDesc,
  688.     unsigned long,
  689.     PCtxtHandle,
  690.     PSecBufferDesc,
  691.     unsigned long SEC_FAR *,
  692.     PTimeStamp);
  693. // end_ntifs
  694. SECURITY_STATUS SEC_ENTRY
  695. InitializeSecurityContextA(
  696.     PCredHandle phCredential,               // Cred to base context
  697.     PCtxtHandle phContext,                  // Existing context (OPT)
  698.     SEC_CHAR SEC_FAR * pszTargetName,       // Name of target
  699.     unsigned long fContextReq,              // Context Requirements
  700.     unsigned long Reserved1,                // Reserved, MBZ
  701.     unsigned long TargetDataRep,            // Data rep of target
  702.     PSecBufferDesc pInput,                  // Input Buffers
  703.     unsigned long Reserved2,                // Reserved, MBZ
  704.     PCtxtHandle phNewContext,               // (out) New Context handle
  705.     PSecBufferDesc pOutput,                 // (inout) Output Buffers
  706.     unsigned long SEC_FAR * pfContextAttr,  // (out) Context attrs
  707.     PTimeStamp ptsExpiry                    // (out) Life span (OPT)
  708.     );
  709. typedef SECURITY_STATUS
  710. (SEC_ENTRY * INITIALIZE_SECURITY_CONTEXT_FN_A)(
  711.     PCredHandle,
  712.     PCtxtHandle,
  713.     SEC_CHAR SEC_FAR *,
  714.     unsigned long,
  715.     unsigned long,
  716.     unsigned long,
  717.     PSecBufferDesc,
  718.     unsigned long,
  719.     PCtxtHandle,
  720.     PSecBufferDesc,
  721.     unsigned long SEC_FAR *,
  722.     PTimeStamp);
  723. #ifdef UNICODE
  724. #  define InitializeSecurityContext InitializeSecurityContextW              // ntifs
  725. #  define INITIALIZE_SECURITY_CONTEXT_FN INITIALIZE_SECURITY_CONTEXT_FN_W   // ntifs
  726. #else
  727. #  define InitializeSecurityContext InitializeSecurityContextA
  728. #  define INITIALIZE_SECURITY_CONTEXT_FN INITIALIZE_SECURITY_CONTEXT_FN_A
  729. #endif // !UNICODE
  730. // begin_ntifs
  731. SECURITY_STATUS SEC_ENTRY
  732. AcceptSecurityContext(
  733.     PCredHandle phCredential,               // Cred to base context
  734.     PCtxtHandle phContext,                  // Existing context (OPT)
  735.     PSecBufferDesc pInput,                  // Input buffer
  736.     unsigned long fContextReq,              // Context Requirements
  737.     unsigned long TargetDataRep,            // Target Data Rep
  738.     PCtxtHandle phNewContext,               // (out) New context handle
  739.     PSecBufferDesc pOutput,                 // (inout) Output buffers
  740.     unsigned long SEC_FAR * pfContextAttr,  // (out) Context attributes
  741.     PTimeStamp ptsExpiry                    // (out) Life span (OPT)
  742.     );
  743. typedef SECURITY_STATUS
  744. (SEC_ENTRY * ACCEPT_SECURITY_CONTEXT_FN)(
  745.     PCredHandle,
  746.     PCtxtHandle,
  747.     PSecBufferDesc,
  748.     unsigned long,
  749.     unsigned long,
  750.     PCtxtHandle,
  751.     PSecBufferDesc,
  752.     unsigned long SEC_FAR *,
  753.     PTimeStamp);
  754. SECURITY_STATUS SEC_ENTRY
  755. CompleteAuthToken(
  756.     PCtxtHandle phContext,              // Context to complete
  757.     PSecBufferDesc pToken               // Token to complete
  758.     );
  759. typedef SECURITY_STATUS
  760. (SEC_ENTRY * COMPLETE_AUTH_TOKEN_FN)(
  761.     PCtxtHandle,
  762.     PSecBufferDesc);
  763. SECURITY_STATUS SEC_ENTRY
  764. ImpersonateSecurityContext(
  765.     PCtxtHandle phContext               // Context to impersonate
  766.     );
  767. typedef SECURITY_STATUS
  768. (SEC_ENTRY * IMPERSONATE_SECURITY_CONTEXT_FN)(
  769.     PCtxtHandle);
  770. SECURITY_STATUS SEC_ENTRY
  771. RevertSecurityContext(
  772.     PCtxtHandle phContext               // Context from which to re
  773.     );
  774. typedef SECURITY_STATUS
  775. (SEC_ENTRY * REVERT_SECURITY_CONTEXT_FN)(
  776.     PCtxtHandle);
  777. SECURITY_STATUS SEC_ENTRY
  778. QuerySecurityContextToken(
  779.     PCtxtHandle phContext,
  780.     void SEC_FAR * SEC_FAR * Token
  781.     );
  782. typedef SECURITY_STATUS
  783. (SEC_ENTRY * QUERY_SECURITY_CONTEXT_TOKEN_FN)(
  784.     PCtxtHandle, void SEC_FAR * SEC_FAR *);
  785. SECURITY_STATUS SEC_ENTRY
  786. DeleteSecurityContext(
  787.     PCtxtHandle phContext               // Context to delete
  788.     );
  789. typedef SECURITY_STATUS
  790. (SEC_ENTRY * DELETE_SECURITY_CONTEXT_FN)(
  791.     PCtxtHandle);
  792. SECURITY_STATUS SEC_ENTRY
  793. ApplyControlToken(
  794.     PCtxtHandle phContext,              // Context to modify
  795.     PSecBufferDesc pInput               // Input token to apply
  796.     );
  797. typedef SECURITY_STATUS
  798. (SEC_ENTRY * APPLY_CONTROL_TOKEN_FN)(
  799.     PCtxtHandle, PSecBufferDesc);
  800. SECURITY_STATUS SEC_ENTRY
  801. QueryContextAttributesW(
  802.     PCtxtHandle phContext,              // Context to query
  803.     unsigned long ulAttribute,          // Attribute to query
  804.     void SEC_FAR * pBuffer              // Buffer for attributes
  805.     );
  806. typedef SECURITY_STATUS
  807. (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_W)(
  808.     PCtxtHandle,
  809.     unsigned long,
  810.     void SEC_FAR *);
  811. // end_ntifs
  812. SECURITY_STATUS SEC_ENTRY
  813. QueryContextAttributesA(
  814.     PCtxtHandle phContext,              // Context to query
  815.     unsigned long ulAttribute,          // Attribute to query
  816.     void SEC_FAR * pBuffer              // Buffer for attributes
  817.     );
  818. typedef SECURITY_STATUS
  819. (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_A)(
  820.     PCtxtHandle,
  821.     unsigned long,
  822.     void SEC_FAR *);
  823. #ifdef UNICODE
  824. #  define QueryContextAttributes QueryContextAttributesW            // ntifs
  825. #  define QUERY_CONTEXT_ATTRIBUTES_FN QUERY_CONTEXT_ATTRIBUTES_FN_W // ntifs
  826. #else
  827. #  define QueryContextAttributes QueryContextAttributesA
  828. #  define QUERY_CONTEXT_ATTRIBUTES_FN QUERY_CONTEXT_ATTRIBUTES_FN_A
  829. #endif // !UNICODE
  830. // begin_ntifs
  831. SECURITY_STATUS SEC_ENTRY
  832. QueryCredentialsAttributesW(
  833.     PCredHandle phCredential,              // Credential to query
  834.     unsigned long ulAttribute,          // Attribute to query
  835.     void SEC_FAR * pBuffer              // Buffer for attributes
  836.     );
  837. typedef SECURITY_STATUS
  838. (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_W)(
  839.     PCredHandle,
  840.     unsigned long,
  841.     void SEC_FAR *);
  842. // end_ntifs
  843. SECURITY_STATUS SEC_ENTRY
  844. QueryCredentialsAttributesA(
  845.     PCredHandle phCredential,              // Credential to query
  846.     unsigned long ulAttribute,          // Attribute to query
  847.     void SEC_FAR * pBuffer              // Buffer for attributes
  848.     );
  849. typedef SECURITY_STATUS
  850. (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_A)(
  851.     PCredHandle,
  852.     unsigned long,
  853.     void SEC_FAR *);
  854. #ifdef UNICODE
  855. #  define QueryCredentialsAttributes QueryCredentialsAttributesW            // ntifs
  856. #  define QUERY_CREDENTIALS_ATTRIBUTES_FN QUERY_CREDENTIALS_ATTRIBUTES_FN_W // ntifs
  857. #else
  858. #  define QueryCredentialsAttributes QueryCredentialsAttributesA
  859. #  define QUERY_CREDENTIALS_ATTRIBUTES_FN QUERY_CREDENTIALS_ATTRIBUTES_FN_A
  860. #endif // !UNICODE
  861. // begin_ntifs
  862. SECURITY_STATUS SEC_ENTRY
  863. FreeContextBuffer(
  864.     void SEC_FAR * pvContextBuffer      // buffer to free
  865.     );
  866. typedef SECURITY_STATUS
  867. (SEC_ENTRY * FREE_CONTEXT_BUFFER_FN)(
  868.     void SEC_FAR *);
  869. // end_ntifs
  870. // begin_ntifs
  871. ///////////////////////////////////////////////////////////////////
  872. ////
  873. ////    Message Support API
  874. ////
  875. //////////////////////////////////////////////////////////////////
  876. SECURITY_STATUS SEC_ENTRY
  877. MakeSignature(
  878.     PCtxtHandle phContext,              // Context to use
  879.     unsigned long fQOP,                 // Quality of Protection
  880.     PSecBufferDesc pMessage,            // Message to sign
  881.     unsigned long MessageSeqNo          // Message Sequence Num.
  882.     );
  883. typedef SECURITY_STATUS
  884. (SEC_ENTRY * MAKE_SIGNATURE_FN)(
  885.     PCtxtHandle,
  886.     unsigned long,
  887.     PSecBufferDesc,
  888.     unsigned long);
  889. SECURITY_STATUS SEC_ENTRY
  890. VerifySignature(
  891.     PCtxtHandle phContext,              // Context to use
  892.     PSecBufferDesc pMessage,            // Message to verify
  893.     unsigned long MessageSeqNo,         // Sequence Num.
  894.     unsigned long SEC_FAR * pfQOP       // QOP used
  895.     );
  896. typedef SECURITY_STATUS
  897. (SEC_ENTRY * VERIFY_SIGNATURE_FN)(
  898.     PCtxtHandle,
  899.     PSecBufferDesc,
  900.     unsigned long,
  901.     unsigned long SEC_FAR *);
  902. SECURITY_STATUS SEC_ENTRY
  903. EncryptMessage( PCtxtHandle         phContext,
  904.                 unsigned long       fQOP,
  905.                 PSecBufferDesc      pMessage,
  906.                 unsigned long       MessageSeqNo);
  907. typedef SECURITY_STATUS
  908. (SEC_ENTRY * ENCRYPT_MESSAGE_FN)(
  909.     PCtxtHandle, unsigned long, PSecBufferDesc, unsigned long);
  910. SECURITY_STATUS SEC_ENTRY
  911. DecryptMessage( PCtxtHandle         phContext,
  912.                 PSecBufferDesc      pMessage,
  913.                 unsigned long       MessageSeqNo,
  914.                 unsigned long *     pfQOP);
  915. typedef SECURITY_STATUS
  916. (SEC_ENTRY * DECRYPT_MESSAGE_FN)(
  917.     PCtxtHandle, PSecBufferDesc, unsigned long,
  918.     unsigned long SEC_FAR *);
  919. // end_ntifs
  920. // begin_ntifs
  921. ///////////////////////////////////////////////////////////////////////////
  922. ////
  923. ////    Misc.
  924. ////
  925. ///////////////////////////////////////////////////////////////////////////
  926. SECURITY_STATUS SEC_ENTRY
  927. EnumerateSecurityPackagesW(
  928.     unsigned long SEC_FAR * pcPackages,     // Receives num. packages
  929.     PSecPkgInfoW SEC_FAR * ppPackageInfo    // Receives array of info
  930.     );
  931. typedef SECURITY_STATUS
  932. (SEC_ENTRY * ENUMERATE_SECURITY_PACKAGES_FN_W)(
  933.     unsigned long SEC_FAR *,
  934.     PSecPkgInfoW SEC_FAR *);
  935. // end_ntifs
  936. SECURITY_STATUS SEC_ENTRY
  937. EnumerateSecurityPackagesA(
  938.     unsigned long SEC_FAR * pcPackages,     // Receives num. packages
  939.     PSecPkgInfoA SEC_FAR * ppPackageInfo    // Receives array of info
  940.     );
  941. typedef SECURITY_STATUS
  942. (SEC_ENTRY * ENUMERATE_SECURITY_PACKAGES_FN_A)(
  943.     unsigned long SEC_FAR *,
  944.     PSecPkgInfoA SEC_FAR *);
  945. #ifdef UNICODE
  946. #  define EnumerateSecurityPackages EnumerateSecurityPackagesW              // ntifs
  947. #  define ENUMERATE_SECURITY_PACKAGES_FN ENUMERATE_SECURITY_PACKAGES_FN_W   // ntifs
  948. #else
  949. #  define EnumerateSecurityPackages EnumerateSecurityPackagesA
  950. #  define ENUMERATE_SECURITY_PACKAGES_FN ENUMERATE_SECURITY_PACKAGES_FN_A
  951. #endif // !UNICODE
  952. // begin_ntifs
  953. SECURITY_STATUS SEC_ENTRY
  954. QuerySecurityPackageInfoW(
  955. #if ISSP_MODE == 0
  956.     PSECURITY_STRING pPackageName,
  957. #else
  958.     SEC_WCHAR SEC_FAR * pszPackageName,     // Name of package
  959. #endif
  960.     PSecPkgInfoW SEC_FAR *ppPackageInfo              // Receives package info
  961.     );
  962. typedef SECURITY_STATUS
  963. (SEC_ENTRY * QUERY_SECURITY_PACKAGE_INFO_FN_W)(
  964. #if ISSP_MODE == 0
  965.     PSECURITY_STRING,
  966. #else
  967.     SEC_WCHAR SEC_FAR *,
  968. #endif
  969.     PSecPkgInfoW SEC_FAR *);
  970. // end_ntifs
  971. SECURITY_STATUS SEC_ENTRY
  972. QuerySecurityPackageInfoA(
  973.     SEC_CHAR SEC_FAR * pszPackageName,      // Name of package
  974.     PSecPkgInfoA SEC_FAR *ppPackageInfo              // Receives package info
  975.     );
  976. typedef SECURITY_STATUS
  977. (SEC_ENTRY * QUERY_SECURITY_PACKAGE_INFO_FN_A)(
  978.     SEC_CHAR SEC_FAR *,
  979.     PSecPkgInfoA SEC_FAR *);
  980. #ifdef UNICODE
  981. #  define QuerySecurityPackageInfo QuerySecurityPackageInfoW                // ntifs
  982. #  define QUERY_SECURITY_PACKAGE_INFO_FN QUERY_SECURITY_PACKAGE_INFO_FN_W   // ntifs
  983. #else
  984. #  define QuerySecurityPackageInfo QuerySecurityPackageInfoA
  985. #  define QUERY_SECURITY_PACKAGE_INFO_FN QUERY_SECURITY_PACKAGE_INFO_FN_A
  986. #endif // !UNICODE
  987. #if ISSP_MODE == 0
  988. #define DeleteSecurityContextDefer  DeleteSecurityContext
  989. #define FreeCredentialsHandleDefer  FreeCredentialsHandle
  990. #if 0
  991. //
  992. // Deferred mode calls for rdr
  993. //
  994. SECURITY_STATUS SEC_ENTRY
  995. DeleteSecurityContextDefer(
  996.     PCtxtHandle     phContext);
  997. SECURITY_STATUS SEC_ENTRY
  998. FreeCredentialsHandleDefer(
  999.     PCredHandle     phCreds);
  1000. #endif
  1001. #endif
  1002. typedef enum _SecDelegationType {
  1003.     SecFull,
  1004.     SecService,
  1005.     SecTree,
  1006.     SecDirectory,
  1007.     SecObject
  1008. } SecDelegationType, * PSecDelegationType;
  1009. SECURITY_STATUS SEC_ENTRY
  1010. DelegateSecurityContext(
  1011.     PCtxtHandle         phContext,          // IN Active context to delegate
  1012. #if ISSP_MODE == 0
  1013.     PSECURITY_STRING    pTarget,            // IN Target path
  1014. #else
  1015.     SEC_CHAR SEC_FAR *  pszTarget,
  1016. #endif
  1017.     SecDelegationType   DelegationType,     // IN Type of delegation
  1018.     PTimeStamp          pExpiry,            // IN OPTIONAL time limit
  1019.     PSecBuffer          pPackageParameters, // IN OPTIONAL package specific
  1020.     PSecBufferDesc      pOutput);           // OUT Token for applycontroltoken.
  1021. ///////////////////////////////////////////////////////////////////////////
  1022. ////
  1023. ////    Proxies
  1024. ////
  1025. ///////////////////////////////////////////////////////////////////////////
  1026. //
  1027. // Proxies are only available on NT platforms
  1028. //
  1029. // begin_ntifs
  1030. ///////////////////////////////////////////////////////////////////////////
  1031. ////
  1032. ////    Context export/import
  1033. ////
  1034. ///////////////////////////////////////////////////////////////////////////
  1035. SECURITY_STATUS SEC_ENTRY
  1036. ExportSecurityContext(
  1037.     PCtxtHandle          phContext,             // (in) context to export
  1038.     ULONG                fFlags,                // (in) option flags
  1039.     PSecBuffer           pPackedContext,        // (out) marshalled context
  1040.     void SEC_FAR * SEC_FAR * pToken                 // (out, optional) token handle for impersonation
  1041.     );
  1042. typedef SECURITY_STATUS
  1043. (SEC_ENTRY * EXPORT_SECURITY_CONTEXT_FN)(
  1044.     PCtxtHandle,
  1045.     ULONG,
  1046.     PSecBuffer,
  1047.     void SEC_FAR * SEC_FAR *
  1048.     );
  1049. SECURITY_STATUS SEC_ENTRY
  1050. ImportSecurityContextW(
  1051.     SEC_WCHAR SEC_FAR * pszPackage,
  1052.     PSecBuffer           pPackedContext,        // (in) marshalled context
  1053.     void SEC_FAR *       Token,                 // (in, optional) handle to token for context
  1054.     PCtxtHandle          phContext              // (out) new context handle
  1055.     );
  1056. typedef SECURITY_STATUS
  1057. (SEC_ENTRY * IMPORT_SECURITY_CONTEXT_FN_W)(
  1058.     SEC_WCHAR SEC_FAR *,
  1059.     PSecBuffer,
  1060.     VOID SEC_FAR *,
  1061.     PCtxtHandle
  1062.     );
  1063. // end_ntifs
  1064. SECURITY_STATUS SEC_ENTRY
  1065. ImportSecurityContextA(
  1066.     SEC_CHAR SEC_FAR * pszPackage,
  1067.     PSecBuffer           pPackedContext,        // (in) marshalled context
  1068.     VOID SEC_FAR *       Token,                 // (in, optional) handle to token for context
  1069.     PCtxtHandle          phContext              // (out) new context handle
  1070.     );
  1071. typedef SECURITY_STATUS
  1072. (SEC_ENTRY * IMPORT_SECURITY_CONTEXT_FN_A)(
  1073.     SEC_CHAR SEC_FAR *,
  1074.     PSecBuffer,
  1075.     void SEC_FAR *,
  1076.     PCtxtHandle
  1077.     );
  1078. #ifdef UNICODE
  1079. #  define ImportSecurityContext ImportSecurityContextW              // ntifs
  1080. #  define IMPORT_SECURITY_CONTEXT_FN IMPORT_SECURITY_CONTEXT_FN_W   // ntifs
  1081. #else
  1082. #  define ImportSecurityContext ImportSecurityContextA
  1083. #  define IMPORT_SECURITY_CONTEXT_FN IMPORT_SECURITY_CONTEXT_FN_A
  1084. #endif // !UNICODE
  1085. ///////////////////////////////////////////////////////////////////////////////
  1086. ////
  1087. ////  Fast access for RPC:
  1088. ////
  1089. ///////////////////////////////////////////////////////////////////////////////
  1090. #define SECURITY_ENTRYPOINT_ANSIW "InitSecurityInterfaceW"
  1091. #define SECURITY_ENTRYPOINT_ANSIA "InitSecurityInterfaceW"
  1092. #define SECURITY_ENTRYPOINTW SEC_TEXT("InitSecurityInterfaceW")     // ntifs
  1093. #define SECURITY_ENTRYPOINTA SEC_TEXT("InitSecurityInterfaceA")
  1094. #define SECURITY_ENTRYPOINT16 "INITSECURITYINTERFACEA"
  1095. #ifdef SECURITY_WIN32
  1096. #  ifdef UNICODE
  1097. #    define SECURITY_ENTRYPOINT SECURITY_ENTRYPOINTW                // ntifs
  1098. #    define SECURITY_ENTRYPOINT_ANSI SECURITY_ENTRYPOINT_ANSIW
  1099. #  else // UNICODE
  1100. #    define SECURITY_ENTRYPOINT SECURITY_ENTRYPOINTA
  1101. #    define SECURITY_ENTRYPOINT_ANSI SECURITY_ENTRYPOINT_ANSIA
  1102. #  endif // UNICODE
  1103. #else // SECURITY_WIN32
  1104. #  define SECURITY_ENTRYPOINT SECURITY_ENTRYPOINT16
  1105. #  define SECURITY_ENTRYPOINT_ANSI SECURITY_ENTRYPOINT16
  1106. #endif // SECURITY_WIN32
  1107. // begin_ntifs
  1108. typedef struct _SECURITY_FUNCTION_TABLE_W {
  1109.     unsigned long                       dwVersion;
  1110.     ENUMERATE_SECURITY_PACKAGES_FN_W    EnumerateSecurityPackagesW;
  1111.     QUERY_CREDENTIALS_ATTRIBUTES_FN_W   QueryCredentialsAttributesW;
  1112.     ACQUIRE_CREDENTIALS_HANDLE_FN_W     AcquireCredentialsHandleW;
  1113.     FREE_CREDENTIALS_HANDLE_FN          FreeCredentialHandle;
  1114. #ifndef WIN32_CHICAGO
  1115.     void SEC_FAR *                      Reserved2;
  1116. #else // WIN32_CHICAGO
  1117.     SSPI_LOGON_USER_FN                       SspiLogonUserW;
  1118. #endif // WIN32_CHICAGO
  1119.     INITIALIZE_SECURITY_CONTEXT_FN_W    InitializeSecurityContextW;
  1120.     ACCEPT_SECURITY_CONTEXT_FN          AcceptSecurityContext;
  1121.     COMPLETE_AUTH_TOKEN_FN              CompleteAuthToken;
  1122.     DELETE_SECURITY_CONTEXT_FN          DeleteSecurityContext;
  1123.     APPLY_CONTROL_TOKEN_FN              ApplyControlToken;
  1124.     QUERY_CONTEXT_ATTRIBUTES_FN_W       QueryContextAttributesW;
  1125.     IMPERSONATE_SECURITY_CONTEXT_FN     ImpersonateSecurityContext;
  1126.     REVERT_SECURITY_CONTEXT_FN          RevertSecurityContext;
  1127.     MAKE_SIGNATURE_FN                   MakeSignature;
  1128.     VERIFY_SIGNATURE_FN                 VerifySignature;
  1129.     FREE_CONTEXT_BUFFER_FN              FreeContextBuffer;
  1130.     QUERY_SECURITY_PACKAGE_INFO_FN_W    QuerySecurityPackageInfoW;
  1131.     void SEC_FAR *                      Reserved3;
  1132.     void SEC_FAR *                      Reserved4;
  1133.     EXPORT_SECURITY_CONTEXT_FN          ExportSecurityContext;
  1134.     IMPORT_SECURITY_CONTEXT_FN_W        ImportSecurityContextW;
  1135.     void SEC_FAR *                      Reserved7;
  1136.     void SEC_FAR *                      Reserved8;
  1137.     QUERY_SECURITY_CONTEXT_TOKEN_FN     QuerySecurityContextToken;
  1138.     ENCRYPT_MESSAGE_FN                  EncryptMessage;
  1139.     DECRYPT_MESSAGE_FN                  DecryptMessage;
  1140. } SecurityFunctionTableW, SEC_FAR * PSecurityFunctionTableW;
  1141. // end_ntifs
  1142. typedef struct _SECURITY_FUNCTION_TABLE_A {
  1143.     unsigned long                       dwVersion;
  1144.     ENUMERATE_SECURITY_PACKAGES_FN_A    EnumerateSecurityPackagesA;
  1145.     QUERY_CREDENTIALS_ATTRIBUTES_FN_A   QueryCredentialsAttributesA;
  1146.     ACQUIRE_CREDENTIALS_HANDLE_FN_A     AcquireCredentialsHandleA;
  1147.     FREE_CREDENTIALS_HANDLE_FN          FreeCredentialHandle;
  1148. #ifndef WIN32_CHICAGO
  1149.     void SEC_FAR *                      Reserved2;
  1150. #else // WIN32_CHICAGO
  1151.     SSPI_LOGON_USER_FN                       SspiLogonUserA;
  1152. #endif // WIN32_CHICAGO
  1153.     INITIALIZE_SECURITY_CONTEXT_FN_A    InitializeSecurityContextA;
  1154.     ACCEPT_SECURITY_CONTEXT_FN          AcceptSecurityContext;
  1155.     COMPLETE_AUTH_TOKEN_FN              CompleteAuthToken;
  1156.     DELETE_SECURITY_CONTEXT_FN          DeleteSecurityContext;
  1157.     APPLY_CONTROL_TOKEN_FN              ApplyControlToken;
  1158.     QUERY_CONTEXT_ATTRIBUTES_FN_A       QueryContextAttributesA;
  1159.     IMPERSONATE_SECURITY_CONTEXT_FN     ImpersonateSecurityContext;
  1160.     REVERT_SECURITY_CONTEXT_FN          RevertSecurityContext;
  1161.     MAKE_SIGNATURE_FN                   MakeSignature;
  1162.     VERIFY_SIGNATURE_FN                 VerifySignature;
  1163.     FREE_CONTEXT_BUFFER_FN              FreeContextBuffer;
  1164.     QUERY_SECURITY_PACKAGE_INFO_FN_A    QuerySecurityPackageInfoA;
  1165.     void SEC_FAR *                      Reserved3;
  1166.     void SEC_FAR *                      Reserved4;
  1167.     EXPORT_SECURITY_CONTEXT_FN          ExportSecurityContext;
  1168.     IMPORT_SECURITY_CONTEXT_FN_A        ImportSecurityContextA;
  1169.    void SEC_FAR *                      Reserved7;
  1170.     void SEC_FAR *                      Reserved8;
  1171.     QUERY_SECURITY_CONTEXT_TOKEN_FN     QuerySecurityContextToken;
  1172.     ENCRYPT_MESSAGE_FN                  EncryptMessage;
  1173.     DECRYPT_MESSAGE_FN                  DecryptMessage;
  1174. } SecurityFunctionTableA, SEC_FAR * PSecurityFunctionTableA;
  1175. #ifdef UNICODE
  1176. #  define SecurityFunctionTable SecurityFunctionTableW
  1177. #  define PSecurityFunctionTable PSecurityFunctionTableW
  1178. #else
  1179. #  define SecurityFunctionTable SecurityFunctionTableA
  1180. #  define PSecurityFunctionTable PSecurityFunctionTableA
  1181. #endif // !UNICODE
  1182. #define SECURITY_
  1183. #define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION     1
  1184. PSecurityFunctionTableA SEC_ENTRY
  1185. InitSecurityInterfaceA(
  1186.     void
  1187.     );
  1188. typedef PSecurityFunctionTableA
  1189. (SEC_ENTRY * INIT_SECURITY_INTERFACE_A)(void);
  1190. // begin_ntifs
  1191. PSecurityFunctionTableW SEC_ENTRY
  1192. InitSecurityInterfaceW(
  1193.     void
  1194.     );
  1195. typedef PSecurityFunctionTableW
  1196. (SEC_ENTRY * INIT_SECURITY_INTERFACE_W)(void);
  1197. // end_ntifs
  1198. #ifdef UNICODE
  1199. #  define InitSecurityInterface InitSecurityInterfaceW          // ntifs
  1200. #  define INIT_SECURITY_INTERFACE INIT_SECURITY_INTERFACE_W     // ntifs
  1201. #else
  1202. #  define InitSecurityInterface InitSecurityInterfaceA
  1203. #  define INIT_SECURITY_INTERFACE INIT_SECURITY_INTERFACE_A
  1204. #endif // !UNICODE
  1205. typedef struct _SECURITY_PACKAGE_OPTIONS {
  1206.     unsigned long   Size;
  1207.     unsigned long   Type;
  1208.     unsigned long   Flags;
  1209.     unsigned long   SignatureSize;
  1210.     void SEC_FAR *  Signature;
  1211. } SECURITY_PACKAGE_OPTIONS, SEC_FAR * PSECURITY_PACKAGE_OPTIONS;
  1212. #define SECPKG_OPTIONS_TYPE_UNKNOWN 0
  1213. #define SECPKG_OPTIONS_TYPE_LSA     1
  1214. #define SECPKG_OPTIONS_TYPE_SSPI    2
  1215. #define SECPKG_OPTIONS_PERMANENT    0x00000001
  1216. SECURITY_STATUS
  1217. SEC_ENTRY
  1218. AddSecurityPackageA(
  1219.     SEC_CHAR SEC_FAR *  pszPackageName,
  1220.     SECURITY_PACKAGE_OPTIONS SEC_FAR * Options
  1221.     );
  1222. SECURITY_STATUS
  1223. SEC_ENTRY
  1224. AddSecurityPackageW(
  1225.     SEC_WCHAR SEC_FAR * pszPackageName,
  1226.     SECURITY_PACKAGE_OPTIONS SEC_FAR * Options
  1227.     );
  1228. #ifdef UNICODE
  1229. #define AddSecurityPackage  AddSecurityPackageW
  1230. #else
  1231. #define AddSecurityPackage  AddSecurityPackageA
  1232. #endif
  1233. SECURITY_STATUS
  1234. SEC_ENTRY
  1235. DeleteSecurityPackageA(
  1236.     SEC_CHAR SEC_FAR *  pszPackageName );
  1237. SECURITY_STATUS
  1238. SEC_ENTRY
  1239. DeleteSecurityPackageW(
  1240.     SEC_WCHAR SEC_FAR * pszPackageName );
  1241. #ifdef UNICODE
  1242. #define DeleteSecurityPackage   DeleteSecurityPackageW
  1243. #else
  1244. #define DeleteSecurityPackage   DeleteSecurityPackageA
  1245. #endif
  1246. //
  1247. // Extended Name APIs for NTDS
  1248. //
  1249. typedef enum
  1250. {
  1251.     // Examples for the following formats assume a fictitous company
  1252.     // which hooks into the global X.500 and DNS name spaces as follows.
  1253.     //
  1254.     // Enterprise root domain in DNS is
  1255.     //
  1256.     //      widget.com
  1257.     //
  1258.     // Enterprise root domain in X.500 (RFC 1779 format) is
  1259.     //
  1260.     //      O=Widget, C=US
  1261.     //
  1262.     // There exists the child domain
  1263.     //
  1264.     //      engineering.widget.com
  1265.     //
  1266.     // equivalent to
  1267.     //
  1268.     //      OU=Engineering, O=Widget, C=US
  1269.     //
  1270.     // There exists a container within the Engineering domain
  1271.     //
  1272.     //      OU=Software, OU=Engineering, O=Widget, C=US
  1273.     //
  1274.     // There exists the user
  1275.     //
  1276.     //      CN=Spencer Katt, OU=Software, OU=Engineering, O=Widget, C=US
  1277.     //
  1278.     // And this user's downlevel (pre-NTDS) user name is
  1279.     //
  1280.     //      EngineeringSpencerK
  1281.     // unknown name type
  1282.     NameUnknown = 0,
  1283.     // CN=Spencer Katt, OU=Software, OU=Engineering, O=Widget, C=US
  1284.     NameFullyQualifiedDN = 1,
  1285.     // EngineeringSpencerK
  1286.     NameSamCompatible = 2,
  1287.     // Probably "Spencer Katt" but could be something else.  I.e. The
  1288.     // display name is not necessarily the defining RDN.
  1289.     NameDisplay = 3,
  1290.     // xxx@engineering.widget.com where xxx could be "SpencerK" or
  1291.     // anything else.  Could be multi-valued to handle migration and aliasing.
  1292.     NameDomainSimple = 4,
  1293.     // xxx@widget.com where xxx could be "SpencerK" or anything else.
  1294.     // Could be multi-valued to handle migration and aliasing.
  1295.     NameEnterpriseSimple = 5,
  1296.     // String-ized GUID as returned by IIDFromString().
  1297.     // eg: {4fa050f0-f561-11cf-bdd9-00aa003a77b6}
  1298.     NameUniqueId = 6,
  1299.     // engineering.widget.com/software/spencer katt
  1300.     NameCanonical = 7
  1301. } EXTENDED_NAME_FORMAT, * PEXTENDED_NAME_FORMAT ;
  1302. BOOLEAN
  1303. SEC_ENTRY
  1304. GetUserNameExA(
  1305.     EXTENDED_NAME_FORMAT  NameFormat,
  1306.     LPSTR lpNameBuffer,
  1307.     PULONG nSize
  1308.     );
  1309. BOOLEAN
  1310. SEC_ENTRY
  1311. GetUserNameExW(
  1312.     EXTENDED_NAME_FORMAT NameFormat,
  1313.     LPWSTR lpNameBuffer,
  1314.     PULONG nSize
  1315.     );
  1316. #ifdef UNICODE
  1317. #define GetUserNameEx   GetUserNameExW
  1318. #else
  1319. #define GetUserNameEx   GetUserNameExA
  1320. #endif
  1321. BOOLEAN
  1322. SEC_ENTRY
  1323. TranslateNameA(
  1324.     LPCSTR lpAccountName,
  1325.     EXTENDED_NAME_FORMAT AccountNameFormat,
  1326.     EXTENDED_NAME_FORMAT DesiredNameFormat,
  1327.     LPSTR lpTranslatedName,
  1328.     PULONG nSize
  1329.     );
  1330. BOOLEAN
  1331. SEC_ENTRY
  1332. TranslateNameW(
  1333.     LPCWSTR lpAccountName,
  1334.     EXTENDED_NAME_FORMAT AccountNameFormat,
  1335.     EXTENDED_NAME_FORMAT DesiredNameFormat,
  1336.     LPWSTR lpTranslatedName,
  1337.     PULONG nSize
  1338.     );
  1339. #ifdef UNICODE
  1340. #define TranslateName   TranslateNameW
  1341. #else
  1342. #define TranslateName   TranslateNameA
  1343. #endif
  1344. #ifdef SECURITY_DOS
  1345. #pragma warning(default:4147)
  1346. #endif
  1347. #endif // __SSPI_H__