Sspi.h 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074
  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992-1999.
  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. // begin_ntifs
  17. #ifndef __SSPI_H__
  18. #define __SSPI_H__
  19. // end_ntifs
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. //
  27. // Determine environment:
  28. //
  29. #ifdef SECURITY_WIN32
  30. #define ISSP_LEVEL 32
  31. #define ISSP_MODE 1
  32. #endif // SECURITY_WIN32
  33. #ifdef SECURITY_KERNEL
  34. #define ISSP_LEVEL 32 // ntifs
  35. //
  36. // SECURITY_KERNEL trumps SECURITY_WIN32. Undefine ISSP_MODE so that
  37. // we don't get redefine errors.
  38. //
  39. #ifdef ISSP_MODE
  40. #undef ISSP_MODE
  41. #endif
  42. #define ISSP_MODE 0 // ntifs
  43. #endif // SECURITY_KERNEL
  44. #ifdef SECURITY_MAC
  45. #define ISSP_LEVEL 32
  46. #define ISSP_MODE 1
  47. #endif // SECURITY_MAC
  48. #ifndef ISSP_LEVEL
  49. #error You must define one of SECURITY_WIN32, SECURITY_KERNEL, or
  50. #error SECURITY_MAC
  51. #endif // !ISSP_LEVEL
  52. //
  53. // Now, define platform specific mappings:
  54. //
  55. // begin_ntifs
  56. typedef WCHAR SEC_WCHAR;
  57. typedef CHAR SEC_CHAR;
  58. #ifndef __SECSTATUS_DEFINED__
  59. typedef LONG SECURITY_STATUS;
  60. #define __SECSTATUS_DEFINED__
  61. #endif
  62. #define SEC_TEXT TEXT
  63. #define SEC_FAR
  64. #define SEC_ENTRY __stdcall
  65. // end_ntifs
  66. //
  67. // Decide what a string - 32 bits only since for 16 bits it is clear.
  68. //
  69. #ifdef UNICODE
  70. typedef SEC_WCHAR SEC_FAR * SECURITY_PSTR;
  71. typedef CONST SEC_WCHAR SEC_FAR * SECURITY_PCSTR;
  72. #else // UNICODE
  73. typedef SEC_CHAR SEC_FAR * SECURITY_PSTR;
  74. typedef CONST SEC_CHAR SEC_FAR * SECURITY_PCSTR;
  75. #endif // UNICODE
  76. //
  77. // Equivalent string for rpcrt:
  78. //
  79. #define __SEC_FAR SEC_FAR
  80. //
  81. // Okay, security specific types:
  82. //
  83. // begin_ntifs
  84. #ifndef __SECHANDLE_DEFINED__
  85. typedef struct _SecHandle
  86. {
  87. ULONG_PTR dwLower ;
  88. ULONG_PTR dwUpper ;
  89. } SecHandle, * PSecHandle ;
  90. #define __SECHANDLE_DEFINED__
  91. #endif // __SECHANDLE_DEFINED__
  92. #define SecInvalidateHandle( x ) \
  93. ((PSecHandle) x)->dwLower = ((ULONG_PTR) ((INT_PTR)-1)) ; \
  94. ((PSecHandle) x)->dwUpper = ((ULONG_PTR) ((INT_PTR)-1)) ; \
  95. #define SecIsValidHandle( x ) \
  96. ( ( ((PSecHandle) x)->dwLower != ((ULONG_PTR) ((INT_PTR) -1 ))) && \
  97. ( ((PSecHandle) x)->dwUpper != ((ULONG_PTR) ((INT_PTR) -1 ))) )
  98. typedef SecHandle CredHandle;
  99. typedef PSecHandle PCredHandle;
  100. typedef SecHandle CtxtHandle;
  101. typedef PSecHandle PCtxtHandle;
  102. // end_ntifs
  103. # ifdef WIN32_CHICAGO
  104. typedef unsigned __int64 QWORD;
  105. typedef QWORD SECURITY_INTEGER, *PSECURITY_INTEGER;
  106. #define SEC_SUCCESS(Status) ((Status) >= 0)
  107. # elif defined(_NTDEF_) || defined(_WINNT_)
  108. typedef LARGE_INTEGER _SECURITY_INTEGER, SECURITY_INTEGER, *PSECURITY_INTEGER; // ntifs
  109. # else // _NTDEF_ || _WINNT_
  110. typedef struct _SECURITY_INTEGER
  111. {
  112. unsigned long LowPart;
  113. long HighPart;
  114. } SECURITY_INTEGER, *PSECURITY_INTEGER;
  115. # endif // _NTDEF_ || _WINNT_
  116. # ifndef SECURITY_MAC
  117. typedef SECURITY_INTEGER TimeStamp; // ntifs
  118. typedef SECURITY_INTEGER SEC_FAR * PTimeStamp; // ntifs
  119. # else // SECURITY_MAC
  120. typedef unsigned long TimeStamp;
  121. typedef unsigned long * PTimeStamp;
  122. # endif // SECUIRT_MAC
  123. //
  124. // If we are in 32 bit mode, define the SECURITY_STRING structure,
  125. // as a clone of the base UNICODE_STRING structure. This is used
  126. // internally in security components, an as the string interface
  127. // for kernel components (e.g. FSPs)
  128. //
  129. # ifndef _NTDEF_
  130. typedef struct _SECURITY_STRING {
  131. unsigned short Length;
  132. unsigned short MaximumLength;
  133. # ifdef MIDL_PASS
  134. [size_is(MaximumLength / 2), length_is(Length / 2)]
  135. # endif // MIDL_PASS
  136. unsigned short * Buffer;
  137. } SECURITY_STRING, * PSECURITY_STRING;
  138. # else // _NTDEF_
  139. typedef UNICODE_STRING SECURITY_STRING, *PSECURITY_STRING; // ntifs
  140. # endif // _NTDEF_
  141. // begin_ntifs
  142. //
  143. // SecPkgInfo structure
  144. //
  145. // Provides general information about a security provider
  146. //
  147. typedef struct _SecPkgInfoW
  148. {
  149. unsigned long fCapabilities; // Capability bitmask
  150. unsigned short wVersion; // Version of driver
  151. unsigned short wRPCID; // ID for RPC Runtime
  152. unsigned long cbMaxToken; // Size of authentication token (max)
  153. #ifdef MIDL_PASS
  154. [string]
  155. #endif
  156. SEC_WCHAR SEC_FAR * Name; // Text name
  157. #ifdef MIDL_PASS
  158. [string]
  159. #endif
  160. SEC_WCHAR SEC_FAR * Comment; // Comment
  161. } SecPkgInfoW, SEC_FAR * PSecPkgInfoW;
  162. // end_ntifs
  163. typedef struct _SecPkgInfoA
  164. {
  165. unsigned long fCapabilities; // Capability bitmask
  166. unsigned short wVersion; // Version of driver
  167. unsigned short wRPCID; // ID for RPC Runtime
  168. unsigned long cbMaxToken; // Size of authentication token (max)
  169. #ifdef MIDL_PASS
  170. [string]
  171. #endif
  172. SEC_CHAR SEC_FAR * Name; // Text name
  173. #ifdef MIDL_PASS
  174. [string]
  175. #endif
  176. SEC_CHAR SEC_FAR * Comment; // Comment
  177. } SecPkgInfoA, SEC_FAR * PSecPkgInfoA;
  178. #ifdef UNICODE
  179. # define SecPkgInfo SecPkgInfoW // ntifs
  180. # define PSecPkgInfo PSecPkgInfoW // ntifs
  181. #else
  182. # define SecPkgInfo SecPkgInfoA
  183. # define PSecPkgInfo PSecPkgInfoA
  184. #endif // !UNICODE
  185. // begin_ntifs
  186. //
  187. // Security Package Capabilities
  188. //
  189. #define SECPKG_FLAG_INTEGRITY 0x00000001 // Supports integrity on messages
  190. #define SECPKG_FLAG_PRIVACY 0x00000002 // Supports privacy (confidentiality)
  191. #define SECPKG_FLAG_TOKEN_ONLY 0x00000004 // Only security token needed
  192. #define SECPKG_FLAG_DATAGRAM 0x00000008 // Datagram RPC support
  193. #define SECPKG_FLAG_CONNECTION 0x00000010 // Connection oriented RPC support
  194. #define SECPKG_FLAG_MULTI_REQUIRED 0x00000020 // Full 3-leg required for re-auth.
  195. #define SECPKG_FLAG_CLIENT_ONLY 0x00000040 // Server side functionality not available
  196. #define SECPKG_FLAG_EXTENDED_ERROR 0x00000080 // Supports extended error msgs
  197. #define SECPKG_FLAG_IMPERSONATION 0x00000100 // Supports impersonation
  198. #define SECPKG_FLAG_ACCEPT_WIN32_NAME 0x00000200 // Accepts Win32 names
  199. #define SECPKG_FLAG_STREAM 0x00000400 // Supports stream semantics
  200. #define SECPKG_FLAG_NEGOTIABLE 0x00000800 // Can be used by the negotiate package
  201. #define SECPKG_FLAG_GSS_COMPATIBLE 0x00001000 // GSS Compatibility Available
  202. #define SECPKG_FLAG_LOGON 0x00002000 // Supports common LsaLogonUser
  203. #define SECPKG_FLAG_ASCII_BUFFERS 0x00004000 // Token Buffers are in ASCII
  204. #define SECPKG_FLAG_FRAGMENT 0x00008000 // Package can fragment to fit
  205. #define SECPKG_FLAG_MUTUAL_AUTH 0x00010000 // Package can perform mutual authentication
  206. #define SECPKG_FLAG_DELEGATION 0x00020000 // Package can delegate
  207. #define SECPKG_FLAG_READONLY_WITH_CHECKSUM 0x00040000 // Package supports READONLY_WITH_CHECKSUM
  208. #define SECPKG_ID_NONE 0xFFFF
  209. //
  210. // SecBuffer
  211. //
  212. // Generic memory descriptors for buffers passed in to the security
  213. // API
  214. //
  215. typedef struct _SecBuffer {
  216. unsigned long cbBuffer; // Size of the buffer, in bytes
  217. unsigned long BufferType; // Type of the buffer (below)
  218. void SEC_FAR * pvBuffer; // Pointer to the buffer
  219. } SecBuffer, SEC_FAR * PSecBuffer;
  220. typedef struct _SecBufferDesc {
  221. unsigned long ulVersion; // Version number
  222. unsigned long cBuffers; // Number of buffers
  223. #ifdef MIDL_PASS
  224. [size_is(cBuffers)]
  225. #endif
  226. PSecBuffer pBuffers; // Pointer to array of buffers
  227. } SecBufferDesc, SEC_FAR * PSecBufferDesc;
  228. #define SECBUFFER_VERSION 0
  229. #define SECBUFFER_EMPTY 0 // Undefined, replaced by provider
  230. #define SECBUFFER_DATA 1 // Packet data
  231. #define SECBUFFER_TOKEN 2 // Security token
  232. #define SECBUFFER_PKG_PARAMS 3 // Package specific parameters
  233. #define SECBUFFER_MISSING 4 // Missing Data indicator
  234. #define SECBUFFER_EXTRA 5 // Extra data
  235. #define SECBUFFER_STREAM_TRAILER 6 // Security Trailer
  236. #define SECBUFFER_STREAM_HEADER 7 // Security Header
  237. #define SECBUFFER_NEGOTIATION_INFO 8 // Hints from the negotiation pkg
  238. #define SECBUFFER_PADDING 9 // non-data padding
  239. #define SECBUFFER_STREAM 10 // whole encrypted message
  240. #define SECBUFFER_MECHLIST 11
  241. #define SECBUFFER_MECHLIST_SIGNATURE 12
  242. #define SECBUFFER_TARGET 13
  243. #define SECBUFFER_CHANNEL_BINDINGS 14
  244. #define SECBUFFER_ATTRMASK 0xF0000000
  245. #define SECBUFFER_READONLY 0x80000000 // Buffer is read-only - deprecated...
  246. #define SECBUFFER_RESERVED 0x60000000 // Flags reserved to security system
  247. #define SECBUFFER_READONLY_WITH_CHECKSUM 0x10000000 // Buffer is read-only, and checksummed
  248. typedef struct _SEC_NEGOTIATION_INFO {
  249. unsigned long Size; // Size of this structure
  250. unsigned long NameLength; // Length of name hint
  251. SEC_WCHAR SEC_FAR * Name; // Name hint
  252. void SEC_FAR * Reserved; // Reserved
  253. } SEC_NEGOTIATION_INFO, SEC_FAR * PSEC_NEGOTIATION_INFO ;
  254. typedef struct _SEC_CHANNEL_BINDINGS {
  255. unsigned long dwInitiatorAddrType;
  256. unsigned long cbInitiatorLength;
  257. unsigned long dwInitiatorOffset;
  258. unsigned long dwAcceptorAddrType;
  259. unsigned long cbAcceptorLength;
  260. unsigned long dwAcceptorOffset;
  261. unsigned long cbApplicationDataLength;
  262. unsigned long dwApplicationDataOffset;
  263. } SEC_CHANNEL_BINDINGS, SEC_FAR * PSEC_CHANNEL_BINDINGS ;
  264. //
  265. // Data Representation Constant:
  266. //
  267. #define SECURITY_NATIVE_DREP 0x00000010
  268. #define SECURITY_NETWORK_DREP 0x00000000
  269. //
  270. // Credential Use Flags
  271. //
  272. #define SECPKG_CRED_INBOUND 0x00000001
  273. #define SECPKG_CRED_OUTBOUND 0x00000002
  274. #define SECPKG_CRED_BOTH 0x00000003
  275. #define SECPKG_CRED_DEFAULT 0x00000004
  276. #define SECPKG_CRED_RESERVED 0xF0000000
  277. //
  278. // InitializeSecurityContext Requirement and return flags:
  279. //
  280. #define ISC_REQ_DELEGATE 0x00000001
  281. #define ISC_REQ_MUTUAL_AUTH 0x00000002
  282. #define ISC_REQ_REPLAY_DETECT 0x00000004
  283. #define ISC_REQ_SEQUENCE_DETECT 0x00000008
  284. #define ISC_REQ_CONFIDENTIALITY 0x00000010
  285. #define ISC_REQ_USE_SESSION_KEY 0x00000020
  286. #define ISC_REQ_PROMPT_FOR_CREDS 0x00000040
  287. #define ISC_REQ_USE_SUPPLIED_CREDS 0x00000080
  288. #define ISC_REQ_ALLOCATE_MEMORY 0x00000100
  289. #define ISC_REQ_USE_DCE_STYLE 0x00000200
  290. #define ISC_REQ_DATAGRAM 0x00000400
  291. #define ISC_REQ_CONNECTION 0x00000800
  292. #define ISC_REQ_CALL_LEVEL 0x00001000
  293. #define ISC_REQ_FRAGMENT_SUPPLIED 0x00002000
  294. #define ISC_REQ_EXTENDED_ERROR 0x00004000
  295. #define ISC_REQ_STREAM 0x00008000
  296. #define ISC_REQ_INTEGRITY 0x00010000
  297. #define ISC_REQ_IDENTIFY 0x00020000
  298. #define ISC_REQ_NULL_SESSION 0x00040000
  299. #define ISC_REQ_MANUAL_CRED_VALIDATION 0x00080000
  300. #define ISC_REQ_RESERVED1 0x00100000
  301. #define ISC_REQ_FRAGMENT_TO_FIT 0x00200000
  302. #define ISC_RET_DELEGATE 0x00000001
  303. #define ISC_RET_MUTUAL_AUTH 0x00000002
  304. #define ISC_RET_REPLAY_DETECT 0x00000004
  305. #define ISC_RET_SEQUENCE_DETECT 0x00000008
  306. #define ISC_RET_CONFIDENTIALITY 0x00000010
  307. #define ISC_RET_USE_SESSION_KEY 0x00000020
  308. #define ISC_RET_USED_COLLECTED_CREDS 0x00000040
  309. #define ISC_RET_USED_SUPPLIED_CREDS 0x00000080
  310. #define ISC_RET_ALLOCATED_MEMORY 0x00000100
  311. #define ISC_RET_USED_DCE_STYLE 0x00000200
  312. #define ISC_RET_DATAGRAM 0x00000400
  313. #define ISC_RET_CONNECTION 0x00000800
  314. #define ISC_RET_INTERMEDIATE_RETURN 0x00001000
  315. #define ISC_RET_CALL_LEVEL 0x00002000
  316. #define ISC_RET_EXTENDED_ERROR 0x00004000
  317. #define ISC_RET_STREAM 0x00008000
  318. #define ISC_RET_INTEGRITY 0x00010000
  319. #define ISC_RET_IDENTIFY 0x00020000
  320. #define ISC_RET_NULL_SESSION 0x00040000
  321. #define ISC_RET_MANUAL_CRED_VALIDATION 0x00080000
  322. #define ISC_RET_RESERVED1 0x00100000
  323. #define ISC_RET_FRAGMENT_ONLY 0x00200000
  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_REQ_ALLOW_NON_USER_LOGONS 0x00200000
  342. #define ASC_REQ_ALLOW_CONTEXT_REPLAY 0x00400000
  343. #define ASC_REQ_FRAGMENT_TO_FIT 0x00800000
  344. #define ASC_REQ_FRAGMENT_SUPPLIED 0x00002000
  345. #define ASC_RET_DELEGATE 0x00000001
  346. #define ASC_RET_MUTUAL_AUTH 0x00000002
  347. #define ASC_RET_REPLAY_DETECT 0x00000004
  348. #define ASC_RET_SEQUENCE_DETECT 0x00000008
  349. #define ASC_RET_CONFIDENTIALITY 0x00000010
  350. #define ASC_RET_USE_SESSION_KEY 0x00000020
  351. #define ASC_RET_ALLOCATED_MEMORY 0x00000100
  352. #define ASC_RET_USED_DCE_STYLE 0x00000200
  353. #define ASC_RET_DATAGRAM 0x00000400
  354. #define ASC_RET_CONNECTION 0x00000800
  355. #define ASC_RET_CALL_LEVEL 0x00002000 // skipped 1000 to be like ISC_
  356. #define ASC_RET_THIRD_LEG_FAILED 0x00004000
  357. #define ASC_RET_EXTENDED_ERROR 0x00008000
  358. #define ASC_RET_STREAM 0x00010000
  359. #define ASC_RET_INTEGRITY 0x00020000
  360. #define ASC_RET_LICENSING 0x00040000
  361. #define ASC_RET_IDENTIFY 0x00080000
  362. #define ASC_RET_NULL_SESSION 0x00100000
  363. #define ASC_RET_ALLOW_NON_USER_LOGONS 0x00200000
  364. #define ASC_RET_ALLOW_CONTEXT_REPLAY 0x00400000
  365. #define ASC_RET_FRAGMENT_ONLY 0x00800000
  366. //
  367. // Security Credentials Attributes:
  368. //
  369. #define SECPKG_CRED_ATTR_NAMES 1
  370. typedef struct _SecPkgCredentials_NamesW
  371. {
  372. SEC_WCHAR SEC_FAR * sUserName;
  373. } SecPkgCredentials_NamesW, SEC_FAR * PSecPkgCredentials_NamesW;
  374. // end_ntifs
  375. typedef struct _SecPkgCredentials_NamesA
  376. {
  377. SEC_CHAR SEC_FAR * sUserName;
  378. } SecPkgCredentials_NamesA, SEC_FAR * PSecPkgCredentials_NamesA;
  379. #ifdef UNICODE
  380. # define SecPkgCredentials_Names SecPkgCredentials_NamesW // ntifs
  381. # define PSecPkgCredentials_Names PSecPkgCredentials_NamesW // ntifs
  382. #else
  383. # define SecPkgCredentials_Names SecPkgCredentials_NamesA
  384. # define PSecPkgCredentials_Names PSecPkgCredentials_NamesA
  385. #endif // !UNICODE
  386. // begin_ntifs
  387. //
  388. // Security Context Attributes:
  389. //
  390. #define SECPKG_ATTR_SIZES 0
  391. #define SECPKG_ATTR_NAMES 1
  392. #define SECPKG_ATTR_LIFESPAN 2
  393. #define SECPKG_ATTR_DCE_INFO 3
  394. #define SECPKG_ATTR_STREAM_SIZES 4
  395. #define SECPKG_ATTR_KEY_INFO 5
  396. #define SECPKG_ATTR_AUTHORITY 6
  397. #define SECPKG_ATTR_PROTO_INFO 7
  398. #define SECPKG_ATTR_PASSWORD_EXPIRY 8
  399. #define SECPKG_ATTR_SESSION_KEY 9
  400. #define SECPKG_ATTR_PACKAGE_INFO 10
  401. #define SECPKG_ATTR_USER_FLAGS 11
  402. #define SECPKG_ATTR_NEGOTIATION_INFO 12
  403. #define SECPKG_ATTR_NATIVE_NAMES 13
  404. #define SECPKG_ATTR_FLAGS 14
  405. #define SECPKG_ATTR_USE_VALIDATED 15
  406. #define SECPKG_ATTR_CREDENTIAL_NAME 16
  407. #define SECPKG_ATTR_TARGET_INFORMATION 17
  408. #define SECPKG_ATTR_ACCESS_TOKEN 18
  409. typedef struct _SecPkgContext_Sizes
  410. {
  411. unsigned long cbMaxToken;
  412. unsigned long cbMaxSignature;
  413. unsigned long cbBlockSize;
  414. unsigned long cbSecurityTrailer;
  415. } SecPkgContext_Sizes, SEC_FAR * PSecPkgContext_Sizes;
  416. typedef struct _SecPkgContext_StreamSizes
  417. {
  418. unsigned long cbHeader;
  419. unsigned long cbTrailer;
  420. unsigned long cbMaximumMessage;
  421. unsigned long cBuffers;
  422. unsigned long cbBlockSize;
  423. } SecPkgContext_StreamSizes, * PSecPkgContext_StreamSizes;
  424. typedef struct _SecPkgContext_NamesW
  425. {
  426. SEC_WCHAR SEC_FAR * sUserName;
  427. } SecPkgContext_NamesW, SEC_FAR * PSecPkgContext_NamesW;
  428. // end_ntifs
  429. typedef struct _SecPkgContext_NamesA
  430. {
  431. SEC_CHAR SEC_FAR * sUserName;
  432. } SecPkgContext_NamesA, SEC_FAR * PSecPkgContext_NamesA;
  433. #ifdef UNICODE
  434. # define SecPkgContext_Names SecPkgContext_NamesW // ntifs
  435. # define PSecPkgContext_Names PSecPkgContext_NamesW // ntifs
  436. #else
  437. # define SecPkgContext_Names SecPkgContext_NamesA
  438. # define PSecPkgContext_Names PSecPkgContext_NamesA
  439. #endif // !UNICODE
  440. // begin_ntifs
  441. typedef struct _SecPkgContext_Lifespan
  442. {
  443. TimeStamp tsStart;
  444. TimeStamp tsExpiry;
  445. } SecPkgContext_Lifespan, SEC_FAR * PSecPkgContext_Lifespan;
  446. typedef struct _SecPkgContext_DceInfo
  447. {
  448. unsigned long AuthzSvc;
  449. void SEC_FAR * pPac;
  450. } SecPkgContext_DceInfo, SEC_FAR * PSecPkgContext_DceInfo;
  451. // end_ntifs
  452. typedef struct _SecPkgContext_KeyInfoA
  453. {
  454. SEC_CHAR SEC_FAR * sSignatureAlgorithmName;
  455. SEC_CHAR SEC_FAR * sEncryptAlgorithmName;
  456. unsigned long KeySize;
  457. unsigned long SignatureAlgorithm;
  458. unsigned long EncryptAlgorithm;
  459. } SecPkgContext_KeyInfoA, SEC_FAR * PSecPkgContext_KeyInfoA;
  460. // begin_ntifs
  461. typedef struct _SecPkgContext_KeyInfoW
  462. {
  463. SEC_WCHAR SEC_FAR * sSignatureAlgorithmName;
  464. SEC_WCHAR SEC_FAR * sEncryptAlgorithmName;
  465. unsigned long KeySize;
  466. unsigned long SignatureAlgorithm;
  467. unsigned long EncryptAlgorithm;
  468. } SecPkgContext_KeyInfoW, SEC_FAR * PSecPkgContext_KeyInfoW;
  469. // end_ntifs
  470. #ifdef UNICODE
  471. #define SecPkgContext_KeyInfo SecPkgContext_KeyInfoW // ntifs
  472. #define PSecPkgContext_KeyInfo PSecPkgContext_KeyInfoW // ntifs
  473. #else
  474. #define SecPkgContext_KeyInfo SecPkgContext_KeyInfoA
  475. #define PSecPkgContext_KeyInfo PSecPkgContext_KeyInfoA
  476. #endif
  477. typedef struct _SecPkgContext_AuthorityA
  478. {
  479. SEC_CHAR SEC_FAR * sAuthorityName;
  480. } SecPkgContext_AuthorityA, * PSecPkgContext_AuthorityA;
  481. // begin_ntifs
  482. typedef struct _SecPkgContext_AuthorityW
  483. {
  484. SEC_WCHAR SEC_FAR * sAuthorityName;
  485. } SecPkgContext_AuthorityW, * PSecPkgContext_AuthorityW;
  486. // end_ntifs
  487. #ifdef UNICODE
  488. #define SecPkgContext_Authority SecPkgContext_AuthorityW // ntifs
  489. #define PSecPkgContext_Authority PSecPkgContext_AuthorityW // ntifs
  490. #else
  491. #define SecPkgContext_Authority SecPkgContext_AuthorityA
  492. #define PSecPkgContext_Authority PSecPkgContext_AuthorityA
  493. #endif
  494. typedef struct _SecPkgContext_ProtoInfoA
  495. {
  496. SEC_CHAR SEC_FAR * sProtocolName;
  497. unsigned long majorVersion;
  498. unsigned long minorVersion;
  499. } SecPkgContext_ProtoInfoA, SEC_FAR * PSecPkgContext_ProtoInfoA;
  500. // begin_ntifs
  501. typedef struct _SecPkgContext_ProtoInfoW
  502. {
  503. SEC_WCHAR SEC_FAR * sProtocolName;
  504. unsigned long majorVersion;
  505. unsigned long minorVersion;
  506. } SecPkgContext_ProtoInfoW, SEC_FAR * PSecPkgContext_ProtoInfoW;
  507. // end_ntifs
  508. #ifdef UNICODE
  509. #define SecPkgContext_ProtoInfo SecPkgContext_ProtoInfoW // ntifs
  510. #define PSecPkgContext_ProtoInfo PSecPkgContext_ProtoInfoW // ntifs
  511. #else
  512. #define SecPkgContext_ProtoInfo SecPkgContext_ProtoInfoA
  513. #define PSecPkgContext_ProtoInfo PSecPkgContext_ProtoInfoA
  514. #endif
  515. // begin_ntifs
  516. typedef struct _SecPkgContext_PasswordExpiry
  517. {
  518. TimeStamp tsPasswordExpires;
  519. } SecPkgContext_PasswordExpiry, SEC_FAR * PSecPkgContext_PasswordExpiry;
  520. typedef struct _SecPkgContext_SessionKey
  521. {
  522. unsigned long SessionKeyLength;
  523. unsigned char SEC_FAR * SessionKey;
  524. } SecPkgContext_SessionKey, *PSecPkgContext_SessionKey;
  525. typedef struct _SecPkgContext_PackageInfoW
  526. {
  527. PSecPkgInfoW PackageInfo;
  528. } SecPkgContext_PackageInfoW, SEC_FAR * PSecPkgContext_PackageInfoW;
  529. // end_ntifs
  530. typedef struct _SecPkgContext_PackageInfoA
  531. {
  532. PSecPkgInfoA PackageInfo;
  533. } SecPkgContext_PackageInfoA, SEC_FAR * PSecPkgContext_PackageInfoA;
  534. // begin_ntifs
  535. typedef struct _SecPkgContext_UserFlags
  536. {
  537. unsigned long UserFlags;
  538. } SecPkgContext_UserFlags, SEC_FAR * PSecPkgContext_UserFlags;
  539. typedef struct _SecPkgContext_Flags
  540. {
  541. unsigned long Flags;
  542. } SecPkgContext_Flags, SEC_FAR * PSecPkgContext_Flags;
  543. // end_ntifs
  544. #ifdef UNICODE
  545. #define SecPkgContext_PackageInfo SecPkgContext_PackageInfoW // ntifs
  546. #define PSecPkgContext_PackageInfo PSecPkgContext_PackageInfoW // ntifs
  547. #else
  548. #define SecPkgContext_PackageInfo SecPkgContext_PackageInfoA
  549. #define PSecPkgContext_PackageInfo PSecPkgContext_PackageInfoA
  550. #endif
  551. typedef struct _SecPkgContext_NegotiationInfoA
  552. {
  553. PSecPkgInfoA PackageInfo ;
  554. unsigned long NegotiationState ;
  555. } SecPkgContext_NegotiationInfoA, SEC_FAR * PSecPkgContext_NegotiationInfoA ;
  556. // begin_ntifs
  557. typedef struct _SecPkgContext_NegotiationInfoW
  558. {
  559. PSecPkgInfoW PackageInfo ;
  560. unsigned long NegotiationState ;
  561. } SecPkgContext_NegotiationInfoW, SEC_FAR * PSecPkgContext_NegotiationInfoW ;
  562. // end_ntifs
  563. #ifdef UNICODE
  564. #define SecPkgContext_NegotiationInfo SecPkgContext_NegotiationInfoW
  565. #define PSecPkgContext_NegotiationInfo PSecPkgContext_NegotiationInfoW
  566. #else
  567. #define SecPkgContext_NegotiationInfo SecPkgContext_NegotiationInfoA
  568. #define PSecPkgContext_NegotiationInfo PSecPkgContext_NegotiationInfoA
  569. #endif
  570. #define SECPKG_NEGOTIATION_COMPLETE 0
  571. #define SECPKG_NEGOTIATION_OPTIMISTIC 1
  572. #define SECPKG_NEGOTIATION_IN_PROGRESS 2
  573. #define SECPKG_NEGOTIATION_DIRECT 3
  574. typedef struct _SecPkgContext_NativeNamesW
  575. {
  576. SEC_WCHAR SEC_FAR * sClientName;
  577. SEC_WCHAR SEC_FAR * sServerName;
  578. } SecPkgContext_NativeNamesW, SEC_FAR * PSecPkgContext_NativeNamesW;
  579. typedef struct _SecPkgContext_NativeNamesA
  580. {
  581. SEC_CHAR SEC_FAR * sClientName;
  582. SEC_CHAR SEC_FAR * sServerName;
  583. } SecPkgContext_NativeNamesA, SEC_FAR * PSecPkgContext_NativeNamesA;
  584. #ifdef UNICODE
  585. # define SecPkgContext_NativeNames SecPkgContext_NativeNamesW // ntifs
  586. # define PSecPkgContext_NativeNames PSecPkgContext_NativeNamesW // ntifs
  587. #else
  588. # define SecPkgContext_NativeNames SecPkgContext_NativeNamesA
  589. # define PSecPkgContext_NativeNames PSecPkgContext_NativeNamesA
  590. #endif // !UNICODE
  591. // begin_ntifs
  592. typedef struct _SecPkgContext_CredentialNameW
  593. {
  594. unsigned long CredentialType;
  595. SEC_WCHAR SEC_FAR *sCredentialName;
  596. } SecPkgContext_CredentialNameW, SEC_FAR * PSecPkgContext_CredentialNameW;
  597. // end_ntifs
  598. typedef struct _SecPkgContext_CredentialNameA
  599. {
  600. unsigned long CredentialType;
  601. SEC_CHAR SEC_FAR *sCredentialName;
  602. } SecPkgContext_CredentialNameA, SEC_FAR * PSecPkgContext_CredentialNameA;
  603. #ifdef UNICODE
  604. # define SecPkgContext_CredentialName SecPkgContext_CredentialNameW // ntifs
  605. # define PSecPkgContext_CredentialName PSecPkgContext_CredentialNameW // ntifs
  606. #else
  607. # define SecPkgContext_CredentialName SecPkgContext_CredentialNameA
  608. # define PSecPkgContext_CredentialName PSecPkgContext_CredentialNameA
  609. #endif // !UNICODE
  610. typedef struct _SecPkgContext_AccessToken
  611. {
  612. void SEC_FAR * AccessToken;
  613. } SecPkgContext_AccessToken, SEC_FAR * PSecPkgContext_AccessToken;
  614. typedef struct _SecPkgContext_TargetInformation
  615. {
  616. unsigned long MarshalledTargetInfoLength;
  617. unsigned char SEC_FAR * MarshalledTargetInfo;
  618. } SecPkgContext_TargetInformation, SEC_FAR * PSecPkgContext_TargetInformation;
  619. // begin_ntifs
  620. typedef void
  621. (SEC_ENTRY SEC_FAR * SEC_GET_KEY_FN) (
  622. void SEC_FAR * Arg, // Argument passed in
  623. void SEC_FAR * Principal, // Principal ID
  624. unsigned long KeyVer, // Key Version
  625. void SEC_FAR * SEC_FAR * Key, // Returned ptr to key
  626. SECURITY_STATUS SEC_FAR * Status // returned status
  627. );
  628. //
  629. // Flags for ExportSecurityContext
  630. //
  631. #define SECPKG_CONTEXT_EXPORT_RESET_NEW 0x00000001 // New context is reset to initial state
  632. #define SECPKG_CONTEXT_EXPORT_DELETE_OLD 0x00000002 // Old context is deleted during export
  633. SECURITY_STATUS SEC_ENTRY
  634. AcquireCredentialsHandleW(
  635. #if ISSP_MODE == 0 // For Kernel mode
  636. PSECURITY_STRING pPrincipal,
  637. PSECURITY_STRING pPackage,
  638. #else
  639. SEC_WCHAR SEC_FAR * pszPrincipal, // Name of principal
  640. SEC_WCHAR SEC_FAR * pszPackage, // Name of package
  641. #endif
  642. unsigned long fCredentialUse, // Flags indicating use
  643. void SEC_FAR * pvLogonId, // Pointer to logon ID
  644. void SEC_FAR * pAuthData, // Package specific data
  645. SEC_GET_KEY_FN pGetKeyFn, // Pointer to GetKey() func
  646. void SEC_FAR * pvGetKeyArgument, // Value to pass to GetKey()
  647. PCredHandle phCredential, // (out) Cred Handle
  648. PTimeStamp ptsExpiry // (out) Lifetime (optional)
  649. );
  650. typedef SECURITY_STATUS
  651. (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_W)(
  652. #if ISSP_MODE == 0
  653. PSECURITY_STRING,
  654. PSECURITY_STRING,
  655. #else
  656. SEC_WCHAR SEC_FAR *,
  657. SEC_WCHAR SEC_FAR *,
  658. #endif
  659. unsigned long,
  660. void SEC_FAR *,
  661. void SEC_FAR *,
  662. SEC_GET_KEY_FN,
  663. void SEC_FAR *,
  664. PCredHandle,
  665. PTimeStamp);
  666. // end_ntifs
  667. SECURITY_STATUS SEC_ENTRY
  668. AcquireCredentialsHandleA(
  669. SEC_CHAR SEC_FAR * pszPrincipal, // Name of principal
  670. SEC_CHAR SEC_FAR * pszPackage, // Name of package
  671. unsigned long fCredentialUse, // Flags indicating use
  672. void SEC_FAR * pvLogonId, // Pointer to logon ID
  673. void SEC_FAR * pAuthData, // Package specific data
  674. SEC_GET_KEY_FN pGetKeyFn, // Pointer to GetKey() func
  675. void SEC_FAR * pvGetKeyArgument, // Value to pass to GetKey()
  676. PCredHandle phCredential, // (out) Cred Handle
  677. PTimeStamp ptsExpiry // (out) Lifetime (optional)
  678. );
  679. typedef SECURITY_STATUS
  680. (SEC_ENTRY * ACQUIRE_CREDENTIALS_HANDLE_FN_A)(
  681. SEC_CHAR SEC_FAR *,
  682. SEC_CHAR SEC_FAR *,
  683. unsigned long,
  684. void SEC_FAR *,
  685. void SEC_FAR *,
  686. SEC_GET_KEY_FN,
  687. void SEC_FAR *,
  688. PCredHandle,
  689. PTimeStamp);
  690. #ifdef UNICODE
  691. # define AcquireCredentialsHandle AcquireCredentialsHandleW // ntifs
  692. # define ACQUIRE_CREDENTIALS_HANDLE_FN ACQUIRE_CREDENTIALS_HANDLE_FN_W // ntifs
  693. #else
  694. # define AcquireCredentialsHandle AcquireCredentialsHandleA
  695. # define ACQUIRE_CREDENTIALS_HANDLE_FN ACQUIRE_CREDENTIALS_HANDLE_FN_A
  696. #endif // !UNICODE
  697. // begin_ntifs
  698. SECURITY_STATUS SEC_ENTRY
  699. FreeCredentialsHandle(
  700. PCredHandle phCredential // Handle to free
  701. );
  702. typedef SECURITY_STATUS
  703. (SEC_ENTRY * FREE_CREDENTIALS_HANDLE_FN)(
  704. PCredHandle );
  705. SECURITY_STATUS SEC_ENTRY
  706. AddCredentialsW(
  707. PCredHandle hCredentials,
  708. #if ISSP_MODE == 0 // For Kernel mode
  709. PSECURITY_STRING pPrincipal,
  710. PSECURITY_STRING pPackage,
  711. #else
  712. SEC_WCHAR SEC_FAR * pszPrincipal, // Name of principal
  713. SEC_WCHAR SEC_FAR * pszPackage, // Name of package
  714. #endif
  715. unsigned long fCredentialUse, // Flags indicating use
  716. void SEC_FAR * pAuthData, // Package specific data
  717. SEC_GET_KEY_FN pGetKeyFn, // Pointer to GetKey() func
  718. void SEC_FAR * pvGetKeyArgument, // Value to pass to GetKey()
  719. PTimeStamp ptsExpiry // (out) Lifetime (optional)
  720. );
  721. typedef SECURITY_STATUS
  722. (SEC_ENTRY * ADD_CREDENTIALS_FN_W)(
  723. PCredHandle,
  724. #if ISSP_MODE == 0
  725. PSECURITY_STRING,
  726. PSECURITY_STRING,
  727. #else
  728. SEC_WCHAR SEC_FAR *,
  729. SEC_WCHAR SEC_FAR *,
  730. #endif
  731. unsigned long,
  732. void SEC_FAR *,
  733. SEC_GET_KEY_FN,
  734. void SEC_FAR *,
  735. PTimeStamp);
  736. SECURITY_STATUS SEC_ENTRY
  737. AddCredentialsA(
  738. PCredHandle hCredentials,
  739. SEC_CHAR SEC_FAR * pszPrincipal, // Name of principal
  740. SEC_CHAR SEC_FAR * pszPackage, // Name of package
  741. unsigned long fCredentialUse, // Flags indicating use
  742. void SEC_FAR * pAuthData, // Package specific data
  743. SEC_GET_KEY_FN pGetKeyFn, // Pointer to GetKey() func
  744. void SEC_FAR * pvGetKeyArgument, // Value to pass to GetKey()
  745. PTimeStamp ptsExpiry // (out) Lifetime (optional)
  746. );
  747. typedef SECURITY_STATUS
  748. (SEC_ENTRY * ADD_CREDENTIALS_FN_A)(
  749. PCredHandle,
  750. SEC_CHAR SEC_FAR *,
  751. SEC_CHAR SEC_FAR *,
  752. unsigned long,
  753. void SEC_FAR *,
  754. SEC_GET_KEY_FN,
  755. void SEC_FAR *,
  756. PTimeStamp);
  757. #ifdef UNICODE
  758. #define AddCredentials AddCredentialsW
  759. #define ADD_CREDENTIALS_FN ADD_CREDENTIALS_FN_W
  760. #else
  761. #define AddCredentials AddCredentialsA
  762. #define ADD_CREDENTIALS_FN ADD_CREDENTIALS_FN_A
  763. #endif
  764. // end_ntifs
  765. #ifdef WIN32_CHICAGO
  766. SECURITY_STATUS SEC_ENTRY
  767. SspiLogonUserW(
  768. SEC_WCHAR SEC_FAR * pszPackage, // Name of package
  769. SEC_WCHAR SEC_FAR * pszUserName, // Name of package
  770. SEC_WCHAR SEC_FAR * pszDomainName, // Name of package
  771. SEC_WCHAR SEC_FAR * pszPassword // Name of package
  772. );
  773. typedef SECURITY_STATUS
  774. (SEC_ENTRY * SSPI_LOGON_USER_FN_W)(
  775. SEC_CHAR SEC_FAR *,
  776. SEC_CHAR SEC_FAR *,
  777. SEC_CHAR SEC_FAR *,
  778. SEC_CHAR SEC_FAR *);
  779. SECURITY_STATUS SEC_ENTRY
  780. SspiLogonUserA(
  781. SEC_CHAR SEC_FAR * pszPackage, // Name of package
  782. SEC_CHAR SEC_FAR * pszUserName, // Name of package
  783. SEC_CHAR SEC_FAR * pszDomainName, // Name of package
  784. SEC_CHAR SEC_FAR * pszPassword // Name of package
  785. );
  786. typedef SECURITY_STATUS
  787. (SEC_ENTRY * SSPI_LOGON_USER_FN_A)(
  788. SEC_CHAR SEC_FAR *,
  789. SEC_CHAR SEC_FAR *,
  790. SEC_CHAR SEC_FAR *,
  791. SEC_CHAR SEC_FAR *);
  792. #ifdef UNICODE
  793. #define SspiLogonUser SspiLogonUserW // ntifs
  794. #define SSPI_LOGON_USER_FN SSPI_LOGON_USER_FN_W
  795. #else
  796. #define SspiLogonUser SspiLogonUserA
  797. #define SSPI_LOGON_USER_FN SSPI_LOGON_USER_FN_A
  798. #endif // !UNICODE
  799. #endif // WIN32_CHICAGO
  800. // begin_ntifs
  801. ////////////////////////////////////////////////////////////////////////
  802. ///
  803. /// Context Management Functions
  804. ///
  805. ////////////////////////////////////////////////////////////////////////
  806. SECURITY_STATUS SEC_ENTRY
  807. InitializeSecurityContextW(
  808. PCredHandle phCredential, // Cred to base context
  809. PCtxtHandle phContext, // Existing context (OPT)
  810. #if ISSP_MODE == 0
  811. PSECURITY_STRING pTargetName,
  812. #else
  813. SEC_WCHAR SEC_FAR * pszTargetName, // Name of target
  814. #endif
  815. unsigned long fContextReq, // Context Requirements
  816. unsigned long Reserved1, // Reserved, MBZ
  817. unsigned long TargetDataRep, // Data rep of target
  818. PSecBufferDesc pInput, // Input Buffers
  819. unsigned long Reserved2, // Reserved, MBZ
  820. PCtxtHandle phNewContext, // (out) New Context handle
  821. PSecBufferDesc pOutput, // (inout) Output Buffers
  822. unsigned long SEC_FAR * pfContextAttr, // (out) Context attrs
  823. PTimeStamp ptsExpiry // (out) Life span (OPT)
  824. );
  825. typedef SECURITY_STATUS
  826. (SEC_ENTRY * INITIALIZE_SECURITY_CONTEXT_FN_W)(
  827. PCredHandle,
  828. PCtxtHandle,
  829. #if ISSP_MODE == 0
  830. PSECURITY_STRING,
  831. #else
  832. SEC_WCHAR SEC_FAR *,
  833. #endif
  834. unsigned long,
  835. unsigned long,
  836. unsigned long,
  837. PSecBufferDesc,
  838. unsigned long,
  839. PCtxtHandle,
  840. PSecBufferDesc,
  841. unsigned long SEC_FAR *,
  842. PTimeStamp);
  843. // end_ntifs
  844. SECURITY_STATUS SEC_ENTRY
  845. InitializeSecurityContextA(
  846. PCredHandle phCredential, // Cred to base context
  847. PCtxtHandle phContext, // Existing context (OPT)
  848. SEC_CHAR SEC_FAR * pszTargetName, // Name of target
  849. unsigned long fContextReq, // Context Requirements
  850. unsigned long Reserved1, // Reserved, MBZ
  851. unsigned long TargetDataRep, // Data rep of target
  852. PSecBufferDesc pInput, // Input Buffers
  853. unsigned long Reserved2, // Reserved, MBZ
  854. PCtxtHandle phNewContext, // (out) New Context handle
  855. PSecBufferDesc pOutput, // (inout) Output Buffers
  856. unsigned long SEC_FAR * pfContextAttr, // (out) Context attrs
  857. PTimeStamp ptsExpiry // (out) Life span (OPT)
  858. );
  859. typedef SECURITY_STATUS
  860. (SEC_ENTRY * INITIALIZE_SECURITY_CONTEXT_FN_A)(
  861. PCredHandle,
  862. PCtxtHandle,
  863. SEC_CHAR SEC_FAR *,
  864. unsigned long,
  865. unsigned long,
  866. unsigned long,
  867. PSecBufferDesc,
  868. unsigned long,
  869. PCtxtHandle,
  870. PSecBufferDesc,
  871. unsigned long SEC_FAR *,
  872. PTimeStamp);
  873. #ifdef UNICODE
  874. # define InitializeSecurityContext InitializeSecurityContextW // ntifs
  875. # define INITIALIZE_SECURITY_CONTEXT_FN INITIALIZE_SECURITY_CONTEXT_FN_W // ntifs
  876. #else
  877. # define InitializeSecurityContext InitializeSecurityContextA
  878. # define INITIALIZE_SECURITY_CONTEXT_FN INITIALIZE_SECURITY_CONTEXT_FN_A
  879. #endif // !UNICODE
  880. // begin_ntifs
  881. SECURITY_STATUS SEC_ENTRY
  882. AcceptSecurityContext(
  883. PCredHandle phCredential, // Cred to base context
  884. PCtxtHandle phContext, // Existing context (OPT)
  885. PSecBufferDesc pInput, // Input buffer
  886. unsigned long fContextReq, // Context Requirements
  887. unsigned long TargetDataRep, // Target Data Rep
  888. PCtxtHandle phNewContext, // (out) New context handle
  889. PSecBufferDesc pOutput, // (inout) Output buffers
  890. unsigned long SEC_FAR * pfContextAttr, // (out) Context attributes
  891. PTimeStamp ptsExpiry // (out) Life span (OPT)
  892. );
  893. typedef SECURITY_STATUS
  894. (SEC_ENTRY * ACCEPT_SECURITY_CONTEXT_FN)(
  895. PCredHandle,
  896. PCtxtHandle,
  897. PSecBufferDesc,
  898. unsigned long,
  899. unsigned long,
  900. PCtxtHandle,
  901. PSecBufferDesc,
  902. unsigned long SEC_FAR *,
  903. PTimeStamp);
  904. SECURITY_STATUS SEC_ENTRY
  905. CompleteAuthToken(
  906. PCtxtHandle phContext, // Context to complete
  907. PSecBufferDesc pToken // Token to complete
  908. );
  909. typedef SECURITY_STATUS
  910. (SEC_ENTRY * COMPLETE_AUTH_TOKEN_FN)(
  911. PCtxtHandle,
  912. PSecBufferDesc);
  913. SECURITY_STATUS SEC_ENTRY
  914. ImpersonateSecurityContext(
  915. PCtxtHandle phContext // Context to impersonate
  916. );
  917. typedef SECURITY_STATUS
  918. (SEC_ENTRY * IMPERSONATE_SECURITY_CONTEXT_FN)(
  919. PCtxtHandle);
  920. SECURITY_STATUS SEC_ENTRY
  921. RevertSecurityContext(
  922. PCtxtHandle phContext // Context from which to re
  923. );
  924. typedef SECURITY_STATUS
  925. (SEC_ENTRY * REVERT_SECURITY_CONTEXT_FN)(
  926. PCtxtHandle);
  927. SECURITY_STATUS SEC_ENTRY
  928. QuerySecurityContextToken(
  929. PCtxtHandle phContext,
  930. void SEC_FAR * SEC_FAR * Token
  931. );
  932. typedef SECURITY_STATUS
  933. (SEC_ENTRY * QUERY_SECURITY_CONTEXT_TOKEN_FN)(
  934. PCtxtHandle, void SEC_FAR * SEC_FAR *);
  935. SECURITY_STATUS SEC_ENTRY
  936. DeleteSecurityContext(
  937. PCtxtHandle phContext // Context to delete
  938. );
  939. typedef SECURITY_STATUS
  940. (SEC_ENTRY * DELETE_SECURITY_CONTEXT_FN)(
  941. PCtxtHandle);
  942. SECURITY_STATUS SEC_ENTRY
  943. ApplyControlToken(
  944. PCtxtHandle phContext, // Context to modify
  945. PSecBufferDesc pInput // Input token to apply
  946. );
  947. typedef SECURITY_STATUS
  948. (SEC_ENTRY * APPLY_CONTROL_TOKEN_FN)(
  949. PCtxtHandle, PSecBufferDesc);
  950. SECURITY_STATUS SEC_ENTRY
  951. QueryContextAttributesW(
  952. PCtxtHandle phContext, // Context to query
  953. unsigned long ulAttribute, // Attribute to query
  954. void SEC_FAR * pBuffer // Buffer for attributes
  955. );
  956. typedef SECURITY_STATUS
  957. (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_W)(
  958. PCtxtHandle,
  959. unsigned long,
  960. void SEC_FAR *);
  961. // end_ntifs
  962. SECURITY_STATUS SEC_ENTRY
  963. QueryContextAttributesA(
  964. PCtxtHandle phContext, // Context to query
  965. unsigned long ulAttribute, // Attribute to query
  966. void SEC_FAR * pBuffer // Buffer for attributes
  967. );
  968. typedef SECURITY_STATUS
  969. (SEC_ENTRY * QUERY_CONTEXT_ATTRIBUTES_FN_A)(
  970. PCtxtHandle,
  971. unsigned long,
  972. void SEC_FAR *);
  973. #ifdef UNICODE
  974. # define QueryContextAttributes QueryContextAttributesW // ntifs
  975. # define QUERY_CONTEXT_ATTRIBUTES_FN QUERY_CONTEXT_ATTRIBUTES_FN_W // ntifs
  976. #else
  977. # define QueryContextAttributes QueryContextAttributesA
  978. # define QUERY_CONTEXT_ATTRIBUTES_FN QUERY_CONTEXT_ATTRIBUTES_FN_A
  979. #endif // !UNICODE
  980. // begin_ntifs
  981. SECURITY_STATUS SEC_ENTRY
  982. SetContextAttributesW(
  983. PCtxtHandle phContext, // Context to Set
  984. unsigned long ulAttribute, // Attribute to Set
  985. void SEC_FAR * pBuffer, // Buffer for attributes
  986. unsigned long cbBuffer // Size (in bytes) of Buffer
  987. );
  988. typedef SECURITY_STATUS
  989. (SEC_ENTRY * SET_CONTEXT_ATTRIBUTES_FN_W)(
  990. PCtxtHandle,
  991. unsigned long,
  992. void SEC_FAR *,
  993. unsigned long );
  994. // end_ntifs
  995. SECURITY_STATUS SEC_ENTRY
  996. SetContextAttributesA(
  997. PCtxtHandle phContext, // Context to Set
  998. unsigned long ulAttribute, // Attribute to Set
  999. void SEC_FAR * pBuffer, // Buffer for attributes
  1000. unsigned long cbBuffer // Size (in bytes) of Buffer
  1001. );
  1002. typedef SECURITY_STATUS
  1003. (SEC_ENTRY * SET_CONTEXT_ATTRIBUTES_FN_A)(
  1004. PCtxtHandle,
  1005. unsigned long,
  1006. void SEC_FAR *,
  1007. unsigned long );
  1008. #ifdef UNICODE
  1009. # define SetContextAttributes SetContextAttributesW // ntifs
  1010. # define SET_CONTEXT_ATTRIBUTES_FN SET_CONTEXT_ATTRIBUTES_FN_W // ntifs
  1011. #else
  1012. # define SetContextAttributes SetContextAttributesA
  1013. # define SET_CONTEXT_ATTRIBUTES_FN SET_CONTEXT_ATTRIBUTES_FN_A
  1014. #endif // !UNICODE
  1015. // begin_ntifs
  1016. SECURITY_STATUS SEC_ENTRY
  1017. QueryCredentialsAttributesW(
  1018. PCredHandle phCredential, // Credential to query
  1019. unsigned long ulAttribute, // Attribute to query
  1020. void SEC_FAR * pBuffer // Buffer for attributes
  1021. );
  1022. typedef SECURITY_STATUS
  1023. (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_W)(
  1024. PCredHandle,
  1025. unsigned long,
  1026. void SEC_FAR *);
  1027. // end_ntifs
  1028. SECURITY_STATUS SEC_ENTRY
  1029. QueryCredentialsAttributesA(
  1030. PCredHandle phCredential, // Credential to query
  1031. unsigned long ulAttribute, // Attribute to query
  1032. void SEC_FAR * pBuffer // Buffer for attributes
  1033. );
  1034. typedef SECURITY_STATUS
  1035. (SEC_ENTRY * QUERY_CREDENTIALS_ATTRIBUTES_FN_A)(
  1036. PCredHandle,
  1037. unsigned long,
  1038. void SEC_FAR *);
  1039. #ifdef UNICODE
  1040. # define QueryCredentialsAttributes QueryCredentialsAttributesW // ntifs
  1041. # define QUERY_CREDENTIALS_ATTRIBUTES_FN QUERY_CREDENTIALS_ATTRIBUTES_FN_W // ntifs
  1042. #else
  1043. # define QueryCredentialsAttributes QueryCredentialsAttributesA
  1044. # define QUERY_CREDENTIALS_ATTRIBUTES_FN QUERY_CREDENTIALS_ATTRIBUTES_FN_A
  1045. #endif // !UNICODE
  1046. // begin_ntifs
  1047. SECURITY_STATUS SEC_ENTRY
  1048. FreeContextBuffer(
  1049. void SEC_FAR * pvContextBuffer // buffer to free
  1050. );
  1051. typedef SECURITY_STATUS
  1052. (SEC_ENTRY * FREE_CONTEXT_BUFFER_FN)(
  1053. void SEC_FAR *);
  1054. // end_ntifs
  1055. // begin_ntifs
  1056. ///////////////////////////////////////////////////////////////////
  1057. ////
  1058. //// Message Support API
  1059. ////
  1060. //////////////////////////////////////////////////////////////////
  1061. SECURITY_STATUS SEC_ENTRY
  1062. MakeSignature(
  1063. PCtxtHandle phContext, // Context to use
  1064. unsigned long fQOP, // Quality of Protection
  1065. PSecBufferDesc pMessage, // Message to sign
  1066. unsigned long MessageSeqNo // Message Sequence Num.
  1067. );
  1068. typedef SECURITY_STATUS
  1069. (SEC_ENTRY * MAKE_SIGNATURE_FN)(
  1070. PCtxtHandle,
  1071. unsigned long,
  1072. PSecBufferDesc,
  1073. unsigned long);
  1074. SECURITY_STATUS SEC_ENTRY
  1075. VerifySignature(
  1076. PCtxtHandle phContext, // Context to use
  1077. PSecBufferDesc pMessage, // Message to verify
  1078. unsigned long MessageSeqNo, // Sequence Num.
  1079. unsigned long SEC_FAR * pfQOP // QOP used
  1080. );
  1081. typedef SECURITY_STATUS
  1082. (SEC_ENTRY * VERIFY_SIGNATURE_FN)(
  1083. PCtxtHandle,
  1084. PSecBufferDesc,
  1085. unsigned long,
  1086. unsigned long SEC_FAR *);
  1087. SECURITY_STATUS SEC_ENTRY
  1088. EncryptMessage( PCtxtHandle phContext,
  1089. unsigned long fQOP,
  1090. PSecBufferDesc pMessage,
  1091. unsigned long MessageSeqNo);
  1092. typedef SECURITY_STATUS
  1093. (SEC_ENTRY * ENCRYPT_MESSAGE_FN)(
  1094. PCtxtHandle, unsigned long, PSecBufferDesc, unsigned long);
  1095. SECURITY_STATUS SEC_ENTRY
  1096. DecryptMessage( PCtxtHandle phContext,
  1097. PSecBufferDesc pMessage,
  1098. unsigned long MessageSeqNo,
  1099. unsigned long * pfQOP);
  1100. typedef SECURITY_STATUS
  1101. (SEC_ENTRY * DECRYPT_MESSAGE_FN)(
  1102. PCtxtHandle, PSecBufferDesc, unsigned long,
  1103. unsigned long SEC_FAR *);
  1104. // end_ntifs
  1105. // begin_ntifs
  1106. ///////////////////////////////////////////////////////////////////////////
  1107. ////
  1108. //// Misc.
  1109. ////
  1110. ///////////////////////////////////////////////////////////////////////////
  1111. SECURITY_STATUS SEC_ENTRY
  1112. EnumerateSecurityPackagesW(
  1113. unsigned long SEC_FAR * pcPackages, // Receives num. packages
  1114. PSecPkgInfoW SEC_FAR * ppPackageInfo // Receives array of info
  1115. );
  1116. typedef SECURITY_STATUS
  1117. (SEC_ENTRY * ENUMERATE_SECURITY_PACKAGES_FN_W)(
  1118. unsigned long SEC_FAR *,
  1119. PSecPkgInfoW SEC_FAR *);
  1120. // end_ntifs
  1121. SECURITY_STATUS SEC_ENTRY
  1122. EnumerateSecurityPackagesA(
  1123. unsigned long SEC_FAR * pcPackages, // Receives num. packages
  1124. PSecPkgInfoA SEC_FAR * ppPackageInfo // Receives array of info
  1125. );
  1126. typedef SECURITY_STATUS
  1127. (SEC_ENTRY * ENUMERATE_SECURITY_PACKAGES_FN_A)(
  1128. unsigned long SEC_FAR *,
  1129. PSecPkgInfoA SEC_FAR *);
  1130. #ifdef UNICODE
  1131. # define EnumerateSecurityPackages EnumerateSecurityPackagesW // ntifs
  1132. # define ENUMERATE_SECURITY_PACKAGES_FN ENUMERATE_SECURITY_PACKAGES_FN_W // ntifs
  1133. #else
  1134. # define EnumerateSecurityPackages EnumerateSecurityPackagesA
  1135. # define ENUMERATE_SECURITY_PACKAGES_FN ENUMERATE_SECURITY_PACKAGES_FN_A
  1136. #endif // !UNICODE
  1137. // begin_ntifs
  1138. SECURITY_STATUS SEC_ENTRY
  1139. QuerySecurityPackageInfoW(
  1140. #if ISSP_MODE == 0
  1141. PSECURITY_STRING pPackageName,
  1142. #else
  1143. SEC_WCHAR SEC_FAR * pszPackageName, // Name of package
  1144. #endif
  1145. PSecPkgInfoW SEC_FAR *ppPackageInfo // Receives package info
  1146. );
  1147. typedef SECURITY_STATUS
  1148. (SEC_ENTRY * QUERY_SECURITY_PACKAGE_INFO_FN_W)(
  1149. #if ISSP_MODE == 0
  1150. PSECURITY_STRING,
  1151. #else
  1152. SEC_WCHAR SEC_FAR *,
  1153. #endif
  1154. PSecPkgInfoW SEC_FAR *);
  1155. // end_ntifs
  1156. SECURITY_STATUS SEC_ENTRY
  1157. QuerySecurityPackageInfoA(
  1158. SEC_CHAR SEC_FAR * pszPackageName, // Name of package
  1159. PSecPkgInfoA SEC_FAR *ppPackageInfo // Receives package info
  1160. );
  1161. typedef SECURITY_STATUS
  1162. (SEC_ENTRY * QUERY_SECURITY_PACKAGE_INFO_FN_A)(
  1163. SEC_CHAR SEC_FAR *,
  1164. PSecPkgInfoA SEC_FAR *);
  1165. #ifdef UNICODE
  1166. # define QuerySecurityPackageInfo QuerySecurityPackageInfoW // ntifs
  1167. # define QUERY_SECURITY_PACKAGE_INFO_FN QUERY_SECURITY_PACKAGE_INFO_FN_W // ntifs
  1168. #else
  1169. # define QuerySecurityPackageInfo QuerySecurityPackageInfoA
  1170. # define QUERY_SECURITY_PACKAGE_INFO_FN QUERY_SECURITY_PACKAGE_INFO_FN_A
  1171. #endif // !UNICODE
  1172. typedef enum _SecDelegationType {
  1173. SecFull,
  1174. SecService,
  1175. SecTree,
  1176. SecDirectory,
  1177. SecObject
  1178. } SecDelegationType, * PSecDelegationType;
  1179. SECURITY_STATUS SEC_ENTRY
  1180. DelegateSecurityContext(
  1181. PCtxtHandle phContext, // IN Active context to delegate
  1182. #if ISSP_MODE == 0
  1183. PSECURITY_STRING pTarget, // IN Target path
  1184. #else
  1185. SEC_CHAR SEC_FAR * pszTarget,
  1186. #endif
  1187. SecDelegationType DelegationType, // IN Type of delegation
  1188. PTimeStamp pExpiry, // IN OPTIONAL time limit
  1189. PSecBuffer pPackageParameters, // IN OPTIONAL package specific
  1190. PSecBufferDesc pOutput); // OUT Token for applycontroltoken.
  1191. ///////////////////////////////////////////////////////////////////////////
  1192. ////
  1193. //// Proxies
  1194. ////
  1195. ///////////////////////////////////////////////////////////////////////////
  1196. //
  1197. // Proxies are only available on NT platforms
  1198. //
  1199. // begin_ntifs
  1200. ///////////////////////////////////////////////////////////////////////////
  1201. ////
  1202. //// Context export/import
  1203. ////
  1204. ///////////////////////////////////////////////////////////////////////////
  1205. SECURITY_STATUS SEC_ENTRY
  1206. ExportSecurityContext(
  1207. PCtxtHandle phContext, // (in) context to export
  1208. ULONG fFlags, // (in) option flags
  1209. PSecBuffer pPackedContext, // (out) marshalled context
  1210. void SEC_FAR * SEC_FAR * pToken // (out, optional) token handle for impersonation
  1211. );
  1212. typedef SECURITY_STATUS
  1213. (SEC_ENTRY * EXPORT_SECURITY_CONTEXT_FN)(
  1214. PCtxtHandle,
  1215. ULONG,
  1216. PSecBuffer,
  1217. void SEC_FAR * SEC_FAR *
  1218. );
  1219. SECURITY_STATUS SEC_ENTRY
  1220. ImportSecurityContextW(
  1221. #if ISSP_MODE == 0
  1222. PSECURITY_STRING pszPackage,
  1223. #else
  1224. SEC_WCHAR SEC_FAR * pszPackage,
  1225. #endif
  1226. PSecBuffer pPackedContext, // (in) marshalled context
  1227. void SEC_FAR * Token, // (in, optional) handle to token for context
  1228. PCtxtHandle phContext // (out) new context handle
  1229. );
  1230. typedef SECURITY_STATUS
  1231. (SEC_ENTRY * IMPORT_SECURITY_CONTEXT_FN_W)(
  1232. #if ISSP_MODE == 0
  1233. PSECURITY_STRING,
  1234. #else
  1235. SEC_WCHAR SEC_FAR *,
  1236. #endif
  1237. PSecBuffer,
  1238. VOID SEC_FAR *,
  1239. PCtxtHandle
  1240. );
  1241. // end_ntifs
  1242. SECURITY_STATUS SEC_ENTRY
  1243. ImportSecurityContextA(
  1244. SEC_CHAR SEC_FAR * pszPackage,
  1245. PSecBuffer pPackedContext, // (in) marshalled context
  1246. VOID SEC_FAR * Token, // (in, optional) handle to token for context
  1247. PCtxtHandle phContext // (out) new context handle
  1248. );
  1249. typedef SECURITY_STATUS
  1250. (SEC_ENTRY * IMPORT_SECURITY_CONTEXT_FN_A)(
  1251. SEC_CHAR SEC_FAR *,
  1252. PSecBuffer,
  1253. void SEC_FAR *,
  1254. PCtxtHandle
  1255. );
  1256. #ifdef UNICODE
  1257. # define ImportSecurityContext ImportSecurityContextW // ntifs
  1258. # define IMPORT_SECURITY_CONTEXT_FN IMPORT_SECURITY_CONTEXT_FN_W // ntifs
  1259. #else
  1260. # define ImportSecurityContext ImportSecurityContextA
  1261. # define IMPORT_SECURITY_CONTEXT_FN IMPORT_SECURITY_CONTEXT_FN_A
  1262. #endif // !UNICODE
  1263. // begin_ntifs
  1264. #if ISSP_MODE == 0
  1265. NTSTATUS
  1266. NTAPI
  1267. SecMakeSPN(
  1268. IN PUNICODE_STRING ServiceClass,
  1269. IN PUNICODE_STRING ServiceName,
  1270. IN PUNICODE_STRING InstanceName OPTIONAL,
  1271. IN USHORT InstancePort OPTIONAL,
  1272. IN PUNICODE_STRING Referrer OPTIONAL,
  1273. IN OUT PUNICODE_STRING Spn,
  1274. OUT PULONG Length OPTIONAL,
  1275. IN BOOLEAN Allocate
  1276. );
  1277. NTSTATUS
  1278. NTAPI
  1279. SecMakeSPNEx(
  1280. IN PUNICODE_STRING ServiceClass,
  1281. IN PUNICODE_STRING ServiceName,
  1282. IN PUNICODE_STRING InstanceName OPTIONAL,
  1283. IN USHORT InstancePort OPTIONAL,
  1284. IN PUNICODE_STRING Referrer OPTIONAL,
  1285. IN PUNICODE_STRING TargetInfo OPTIONAL,
  1286. IN OUT PUNICODE_STRING Spn,
  1287. OUT PULONG Length OPTIONAL,
  1288. IN BOOLEAN Allocate
  1289. );
  1290. NTSTATUS
  1291. SEC_ENTRY
  1292. SecLookupAccountSid(
  1293. IN PSID Sid,
  1294. IN OUT PULONG NameSize,
  1295. OUT PUNICODE_STRING NameBuffer,
  1296. IN OUT PULONG DomainSize OPTIONAL,
  1297. OUT PUNICODE_STRING DomainBuffer OPTIONAL,
  1298. OUT PSID_NAME_USE NameUse
  1299. );
  1300. NTSTATUS
  1301. SEC_ENTRY
  1302. SecLookupAccountName(
  1303. IN PUNICODE_STRING Name,
  1304. IN OUT PULONG SidSize,
  1305. OUT PSID Sid,
  1306. OUT PSID_NAME_USE NameUse,
  1307. IN OUT PULONG DomainSize OPTIONAL,
  1308. OUT PUNICODE_STRING ReferencedDomain OPTIONAL
  1309. );
  1310. #endif
  1311. // end_ntifs
  1312. ///////////////////////////////////////////////////////////////////////////////
  1313. ////
  1314. //// Fast access for RPC:
  1315. ////
  1316. ///////////////////////////////////////////////////////////////////////////////
  1317. #define SECURITY_ENTRYPOINT_ANSIW "InitSecurityInterfaceW"
  1318. #define SECURITY_ENTRYPOINT_ANSIA "InitSecurityInterfaceA"
  1319. #define SECURITY_ENTRYPOINTW SEC_TEXT("InitSecurityInterfaceW") // ntifs
  1320. #define SECURITY_ENTRYPOINTA SEC_TEXT("InitSecurityInterfaceA")
  1321. #define SECURITY_ENTRYPOINT16 "INITSECURITYINTERFACEA"
  1322. #ifdef SECURITY_WIN32
  1323. # ifdef UNICODE
  1324. # define SECURITY_ENTRYPOINT SECURITY_ENTRYPOINTW // ntifs
  1325. # define SECURITY_ENTRYPOINT_ANSI SECURITY_ENTRYPOINT_ANSIW
  1326. # else // UNICODE
  1327. # define SECURITY_ENTRYPOINT SECURITY_ENTRYPOINTA
  1328. # define SECURITY_ENTRYPOINT_ANSI SECURITY_ENTRYPOINT_ANSIA
  1329. # endif // UNICODE
  1330. #else // SECURITY_WIN32
  1331. # define SECURITY_ENTRYPOINT SECURITY_ENTRYPOINT16
  1332. # define SECURITY_ENTRYPOINT_ANSI SECURITY_ENTRYPOINT16
  1333. #endif // SECURITY_WIN32
  1334. // begin_ntifs
  1335. #define FreeCredentialHandle FreeCredentialsHandle
  1336. typedef struct _SECURITY_FUNCTION_TABLE_W {
  1337. unsigned long dwVersion;
  1338. ENUMERATE_SECURITY_PACKAGES_FN_W EnumerateSecurityPackagesW;
  1339. QUERY_CREDENTIALS_ATTRIBUTES_FN_W QueryCredentialsAttributesW;
  1340. ACQUIRE_CREDENTIALS_HANDLE_FN_W AcquireCredentialsHandleW;
  1341. FREE_CREDENTIALS_HANDLE_FN FreeCredentialsHandle;
  1342. #ifndef WIN32_CHICAGO
  1343. void SEC_FAR * Reserved2;
  1344. #else // WIN32_CHICAGO
  1345. SSPI_LOGON_USER_FN SspiLogonUserW;
  1346. #endif // WIN32_CHICAGO
  1347. INITIALIZE_SECURITY_CONTEXT_FN_W InitializeSecurityContextW;
  1348. ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext;
  1349. COMPLETE_AUTH_TOKEN_FN CompleteAuthToken;
  1350. DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext;
  1351. APPLY_CONTROL_TOKEN_FN ApplyControlToken;
  1352. QUERY_CONTEXT_ATTRIBUTES_FN_W QueryContextAttributesW;
  1353. IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext;
  1354. REVERT_SECURITY_CONTEXT_FN RevertSecurityContext;
  1355. MAKE_SIGNATURE_FN MakeSignature;
  1356. VERIFY_SIGNATURE_FN VerifySignature;
  1357. FREE_CONTEXT_BUFFER_FN FreeContextBuffer;
  1358. QUERY_SECURITY_PACKAGE_INFO_FN_W QuerySecurityPackageInfoW;
  1359. void SEC_FAR * Reserved3;
  1360. void SEC_FAR * Reserved4;
  1361. EXPORT_SECURITY_CONTEXT_FN ExportSecurityContext;
  1362. IMPORT_SECURITY_CONTEXT_FN_W ImportSecurityContextW;
  1363. ADD_CREDENTIALS_FN_W AddCredentialsW ;
  1364. void SEC_FAR * Reserved8;
  1365. QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken;
  1366. ENCRYPT_MESSAGE_FN EncryptMessage;
  1367. DECRYPT_MESSAGE_FN DecryptMessage;
  1368. SET_CONTEXT_ATTRIBUTES_FN_W SetContextAttributesW;
  1369. } SecurityFunctionTableW, SEC_FAR * PSecurityFunctionTableW;
  1370. // end_ntifs
  1371. typedef struct _SECURITY_FUNCTION_TABLE_A {
  1372. unsigned long dwVersion;
  1373. ENUMERATE_SECURITY_PACKAGES_FN_A EnumerateSecurityPackagesA;
  1374. QUERY_CREDENTIALS_ATTRIBUTES_FN_A QueryCredentialsAttributesA;
  1375. ACQUIRE_CREDENTIALS_HANDLE_FN_A AcquireCredentialsHandleA;
  1376. FREE_CREDENTIALS_HANDLE_FN FreeCredentialHandle;
  1377. #ifndef WIN32_CHICAGO
  1378. void SEC_FAR * Reserved2;
  1379. #else // WIN32_CHICAGO
  1380. SSPI_LOGON_USER_FN SspiLogonUserA;
  1381. #endif // WIN32_CHICAGO
  1382. INITIALIZE_SECURITY_CONTEXT_FN_A InitializeSecurityContextA;
  1383. ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext;
  1384. COMPLETE_AUTH_TOKEN_FN CompleteAuthToken;
  1385. DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext;
  1386. APPLY_CONTROL_TOKEN_FN ApplyControlToken;
  1387. QUERY_CONTEXT_ATTRIBUTES_FN_A QueryContextAttributesA;
  1388. IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext;
  1389. REVERT_SECURITY_CONTEXT_FN RevertSecurityContext;
  1390. MAKE_SIGNATURE_FN MakeSignature;
  1391. VERIFY_SIGNATURE_FN VerifySignature;
  1392. FREE_CONTEXT_BUFFER_FN FreeContextBuffer;
  1393. QUERY_SECURITY_PACKAGE_INFO_FN_A QuerySecurityPackageInfoA;
  1394. void SEC_FAR * Reserved3;
  1395. void SEC_FAR * Reserved4;
  1396. EXPORT_SECURITY_CONTEXT_FN ExportSecurityContext;
  1397. IMPORT_SECURITY_CONTEXT_FN_A ImportSecurityContextA;
  1398. ADD_CREDENTIALS_FN_A AddCredentialsA ;
  1399. void SEC_FAR * Reserved8;
  1400. QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken;
  1401. ENCRYPT_MESSAGE_FN EncryptMessage;
  1402. DECRYPT_MESSAGE_FN DecryptMessage;
  1403. SET_CONTEXT_ATTRIBUTES_FN_A SetContextAttributesA;
  1404. } SecurityFunctionTableA, SEC_FAR * PSecurityFunctionTableA;
  1405. #ifdef UNICODE
  1406. # define SecurityFunctionTable SecurityFunctionTableW // ntifs
  1407. # define PSecurityFunctionTable PSecurityFunctionTableW // ntifs
  1408. #else
  1409. # define SecurityFunctionTable SecurityFunctionTableA
  1410. # define PSecurityFunctionTable PSecurityFunctionTableA
  1411. #endif // !UNICODE
  1412. #define SECURITY_
  1413. // Function table has all routines through DecryptMessage
  1414. #define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION 1 // ntifs
  1415. // Function table has all routines through SetContextAttributes
  1416. #define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 2 // ntifs
  1417. PSecurityFunctionTableA SEC_ENTRY
  1418. InitSecurityInterfaceA(
  1419. void
  1420. );
  1421. typedef PSecurityFunctionTableA
  1422. (SEC_ENTRY * INIT_SECURITY_INTERFACE_A)(void);
  1423. // begin_ntifs
  1424. PSecurityFunctionTableW SEC_ENTRY
  1425. InitSecurityInterfaceW(
  1426. void
  1427. );
  1428. typedef PSecurityFunctionTableW
  1429. (SEC_ENTRY * INIT_SECURITY_INTERFACE_W)(void);
  1430. // end_ntifs
  1431. #ifdef UNICODE
  1432. # define InitSecurityInterface InitSecurityInterfaceW // ntifs
  1433. # define INIT_SECURITY_INTERFACE INIT_SECURITY_INTERFACE_W // ntifs
  1434. #else
  1435. # define InitSecurityInterface InitSecurityInterfaceA
  1436. # define INIT_SECURITY_INTERFACE INIT_SECURITY_INTERFACE_A
  1437. #endif // !UNICODE
  1438. #ifdef SECURITY_WIN32
  1439. //
  1440. // SASL Profile Support
  1441. //
  1442. SECURITY_STATUS
  1443. SEC_ENTRY
  1444. SaslEnumerateProfilesA(
  1445. OUT LPSTR * ProfileList,
  1446. OUT ULONG * ProfileCount
  1447. );
  1448. SECURITY_STATUS
  1449. SEC_ENTRY
  1450. SaslEnumerateProfilesW(
  1451. OUT LPWSTR * ProfileList,
  1452. OUT ULONG * ProfileCount
  1453. );
  1454. #ifdef UNICODE
  1455. #define SaslEnumerateProfiles SaslEnumerateProfilesW
  1456. #else
  1457. #define SaslEnumerateProfiles SaslEnumerateProfilesA
  1458. #endif
  1459. SECURITY_STATUS
  1460. SEC_ENTRY
  1461. SaslGetProfilePackageA(
  1462. IN LPSTR ProfileName,
  1463. OUT PSecPkgInfoA * PackageInfo
  1464. );
  1465. SECURITY_STATUS
  1466. SEC_ENTRY
  1467. SaslGetProfilePackageW(
  1468. IN LPWSTR ProfileName,
  1469. OUT PSecPkgInfoW * PackageInfo
  1470. );
  1471. #ifdef UNICODE
  1472. #define SaslGetProfilePackage SaslGetProfilePackageW
  1473. #else
  1474. #define SaslGetProfilePackage SaslGetProfilePackageA
  1475. #endif
  1476. SECURITY_STATUS
  1477. SEC_ENTRY
  1478. SaslIdentifyPackageA(
  1479. IN PSecBufferDesc pInput,
  1480. OUT PSecPkgInfoA * PackageInfo
  1481. );
  1482. SECURITY_STATUS
  1483. SEC_ENTRY
  1484. SaslIdentifyPackageW(
  1485. IN PSecBufferDesc pInput,
  1486. OUT PSecPkgInfoW * PackageInfo
  1487. );
  1488. #ifdef UNICODE
  1489. #define SaslIdentifyPackage SaslIdentifyPackageW
  1490. #else
  1491. #define SaslIdentifyPackage SaslIdentifyPackageA
  1492. #endif
  1493. SECURITY_STATUS
  1494. SEC_ENTRY
  1495. SaslInitializeSecurityContextW(
  1496. PCredHandle phCredential, // Cred to base context
  1497. PCtxtHandle phContext, // Existing context (OPT)
  1498. LPWSTR pszTargetName, // Name of target
  1499. unsigned long fContextReq, // Context Requirements
  1500. unsigned long Reserved1, // Reserved, MBZ
  1501. unsigned long TargetDataRep, // Data rep of target
  1502. PSecBufferDesc pInput, // Input Buffers
  1503. unsigned long Reserved2, // Reserved, MBZ
  1504. PCtxtHandle phNewContext, // (out) New Context handle
  1505. PSecBufferDesc pOutput, // (inout) Output Buffers
  1506. unsigned long SEC_FAR * pfContextAttr, // (out) Context attrs
  1507. PTimeStamp ptsExpiry // (out) Life span (OPT)
  1508. );
  1509. SECURITY_STATUS
  1510. SEC_ENTRY
  1511. SaslInitializeSecurityContextA(
  1512. PCredHandle phCredential, // Cred to base context
  1513. PCtxtHandle phContext, // Existing context (OPT)
  1514. LPSTR pszTargetName, // Name of target
  1515. unsigned long fContextReq, // Context Requirements
  1516. unsigned long Reserved1, // Reserved, MBZ
  1517. unsigned long TargetDataRep, // Data rep of target
  1518. PSecBufferDesc pInput, // Input Buffers
  1519. unsigned long Reserved2, // Reserved, MBZ
  1520. PCtxtHandle phNewContext, // (out) New Context handle
  1521. PSecBufferDesc pOutput, // (inout) Output Buffers
  1522. unsigned long SEC_FAR * pfContextAttr, // (out) Context attrs
  1523. PTimeStamp ptsExpiry // (out) Life span (OPT)
  1524. );
  1525. #ifdef UNICODE
  1526. #define SaslInitializeSecurityContext SaslInitializeSecurityContextW
  1527. #else
  1528. #define SaslInitializeSecurityContext SaslInitializeSecurityContextA
  1529. #endif
  1530. SECURITY_STATUS
  1531. SEC_ENTRY
  1532. SaslAcceptSecurityContext(
  1533. PCredHandle phCredential, // Cred to base context
  1534. PCtxtHandle phContext, // Existing context (OPT)
  1535. PSecBufferDesc pInput, // Input buffer
  1536. unsigned long fContextReq, // Context Requirements
  1537. unsigned long TargetDataRep, // Target Data Rep
  1538. PCtxtHandle phNewContext, // (out) New context handle
  1539. PSecBufferDesc pOutput, // (inout) Output buffers
  1540. unsigned long SEC_FAR * pfContextAttr, // (out) Context attributes
  1541. PTimeStamp ptsExpiry // (out) Life span (OPT)
  1542. );
  1543. #define SASL_OPTION_SEND_SIZE 1
  1544. #define SASL_OPTION_RECV_SIZE 2
  1545. #define SASL_OPTION_AUTHZ_STRING 3
  1546. SECURITY_STATUS
  1547. SEC_ENTRY
  1548. SaslSetContextOption(
  1549. PCtxtHandle ContextHandle,
  1550. ULONG Option,
  1551. PVOID Value,
  1552. ULONG Size
  1553. );
  1554. SECURITY_STATUS
  1555. SEC_ENTRY
  1556. SaslGetContextOption(
  1557. PCtxtHandle ContextHandle,
  1558. ULONG Option,
  1559. PVOID Value,
  1560. ULONG Size,
  1561. PULONG Needed OPTIONAL
  1562. );
  1563. #endif
  1564. #ifdef SECURITY_DOS
  1565. #if _MSC_VER >= 1200
  1566. #pragma warning(pop)
  1567. #else
  1568. #pragma warning(default:4147)
  1569. #endif
  1570. #endif
  1571. //
  1572. // This is the legacy credentials structure.
  1573. // The EX version below is preferred.
  1574. // begin_ntifs
  1575. #ifndef _AUTH_IDENTITY_DEFINED
  1576. #define _AUTH_IDENTITY_DEFINED
  1577. #define SEC_WINNT_AUTH_IDENTITY_ANSI 0x1
  1578. #define SEC_WINNT_AUTH_IDENTITY_UNICODE 0x2
  1579. typedef struct _SEC_WINNT_AUTH_IDENTITY_W {
  1580. unsigned short *User;
  1581. unsigned long UserLength;
  1582. unsigned short *Domain;
  1583. unsigned long DomainLength;
  1584. unsigned short *Password;
  1585. unsigned long PasswordLength;
  1586. unsigned long Flags;
  1587. } SEC_WINNT_AUTH_IDENTITY_W, *PSEC_WINNT_AUTH_IDENTITY_W;
  1588. // end_ntifs
  1589. typedef struct _SEC_WINNT_AUTH_IDENTITY_A {
  1590. unsigned char *User;
  1591. unsigned long UserLength;
  1592. unsigned char *Domain;
  1593. unsigned long DomainLength;
  1594. unsigned char *Password;
  1595. unsigned long PasswordLength;
  1596. unsigned long Flags;
  1597. } SEC_WINNT_AUTH_IDENTITY_A, *PSEC_WINNT_AUTH_IDENTITY_A;
  1598. #ifdef UNICODE
  1599. #define SEC_WINNT_AUTH_IDENTITY SEC_WINNT_AUTH_IDENTITY_W // ntifs
  1600. #define PSEC_WINNT_AUTH_IDENTITY PSEC_WINNT_AUTH_IDENTITY_W // ntifs
  1601. #define _SEC_WINNT_AUTH_IDENTITY _SEC_WINNT_AUTH_IDENTITY_W // ntifs
  1602. #else // UNICODE
  1603. #define SEC_WINNT_AUTH_IDENTITY SEC_WINNT_AUTH_IDENTITY_A
  1604. #define PSEC_WINNT_AUTH_IDENTITY PSEC_WINNT_AUTH_IDENTITY_A
  1605. #define _SEC_WINNT_AUTH_IDENTITY _SEC_WINNT_AUTH_IDENTITY_A
  1606. #endif // UNICODE
  1607. #endif //_AUTH_IDENTITY_DEFINED // ntifs
  1608. // begin_ntifs
  1609. //
  1610. // This is the combined authentication identity structure that may be
  1611. // used with the negotiate package, NTLM, Kerberos, or SCHANNEL
  1612. //
  1613. #ifndef SEC_WINNT_AUTH_IDENTITY_VERSION
  1614. #define SEC_WINNT_AUTH_IDENTITY_VERSION 0x200
  1615. typedef struct _SEC_WINNT_AUTH_IDENTITY_EXW {
  1616. unsigned long Version;
  1617. unsigned long Length;
  1618. unsigned short SEC_FAR *User;
  1619. unsigned long UserLength;
  1620. unsigned short SEC_FAR *Domain;
  1621. unsigned long DomainLength;
  1622. unsigned short SEC_FAR *Password;
  1623. unsigned long PasswordLength;
  1624. unsigned long Flags;
  1625. unsigned short SEC_FAR * PackageList;
  1626. unsigned long PackageListLength;
  1627. } SEC_WINNT_AUTH_IDENTITY_EXW, *PSEC_WINNT_AUTH_IDENTITY_EXW;
  1628. // end_ntifs
  1629. typedef struct _SEC_WINNT_AUTH_IDENTITY_EXA {
  1630. unsigned long Version;
  1631. unsigned long Length;
  1632. unsigned char SEC_FAR *User;
  1633. unsigned long UserLength;
  1634. unsigned char SEC_FAR *Domain;
  1635. unsigned long DomainLength;
  1636. unsigned char SEC_FAR *Password;
  1637. unsigned long PasswordLength;
  1638. unsigned long Flags;
  1639. unsigned char SEC_FAR * PackageList;
  1640. unsigned long PackageListLength;
  1641. } SEC_WINNT_AUTH_IDENTITY_EXA, *PSEC_WINNT_AUTH_IDENTITY_EXA;
  1642. #ifdef UNICODE
  1643. #define SEC_WINNT_AUTH_IDENTITY_EX SEC_WINNT_AUTH_IDENTITY_EXW // ntifs
  1644. #define PSEC_WINNT_AUTH_IDENTITY_EX PSEC_WINNT_AUTH_IDENTITY_EXW // ntifs
  1645. #else
  1646. #define SEC_WINNT_AUTH_IDENTITY_EX SEC_WINNT_AUTH_IDENTITY_EXA
  1647. #endif
  1648. // begin_ntifs
  1649. #endif // SEC_WINNT_AUTH_IDENTITY_VERSION
  1650. //
  1651. // Common types used by negotiable security packages
  1652. //
  1653. #define SEC_WINNT_AUTH_IDENTITY_MARSHALLED 0x4 // all data is in one buffer
  1654. #define SEC_WINNT_AUTH_IDENTITY_ONLY 0x8 // these credentials are for identity only - no PAC needed
  1655. // end_ntifs
  1656. //
  1657. // Routines for manipulating packages
  1658. //
  1659. typedef struct _SECURITY_PACKAGE_OPTIONS {
  1660. unsigned long Size;
  1661. unsigned long Type;
  1662. unsigned long Flags;
  1663. unsigned long SignatureSize;
  1664. void SEC_FAR * Signature;
  1665. } SECURITY_PACKAGE_OPTIONS, SEC_FAR * PSECURITY_PACKAGE_OPTIONS;
  1666. #define SECPKG_OPTIONS_TYPE_UNKNOWN 0
  1667. #define SECPKG_OPTIONS_TYPE_LSA 1
  1668. #define SECPKG_OPTIONS_TYPE_SSPI 2
  1669. #define SECPKG_OPTIONS_PERMANENT 0x00000001
  1670. SECURITY_STATUS
  1671. SEC_ENTRY
  1672. AddSecurityPackageA(
  1673. SEC_CHAR SEC_FAR * pszPackageName,
  1674. SECURITY_PACKAGE_OPTIONS SEC_FAR * Options
  1675. );
  1676. SECURITY_STATUS
  1677. SEC_ENTRY
  1678. AddSecurityPackageW(
  1679. SEC_WCHAR SEC_FAR * pszPackageName,
  1680. SECURITY_PACKAGE_OPTIONS SEC_FAR * Options
  1681. );
  1682. #ifdef UNICODE
  1683. #define AddSecurityPackage AddSecurityPackageW
  1684. #else
  1685. #define AddSecurityPackage AddSecurityPackageA
  1686. #endif
  1687. SECURITY_STATUS
  1688. SEC_ENTRY
  1689. DeleteSecurityPackageA(
  1690. SEC_CHAR SEC_FAR * pszPackageName );
  1691. SECURITY_STATUS
  1692. SEC_ENTRY
  1693. DeleteSecurityPackageW(
  1694. SEC_WCHAR SEC_FAR * pszPackageName );
  1695. #ifdef UNICODE
  1696. #define DeleteSecurityPackage DeleteSecurityPackageW
  1697. #else
  1698. #define DeleteSecurityPackage DeleteSecurityPackageA
  1699. #endif
  1700. #ifdef __cplusplus
  1701. } // extern "C"
  1702. #endif
  1703. // begin_ntifs
  1704. #endif // __SSPI_H__
  1705. // end_ntifs