winapi_ui_automation/shared/
sspi.rs

1// Licensed under the Apache License, Version 2.0
2// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4// All files in the project carrying such notice may not be copied, modified, or distributed
5// except according to those terms.
6//! Security Support Provider Interface Prototypes and structure definitions
7use ctypes::{c_char, c_int, c_uchar, c_ulong, c_ushort, c_void};
8use shared::basetsd::ULONG_PTR;
9use shared::guiddef::GUID;
10use shared::minwindef::{PUCHAR, ULONG, USHORT};
11use um::subauth::PUNICODE_STRING;
12use um::wincred::{PCREDUI_INFOA, PCREDUI_INFOW};
13use um::winnt::{
14    ANYSIZE_ARRAY, BOOLEAN, CHAR, HANDLE, LARGE_INTEGER, LONG, LPSTR, LPWSTR, LUID, PCSTR, PCWSTR,
15    PVOID, WCHAR
16};
17pub type SEC_WCHAR = WCHAR;
18pub type SEC_CHAR = CHAR;
19pub type SECURITY_STATUS = LONG;
20STRUCT!{struct SecHandle {
21    dwLower: ULONG_PTR,
22    dwUpper: ULONG_PTR,
23}}
24pub type PSecHandle = *mut SecHandle;
25pub const SEC_DELETED_HANDLE: ULONG_PTR = 2;
26pub type CredHandle = SecHandle;
27pub type PCredHandle = PSecHandle;
28pub type CtxtHandle = SecHandle;
29pub type PCtxtHandle = PSecHandle;
30pub type SECURITY_INTEGER = LARGE_INTEGER;
31pub type PSECURITY_INTEGER = *mut LARGE_INTEGER;
32pub type TimeStamp = SECURITY_INTEGER;
33pub type PTimeStamp = *mut SECURITY_INTEGER;
34STRUCT!{struct SECURITY_STRING {
35    Length: c_ushort,
36    MaximumLength: c_ushort,
37    Buffer: *mut c_ushort,
38}}
39pub type PSECURITY_STRING = *mut SECURITY_STRING;
40STRUCT!{struct SecPkgInfoW {
41    fCapabilities: c_ulong,
42    wVersion: c_ushort,
43    wRPCID: c_ushort,
44    cbMaxToken: c_ulong,
45    Name: *mut SEC_WCHAR,
46    Comment: *mut SEC_WCHAR,
47}}
48pub type PSecPkgInfoW = *mut SecPkgInfoW;
49STRUCT!{struct SecPkgInfoA {
50    fCapabilities: c_ulong,
51    wVersion: c_ushort,
52    wRPCID: c_ushort,
53    cbMaxToken: c_ulong,
54    Name: *mut SEC_CHAR,
55    Comment: *mut SEC_CHAR,
56}}
57pub type PSecPkgInfoA = *mut SecPkgInfoA;
58pub const SECPKG_FLAG_INTEGRITY: c_ulong = 0x00000001;
59pub const SECPKG_FLAG_PRIVACY: c_ulong = 0x00000002;
60pub const SECPKG_FLAG_TOKEN_ONLY: c_ulong = 0x00000004;
61pub const SECPKG_FLAG_DATAGRAM: c_ulong = 0x00000008;
62pub const SECPKG_FLAG_CONNECTION: c_ulong = 0x00000010;
63pub const SECPKG_FLAG_MULTI_REQUIRED: c_ulong = 0x00000020;
64pub const SECPKG_FLAG_CLIENT_ONLY: c_ulong = 0x00000040;
65pub const SECPKG_FLAG_EXTENDED_ERROR: c_ulong = 0x00000080;
66pub const SECPKG_FLAG_IMPERSONATION: c_ulong = 0x00000100;
67pub const SECPKG_FLAG_ACCEPT_WIN32_NAME: c_ulong = 0x00000200;
68pub const SECPKG_FLAG_STREAM: c_ulong = 0x00000400;
69pub const SECPKG_FLAG_NEGOTIABLE: c_ulong = 0x00000800;
70pub const SECPKG_FLAG_GSS_COMPATIBLE: c_ulong = 0x00001000;
71pub const SECPKG_FLAG_LOGON: c_ulong = 0x00002000;
72pub const SECPKG_FLAG_ASCII_BUFFERS: c_ulong = 0x00004000;
73pub const SECPKG_FLAG_FRAGMENT: c_ulong = 0x00008000;
74pub const SECPKG_FLAG_MUTUAL_AUTH: c_ulong = 0x00010000;
75pub const SECPKG_FLAG_DELEGATION: c_ulong = 0x00020000;
76pub const SECPKG_FLAG_READONLY_WITH_CHECKSUM: c_ulong = 0x00040000;
77pub const SECPKG_FLAG_RESTRICTED_TOKENS: c_ulong = 0x00080000;
78pub const SECPKG_FLAG_NEGO_EXTENDER: c_ulong = 0x00100000;
79pub const SECPKG_FLAG_NEGOTIABLE2: c_ulong = 0x00200000;
80pub const SECPKG_FLAG_APPCONTAINER_PASSTHROUGH: c_ulong = 0x00400000;
81pub const SECPKG_FLAG_APPCONTAINER_CHECKS: c_ulong = 0x00800000;
82pub const SECPKG_ID_NONE: c_ulong = 0xFFFF;
83pub const SECPKG_CALLFLAGS_APPCONTAINER: c_ulong = 0x00000001;
84pub const SECPKG_CALLFLAGS_APPCONTAINER_AUTHCAPABLE: c_ulong = 0x00000002;
85pub const SECPKG_CALLFLAGS_FORCE_SUPPLIED: c_ulong = 0x00000004;
86STRUCT!{struct SecBuffer {
87    cbBuffer: c_ulong,
88    BufferType: c_ulong,
89    pvBuffer: *mut c_void,
90}}
91pub type PSecBuffer = *mut SecBuffer;
92STRUCT!{struct SecBufferDesc {
93    ulVersion: c_ulong,
94    cBuffers: c_ulong,
95    pBuffers: PSecBuffer,
96}}
97pub type PSecBufferDesc = *mut SecBufferDesc;
98pub const SECBUFFER_VERSION: c_ulong = 0;
99pub const SECBUFFER_EMPTY: c_ulong = 0;
100pub const SECBUFFER_DATA: c_ulong = 1;
101pub const SECBUFFER_TOKEN: c_ulong = 2;
102pub const SECBUFFER_PKG_PARAMS: c_ulong = 3;
103pub const SECBUFFER_MISSING: c_ulong = 4;
104pub const SECBUFFER_EXTRA: c_ulong = 5;
105pub const SECBUFFER_STREAM_TRAILER: c_ulong = 6;
106pub const SECBUFFER_STREAM_HEADER: c_ulong = 7;
107pub const SECBUFFER_NEGOTIATION_INFO: c_ulong = 8;
108pub const SECBUFFER_PADDING: c_ulong = 9;
109pub const SECBUFFER_STREAM: c_ulong = 10;
110pub const SECBUFFER_MECHLIST: c_ulong = 11;
111pub const SECBUFFER_MECHLIST_SIGNATURE: c_ulong = 12;
112pub const SECBUFFER_TARGET: c_ulong = 13;
113pub const SECBUFFER_CHANNEL_BINDINGS: c_ulong = 14;
114pub const SECBUFFER_CHANGE_PASS_RESPONSE: c_ulong = 15;
115pub const SECBUFFER_TARGET_HOST: c_ulong = 16;
116pub const SECBUFFER_ALERT: c_ulong = 17;
117pub const SECBUFFER_APPLICATION_PROTOCOLS: c_ulong = 18;
118pub const SECBUFFER_ATTRMASK: c_ulong = 0xF0000000;
119pub const SECBUFFER_READONLY: c_ulong = 0x80000000;
120pub const SECBUFFER_READONLY_WITH_CHECKSUM: c_ulong = 0x10000000;
121pub const SECBUFFER_RESERVED: c_ulong = 0x60000000;
122STRUCT!{struct SEC_NEGOTIATION_INFO {
123    Size: c_ulong,
124    NameLength: c_ulong,
125    Name: *mut SEC_WCHAR,
126    Reserved: *mut c_void,
127}}
128pub type PSEC_NEGOTIATION_INFO = *mut SEC_NEGOTIATION_INFO;
129STRUCT!{struct SEC_CHANNEL_BINDINGS {
130    dwInitiatorAddrType: c_ulong,
131    cbInitiatorLength: c_ulong,
132    dwInitiatorOffset: c_ulong,
133    dwAcceptorAddrType: c_ulong,
134    cbAcceptorLength: c_ulong,
135    dwAcceptorOffset: c_ulong,
136    cbApplicationDataLength: c_ulong,
137    dwApplicationDataOffset: c_ulong,
138}}
139pub type PSEC_CHANNEL_BINDINGS = *mut SEC_CHANNEL_BINDINGS;
140ENUM!{enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT {
141    SecApplicationProtocolNegotiationExt_None,
142    SecApplicationProtocolNegotiationExt_NPN,
143    SecApplicationProtocolNegotiationExt_ALPN,
144}}
145pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT = *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT;
146STRUCT!{struct SEC_APPLICATION_PROTOCOL_LIST {
147    ProtoNegoExt: SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT,
148    ProtocolListSize: c_ushort,
149    ProtocolList: [c_uchar; 0],
150}}
151pub type PSEC_APPLICATION_PROTOCOL_LIST = *mut SEC_APPLICATION_PROTOCOL_LIST;
152STRUCT!{struct SEC_APPLICATION_PROTOCOLS {
153    ProtocolListsSize: c_ulong,
154    ProtocolLists: [SEC_APPLICATION_PROTOCOL_LIST; ANYSIZE_ARRAY],
155}}
156pub type PSEC_APPLICATION_PROTOCOLS = *mut SEC_APPLICATION_PROTOCOLS;
157pub const SECURITY_NATIVE_DREP: c_ulong = 0x00000010;
158pub const SECURITY_NETWORK_DREP: c_ulong = 0x00000000;
159pub const SECPKG_CRED_INBOUND: c_ulong = 0x00000001;
160pub const SECPKG_CRED_OUTBOUND: c_ulong = 0x00000002;
161pub const SECPKG_CRED_BOTH: c_ulong = 0x00000003;
162pub const SECPKG_CRED_DEFAULT: c_ulong = 0x00000004;
163pub const SECPKG_CRED_RESERVED: c_ulong = 0xF0000000;
164pub const SECPKG_CRED_AUTOLOGON_RESTRICTED: c_ulong = 0x00000010;
165pub const SECPKG_CRED_PROCESS_POLICY_ONLY: c_ulong = 0x00000020;
166pub const ISC_REQ_DELEGATE: c_ulong = 0x00000001;
167pub const ISC_REQ_MUTUAL_AUTH: c_ulong = 0x00000002;
168pub const ISC_REQ_REPLAY_DETECT: c_ulong = 0x00000004;
169pub const ISC_REQ_SEQUENCE_DETECT: c_ulong = 0x00000008;
170pub const ISC_REQ_CONFIDENTIALITY: c_ulong = 0x00000010;
171pub const ISC_REQ_USE_SESSION_KEY: c_ulong = 0x00000020;
172pub const ISC_REQ_PROMPT_FOR_CREDS: c_ulong = 0x00000040;
173pub const ISC_REQ_USE_SUPPLIED_CREDS: c_ulong = 0x00000080;
174pub const ISC_REQ_ALLOCATE_MEMORY: c_ulong = 0x00000100;
175pub const ISC_REQ_USE_DCE_STYLE: c_ulong = 0x00000200;
176pub const ISC_REQ_DATAGRAM: c_ulong = 0x00000400;
177pub const ISC_REQ_CONNECTION: c_ulong = 0x00000800;
178pub const ISC_REQ_CALL_LEVEL: c_ulong = 0x00001000;
179pub const ISC_REQ_FRAGMENT_SUPPLIED: c_ulong = 0x00002000;
180pub const ISC_REQ_EXTENDED_ERROR: c_ulong = 0x00004000;
181pub const ISC_REQ_STREAM: c_ulong = 0x00008000;
182pub const ISC_REQ_INTEGRITY: c_ulong = 0x00010000;
183pub const ISC_REQ_IDENTIFY: c_ulong = 0x00020000;
184pub const ISC_REQ_NULL_SESSION: c_ulong = 0x00040000;
185pub const ISC_REQ_MANUAL_CRED_VALIDATION: c_ulong = 0x00080000;
186pub const ISC_REQ_RESERVED1: c_ulong = 0x00100000;
187pub const ISC_REQ_FRAGMENT_TO_FIT: c_ulong = 0x00200000;
188pub const ISC_REQ_FORWARD_CREDENTIALS: c_ulong = 0x00400000;
189pub const ISC_REQ_NO_INTEGRITY: c_ulong = 0x00800000;
190pub const ISC_REQ_USE_HTTP_STYLE: c_ulong = 0x01000000;
191pub const ISC_REQ_UNVERIFIED_TARGET_NAME: c_ulong = 0x20000000;
192pub const ISC_REQ_CONFIDENTIALITY_ONLY: c_ulong = 0x40000000;
193pub const ISC_RET_DELEGATE: c_ulong = 0x00000001;
194pub const ISC_RET_MUTUAL_AUTH: c_ulong = 0x00000002;
195pub const ISC_RET_REPLAY_DETECT: c_ulong = 0x00000004;
196pub const ISC_RET_SEQUENCE_DETECT: c_ulong = 0x00000008;
197pub const ISC_RET_CONFIDENTIALITY: c_ulong = 0x00000010;
198pub const ISC_RET_USE_SESSION_KEY: c_ulong = 0x00000020;
199pub const ISC_RET_USED_COLLECTED_CREDS: c_ulong = 0x00000040;
200pub const ISC_RET_USED_SUPPLIED_CREDS: c_ulong = 0x00000080;
201pub const ISC_RET_ALLOCATED_MEMORY: c_ulong = 0x00000100;
202pub const ISC_RET_USED_DCE_STYLE: c_ulong = 0x00000200;
203pub const ISC_RET_DATAGRAM: c_ulong = 0x00000400;
204pub const ISC_RET_CONNECTION: c_ulong = 0x00000800;
205pub const ISC_RET_INTERMEDIATE_RETURN: c_ulong = 0x00001000;
206pub const ISC_RET_CALL_LEVEL: c_ulong = 0x00002000;
207pub const ISC_RET_EXTENDED_ERROR: c_ulong = 0x00004000;
208pub const ISC_RET_STREAM: c_ulong = 0x00008000;
209pub const ISC_RET_INTEGRITY: c_ulong = 0x00010000;
210pub const ISC_RET_IDENTIFY: c_ulong = 0x00020000;
211pub const ISC_RET_NULL_SESSION: c_ulong = 0x00040000;
212pub const ISC_RET_MANUAL_CRED_VALIDATION: c_ulong = 0x00080000;
213pub const ISC_RET_RESERVED1: c_ulong = 0x00100000;
214pub const ISC_RET_FRAGMENT_ONLY: c_ulong = 0x00200000;
215pub const ISC_RET_FORWARD_CREDENTIALS: c_ulong = 0x00400000;
216pub const ISC_RET_USED_HTTP_STYLE: c_ulong = 0x01000000;
217pub const ISC_RET_NO_ADDITIONAL_TOKEN: c_ulong = 0x02000000;
218pub const ISC_RET_REAUTHENTICATION: c_ulong = 0x08000000;
219pub const ISC_RET_CONFIDENTIALITY_ONLY: c_ulong = 0x40000000;
220pub const ASC_REQ_DELEGATE: c_ulong = 0x00000001;
221pub const ASC_REQ_MUTUAL_AUTH: c_ulong = 0x00000002;
222pub const ASC_REQ_REPLAY_DETECT: c_ulong = 0x00000004;
223pub const ASC_REQ_SEQUENCE_DETECT: c_ulong = 0x00000008;
224pub const ASC_REQ_CONFIDENTIALITY: c_ulong = 0x00000010;
225pub const ASC_REQ_USE_SESSION_KEY: c_ulong = 0x00000020;
226pub const ASC_REQ_SESSION_TICKET: c_ulong = 0x00000040;
227pub const ASC_REQ_ALLOCATE_MEMORY: c_ulong = 0x00000100;
228pub const ASC_REQ_USE_DCE_STYLE: c_ulong = 0x00000200;
229pub const ASC_REQ_DATAGRAM: c_ulong = 0x00000400;
230pub const ASC_REQ_CONNECTION: c_ulong = 0x00000800;
231pub const ASC_REQ_CALL_LEVEL: c_ulong = 0x00001000;
232pub const ASC_REQ_EXTENDED_ERROR: c_ulong = 0x00008000;
233pub const ASC_REQ_STREAM: c_ulong = 0x00010000;
234pub const ASC_REQ_INTEGRITY: c_ulong = 0x00020000;
235pub const ASC_REQ_LICENSING: c_ulong = 0x00040000;
236pub const ASC_REQ_IDENTIFY: c_ulong = 0x00080000;
237pub const ASC_REQ_ALLOW_NULL_SESSION: c_ulong = 0x00100000;
238pub const ASC_REQ_ALLOW_NON_USER_LOGONS: c_ulong = 0x00200000;
239pub const ASC_REQ_ALLOW_CONTEXT_REPLAY: c_ulong = 0x00400000;
240pub const ASC_REQ_FRAGMENT_TO_FIT: c_ulong = 0x00800000;
241pub const ASC_REQ_FRAGMENT_SUPPLIED: c_ulong = 0x00002000;
242pub const ASC_REQ_NO_TOKEN: c_ulong = 0x01000000;
243pub const ASC_REQ_PROXY_BINDINGS: c_ulong = 0x04000000;
244pub const ASC_REQ_ALLOW_MISSING_BINDINGS: c_ulong = 0x10000000;
245pub const ASC_RET_DELEGATE: c_ulong = 0x00000001;
246pub const ASC_RET_MUTUAL_AUTH: c_ulong = 0x00000002;
247pub const ASC_RET_REPLAY_DETECT: c_ulong = 0x00000004;
248pub const ASC_RET_SEQUENCE_DETECT: c_ulong = 0x00000008;
249pub const ASC_RET_CONFIDENTIALITY: c_ulong = 0x00000010;
250pub const ASC_RET_USE_SESSION_KEY: c_ulong = 0x00000020;
251pub const ASC_RET_SESSION_TICKET: c_ulong = 0x00000040;
252pub const ASC_RET_ALLOCATED_MEMORY: c_ulong = 0x00000100;
253pub const ASC_RET_USED_DCE_STYLE: c_ulong = 0x00000200;
254pub const ASC_RET_DATAGRAM: c_ulong = 0x00000400;
255pub const ASC_RET_CONNECTION: c_ulong = 0x00000800;
256pub const ASC_RET_CALL_LEVEL: c_ulong = 0x00002000;
257pub const ASC_RET_THIRD_LEG_FAILED: c_ulong = 0x00004000;
258pub const ASC_RET_EXTENDED_ERROR: c_ulong = 0x00008000;
259pub const ASC_RET_STREAM: c_ulong = 0x00010000;
260pub const ASC_RET_INTEGRITY: c_ulong = 0x00020000;
261pub const ASC_RET_LICENSING: c_ulong = 0x00040000;
262pub const ASC_RET_IDENTIFY: c_ulong = 0x00080000;
263pub const ASC_RET_NULL_SESSION: c_ulong = 0x00100000;
264pub const ASC_RET_ALLOW_NON_USER_LOGONS: c_ulong = 0x00200000;
265pub const ASC_RET_ALLOW_CONTEXT_REPLAY: c_ulong = 0x00400000;
266pub const ASC_RET_FRAGMENT_ONLY: c_ulong = 0x00800000;
267pub const ASC_RET_NO_TOKEN: c_ulong = 0x01000000;
268pub const ASC_RET_NO_ADDITIONAL_TOKEN: c_ulong = 0x02000000;
269pub const SECPKG_CRED_ATTR_NAMES: c_ulong = 1;
270pub const SECPKG_CRED_ATTR_SSI_PROVIDER: c_ulong = 2;
271pub const SECPKG_CRED_ATTR_KDC_PROXY_SETTINGS: c_ulong = 3;
272pub const SECPKG_CRED_ATTR_CERT: c_ulong = 4;
273STRUCT!{struct SecPkgCredentials_NamesW {
274    sUserName: *mut SEC_WCHAR,
275}}
276pub type PSecPkgCredentials_NamesW = *mut SecPkgCredentials_NamesW;
277STRUCT!{struct SecPkgCredentials_NamesA {
278    sUserName: *mut SEC_CHAR,
279}}
280pub type PSecPkgCredentials_NamesA = *mut SecPkgCredentials_NamesA;
281STRUCT!{struct SecPkgCredentials_SSIProviderW {
282    sProviderName: *mut SEC_WCHAR,
283    ProviderInfoLength: c_ulong,
284    ProviderInfo: *mut c_char,
285}}
286pub type PSecPkgCredentials_SSIProviderW = *mut SecPkgCredentials_SSIProviderW;
287STRUCT!{struct SecPkgCredentials_SSIProviderA {
288    sProviderName: *mut SEC_CHAR,
289    ProviderInfoLength: c_ulong,
290    ProviderInfo: *mut c_char,
291}}
292pub type PSecPkgCredentials_SSIProviderA = *mut SecPkgCredentials_SSIProviderA;
293pub const KDC_PROXY_SETTINGS_V1: ULONG = 1;
294pub const KDC_PROXY_SETTINGS_FLAGS_FORCEPROXY: ULONG = 0x1;
295STRUCT!{struct SecPkgCredentials_KdcProxySettingsW {
296    Version: ULONG,
297    Flags: ULONG,
298    ProxyServerOffset: USHORT,
299    ProxyServerLength: USHORT,
300    ClientTlsCredOffset: USHORT,
301    ClientTlsCredLength: USHORT,
302}}
303pub type PSecPkgCredentials_KdcProxySettingsW = *mut SecPkgCredentials_KdcProxySettingsW;
304STRUCT!{struct SecPkgCredentials_Cert {
305    EncodedCertSize: c_ulong,
306    EncodedCert: *mut c_uchar,
307}}
308pub type PSecPkgCredentials_Cert = *mut SecPkgCredentials_Cert;
309pub const SECPKG_ATTR_SIZES: c_ulong = 0;
310pub const SECPKG_ATTR_NAMES: c_ulong = 1;
311pub const SECPKG_ATTR_LIFESPAN: c_ulong = 2;
312pub const SECPKG_ATTR_DCE_INFO: c_ulong = 3;
313pub const SECPKG_ATTR_STREAM_SIZES: c_ulong = 4;
314pub const SECPKG_ATTR_KEY_INFO: c_ulong = 5;
315pub const SECPKG_ATTR_AUTHORITY: c_ulong = 6;
316pub const SECPKG_ATTR_PROTO_INFO: c_ulong = 7;
317pub const SECPKG_ATTR_PASSWORD_EXPIRY: c_ulong = 8;
318pub const SECPKG_ATTR_SESSION_KEY: c_ulong = 9;
319pub const SECPKG_ATTR_PACKAGE_INFO: c_ulong = 10;
320pub const SECPKG_ATTR_USER_FLAGS: c_ulong = 11;
321pub const SECPKG_ATTR_NEGOTIATION_INFO: c_ulong = 12;
322pub const SECPKG_ATTR_NATIVE_NAMES: c_ulong = 13;
323pub const SECPKG_ATTR_FLAGS: c_ulong = 14;
324pub const SECPKG_ATTR_USE_VALIDATED: c_ulong = 15;
325pub const SECPKG_ATTR_CREDENTIAL_NAME: c_ulong = 16;
326pub const SECPKG_ATTR_TARGET_INFORMATION: c_ulong = 17;
327pub const SECPKG_ATTR_ACCESS_TOKEN: c_ulong = 18;
328pub const SECPKG_ATTR_TARGET: c_ulong = 19;
329pub const SECPKG_ATTR_AUTHENTICATION_ID: c_ulong = 20;
330pub const SECPKG_ATTR_LOGOFF_TIME: c_ulong = 21;
331pub const SECPKG_ATTR_NEGO_KEYS: c_ulong = 22;
332pub const SECPKG_ATTR_PROMPTING_NEEDED: c_ulong = 24;
333pub const SECPKG_ATTR_UNIQUE_BINDINGS: c_ulong = 25;
334pub const SECPKG_ATTR_ENDPOINT_BINDINGS: c_ulong = 26;
335pub const SECPKG_ATTR_CLIENT_SPECIFIED_TARGET: c_ulong = 27;
336pub const SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS: c_ulong = 30;
337pub const SECPKG_ATTR_NEGO_PKG_INFO: c_ulong = 31;
338pub const SECPKG_ATTR_NEGO_STATUS: c_ulong = 32;
339pub const SECPKG_ATTR_CONTEXT_DELETED: c_ulong = 33;
340pub const SECPKG_ATTR_DTLS_MTU: c_ulong = 34;
341pub const SECPKG_ATTR_DATAGRAM_SIZES: c_ulong = SECPKG_ATTR_STREAM_SIZES;
342pub const SECPKG_ATTR_SUBJECT_SECURITY_ATTRIBUTES: c_ulong = 128;
343pub const SECPKG_ATTR_APPLICATION_PROTOCOL: c_ulong = 35;
344STRUCT!{struct SecPkgContext_SubjectAttributes {
345    AttributeInfo: *mut c_void,
346}}
347pub type PSecPkgContext_SubjectAttributes = *mut SecPkgContext_SubjectAttributes;
348pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_KERBEROS: c_ulong = 0x1;
349pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_NTLM: c_ulong = 0x2;
350ENUM!{enum SECPKG_CRED_CLASS {
351    SecPkgCredClass_None = 0,
352    SecPkgCredClass_Ephemeral = 10,
353    SecPkgCredClass_PersistedGeneric = 20,
354    SecPkgCredClass_PersistedSpecific = 30,
355    SecPkgCredClass_Explicit = 40,
356}}
357pub type PSECPKG_CRED_CLASS = *mut SECPKG_CRED_CLASS;
358STRUCT!{struct SecPkgContext_CredInfo {
359    CredClass: SECPKG_CRED_CLASS,
360    IsPromptingNeeded: c_ulong,
361}}
362pub type PSecPkgContext_CredInfo = *mut SecPkgContext_CredInfo;
363STRUCT!{struct SecPkgContext_NegoPackageInfo {
364    PackageMask: c_ulong,
365}}
366pub type PSecPkgContext_NegoPackageInfo = *mut SecPkgContext_NegoPackageInfo;
367STRUCT!{struct SecPkgContext_NegoStatus {
368    LastStatus: c_ulong,
369}}
370pub type PSecPkgContext_NegoStatus = *mut SecPkgContext_NegoStatus;
371STRUCT!{struct SecPkgContext_Sizes {
372    cbMaxToken: c_ulong,
373    cbMaxSignature: c_ulong,
374    cbBlockSize: c_ulong,
375    cbSecurityTrailer: c_ulong,
376}}
377pub type PSecPkgContext_Sizes = *mut SecPkgContext_Sizes;
378STRUCT!{struct SecPkgContext_StreamSizes {
379    cbHeader: c_ulong,
380    cbTrailer: c_ulong,
381    cbMaximumMessage: c_ulong,
382    cBuffers: c_ulong,
383    cbBlockSize: c_ulong,
384}}
385pub type PSecPkgContext_StreamSizes = *mut SecPkgContext_StreamSizes;
386pub type SecPkgContext_DatagramSizes = SecPkgContext_StreamSizes;
387pub type PSecPkgContext_DatagramSizes = PSecPkgContext_StreamSizes;
388STRUCT!{struct SecPkgContext_NamesW {
389    sUserName: *mut SEC_WCHAR,
390}}
391pub type PSecPkgContext_NamesW = *mut SecPkgContext_NamesW;
392ENUM!{enum SECPKG_ATTR_LCT_STATUS {
393    SecPkgAttrLastClientTokenYes,
394    SecPkgAttrLastClientTokenNo,
395    SecPkgAttrLastClientTokenMaybe,
396}}
397pub type PSECPKG_ATTR_LCT_STATUS = *mut SECPKG_ATTR_LCT_STATUS;
398STRUCT!{struct SecPkgContext_LastClientTokenStatus {
399    LastClientTokenStatus: SECPKG_ATTR_LCT_STATUS,
400}}
401pub type PSecPkgContext_LastClientTokenStatus = *mut SecPkgContext_LastClientTokenStatus;
402STRUCT!{struct SecPkgContext_NamesA {
403    sUserName: *mut SEC_CHAR,
404}}
405pub type PSecPkgContext_NamesA = *mut SecPkgContext_NamesA;
406STRUCT!{struct SecPkgContext_Lifespan {
407    tsStart: TimeStamp,
408    tsExpiry: TimeStamp,
409}}
410pub type PSecPkgContext_Lifespan = *mut SecPkgContext_Lifespan;
411STRUCT!{struct SecPkgContext_DceInfo {
412    AuthzSvc: c_ulong,
413    pPac: *mut c_void,
414}}
415pub type PSecPkgContext_DceInfo = *mut SecPkgContext_DceInfo;
416STRUCT!{struct SecPkgContext_KeyInfoA {
417    sSignatureAlgorithmName: *mut SEC_CHAR,
418    sEncryptAlgorithmName: *mut SEC_CHAR,
419    KeySize: c_ulong,
420    SignatureAlgorithm: c_ulong,
421    EncryptAlgorithm: c_ulong,
422}}
423pub type PSecPkgContext_KeyInfoA = *mut SecPkgContext_KeyInfoA;
424STRUCT!{struct SecPkgContext_KeyInfoW {
425    sSignatureAlgorithmName: *mut SEC_WCHAR,
426    sEncryptAlgorithmName: *mut SEC_WCHAR,
427    KeySize: c_ulong,
428    SignatureAlgorithm: c_ulong,
429    EncryptAlgorithm: c_ulong,
430}}
431pub type PSecPkgContext_KeyInfoW = *mut SecPkgContext_KeyInfoW;
432STRUCT!{struct SecPkgContext_AuthorityA {
433    sAuthorityName: *mut SEC_CHAR,
434}}
435pub type PSecPkgContext_AuthorityA = *mut SecPkgContext_AuthorityA;
436STRUCT!{struct SecPkgContext_AuthorityW {
437    sAuthorityName: *mut SEC_WCHAR,
438}}
439pub type PSecPkgContext_AuthorityW = *mut SecPkgContext_AuthorityW;
440STRUCT!{struct SecPkgContext_ProtoInfoA {
441    sProtocolName: *mut SEC_CHAR,
442    majorVersion: c_ulong,
443    minorVersion: c_ulong,
444}}
445pub type PSecPkgContext_ProtoInfoA = *mut SecPkgContext_ProtoInfoA;
446STRUCT!{struct SecPkgContext_ProtoInfoW {
447    sProtocolName: *mut SEC_WCHAR,
448    majorVersion: c_ulong,
449    minorVersion: c_ulong,
450}}
451pub type PSecPkgContext_ProtoInfoW = *mut SecPkgContext_ProtoInfoW;
452STRUCT!{struct SecPkgContext_PasswordExpiry {
453    tsPasswordExpires: TimeStamp,
454}}
455pub type PSecPkgContext_PasswordExpiry = *mut SecPkgContext_PasswordExpiry;
456STRUCT!{struct SecPkgContext_LogoffTime {
457    tsLogoffTime: TimeStamp,
458}}
459pub type PSecPkgContext_LogoffTime = *mut SecPkgContext_LogoffTime;
460STRUCT!{struct SecPkgContext_SessionKey {
461    SessionKeyLength: c_ulong,
462    SessionKey: *mut c_uchar,
463}}
464pub type PSecPkgContext_SessionKey = *mut SecPkgContext_SessionKey;
465STRUCT!{struct SecPkgContext_NegoKeys {
466    KeyType: c_ulong,
467    KeyLength: c_ushort,
468    KeyValue: *mut c_uchar,
469    VerifyKeyType: c_ulong,
470    VerifyKeyLength: c_ushort,
471    VerifyKeyValue: *mut c_uchar,
472}}
473pub type PSecPkgContext_NegoKeys = *mut SecPkgContext_NegoKeys;
474STRUCT!{struct SecPkgContext_PackageInfoW {
475    PackageInfo: PSecPkgInfoW,
476}}
477pub type PSecPkgContext_PackageInfoW = *mut SecPkgContext_PackageInfoW;
478STRUCT!{struct SecPkgContext_PackageInfoA {
479    PackageInfo: PSecPkgInfoA,
480}}
481pub type PSecPkgContext_PackageInfoA = *mut SecPkgContext_PackageInfoA;
482STRUCT!{struct SecPkgContext_UserFlags {
483    UserFlags: c_ulong,
484}}
485pub type PSecPkgContext_UserFlags = *mut SecPkgContext_UserFlags;
486STRUCT!{struct SecPkgContext_Flags {
487    Flags: c_ulong,
488}}
489pub type PSecPkgContext_Flags = *mut SecPkgContext_Flags;
490STRUCT!{struct SecPkgContext_NegotiationInfoA {
491    PackageInfo: PSecPkgInfoA,
492    NegotiationState: c_ulong,
493}}
494pub type PSecPkgContext_NegotiationInfoA = *mut SecPkgContext_NegotiationInfoA;
495STRUCT!{struct SecPkgContext_NegotiationInfoW {
496    PackageInfo: PSecPkgInfoW,
497    NegotiationState: c_ulong,
498}}
499pub type PSecPkgContext_NegotiationInfoW = *mut SecPkgContext_NegotiationInfoW;
500pub const SECPKG_NEGOTIATION_COMPLETE: c_ulong = 0;
501pub const SECPKG_NEGOTIATION_OPTIMISTIC: c_ulong = 1;
502pub const SECPKG_NEGOTIATION_IN_PROGRESS: c_ulong = 2;
503pub const SECPKG_NEGOTIATION_DIRECT: c_ulong = 3;
504pub const SECPKG_NEGOTIATION_TRY_MULTICRED: c_ulong = 4;
505STRUCT!{struct SecPkgContext_NativeNamesW {
506    sClientName: *mut SEC_WCHAR,
507    sServerName: *mut SEC_WCHAR,
508}}
509pub type PSecPkgContext_NativeNamesW = *mut SecPkgContext_NativeNamesW;
510STRUCT!{struct SecPkgContext_NativeNamesA {
511    sClientName: *mut SEC_CHAR,
512    sServerName: *mut SEC_CHAR,
513}}
514pub type PSecPkgContext_NativeNamesA = *mut SecPkgContext_NativeNamesA;
515STRUCT!{struct SecPkgContext_CredentialNameW {
516    CredentialType: c_ulong,
517    sCredentialName: *mut SEC_WCHAR,
518}}
519pub type PSecPkgContext_CredentialNameW = *mut SecPkgContext_CredentialNameW;
520STRUCT!{struct SecPkgContext_CredentialNameA {
521    CredentialType: c_ulong,
522    sCredentialName: *mut SEC_CHAR,
523}}
524pub type PSecPkgContext_CredentialNameA = *mut SecPkgContext_CredentialNameA;
525STRUCT!{struct SecPkgContext_AccessToken {
526    AccessToken: *mut c_void,
527}}
528pub type PSecPkgContext_AccessToken = *mut SecPkgContext_AccessToken;
529STRUCT!{struct SecPkgContext_TargetInformation {
530    MarshalledTargetInfoLength: c_ulong,
531    MarshalledTargetInfo: *mut c_uchar,
532}}
533pub type PSecPkgContext_TargetInformation = *mut SecPkgContext_TargetInformation;
534STRUCT!{struct SecPkgContext_AuthzID {
535    AuthzIDLength: c_ulong,
536    AuthzID: *mut c_char,
537}}
538pub type PSecPkgContext_AuthzID = *mut SecPkgContext_AuthzID;
539STRUCT!{struct SecPkgContext_Target {
540    TargetLength: c_ulong,
541    Target: *mut c_char,
542}}
543pub type PSecPkgContext_Target = *mut SecPkgContext_Target;
544STRUCT!{struct SecPkgContext_ClientSpecifiedTarget {
545    sTargetName: *mut SEC_WCHAR,
546}}
547pub type PSecPkgContext_ClientSpecifiedTarget = *mut SecPkgContext_ClientSpecifiedTarget;
548STRUCT!{struct SecPkgContext_Bindings {
549    BindingsLength: c_ulong,
550    Bindings: *mut SEC_CHANNEL_BINDINGS,
551}}
552pub type PSecPkgContext_Bindings = *mut SecPkgContext_Bindings;
553ENUM!{enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS {
554    SecApplicationProtocolNegotiationStatus_None,
555    SecApplicationProtocolNegotiationStatus_Success,
556    SecApplicationProtocolNegotiationStatus_SelectedClientOnly,
557}}
558pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS =
559    *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS;
560pub const MAX_PROTOCOL_ID_SIZE: usize = 0xff;
561STRUCT!{struct SecPkgContext_ApplicationProtocol {
562    ProtoNegoStatus: SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS,
563    ProtoNegoExt: SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT,
564    ProtocolIdSize: c_uchar,
565    ProtocolId: [c_uchar; MAX_PROTOCOL_ID_SIZE],
566}}
567pub type PSecPkgContext_ApplicationProtocol = *mut SecPkgContext_ApplicationProtocol;
568FN!{stdcall SEC_GET_KEY_FN(
569    Arg: *mut c_void,
570    Principal: *mut c_void,
571    KeyVer: c_ulong,
572    Key: *mut *mut c_void,
573    Status: *mut SECURITY_STATUS,
574) -> ()}
575pub const SECPKG_CONTEXT_EXPORT_RESET_NEW: c_ulong = 0x00000001;
576pub const SECPKG_CONTEXT_EXPORT_DELETE_OLD: c_ulong = 0x00000002;
577pub const SECPKG_CONTEXT_EXPORT_TO_KERNEL: c_ulong = 0x00000004;
578extern "system" {
579    pub fn AcquireCredentialsHandleW(
580        pszPrincipal: LPWSTR,
581        pszPackage: LPWSTR,
582        fCredentialUse: c_ulong,
583        pvLogonId: *mut c_void,
584        pAuthData: *mut c_void,
585        pGetKeyFn: SEC_GET_KEY_FN,
586        pvGetKeyArgument: *mut c_void,
587        phCredential: PCredHandle,
588        ptsExpiry: PTimeStamp,
589    ) -> SECURITY_STATUS;
590}
591FN!{stdcall ACQUIRE_CREDENTIALS_HANDLE_FN_W(
592    *mut SEC_WCHAR,
593    *mut SEC_WCHAR,
594    c_ulong,
595    *mut c_void,
596    *mut c_void,
597    SEC_GET_KEY_FN,
598    *mut c_void,
599    PCredHandle,
600    PTimeStamp,
601) -> SECURITY_STATUS}
602extern "system" {
603    pub fn AcquireCredentialsHandleA(
604        pszPrincipal: LPSTR,
605        pszPackage: LPSTR,
606        fCredentialUse: c_ulong,
607        pvLogonId: *mut c_void,
608        pAuthData: *mut c_void,
609        pGetKeyFn: SEC_GET_KEY_FN,
610        pvGetKeyArgument: *mut c_void,
611        phCredential: PCredHandle,
612        ptsExpiry: PTimeStamp,
613    ) -> SECURITY_STATUS;
614}
615FN!{stdcall ACQUIRE_CREDENTIALS_HANDLE_FN_A(
616    *mut SEC_CHAR,
617    *mut SEC_CHAR,
618    c_ulong,
619    *mut c_void,
620    *mut c_void,
621    SEC_GET_KEY_FN,
622    *mut c_void,
623    PCredHandle,
624    PTimeStamp,
625) -> SECURITY_STATUS}
626extern "system" {
627    pub fn FreeCredentialsHandle(
628        phCredential: PCredHandle,
629    ) -> SECURITY_STATUS;
630}
631FN!{stdcall FREE_CREDENTIALS_HANDLE_FN(
632    PCredHandle,
633) -> SECURITY_STATUS}
634extern "system" {
635    pub fn AddCredentialsW(
636        hCredentials: PCredHandle,
637        pszPrincipal: LPWSTR,
638        pszPackage: LPWSTR,
639        fCredentialUse: c_ulong,
640        pAuthData: *mut c_void,
641        pGetKeyFn: SEC_GET_KEY_FN,
642        pvGetKeyArgument: *mut c_void,
643        ptsExpiry: PTimeStamp,
644    ) -> SECURITY_STATUS;
645}
646FN!{stdcall ADD_CREDENTIALS_FN_W(
647    PCredHandle,
648    *mut SEC_WCHAR,
649    *mut SEC_WCHAR,
650    c_ulong,
651    *mut c_void,
652    SEC_GET_KEY_FN,
653    *mut c_void,
654    PTimeStamp,
655) -> SECURITY_STATUS}
656extern "system" {
657    pub fn AddCredentialsA(
658        hCredentials: PCredHandle,
659        pszPrincipal: LPSTR,
660        pszPackage: LPSTR,
661        fCredentialUse: c_ulong,
662        pAuthData: *mut c_void,
663        pGetKeyFn: SEC_GET_KEY_FN,
664        pvGetKeyArgument: *mut c_void,
665        ptsExpiry: PTimeStamp,
666    ) -> SECURITY_STATUS;
667}
668FN!{stdcall ADD_CREDENTIALS_FN_A(
669    PCredHandle,
670    *mut SEC_CHAR,
671    *mut SEC_CHAR,
672    c_ulong,
673    *mut c_void,
674    SEC_GET_KEY_FN,
675    *mut c_void,
676    PTimeStamp,
677) -> SECURITY_STATUS}
678extern "system" {
679    // pub fn spiCreateAsyncContext();
680    // pub fn SspiFreeAsyncContext();
681    // pub fn SspiReinitAsyncContext();
682    // pub fn SspiSetAsyncNotifyCallback();
683    // pub fn SspiAsyncContextRequiresNotify();
684    // pub fn SspiGetAsyncCallStatus();
685    // pub fn SspiAcquireCredentialsHandleAsyncW();
686    // pub fn SspiAcquireCredentialsHandleAsyncA();
687    // pub fn SspiInitializeSecurityContextAsyncW();
688    // pub fn SspiInitializeSecurityContextAsyncA();
689    // pub fn SspiAcceptSecurityContextAsync();
690    // pub fn SspiFreeCredentialsHandleAsync();
691    // pub fn SspiDeleteSecurityContextAsync();
692    pub fn ChangeAccountPasswordW(
693        pszPackageName: *mut SEC_WCHAR,
694        pszDomainName: *mut SEC_WCHAR,
695        pszAccountName: *mut SEC_WCHAR,
696        pszOldPassword: *mut SEC_WCHAR,
697        pszNewPassword: *mut SEC_WCHAR,
698        bImpersonating: BOOLEAN,
699        dwReserved: c_ulong,
700        pOutput: PSecBufferDesc,
701    ) -> SECURITY_STATUS;
702}
703FN!{stdcall CHANGE_PASSWORD_FN_W(
704    *mut SEC_WCHAR,
705    *mut SEC_WCHAR,
706    *mut SEC_WCHAR,
707    *mut SEC_WCHAR,
708    *mut SEC_WCHAR,
709    BOOLEAN,
710    c_ulong,
711    PSecBufferDesc,
712) -> SECURITY_STATUS}
713extern "system" {
714    pub fn ChangeAccountPasswordA(
715        pszPackageName: *mut SEC_CHAR,
716        pszDomainName: *mut SEC_CHAR,
717        pszAccountName: *mut SEC_CHAR,
718        pszOldPassword: *mut SEC_CHAR,
719        pszNewPassword: *mut SEC_CHAR,
720        bImpersonating: BOOLEAN,
721        dwReserved: c_ulong,
722        pOutput: PSecBufferDesc,
723    ) -> SECURITY_STATUS;
724}
725FN!{stdcall CHANGE_PASSWORD_FN_A(
726    *mut SEC_CHAR,
727    *mut SEC_CHAR,
728    *mut SEC_CHAR,
729    *mut SEC_CHAR,
730    *mut SEC_CHAR,
731    BOOLEAN,
732    c_ulong,
733    PSecBufferDesc,
734) -> SECURITY_STATUS}
735extern "system" {
736    pub fn InitializeSecurityContextW(
737        phCredential: PCredHandle,
738        phContext: PCtxtHandle,
739        pszTargetName: *mut SEC_WCHAR,
740        fContextReq: c_ulong,
741        Reserved1: c_ulong,
742        TargetDataRep: c_ulong,
743        pInput: PSecBufferDesc,
744        Reserved2: c_ulong,
745        phNewContext: PCtxtHandle,
746        pOutput: PSecBufferDesc,
747        pfContextAttr: *mut c_ulong,
748        ptsExpiry: PTimeStamp,
749    ) -> SECURITY_STATUS;
750}
751// INITIALIZE_SECURITY_CONTEXT_FN_W
752extern "system" {
753    pub fn InitializeSecurityContextA(
754        phCredential: PCredHandle,
755        phContext: PCtxtHandle,
756        pszTargetName: *mut SEC_CHAR,
757        fContextReq: c_ulong,
758        Reserved1: c_ulong,
759        TargetDataRep: c_ulong,
760        pInput: PSecBufferDesc,
761        Reserved2: c_ulong,
762        phNewContext: PCtxtHandle,
763        pOutput: PSecBufferDesc,
764        pfContextAttr: *mut c_ulong,
765        ptsExpiry: PTimeStamp,
766    ) -> SECURITY_STATUS;
767    pub fn AcceptSecurityContext(
768        phCredential: PCredHandle,
769        phContext: PCtxtHandle,
770        pInput: PSecBufferDesc,
771        fContextReq: c_ulong,
772        TargetDataRep: c_ulong,
773        phNewContext: PCtxtHandle,
774        pOutput: PSecBufferDesc,
775        pfContextAttr: *mut c_ulong,
776        ptsExpiry: PTimeStamp,
777    ) -> SECURITY_STATUS;
778    pub fn CompleteAuthToken(
779        phContext: PCtxtHandle,
780        pToken: PSecBufferDesc,
781    ) -> SECURITY_STATUS;
782    pub fn ImpersonateSecurityContext(
783        phContext: PCtxtHandle,
784    ) -> SECURITY_STATUS;
785    pub fn RevertSecurityContext(
786        phContext: PCtxtHandle,
787    ) -> SECURITY_STATUS;
788    pub fn QuerySecurityContextToken(
789        phContext: PCtxtHandle,
790        Token: *mut *mut c_void,
791    ) -> SECURITY_STATUS;
792    pub fn DeleteSecurityContext(
793        phContext: PCtxtHandle,
794    ) -> SECURITY_STATUS;
795    pub fn ApplyControlToken(
796        phContext: PCtxtHandle,
797        pInput: PSecBufferDesc,
798    ) -> SECURITY_STATUS;
799    pub fn QueryContextAttributesW(
800        phContext: PCtxtHandle,
801        ulAttribute: c_ulong,
802        pBuffer: *mut c_void,
803    ) -> SECURITY_STATUS;
804    // pub fn QueryContextAttributesExW();
805    pub fn QueryContextAttributesA(
806        phContext: PCtxtHandle,
807        ulAttribute: c_ulong,
808        pBuffer: *mut c_void,
809    ) -> SECURITY_STATUS;
810    // pub fn QueryContextAttributesExA();
811    pub fn SetContextAttributesW(
812        phContext: PCtxtHandle,
813        ulAttribute: c_ulong,
814        pBuffer: *mut c_void,
815        cbBuffer: c_ulong,
816    ) -> SECURITY_STATUS;
817    pub fn SetContextAttributesA(
818        phContext: PCtxtHandle,
819        ulAttribute: c_ulong,
820        pBuffer: *mut c_void,
821        cbBuffer: c_ulong,
822    ) -> SECURITY_STATUS;
823    pub fn QueryCredentialsAttributesW(
824        phCredential: PCredHandle,
825        ulAttribute: c_ulong,
826        pBuffer: *mut c_void,
827    ) -> SECURITY_STATUS;
828    // pub fn QueryCredentialsAttributesExW();
829    pub fn QueryCredentialsAttributesA(
830        phCredential: PCredHandle,
831        ulAttribute: c_ulong,
832        pBuffer: *mut c_void,
833    ) -> SECURITY_STATUS;
834    // pub fn QueryCredentialsAttributesExA();
835    pub fn SetCredentialsAttributesW(
836        phCredential: PCredHandle,
837        ulAttribute: c_ulong,
838        pBuffer: *mut c_void,
839        cbBuffer: c_ulong,
840    ) -> SECURITY_STATUS;
841    pub fn SetCredentialsAttributesA(
842        phCredential: PCredHandle,
843        ulAttribute: c_ulong,
844        pBuffer: *mut c_void,
845        cbBuffer: c_ulong,
846    ) -> SECURITY_STATUS;
847    pub fn FreeContextBuffer(
848        pvContextBuffer: PVOID,
849    ) -> SECURITY_STATUS;
850    pub fn MakeSignature(
851        phContext: PCtxtHandle,
852        fQOP: c_ulong,
853        pMessage: PSecBufferDesc,
854        MessageSeqNo: c_ulong,
855    ) -> SECURITY_STATUS;
856    pub fn VerifySignature(
857        phContext: PCtxtHandle,
858        pMessage: PSecBufferDesc,
859        MessageSeqNo: c_ulong,
860        pfQOP: *mut c_ulong,
861    ) -> SECURITY_STATUS;
862    pub fn EncryptMessage(
863        phContext: PCtxtHandle,
864        fQOP: c_ulong,
865        pMessage: PSecBufferDesc,
866        MessageSeqNo: c_ulong,
867    ) -> SECURITY_STATUS;
868    pub fn DecryptMessage(
869        phContext: PCtxtHandle,
870        pMessage: PSecBufferDesc,
871        MessageSeqNo: c_ulong,
872        pfQOP: *mut c_ulong,
873    ) -> SECURITY_STATUS;
874    pub fn EnumerateSecurityPackagesW(
875        pcPackages: *mut c_ulong,
876        ppPackageInfo: *mut PSecPkgInfoW,
877    ) -> SECURITY_STATUS;
878    pub fn EnumerateSecurityPackagesA(
879        pcPackages: *mut c_ulong,
880        ppPackageInfo: *mut PSecPkgInfoA,
881    ) -> SECURITY_STATUS;
882    pub fn QuerySecurityPackageInfoW(
883        pszPackageName: LPWSTR,
884        ppPackageInfo: *mut PSecPkgInfoW,
885    ) -> SECURITY_STATUS;
886    pub fn QuerySecurityPackageInfoA(
887        pszPackageName: LPSTR,
888        ppPackageInfo: *mut PSecPkgInfoA,
889    ) -> SECURITY_STATUS;
890}
891ENUM!{enum SecDelegationType {
892    SecFull,
893    SecService,
894    SecTree,
895    SecDirectory,
896    SecObject,
897}}
898pub type PSecDelegationType = *mut SecDelegationType;
899extern "system" {
900    // pub fn DelegateSecurityContext();
901    pub fn ExportSecurityContext(
902        phContext: PCtxtHandle,
903        fFlags: ULONG,
904        pPackedContext: PSecBuffer,
905        pToken: *mut *mut c_void,
906    ) -> SECURITY_STATUS;
907    pub fn ImportSecurityContextW(
908        pszPackage: LPWSTR,
909        pPackedContext: PSecBuffer,
910        Token: *mut c_void,
911        phContext: PCtxtHandle,
912    ) -> SECURITY_STATUS;
913    pub fn ImportSecurityContextA(
914        pszPackage: LPSTR,
915        pPackedContext: PSecBuffer,
916        Token: *mut c_void,
917        phContext: PCtxtHandle,
918    ) -> SECURITY_STATUS;
919// pub fn SecMakeSPN();
920// pub fn SecMakeSPNEx();
921// pub fn SecMakeSPNEx2();
922// pub fn SecLookupAccountSid();
923// pub fn SecLookupAccountName();
924// pub fn SecLookupWellKnownSid();
925}
926extern "system" {
927    // pub fn InitSecurityInterfaceA();
928    // pub fn InitSecurityInterfaceW();
929    // pub fn SaslEnumerateProfilesA();
930    // pub fn SaslEnumerateProfilesW();
931    // pub fn SaslGetProfilePackageA();
932    // pub fn SaslGetProfilePackageW();
933    // pub fn SaslIdentifyPackageA();
934    // pub fn SaslIdentifyPackageW();
935    // pub fn SaslInitializeSecurityContextW();
936    // pub fn SaslInitializeSecurityContextA();
937    // pub fn SaslAcceptSecurityContext();
938    // pub fn SaslSetContextOption();
939    // pub fn SaslGetContextOption();
940}
941pub type PSEC_WINNT_AUTH_IDENTITY_OPAQUE = PVOID;
942extern "system" {
943    pub fn SspiPromptForCredentialsW(
944        pszTargetName: PCWSTR,
945        pUiInfo: PCREDUI_INFOW,
946        dwAuthError: c_ulong,
947        pszPackage: PCWSTR,
948        pInputAuthIdentity: PSEC_WINNT_AUTH_IDENTITY_OPAQUE,
949        ppAuthIdentity: *mut PSEC_WINNT_AUTH_IDENTITY_OPAQUE,
950        pfSave: *mut c_int,
951        dwFlags: c_ulong,
952    ) -> c_ulong;
953    pub fn SspiPromptForCredentialsA(
954        pszTargetName: PCSTR,
955        pUiInfo: PCREDUI_INFOA,
956        dwAuthError: c_ulong,
957        pszPackage: PCSTR,
958        pInputAuthIdentity: PSEC_WINNT_AUTH_IDENTITY_OPAQUE,
959        ppAuthIdentity: *mut PSEC_WINNT_AUTH_IDENTITY_OPAQUE,
960        pfSave: *mut c_int,
961        dwFlags: c_ulong,
962    ) -> c_ulong;
963}
964STRUCT!{struct SEC_WINNT_AUTH_BYTE_VECTOR {
965    ByteArrayOffset: c_ulong,
966    ByteArrayLength: c_ushort,
967}}
968pub type PSEC_WINNT_AUTH_BYTE_VECTOR = *mut SEC_WINNT_AUTH_BYTE_VECTOR;
969STRUCT!{struct SEC_WINNT_AUTH_DATA {
970    CredType: GUID,
971    CredData: SEC_WINNT_AUTH_BYTE_VECTOR,
972}}
973pub type PSEC_WINNT_AUTH_DATA = *mut SEC_WINNT_AUTH_DATA;
974STRUCT!{struct SEC_WINNT_AUTH_PACKED_CREDENTIALS {
975    cbHeaderLength: c_ushort,
976    cbStructureLength: c_ushort,
977    AuthData: SEC_WINNT_AUTH_DATA,
978}}
979pub type PSEC_WINNT_AUTH_PACKED_CREDENTIALS = *mut SEC_WINNT_AUTH_PACKED_CREDENTIALS;
980DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_PASSWORD,
981    0x28bfc32f, 0x10f6, 0x4738, 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a}
982DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_CERT,
983    0x235f69ad, 0x73fb, 0x4dbc, 0x82, 0x3, 0x6, 0x29, 0xe7, 0x39, 0x33, 0x9b}
984STRUCT!{struct SEC_WINNT_AUTH_DATA_PASSWORD {
985    UnicodePassword: SEC_WINNT_AUTH_BYTE_VECTOR,
986}}
987pub type PSEC_WINNT_AUTH_DATA_PASSWORD = *mut SEC_WINNT_AUTH_DATA_PASSWORD;
988DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_CSP_DATA,
989    0x68fd9879, 0x79c, 0x4dfe, 0x82, 0x81, 0x57, 0x8a, 0xad, 0xc1, 0xc1, 0x0}
990// GUID SEC_WINNT_AUTH_DATA_TYPE_SMARTCARD_CONTEXTS
991STRUCT!{struct SEC_WINNT_AUTH_CERTIFICATE_DATA {
992    cbHeaderLength: c_ushort,
993    cbStructureLength: c_ushort,
994    Certificate: SEC_WINNT_AUTH_BYTE_VECTOR,
995}}
996pub type PSEC_WINNT_AUTH_CERTIFICATE_DATA = *mut SEC_WINNT_AUTH_CERTIFICATE_DATA;
997STRUCT!{struct SEC_WINNT_CREDUI_CONTEXT_VECTOR {
998    CredUIContextArrayOffset: ULONG,
999    CredUIContextCount: USHORT,
1000}}
1001pub type PSEC_WINNT_CREDUI_CONTEXT_VECTOR = *mut SEC_WINNT_CREDUI_CONTEXT_VECTOR;
1002STRUCT!{struct SEC_WINNT_AUTH_SHORT_VECTOR {
1003    ShortArrayOffset: ULONG,
1004    ShortArrayCount: USHORT,
1005}}
1006pub type PSEC_WINNT_AUTH_SHORT_VECTOR = *mut SEC_WINNT_AUTH_SHORT_VECTOR;
1007extern "system" {
1008    pub fn SspiGetCredUIContext(
1009        ContextHandle: HANDLE,
1010        CredType: *mut GUID,
1011        LogonId: *mut LUID,
1012        CredUIContexts: *mut PSEC_WINNT_CREDUI_CONTEXT_VECTOR,
1013        TokenHandle: *mut HANDLE,
1014    ) -> SECURITY_STATUS;
1015    pub fn SspiUpdateCredentials(
1016        ContextHandle: HANDLE,
1017        CredType: *mut GUID,
1018        FlatCredUIContextLength: ULONG,
1019        FlatCredUIContext: PUCHAR,
1020    ) -> SECURITY_STATUS;
1021}
1022STRUCT!{struct CREDUIWIN_MARSHALED_CONTEXT {
1023    StructureType: GUID,
1024    cbHeaderLength: USHORT,
1025    LogonId: LUID,
1026    MarshaledDataType: GUID,
1027    MarshaledDataOffset: ULONG,
1028    MarshaledDataLength: USHORT,
1029}}
1030pub type PCREDUIWIN_MARSHALED_CONTEXT = *mut CREDUIWIN_MARSHALED_CONTEXT;
1031STRUCT!{struct SEC_WINNT_CREDUI_CONTEXT {
1032    cbHeaderLength: USHORT,
1033    CredUIContextHandle: HANDLE,
1034    UIInfo: PCREDUI_INFOW,
1035    dwAuthError: ULONG,
1036    pInputAuthIdentity: PSEC_WINNT_AUTH_IDENTITY_OPAQUE,
1037    TargetName: PUNICODE_STRING,
1038}}
1039pub type PSEC_WINNT_CREDUI_CONTEXT = *mut SEC_WINNT_CREDUI_CONTEXT;
1040// GUID CREDUIWIN_STRUCTURE_TYPE_SSPIPFC
1041// GUID SSPIPFC_STRUCTURE_TYPE_CREDUI_CONTEXT
1042extern "system" {
1043    pub fn SspiUnmarshalCredUIContext(
1044        MarshaledCredUIContext: PUCHAR,
1045        MarshaledCredUIContextLength: ULONG,
1046        CredUIContext: *mut PSEC_WINNT_CREDUI_CONTEXT,
1047    ) -> SECURITY_STATUS;
1048    // pub fn SspiPrepareForCredRead();
1049    // pub fn SspiPrepareForCredWrite();
1050    // pub fn SspiEncryptAuthIdentity();
1051    // pub fn SspiEncryptAuthIdentityEx();
1052    // pub fn SspiDecryptAuthIdentity();
1053    // pub fn SspiDecryptAuthIdentityEx();
1054    // pub fn SspiIsAuthIdentityEncrypted();
1055    // pub fn SspiEncodeAuthIdentityAsStrings();
1056    // pub fn SspiValidateAuthIdentity();
1057    // pub fn SspiCopyAuthIdentity();
1058    // pub fn SspiFreeAuthIdentity();
1059    // pub fn SspiZeroAuthIdentity();
1060    // pub fn SspiLocalFree();
1061    // pub fn SspiEncodeStringsAsAuthIdentity();
1062    // pub fn SspiCompareAuthIdentities();
1063    // pub fn SspiMarshalAuthIdentity();
1064    // pub fn SspiUnmarshalAuthIdentity();
1065    pub fn SspiIsPromptingNeeded(
1066        ErrorOrNtStatus: c_ulong,
1067    ) -> BOOLEAN;
1068    // pub fn SspiGetTargetHostName();
1069    // pub fn SspiExcludePackage();
1070    // pub fn AddSecurityPackageA();
1071    // pub fn AddSecurityPackageW();
1072    // pub fn DeleteSecurityPackageA();
1073    // pub fn DeleteSecurityPackageW();
1074}