gdi: Cast-qual warnings fix.
[wine] / include / sspi.h
1 /*
2  * Copyright (C) 2004 Juan Lang
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 #ifndef __WINE_SSPI_H__
19 #define __WINE_SSPI_H__
20
21 #include <wtypes.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #define SEC_ENTRY __stdcall
28
29 typedef WCHAR SEC_WCHAR;
30 typedef CHAR  SEC_CHAR;
31
32 #ifndef __SECSTATUS_DEFINED__
33 #define __SECSTATUS_DEFINED__
34 typedef LONG SECURITY_STATUS;
35 #endif
36
37 #ifdef UNICODE
38 typedef SEC_WCHAR * SECURITY_PSTR;
39 typedef CONST SEC_WCHAR *  SECURITY_PCSTR;
40 #else
41 typedef SEC_CHAR * SECURITY_PSTR;
42 typedef CONST SEC_CHAR *  SECURITY_PCSTR;
43 #endif
44
45 #ifndef __SECHANDLE_DEFINED__
46 #define __SECHANDLE_DEFINED__
47 typedef struct _SecHandle
48 {
49     ULONG_PTR dwLower;
50     ULONG_PTR dwUpper;
51 } SecHandle, *PSecHandle;
52 #endif
53
54 #define SecInvalidateHandle(x) do { \
55  ((PSecHandle)(x))->dwLower = ((ULONG_PTR)((INT_PTR)-1)); \
56  ((PSecHandle)(x))->dwUpper = ((ULONG_PTR)((INT_PTR)-1)); \
57  while (0)
58
59 #define SecIsValidHandle(x) \
60  ((((PSecHandle)(x))->dwLower != ((ULONG_PTR)(INT_PTR)-1)) && \
61  (((PSecHandle)(x))->dwUpper != ((ULONG_PTR)(INT_PTR)-1)))
62
63 typedef SecHandle CredHandle;
64 typedef PSecHandle PCredHandle;
65
66 typedef SecHandle CtxtHandle;
67 typedef PSecHandle PCtxtHandle;
68
69 typedef struct _SECURITY_INTEGER
70 {
71     unsigned long LowPart;
72     long HighPart;
73 } SECURITY_INTEGER, *PSECURITY_INTEGER;
74 typedef SECURITY_INTEGER TimeStamp, *PTimeStamp;
75
76 typedef struct _SecPkgInfoA
77 {
78     unsigned long  fCapabilities;
79     unsigned short wVersion;
80     unsigned short wRPCID;
81     unsigned long  cbMaxToken;
82     SEC_CHAR      *Name;
83     SEC_CHAR      *Comment;
84 } SecPkgInfoA, *PSecPkgInfoA;
85
86 typedef struct _SecPkgInfoW
87 {
88     unsigned long  fCapabilities;
89     unsigned short wVersion;
90     unsigned short wRPCID;
91     unsigned long  cbMaxToken;
92     SEC_WCHAR     *Name;
93     SEC_WCHAR     *Comment;
94 } SecPkgInfoW, *PSecPkgInfoW;
95
96 #define SecPkgInfo WINELIB_NAME_AW(SecPkgInfo)
97 #define PSecPkgInfo WINELIB_NAME_AW(PSecPkgInfo)
98
99 /* fCapabilities field of SecPkgInfo */
100 #define SECPKG_FLAG_INTEGRITY              0x00000001
101 #define SECPKG_FLAG_PRIVACY                0x00000002
102 #define SECPKG_FLAG_TOKEN_ONLY             0x00000004
103 #define SECPKG_FLAG_DATAGRAM               0x00000008
104 #define SECPKG_FLAG_CONNECTION             0x00000010
105 #define SECPKG_FLAG_MULTI_REQUIRED         0x00000020
106 #define SECPKG_FLAG_CLIENT_ONLY            0x00000040
107 #define SECPKG_FLAG_EXTENDED_ERROR         0x00000080
108 #define SECPKG_FLAG_IMPERSONATION          0x00000100
109 #define SECPKG_FLAG_ACCEPT_WIN32_NAME      0x00000200
110 #define SECPKG_FLAG_STREAM                 0x00000400
111 #define SECPKG_FLAG_NEGOTIABLE             0x00000800
112 #define SECPKG_FLAG_GSS_COMPATIBLE         0x00001000
113 #define SECPKG_FLAG_LOGON                  0x00002000
114 #define SECPKG_FLAG_ASCII_BUFFERS          0x00004000
115 #define SECPKG_FLAG_FRAGMENT               0x00008000
116 #define SECPKG_FLAG_MUTUAL_AUTH            0x00010000
117 #define SECPKG_FLAG_DELEGATION             0x00020000
118 #define SECPKG_FLAG_READONLY_WITH_CHECKSUM 0x00040000
119
120 typedef struct _SecBuffer
121 {
122     unsigned long cbBuffer;
123     unsigned long BufferType;
124     void         *pvBuffer;
125 } SecBuffer, *PSecBuffer;
126
127 /* values for BufferType */
128 #define SECBUFFER_EMPTY               0
129 #define SECBUFFER_DATA                1
130 #define SECBUFFER_TOKEN               2
131 #define SECBUFFER_PKG_PARAMS          3
132 #define SECBUFFER_MISSING             4
133 #define SECBUFFER_EXTRA               5
134 #define SECBUFFER_STREAM_TRAILER      6
135 #define SECBUFFER_HEADER              7
136 #define SECBUFFER_NEGOTIATION_INFO    8
137 #define SECBUFFER_PADDING             9
138 #define SECBUFFER_STREAM             10
139 #define SECBUFFER_MECHLIST           11
140 #define SECBUFFER_MECHLIST_SIGNATURE 12
141 #define SECBUFFER_TARGET             13
142 #define SECBUFFER_CHANNEL_BINDINGS   14
143
144 #define SECBUFFER_ATTRMASK               0xf0000000
145 #define SECBUFFER_READONLY               0x80000000
146 #define SECBUFFER_READONLY_WITH_CHECKSUM 0x10000000
147 #define SECBUFFER_RESERVED               0x60000000
148
149 typedef struct _SecBufferDesc
150 {
151     unsigned long ulVersion;
152     unsigned long cBuffers;
153     PSecBuffer    pBuffers;
154 } SecBufferDesc, *PSecBufferDesc;
155
156 /* values for ulVersion */
157 #define SECBUFFER_VERSION 0
158
159 typedef void (SEC_ENTRY *SEC_GET_KEY_FN)(void *Arg, void *Principal,
160  unsigned long KeyVer, void **Key, SECURITY_STATUS *Status);
161
162 SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(PULONG pcPackages,
163  PSecPkgInfoA *ppPackageInfo);
164 SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesW(PULONG pcPackages,
165  PSecPkgInfoW *ppPackageInfo);
166 #define EnumerateSecurityPackages WINELIB_NAME_AW(EnumerateSecurityPackages)
167
168 typedef SECURITY_STATUS (SEC_ENTRY *ENUMERATE_SECURITY_PACKAGES_FN_A)(PULONG,
169  PSecPkgInfoA *);
170 typedef SECURITY_STATUS (SEC_ENTRY *ENUMERATE_SECURITY_PACKAGES_FN_W)(PULONG,
171  PSecPkgInfoW *);
172 #define ENUMERATE_SECURITY_PACKAGES_FN WINELIB_NAME_AW(ENUMERATE_SECURITY_PACKAGES_FN_)
173
174 SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(
175  PCredHandle phCredential, unsigned long ulAttribute, void *pBuffer);
176 SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(
177  PCredHandle phCredential, unsigned long ulAttribute, void *pBuffer);
178 #define QueryCredentialsAttributes WINELIB_NAME_AW(QueryCredentialsAttributes)
179
180 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_CREDENTIALS_ATTRIBUTES_FN_A)
181  (PCredHandle, unsigned long, PVOID);
182 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_CREDENTIALS_ATTRIBUTES_FN_W)
183  (PCredHandle, unsigned long, PVOID);
184 #define QUERY_CREDENTIALS_ATTRIBUTES_FN WINELIB_NAME_AW(QUERY_CREDENTIALS_ATTRIBUTES_FN_)
185
186 /* values for QueryCredentialsAttributes ulAttribute */
187 #define SECPKG_CRED_ATTR_NAMES 1
188
189 /* types for QueryCredentialsAttributes */
190 typedef struct _SecPkgCredentials_NamesA
191 {
192     SEC_CHAR *sUserName;
193 } SecPkgCredentials_NamesA, *PSecPkgCredentials_NamesA;
194
195 typedef struct _SecPkgCredentials_NamesW
196 {
197     SEC_WCHAR *sUserName;
198 } SecPkgCredentials_NamesW, *PSecPkgCredentials_NamesW;
199
200 #define SecPkgCredentials_Names WINELIB_NAME_AW(SecPkgCredentials_Names)
201
202 SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA(
203  SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse,
204  PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
205  PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
206 SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(
207  SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse,
208  PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
209  PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry);
210 #define AcquireCredentialsHandle WINELIB_NAME_AW(AcquireCredentialsHandle)
211
212 /* flags for fCredentialsUse */
213 #define SECPKG_CRED_INBOUND  0x00000001
214 #define SECPKG_CRED_OUTBOUND 0x00000002
215 #define SECPKG_CRED_BOTH     (SECPKG_CRED_INBOUND | SECPKG_CRED_OUTBOUND)
216 #define SECPKG_CRED_DEFAULT  0x00000004
217 #define SECPKG_CRED_RESERVED 0xf0000000
218
219 typedef SECURITY_STATUS (SEC_ENTRY *ACQUIRE_CREDENTIALS_HANDLE_FN_A)(
220  SEC_CHAR *, SEC_CHAR *, ULONG, PLUID, PVOID, SEC_GET_KEY_FN, PVOID,
221  PCredHandle, PTimeStamp);
222 typedef SECURITY_STATUS (SEC_ENTRY *ACQUIRE_CREDENTIALS_HANDLE_FN_W)(
223  SEC_WCHAR *, SEC_WCHAR *, ULONG, PLUID, PVOID, SEC_GET_KEY_FN, PVOID,
224  PCredHandle, PTimeStamp);
225 #define ACQUIRE_CREDENTIALS_HANDLE_FN WINELIB_NAME_AW(ACQUIRE_CREDENTIALS_HANDLE_FN_)
226
227 SECURITY_STATUS SEC_ENTRY FreeContextBuffer(PVOID pv);
228
229 typedef SECURITY_STATUS (SEC_ENTRY *FREE_CONTEXT_BUFFER_FN)(PVOID);
230
231 SECURITY_STATUS SEC_ENTRY FreeCredentialsHandle(PCredHandle
232  phCredential);
233
234 #define FreeCredentialHandle FreeCredentialsHandle
235
236 typedef SECURITY_STATUS (SEC_ENTRY *FREE_CREDENTIALS_HANDLE_FN)(PCredHandle);
237
238 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(
239  PCredHandle phCredential, PCtxtHandle phContext,
240  SEC_CHAR *pszTargetName, unsigned long fContextReq,
241  unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
242  unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
243  unsigned long *pfContextAttr, PTimeStamp ptsExpiry);
244 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(
245  PCredHandle phCredential, PCtxtHandle phContext,
246  SEC_WCHAR *pszTargetName, unsigned long fContextReq,
247  unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
248  unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
249  unsigned long *pfContextAttr, PTimeStamp ptsExpiry);
250 #define InitializeSecurityContext WINELIB_NAME_AW(InitializeSecurityContext)
251
252 typedef SECURITY_STATUS (SEC_ENTRY *INITIALIZE_SECURITY_CONTEXT_FN_A)
253  (PCredHandle, PCtxtHandle, SEC_CHAR *, unsigned long, unsigned long,
254  unsigned long, PSecBufferDesc, unsigned long, PCtxtHandle, PSecBufferDesc,
255  unsigned long *, PTimeStamp);
256 typedef SECURITY_STATUS (SEC_ENTRY *INITIALIZE_SECURITY_CONTEXT_FN_W)
257  (PCredHandle, PCtxtHandle, SEC_WCHAR *, unsigned long, unsigned long,
258  unsigned long, PSecBufferDesc, unsigned long, PCtxtHandle, PSecBufferDesc,
259  unsigned long *, PTimeStamp);
260 #define INITIALIZE_SECURITY_CONTEXT_FN WINELIB_NAME_AW(INITIALIZE_SECURITY_CONTEXT_FN_)
261
262 /* flags for InitializeSecurityContext fContextReq and pfContextAttr */
263 #define ISC_REQ_DELEGATE               0x00000001
264 #define ISC_REQ_MUTUAL_AUTH            0x00000002
265 #define ISC_REQ_REPLAY_DETECT          0x00000004
266 #define ISC_REQ_SEQUENCE_DETECT        0x00000008
267 #define ISC_REQ_CONFIDENTIALITY        0x00000010
268 #define ISC_REQ_USE_SESSION_KEY        0x00000020
269 #define ISC_REQ_PROMPT_FOR_CREDS       0x00000040
270 #define ISC_REQ_USE_SUPPLIED_CREDS     0x00000080
271 #define ISC_REQ_ALLOCATE_MEMORY        0x00000100
272 #define ISC_REQ_USE_DCE_STYLE          0x00000200
273 #define ISC_REQ_DATAGRAM               0x00000400
274 #define ISC_REQ_CONNECTION             0x00000800
275 #define ISC_REQ_CALL_LEVEL             0x00001000
276 #define ISC_REQ_FRAGMENT_SUPPLIED      0x00002000
277 #define ISC_REQ_EXTENDED_ERROR         0x00004000
278 #define ISC_REQ_STREAM                 0x00008000
279 #define ISC_REQ_INTEGRITY              0x00010000
280 #define ISC_REQ_IDENTIFY               0x00020000
281 #define ISC_REQ_NULL_SESSION           0x00040000
282 #define ISC_REQ_MANUAL_CRED_VALIDATION 0x00080000
283 #define ISC_REQ_RESERVED1              0x00100000
284 #define ISC_REQ_FRAGMENT_TO_FIT        0x00200000
285
286 #define ISC_RET_DELEGATE               0x00000001
287 #define ISC_RET_MUTUAL_AUTH            0x00000002
288 #define ISC_RET_REPLAY_DETECT          0x00000004
289 #define ISC_RET_SEQUENCE_DETECT        0x00000008
290 #define ISC_RET_CONFIDENTIALITY        0x00000010
291 #define ISC_RET_USE_SESSION_KEY        0x00000020
292 #define ISC_RET_USED_COLLECTED_CREDS   0x00000040
293 #define ISC_RET_USED_SUPPLIED_CREDS    0x00000080
294 #define ISC_RET_ALLOCATED_MEMORY       0x00000100
295 #define ISC_RET_USED_DCE_STYLE         0x00000200
296 #define ISC_RET_DATAGRAM               0x00000400
297 #define ISC_RET_CONNECTION             0x00000800
298 #define ISC_RET_INTERMEDIATE_RETURN    0x00001000
299 #define ISC_RET_CALL_LEVEL             0x00002000
300 #define ISC_RET_EXTENDED_ERROR         0x00004000
301 #define ISC_RET_STREAM                 0x00008000
302 #define ISC_RET_INTEGRITY              0x00010000
303 #define ISC_RET_IDENTIFY               0x00020000
304 #define ISC_RET_NULL_SESSION           0x00040000
305 #define ISC_RET_MANUAL_CRED_VALIDATION 0x00080000
306 #define ISC_RET_RESERVED1              0x00100000
307 #define ISC_RET_FRAGMENT_ONLY          0x00200000
308
309 SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(
310  PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
311  unsigned long fContextReq, unsigned long TargetDataRep,
312  PCtxtHandle phNewContext, PSecBufferDesc pOutput,
313  unsigned long *pfContextAttr, PTimeStamp ptsExpiry);
314
315 typedef SECURITY_STATUS (SEC_ENTRY *ACCEPT_SECURITY_CONTEXT_FN)(PCredHandle,
316  PCtxtHandle, PSecBufferDesc, unsigned long, unsigned long, PCtxtHandle,
317  PSecBufferDesc, unsigned long *, PTimeStamp);
318
319 /* flags for AcceptSecurityContext fContextReq and pfContextAttr */
320 #define ASC_REQ_DELEGATE               0x00000001
321 #define ASC_REQ_MUTUAL_AUTH            0x00000002
322 #define ASC_REQ_REPLAY_DETECT          0x00000004
323 #define ASC_REQ_SEQUENCE_DETECT        0x00000008
324 #define ASC_REQ_CONFIDENTIALITY        0x00000010
325 #define ASC_REQ_USE_SESSION_KEY        0x00000020
326 #define ASC_REQ_ALLOCATE_MEMORY        0x00000100
327 #define ASC_REQ_USE_DCE_STYLE          0x00000200
328 #define ASC_REQ_DATAGRAM               0x00000400
329 #define ASC_REQ_CONNECTION             0x00000800
330 #define ASC_REQ_CALL_LEVEL             0x00001000
331 #define ASC_REQ_FRAGMENT_SUPPLIED      0x00002000
332 #define ASC_REQ_EXTENDED_ERROR         0x00008000
333 #define ASC_REQ_STREAM                 0x00010000
334 #define ASC_REQ_INTEGRITY              0x00020000
335 #define ASC_REQ_LICENSING              0x00040000
336 #define ASC_REQ_IDENTIFY               0x00080000
337 #define ASC_REQ_ALLOW_NULL_SESSION     0x00100000
338 #define ASC_REQ_ALLOW_NON_USER_LOGONS  0x00200000
339 #define ASC_REQ_ALLOW_CONTEXT_REPLAY   0x00400000
340 #define ASC_REQ_FRAGMENT_TO_FIT        0x00800000
341 #define ASC_REQ_FRAGMENT_NO_TOKEN      0x01000000
342
343 #define ASC_RET_DELEGATE               0x00000001
344 #define ASC_RET_MUTUAL_AUTH            0x00000002
345 #define ASC_RET_REPLAY_DETECT          0x00000004
346 #define ASC_RET_SEQUENCE_DETECT        0x00000008
347 #define ASC_RET_CONFIDENTIALITY        0x00000010
348 #define ASC_RET_USE_SESSION_KEY        0x00000020
349 #define ASC_RET_ALLOCATED_MEMORY       0x00000100
350 #define ASC_RET_USED_DCE_STYLE         0x00000200
351 #define ASC_RET_DATAGRAM               0x00000400
352 #define ASC_RET_CONNECTION             0x00000800
353 #define ASC_RET_CALL_LEVEL             0x00002000
354 #define ASC_RET_THIRD_LEG_FAILED       0x00004000
355 #define ASC_RET_EXTENDED_ERROR         0x00008000
356 #define ASC_RET_STREAM                 0x00010000
357 #define ASC_RET_INTEGRITY              0x00020000
358 #define ASC_RET_LICENSING              0x00040000
359 #define ASC_RET_IDENTIFY               0x00080000
360 #define ASC_RET_NULL_SESSION           0x00100000
361 #define ASC_RET_ALLOW_NON_USER_LOGONS  0x00200000
362 #define ASC_RET_ALLOW_CONTEXT_REPLAY   0x00400000
363 #define ASC_RET_FRAGMENT_ONLY          0x00800000
364 #define ASC_RET_NO_TOKEN               0x01000000
365
366 /* values for TargetDataRep */
367 #define SECURITY_NATIVE_DREP  0x00000010
368 #define SECURITY_NETWORK_DREP 0x00000000
369
370 SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext,
371  PSecBufferDesc pToken);
372
373 typedef SECURITY_STATUS (SEC_ENTRY *COMPLETE_AUTH_TOKEN_FN)(PCtxtHandle,
374  PSecBufferDesc);
375
376 SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext);
377
378 typedef SECURITY_STATUS (SEC_ENTRY *DELETE_SECURITY_CONTEXT_FN)(PCtxtHandle);
379
380 SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext,
381  PSecBufferDesc pInput);
382
383 typedef SECURITY_STATUS (SEC_ENTRY *APPLY_CONTROL_TOKEN_FN)(PCtxtHandle,
384  PSecBufferDesc);
385
386 SECURITY_STATUS SEC_ENTRY QueryContextAttributesA(PCtxtHandle phContext,
387  unsigned long ulAttribute, void *pBuffer);
388 SECURITY_STATUS SEC_ENTRY QueryContextAttributesW(PCtxtHandle phContext,
389  unsigned long ulAttribute, void *pBuffer);
390 #define QueryContextAttributes WINELIB_NAME_AW(QueryContextAttributes)
391
392 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle,
393  unsigned long, void *);
394 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle,
395  unsigned long, void *);
396 #define QUERY_CONTEXT_ATTRIBUTES_FN WINELIB_NAME_AW(QUERY_CONTEXT_ATTRIBUTES_FN_)
397
398 /* values for QueryContextAttributes/SetContextAttributes ulAttribute */
399 #define SECPKG_ATTR_SIZES               0
400 #define SECPKG_ATTR_NAMES               1
401 #define SECPKG_ATTR_LIFESPAN            2
402 #define SECPKG_ATTR_DCE_INFO            3
403 #define SECPKG_ATTR_STREAM_SIZES        4
404 #define SECPKG_ATTR_KEY_INFO            5
405 #define SECPKG_ATTR_AUTHORITY           6
406 #define SECPKG_ATTR_PROTO_INFO          7
407 #define SECPKG_ATTR_PASSWORD_EXPIRY     8
408 #define SECPKG_ATTR_SESSION_KEY         9
409 #define SECPKG_ATTR_PACKAGE_INFO       10
410 #define SECPKG_ATTR_USER_FLAGS         11
411 #define SECPKG_ATTR_NEGOTIATION_INFO   12
412 #define SECPKG_ATTR_NATIVE_NAMES       13
413 #define SECPKG_ATTR_FLAGS              14
414 #define SECPKG_ATTR_USE_VALIDATED      15
415 #define SECPKG_ATTR_CREDENTIAL_NAME    16
416 #define SECPKG_ATTR_TARGET_INFORMATION 17
417 #define SECPKG_ATTR_ACCESS_TOKEN       18
418 #define SECPKG_ATTR_TARGET             19
419 #define SECPKG_ATTR_AUTHENTICATION_ID  20
420
421 /* types for QueryContextAttributes/SetContextAttributes */
422
423 typedef struct _SecPkgContext_Sizes
424 {
425     unsigned long cbMaxToken;
426     unsigned long cbMaxSignature;
427     unsigned long cbBlockSize;
428     unsigned long cbSecurityTrailer;
429 } SecPkgContext_Sizes, *PSecPkgContext_Sizes;
430
431 typedef struct _SecPkgContext_StreamSizes
432 {
433     unsigned long cbHeader;
434     unsigned long cbTrailer;
435     unsigned long cbMaximumMessage;
436     unsigned long cbBuffers;
437     unsigned long cbBlockSize;
438 } SecPkgContext_StreamSizes, *PSecPkgContext_StreamSizes;
439
440 typedef struct _SecPkgContext_NamesA
441 {
442     SEC_CHAR *sUserName;
443 } SecPkgContext_NamesA, *PSecPkgContext_NamesA;
444
445 typedef struct _SecPkgContext_NamesW
446 {
447     SEC_WCHAR *sUserName;
448 } SecPkgContext_NamesW, *PSecPkgContext_NamesW;
449
450 #define SecPkgContext_Names WINELIB_NAME_AW(SecPkgContext_Names)
451 #define PSecPkgContext_Names WINELIB_NAME_AW(PSecPkgContext_Names)
452
453 typedef struct _SecPkgContext_Lifespan
454 {
455     TimeStamp tsStart;
456     TimeStamp tsExpiry;
457 } SecPkgContext_Lifespan, *PSecPkgContext_Lifespan;
458
459 typedef struct _SecPkgContext_DceInfo
460 {
461     unsigned long AuthzSvc;
462     void *pPac;
463 } SecPkgContext_DceInfo, *PSecPkgContext_DceInfo;
464
465 typedef struct _SecPkgContext_KeyInfoA
466 {
467     SEC_CHAR      *sSignatureAlgorithmName;
468     SEC_CHAR      *sEncryptAlgorithmName;
469     unsigned long  KeySize;
470     unsigned long  SignatureAlgorithm;
471     unsigned long  EncryptAlgorithm;
472 } SecPkgContext_KeyInfoA, *PSecPkgContext_KeyInfoA;
473
474 typedef struct _SecPkgContext_KeyInfoW
475 {
476     SEC_WCHAR     *sSignatureAlgorithmName;
477     SEC_WCHAR     *sEncryptAlgorithmName;
478     unsigned long  KeySize;
479     unsigned long  SignatureAlgorithm;
480     unsigned long  EncryptAlgorithm;
481 } SecPkgContext_KeyInfoW, *PSecPkgContext_KeyInfoW;
482
483 #define SecPkgContext_KeyInfo WINELIB_NAME_AW(SecPkgContext_KeyInfo)
484 #define PSecPkgContext_KeyInfo WINELIB_NAME_AW(PSecPkgContext_KeyInfo)
485
486 typedef struct _SecPkgContext_AuthorityA
487 {
488     SEC_CHAR *sAuthorityName;
489 } SecPkgContext_AuthorityA, *PSecPkgContext_AuthorityA;
490
491 typedef struct _SecPkgContext_AuthorityW
492 {
493     SEC_WCHAR *sAuthorityName;
494 } SecPkgContext_AuthorityW, *PSecPkgContext_AuthorityW;
495
496 #define SecPkgContext_Authority WINELIB_NAME_AW(SecPkgContext_Authority)
497 #define PSecPkgContext_Authority WINELIB_NAME_AW(PSecPkgContext_Authority)
498
499 typedef struct _SecPkgContext_ProtoInfoA
500 {
501     SEC_CHAR     *sProtocolName;
502     unsigned long majorVersion;
503     unsigned long minorVersion;
504 } SecPkgContext_ProtoInfoA, *PSecPkgContext_ProtoInfoA;
505
506 typedef struct _SecPkgContext_ProtoInfoW
507 {
508     SEC_WCHAR    *sProtocolName;
509     unsigned long majorVersion;
510     unsigned long minorVersion;
511 } SecPkgContext_ProtoInfoW, *PSecPkgContext_ProtoInfoW;
512
513 #define SecPkgContext_ProtoInfo WINELIB_NAME_AW(SecPkgContext_ProtoInfo)
514 #define PSecPkgContext_ProtoInfo WINELIB_NAME_AW(PSecPkgContext_ProtoInfo)
515
516 typedef struct _SecPkgContext_PasswordExpiry
517 {
518     TimeStamp tsPasswordExpires;
519 } SecPkgContext_PasswordExpiry, *PSecPkgContext_PasswordExpiry;
520
521 typedef struct _SecPkgContext_SessionKey
522 {
523     unsigned long  SessionKeyLength;
524     unsigned char *SessionKey;
525 } SecPkgContext_SessionKey, *PSecPkgContext_SessionKey;
526
527 typedef struct _SecPkgContext_PackageInfoA
528 {
529     PSecPkgInfoA PackageInfo;
530 } SecPkgContext_PackageInfoA, *PSecPkgContext_PackageInfoA;
531
532 typedef struct _SecPkgContext_PackageInfoW
533 {
534     PSecPkgInfoW PackageInfo;
535 } SecPkgContext_PackageInfoW, *PSecPkgContext_PackageInfoW;
536
537 #define SecPkgContext_PackageInfo WINELIB_NAME_AW(SecPkgContext_PackageInfo)
538 #define PSecPkgContext_PackageInfo WINELIB_NAME_AW(PSecPkgContext_PackageInfo)
539
540 typedef struct _SecPkgContext_Flags
541 {
542     unsigned long Flags;
543 } SecPkgContext_Flags, *PSecPkgContext_Flags;
544
545 typedef struct _SecPkgContext_UserFlags
546 {
547     unsigned long UserFlags;
548 } SecPkgContext_UserFlags, *PSecPkgContext_UserFlags;
549
550 typedef struct _SecPkgContext_NegotiationInfoA
551 {
552     PSecPkgInfoA  PackageInfo;
553     unsigned long NegotiationState;
554 } SecPkgContext_NegotiationInfoA, *PSecPkgContext_NegotiationInfoA;
555
556 typedef struct _SecPkgContext_NegotiationInfoW
557 {
558     PSecPkgInfoW  PackageInfo;
559     unsigned long NegotiationState;
560 } SecPkgContext_NegotiationInfoW, *PSecPkgContext_NegotiationInfoW;
561
562 #define SecPkgContext_NegotiationInfo WINELIB_NAME_AW(SecPkgContext_NegotiationInfo)
563 #define PSecPkgContext_NegotiationInfo WINELIB_NAME_AW(PSecPkgContext_NegotiationInfo)
564
565 /* values for NegotiationState */
566 #define SECPKG_NEGOTIATION_COMPLETE      0
567 #define SECPKG_NEGOTIATION_OPTIMISTIC    1
568 #define SECPKG_NEGOTIATION_IN_PROGRESS   2
569 #define SECPKG_NEGOTIATION_DIRECT        3
570 #define SECPKG_NEGOTIATION_TRY_MULTICRED 4
571
572 typedef struct _SecPkgContext_NativeNamesA
573 {
574     SEC_CHAR *sClientName;
575     SEC_CHAR *sServerName;
576 } SecPkgContext_NativeNamesA, *PSecPkgContext_NativeNamesA;
577
578 typedef struct _SecPkgContext_NativeNamesW
579 {
580     SEC_WCHAR *sClientName;
581     SEC_WCHAR *sServerName;
582 } SecPkgContext_NativeNamesW, *PSecPkgContext_NativeNamesW;
583
584 #define SecPkgContext_NativeNames WINELIB_NAME_AW(SecPkgContext_NativeNames)
585 #define PSecPkgContext_NativeNames WINELIB_NAME_AW(PSecPkgContext_NativeNames)
586
587 typedef struct _SecPkgContext_CredentialNameA
588 {
589     unsigned long  CredentialType;
590     SEC_CHAR      *sCredentialName;
591 } SecPkgContext_CredentialNameA, *PSecPkgContext_CredentialNameA;
592
593 typedef struct _SecPkgContext_CredentialNameW
594 {
595     unsigned long  CredentialType;
596     SEC_WCHAR     *sCredentialName;
597 } SecPkgContext_CredentialNameW, *PSecPkgContext_CredentialNameW;
598
599 #define SecPkgContext_CredentialName WINELIB_NAME_AW(SecPkgContext_CredentialName)
600 #define PSecPkgContext_CredentialName WINELIB_NAME_AW(PSecPkgContext_CredentialName)
601
602 typedef struct _SecPkgContext_AccessToken
603 {
604     void *AccessToken;
605 } SecPkgContext_AccessToken, *PSecPkgContext_AccessToken;
606
607 typedef struct _SecPkgContext_TargetInformation
608 {
609     unsigned long  MarshalledTargetInfoLength;
610     unsigned char *MarshalledTargetInfo;
611 } SecPkgContext_TargetInformation, *PSecPkgContext_TargetInformation;
612
613 typedef struct _SecPkgContext_AuthzID
614 {
615     unsigned long  AuthzIDLength;
616     char          *AuthzID;
617 } SecPkgContext_AuthzID, *PSecPkgContext_AuthzID;
618
619 typedef struct _SecPkgContext_Target
620 {
621     unsigned long  TargetLength;
622     char          *Target;
623 } SecPkgContext_Target, *PSecPkgContext_Target;
624
625 SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext);
626
627 typedef SECURITY_STATUS (SEC_ENTRY *IMPERSONATE_SECURITY_CONTEXT_FN)
628  (PCtxtHandle);
629
630 SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext);
631
632 typedef SECURITY_STATUS (SEC_ENTRY *REVERT_SECURITY_CONTEXT_FN)(PCtxtHandle);
633
634 SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext,
635  ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo);
636
637 typedef SECURITY_STATUS (SEC_ENTRY *MAKE_SIGNATURE_FN)(PCtxtHandle,
638  ULONG, PSecBufferDesc, ULONG);
639
640 SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext,
641  PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
642
643 typedef SECURITY_STATUS (SEC_ENTRY *VERIFY_SIGNATURE_FN)(PCtxtHandle,
644  PSecBufferDesc, ULONG, PULONG);
645
646 SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(
647  SEC_CHAR *pszPackageName, PSecPkgInfoA *ppPackageInfo);
648 SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(
649  SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo);
650 #define QuerySecurityPackageInfo WINELIB_NAME_AW(QuerySecurityPackageInfo)
651
652 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_SECURITY_PACKAGE_INFO_FN_A)
653  (SEC_CHAR *, PSecPkgInfoA *);
654 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_SECURITY_PACKAGE_INFO_FN_W)
655  (SEC_WCHAR *, PSecPkgInfoW *);
656 #define QUERY_SECURITY_PACKAGE_INFO_FN WINELIB_NAME_AW(QUERY_SECURITY_PACKAGE_INFO_FN_)
657
658 SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext,
659  ULONG fFlags, PSecBuffer pPackedContext, void **pToken);
660
661 typedef SECURITY_STATUS (SEC_ENTRY *EXPORT_SECURITY_CONTEXT_FN)(PCtxtHandle,
662  ULONG, PSecBuffer, void **);
663
664 /* values for ExportSecurityContext fFlags */
665 #define SECPKG_CONTEXT_EXPORT_RESET_NEW  0x00000001
666 #define SECPKG_CONTEXT_EXPORT_DELETE_OLD 0x00000002
667
668 SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR *pszPackage,
669  PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext);
670 SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR *pszPackage,
671  PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext);
672 #define ImportSecurityContext WINELIB_NAME_AW(ImportSecurityContext)
673
674 typedef SECURITY_STATUS (SEC_ENTRY *IMPORT_SECURITY_CONTEXT_FN_A)(SEC_CHAR *,
675  PSecBuffer, void *, PCtxtHandle);
676 typedef SECURITY_STATUS (SEC_ENTRY *IMPORT_SECURITY_CONTEXT_FN_W)(SEC_WCHAR *,
677  PSecBuffer, void *, PCtxtHandle);
678 #define IMPORT_SECURITY_CONTEXT_FN WINELIB_NAME_AW(IMPORT_SECURITY_CONTEXT_FN_)
679
680 SECURITY_STATUS SEC_ENTRY AddCredentialsA(PCredHandle hCredentials,
681  SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, unsigned long fCredentialUse,
682  void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
683  PTimeStamp ptsExpiry);
684 SECURITY_STATUS SEC_ENTRY AddCredentialsW(PCredHandle hCredentials,
685  SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, unsigned long fCredentialUse,
686  void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
687  PTimeStamp ptsExpiry);
688 #define AddCredentials WINELIB_NAME_AW(AddCredentials)
689
690 typedef SECURITY_STATUS (SEC_ENTRY *ADD_CREDENTIALS_FN_A)(PCredHandle,
691  SEC_CHAR *, SEC_CHAR *, unsigned long, void *, SEC_GET_KEY_FN, void *,
692  PTimeStamp);
693 typedef SECURITY_STATUS (SEC_ENTRY *ADD_CREDENTIALS_FN_W)(PCredHandle,
694  SEC_WCHAR *, SEC_WCHAR *, unsigned long, void *, SEC_GET_KEY_FN, void *,
695  PTimeStamp);
696
697 SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext,
698  HANDLE *phToken);
699
700 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_SECURITY_CONTEXT_TOKEN_FN)
701  (PCtxtHandle, HANDLE *);
702
703 SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
704  PSecBufferDesc pMessage, ULONG MessageSeqNo);
705 SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext,
706  PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
707
708 /* values for EncryptMessage fQOP */
709 #define SECQOP_WRAP_NO_ENCRYPT 0x80000001
710
711 typedef SECURITY_STATUS (SEC_ENTRY *ENCRYPT_MESSAGE_FN)(PCtxtHandle, ULONG,
712  PSecBufferDesc, ULONG);
713 typedef SECURITY_STATUS (SEC_ENTRY *DECRYPT_MESSAGE_FN)(PCtxtHandle,
714  PSecBufferDesc, ULONG, PULONG);
715
716 SECURITY_STATUS SEC_ENTRY SetContextAttributesA(PCtxtHandle phContext,
717  unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer);
718 SECURITY_STATUS SEC_ENTRY SetContextAttributesW(PCtxtHandle phContext,
719  unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer);
720 #define SetContextAttributes WINELIB_NAME_AW(SetContextAttributes)
721
722 typedef SECURITY_STATUS (SEC_ENTRY *SET_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle,
723  unsigned long, void *, unsigned long);
724 typedef SECURITY_STATUS (SEC_ENTRY *SET_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle,
725  unsigned long, void *, unsigned long);
726
727 #define SECURITY_ENTRYPOINT_ANSIA "InitSecurityInterfaceA"
728 #define SECURITY_ENTRYPOINT_ANSIW "InitSecurityInterfaceW"
729 #define SECURITY_ENTRYPOINT_ANSI WINELIB_NAME_AW(SECURITY_ENTRYPOINT_ANSI)
730
731 typedef struct _SECURITY_FUNCTION_TABLE_A
732 {
733     unsigned long                     dwVersion;
734     ENUMERATE_SECURITY_PACKAGES_FN_A  EnumerateSecurityPackagesA;
735     QUERY_CREDENTIALS_ATTRIBUTES_FN_A QueryCredentialsAttributesA;
736     ACQUIRE_CREDENTIALS_HANDLE_FN_A   AcquireCredentialsHandleA;
737     FREE_CREDENTIALS_HANDLE_FN        FreeCredentialsHandle;
738     void                             *Reserved2;
739     INITIALIZE_SECURITY_CONTEXT_FN_A  InitializeSecurityContextA;
740     ACCEPT_SECURITY_CONTEXT_FN        AcceptSecurityContext;
741     COMPLETE_AUTH_TOKEN_FN            CompleteAuthToken;
742     DELETE_SECURITY_CONTEXT_FN        DeleteSecurityContext;
743     APPLY_CONTROL_TOKEN_FN            ApplyControlToken;
744     QUERY_CONTEXT_ATTRIBUTES_FN_A     QueryContextAttributesA;
745     IMPERSONATE_SECURITY_CONTEXT_FN   ImpersonateSecurityContext;
746     REVERT_SECURITY_CONTEXT_FN        RevertSecurityContext;
747     MAKE_SIGNATURE_FN                 MakeSignature;
748     VERIFY_SIGNATURE_FN               VerifySignature;
749     FREE_CONTEXT_BUFFER_FN            FreeContextBuffer;
750     QUERY_SECURITY_PACKAGE_INFO_FN_A  QuerySecurityPackageInfoA;
751     void                             *Reserved3;
752     void                             *Reserved4;
753     EXPORT_SECURITY_CONTEXT_FN        ExportSecurityContext;
754     IMPORT_SECURITY_CONTEXT_FN_A      ImportSecurityContextA;
755     ADD_CREDENTIALS_FN_A              AddCredentialsA;
756     void                             *Reserved8;
757     QUERY_SECURITY_CONTEXT_TOKEN_FN   QuerySecurityContextToken;
758     ENCRYPT_MESSAGE_FN                EncryptMessage;
759     DECRYPT_MESSAGE_FN                DecryptMessage;
760     SET_CONTEXT_ATTRIBUTES_FN_A       SetContextAttributesA;
761 } SecurityFunctionTableA, *PSecurityFunctionTableA;
762
763 typedef struct _SECURITY_FUNCTION_TABLE_W
764 {
765     unsigned long                     dwVersion;
766     ENUMERATE_SECURITY_PACKAGES_FN_W  EnumerateSecurityPackagesW;
767     QUERY_CREDENTIALS_ATTRIBUTES_FN_W QueryCredentialsAttributesW;
768     ACQUIRE_CREDENTIALS_HANDLE_FN_W   AcquireCredentialsHandleW;
769     FREE_CREDENTIALS_HANDLE_FN        FreeCredentialsHandle;
770     void                             *Reserved2;
771     INITIALIZE_SECURITY_CONTEXT_FN_W  InitializeSecurityContextW;
772     ACCEPT_SECURITY_CONTEXT_FN        AcceptSecurityContext;
773     COMPLETE_AUTH_TOKEN_FN            CompleteAuthToken;
774     DELETE_SECURITY_CONTEXT_FN        DeleteSecurityContext;
775     APPLY_CONTROL_TOKEN_FN            ApplyControlToken;
776     QUERY_CONTEXT_ATTRIBUTES_FN_W     QueryContextAttributesW;
777     IMPERSONATE_SECURITY_CONTEXT_FN   ImpersonateSecurityContext;
778     REVERT_SECURITY_CONTEXT_FN        RevertSecurityContext;
779     MAKE_SIGNATURE_FN                 MakeSignature;
780     VERIFY_SIGNATURE_FN               VerifySignature;
781     FREE_CONTEXT_BUFFER_FN            FreeContextBuffer;
782     QUERY_SECURITY_PACKAGE_INFO_FN_W  QuerySecurityPackageInfoW;
783     void                             *Reserved3;
784     void                             *Reserved4;
785     EXPORT_SECURITY_CONTEXT_FN        ExportSecurityContext;
786     IMPORT_SECURITY_CONTEXT_FN_W      ImportSecurityContextW;
787     ADD_CREDENTIALS_FN_W              AddCredentialsW;
788     void                             *Reserved8;
789     QUERY_SECURITY_CONTEXT_TOKEN_FN   QuerySecurityContextToken;
790     ENCRYPT_MESSAGE_FN                EncryptMessage;
791     DECRYPT_MESSAGE_FN                DecryptMessage;
792     SET_CONTEXT_ATTRIBUTES_FN_W       SetContextAttributesW;
793 } SecurityFunctionTableW, *PSecurityFunctionTableW;
794
795 #define SecurityFunctionTable WINELIB_NAME_AW(SecurityFunctionTable)
796 #define PSecurityFunctionTable WINELIB_NAME_AW(PSecurityFunctionTable)
797
798 #define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION   1
799 #define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 2
800
801 PSecurityFunctionTableA SEC_ENTRY InitSecurityInterfaceA(void);
802 PSecurityFunctionTableW SEC_ENTRY InitSecurityInterfaceW(void);
803 #define InitSecurityInterface WINELIB_NAME_AW(InitSecurityInterface)
804
805 typedef PSecurityFunctionTableA (SEC_ENTRY *INIT_SECURITY_INTERFACE_A)(void);
806 typedef PSecurityFunctionTableW (SEC_ENTRY *INIT_SECURITY_INTERFACE_W)(void);
807 #define INIT_SECURITY_INTERFACE WINELIB_NAME_AW(INIT_SECURITY_INTERFACE_)
808
809 #ifdef __cplusplus
810 }
811 #endif
812
813 #endif /* ndef __WINE_SSPI_H__ */