winspool: An empty string as server name is valid for AddPrinterDriver.
[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 typedef SECURITY_STATUS (SEC_ENTRY *FREE_CREDENTIALS_HANDLE_FN)(PCredHandle);
235
236 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(
237  PCredHandle phCredential, PCtxtHandle phContext,
238  SEC_CHAR *pszTargetName, unsigned long fContextReq,
239  unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
240  unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
241  unsigned long *pfContextAttr, PTimeStamp ptsExpiry);
242 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(
243  PCredHandle phCredential, PCtxtHandle phContext,
244  SEC_WCHAR *pszTargetName, unsigned long fContextReq,
245  unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
246  unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
247  unsigned long *pfContextAttr, PTimeStamp ptsExpiry);
248 #define InitializeSecurityContext WINELIB_NAME_AW(InitializeSecurityContext)
249
250 typedef SECURITY_STATUS (SEC_ENTRY *INITIALIZE_SECURITY_CONTEXT_FN_A)
251  (PCredHandle, PCtxtHandle, SEC_CHAR *, unsigned long, unsigned long,
252  unsigned long, PSecBufferDesc, unsigned long, PCtxtHandle, PSecBufferDesc,
253  unsigned long *, PTimeStamp);
254 typedef SECURITY_STATUS (SEC_ENTRY *INITIALIZE_SECURITY_CONTEXT_FN_W)
255  (PCredHandle, PCtxtHandle, SEC_WCHAR *, unsigned long, unsigned long,
256  unsigned long, PSecBufferDesc, unsigned long, PCtxtHandle, PSecBufferDesc,
257  unsigned long *, PTimeStamp);
258 #define INITIALIZE_SECURITY_CONTEXT_FN WINELIB_NAME_AW(INITIALIZE_SECURITY_CONTEXT_FN_)
259
260 /* flags for InitializeSecurityContext fContextReq and pfContextAttr */
261 #define ISC_REQ_DELEGATE               0x00000001
262 #define ISC_REQ_MUTUAL_AUTH            0x00000002
263 #define ISC_REQ_REPLAY_DETECT          0x00000004
264 #define ISC_REQ_SEQUENCE_DETECT        0x00000008
265 #define ISC_REQ_CONFIDENTIALITY        0x00000010
266 #define ISC_REQ_USE_SESSION_KEY        0x00000020
267 #define ISC_REQ_PROMPT_FOR_CREDS       0x00000040
268 #define ISC_REQ_USE_SUPPLIED_CREDS     0x00000080
269 #define ISC_REQ_ALLOCATE_MEMORY        0x00000100
270 #define ISC_REQ_USE_DCE_STYLE          0x00000200
271 #define ISC_REQ_DATAGRAM               0x00000400
272 #define ISC_REQ_CONNECTION             0x00000800
273 #define ISC_REQ_CALL_LEVEL             0x00001000
274 #define ISC_REQ_FRAGMENT_SUPPLIED      0x00002000
275 #define ISC_REQ_EXTENDED_ERROR         0x00004000
276 #define ISC_REQ_STREAM                 0x00008000
277 #define ISC_REQ_INTEGRITY              0x00001000
278 #define ISC_REQ_IDENTIFY               0x00002000
279 #define ISC_REQ_NULL_SESSION           0x00004000
280 #define ISC_REQ_MANUAL_CRED_VALIDATION 0x00080000
281 #define ISC_REQ_RESERVED1              0x00100000
282 #define ISC_REQ_FRAGMENT_TO_FIT        0x00200000
283
284 #define ISC_RET_DELEGATE               0x00000001
285 #define ISC_RET_MUTUAL_AUTH            0x00000002
286 #define ISC_RET_REPLAY_DETECT          0x00000004
287 #define ISC_RET_SEQUENCE_DETECT        0x00000008
288 #define ISC_RET_CONFIDENTIALITY        0x00000010
289 #define ISC_RET_USE_SESSION_KEY        0x00000020
290 #define ISC_RET_USED_COLLECTED_CREDS   0x00000040
291 #define ISC_RET_USED_SUPPLIED_CREDS    0x00000080
292 #define ISC_RET_ALLOCATED_MEMORY       0x00000100
293 #define ISC_RET_USED_DCE_STYLE         0x00000200
294 #define ISC_RET_DATAGRAM               0x00000400
295 #define ISC_RET_CONNECTION             0x00000800
296 #define ISC_RET_INTERMEDIATE_RETURN    0x00001000
297 #define ISC_RET_CALL_LEVEL             0x00002000
298 #define ISC_RET_EXTENDED_ERROR         0x00004000
299 #define ISC_RET_STREAM                 0x00008000
300 #define ISC_RET_INTEGRITY              0x00001000
301 #define ISC_RET_IDENTIFY               0x00002000
302 #define ISC_RET_NULL_SESSION           0x00004000
303 #define ISC_RET_MANUAL_CRED_VALIDATION 0x00080000
304 #define ISC_RET_RESERVED1              0x00100000
305 #define ISC_RET_FRAGMENT_ONLY          0x00200000
306
307 SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(
308  PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
309  unsigned long fContextReq, unsigned long TargetDataRep,
310  PCtxtHandle phNewContext, PSecBufferDesc pOutput,
311  unsigned long *pfContextAttr, PTimeStamp ptsExpiry);
312
313 typedef SECURITY_STATUS (SEC_ENTRY *ACCEPT_SECURITY_CONTEXT_FN)(PCredHandle,
314  PCtxtHandle, PSecBufferDesc, unsigned long, unsigned long, PCtxtHandle,
315  PSecBufferDesc, unsigned long *, PTimeStamp);
316
317 /* flags for AcceptSecurityContext fContextReq and pfContextAttr */
318 #define ASC_REQ_DELEGATE               0x00000001
319 #define ASC_REQ_MUTUAL_AUTH            0x00000002
320 #define ASC_REQ_REPLAY_DETECT          0x00000004
321 #define ASC_REQ_SEQUENCE_DETECT        0x00000008
322 #define ASC_REQ_CONFIDENTIALITY        0x00000010
323 #define ASC_REQ_USE_SESSION_KEY        0x00000020
324 #define ASC_REQ_ALLOCATE_MEMORY        0x00000100
325 #define ASC_REQ_USE_DCE_STYLE          0x00000200
326 #define ASC_REQ_DATAGRAM               0x00000400
327 #define ASC_REQ_CONNECTION             0x00000800
328 #define ASC_REQ_CALL_LEVEL             0x00001000
329 #define ASC_REQ_FRAGMENT_SUPPLIED      0x00002000
330 #define ASC_REQ_EXTENDED_ERROR         0x00008000
331 #define ASC_REQ_STREAM                 0x00010000
332 #define ASC_REQ_INTEGRITY              0x00020000
333 #define ASC_REQ_LICENSING              0x00040000
334 #define ASC_REQ_IDENTIFY               0x00080000
335 #define ASC_REQ_ALLOW_NULL_SESSION     0x00100000
336 #define ASC_REQ_ALLOW_NON_USER_LOGONS  0x00200000
337 #define ASC_REQ_ALLOW_CONTEXT_REPLAY   0x00400000
338 #define ASC_REQ_FRAGMENT_TO_FIT        0x00800000
339 #define ASC_REQ_FRAGMENT_NO_TOKEN      0x01000000
340
341 #define ASC_RET_DELEGATE               0x00000001
342 #define ASC_RET_MUTUAL_AUTH            0x00000002
343 #define ASC_RET_REPLAY_DETECT          0x00000004
344 #define ASC_RET_SEQUENCE_DETECT        0x00000008
345 #define ASC_RET_CONFIDENTIALITY        0x00000010
346 #define ASC_RET_USE_SESSION_KEY        0x00000020
347 #define ASC_RET_ALLOCATED_MEMORY       0x00000100
348 #define ASC_RET_USED_DCE_STYLE         0x00000200
349 #define ASC_RET_DATAGRAM               0x00000400
350 #define ASC_RET_CONNECTION             0x00000800
351 #define ASC_RET_CALL_LEVEL             0x00002000
352 #define ASC_RET_THIRD_LEG_FAILED       0x00004000
353 #define ASC_RET_EXTENDED_ERROR         0x00008000
354 #define ASC_RET_STREAM                 0x00010000
355 #define ASC_RET_INTEGRITY              0x00020000
356 #define ASC_RET_LICENSING              0x00040000
357 #define ASC_RET_IDENTIFY               0x00080000
358 #define ASC_RET_NULL_SESSION           0x00100000
359 #define ASC_RET_ALLOW_NON_USER_LOGONS  0x00200000
360 #define ASC_RET_ALLOW_CONTEXT_REPLAY   0x00400000
361 #define ASC_RET_FRAGMENT_ONLY          0x00800000
362 #define ASC_RET_NO_TOKEN               0x01000000
363
364 /* values for TargetDataRep */
365 #define SECURITY_NATIVE_DREP  0x00000010
366 #define SECURITY_NETWORK_DREP 0x00000000
367
368 SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext,
369  PSecBufferDesc pToken);
370
371 typedef SECURITY_STATUS (SEC_ENTRY *COMPLETE_AUTH_TOKEN_FN)(PCtxtHandle,
372  PSecBufferDesc);
373
374 SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext);
375
376 typedef SECURITY_STATUS (SEC_ENTRY *DELETE_SECURITY_CONTEXT_FN)(PCtxtHandle);
377
378 SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext,
379  PSecBufferDesc pInput);
380
381 typedef SECURITY_STATUS (SEC_ENTRY *APPLY_CONTROL_TOKEN_FN)(PCtxtHandle,
382  PSecBufferDesc);
383
384 SECURITY_STATUS SEC_ENTRY QueryContextAttributesA(PCtxtHandle phContext,
385  unsigned long ulAttribute, void *pBuffer);
386 SECURITY_STATUS SEC_ENTRY QueryContextAttributesW(PCtxtHandle phContext,
387  unsigned long ulAttribute, void *pBuffer);
388 #define QueryContextAttributes WINELIB_NAME_AW(QueryContextAttributes)
389
390 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle,
391  unsigned long, void *);
392 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle,
393  unsigned long, void *);
394 #define QUERY_CONTEXT_ATTRIBUTES_FN WINELIB_NAME_AW(QUERY_CONTEXT_ATTRIBUTES_FN_)
395
396 /* values for QueryContextAttributes/SetContextAttributes ulAttribute */
397 #define SECPKG_ATTR_SIZES               0
398 #define SECPKG_ATTR_NAMES               1
399 #define SECPKG_ATTR_LIFESPAN            2
400 #define SECPKG_ATTR_DCE_INFO            3
401 #define SECPKG_ATTR_STREAM_SIZES        4
402 #define SECPKG_ATTR_KEY_INFO            5
403 #define SECPKG_ATTR_AUTHORITY           6
404 #define SECPKG_ATTR_PROTO_INFO          7
405 #define SECPKG_ATTR_PASSWORD_EXPIRY     8
406 #define SECPKG_ATTR_SESSION_KEY         9
407 #define SECPKG_ATTR_PACKAGE_INFO       10
408 #define SECPKG_ATTR_USER_FLAGS         11
409 #define SECPKG_ATTR_NEGOTIATION_INFO   12
410 #define SECPKG_ATTR_NATIVE_NAMES       13
411 #define SECPKG_ATTR_FLAGS              14
412 #define SECPKG_ATTR_USE_VALIDATED      15
413 #define SECPKG_ATTR_CREDENTIAL_NAME    16
414 #define SECPKG_ATTR_TARGET_INFORMATION 17
415 #define SECPKG_ATTR_ACCESS_TOKEN       18
416 #define SECPKG_ATTR_TARGET             19
417 #define SECPKG_ATTR_AUTHENTICATION_ID  20
418
419 /* types for QueryContextAttributes/SetContextAttributes */
420
421 typedef struct _SecPkgContext_Sizes
422 {
423     unsigned long cbMaxToken;
424     unsigned long cbMaxSignature;
425     unsigned long cbBlockSize;
426     unsigned long cbSecurityTrailer;
427 } SecPkgContext_Sizes, *PSecPkgContext_Sizes;
428
429 typedef struct _SecPkgContext_StreamSizes
430 {
431     unsigned long cbHeader;
432     unsigned long cbTrailer;
433     unsigned long cbMaximumMessage;
434     unsigned long cbBuffers;
435     unsigned long cbBlockSize;
436 } SecPkgContext_StreamSizes, *PSecPkgContext_StreamSizes;
437
438 typedef struct _SecPkgContext_NamesA
439 {
440     SEC_CHAR *sUserName;
441 } SecPkgContext_NamesA, *PSecPkgContext_NamesA;
442
443 typedef struct _SecPkgContext_NamesW
444 {
445     SEC_WCHAR *sUserName;
446 } SecPkgContext_NamesW, *PSecPkgContext_NamesW;
447
448 #define SecPkgContext_Names WINELIB_NAME_AW(SecPkgContext_Names)
449 #define PSecPkgContext_Names WINELIB_NAME_AW(PSecPkgContext_Names)
450
451 typedef struct _SecPkgContext_Lifespan
452 {
453     TimeStamp tsStart;
454     TimeStamp tsExpiry;
455 } SecPkgContext_Lifespan, *PSecPkgContext_Lifespan;
456
457 typedef struct _SecPkgContext_DceInfo
458 {
459     unsigned long AuthzSvc;
460     void *pPac;
461 } SecPkgContext_DceInfo, *PSecPkgContext_DceInfo;
462
463 typedef struct _SecPkgContext_KeyInfoA
464 {
465     SEC_CHAR      *sSignatureAlgorithmName;
466     SEC_CHAR      *sEncryptAlgorithmName;
467     unsigned long  KeySize;
468     unsigned long  SignatureAlgorithm;
469     unsigned long  EncryptAlgorithm;
470 } SecPkgContext_KeyInfoA, *PSecPkgContext_KeyInfoA;
471
472 typedef struct _SecPkgContext_KeyInfoW
473 {
474     SEC_WCHAR     *sSignatureAlgorithmName;
475     SEC_WCHAR     *sEncryptAlgorithmName;
476     unsigned long  KeySize;
477     unsigned long  SignatureAlgorithm;
478     unsigned long  EncryptAlgorithm;
479 } SecPkgContext_KeyInfoW, *PSecPkgContext_KeyInfoW;
480
481 #define SecPkgContext_KeyInfo WINELIB_NAME_AW(SecPkgContext_KeyInfo)
482 #define PSecPkgContext_KeyInfo WINELIB_NAME_AW(PSecPkgContext_KeyInfo)
483
484 typedef struct _SecPkgContext_AuthorityA
485 {
486     SEC_CHAR *sAuthorityName;
487 } SecPkgContext_AuthorityA, *PSecPkgContext_AuthorityA;
488
489 typedef struct _SecPkgContext_AuthorityW
490 {
491     SEC_WCHAR *sAuthorityName;
492 } SecPkgContext_AuthorityW, *PSecPkgContext_AuthorityW;
493
494 #define SecPkgContext_Authority WINELIB_NAME_AW(SecPkgContext_Authority)
495 #define PSecPkgContext_Authority WINELIB_NAME_AW(PSecPkgContext_Authority)
496
497 typedef struct _SecPkgContext_ProtoInfoA
498 {
499     SEC_CHAR     *sProtocolName;
500     unsigned long majorVersion;
501     unsigned long minorVersion;
502 } SecPkgContext_ProtoInfoA, *PSecPkgContext_ProtoInfoA;
503
504 typedef struct _SecPkgContext_ProtoInfoW
505 {
506     SEC_WCHAR    *sProtocolName;
507     unsigned long majorVersion;
508     unsigned long minorVersion;
509 } SecPkgContext_ProtoInfoW, *PSecPkgContext_ProtoInfoW;
510
511 #define SecPkgContext_ProtoInfo WINELIB_NAME_AW(SecPkgContext_ProtoInfo)
512 #define PSecPkgContext_ProtoInfo WINELIB_NAME_AW(PSecPkgContext_ProtoInfo)
513
514 typedef struct _SecPkgContext_PasswordExpiry
515 {
516     TimeStamp tsPasswordExpires;
517 } SecPkgContext_PasswordExpiry, *PSecPkgContext_PasswordExpiry;
518
519 typedef struct _SecPkgContext_SessionKey
520 {
521     unsigned long  SessionKeyLength;
522     unsigned char *SessionKey;
523 } SecPkgContext_SessionKey, *PSecPkgContext_SessionKey;
524
525 typedef struct _SecPkgContext_PackageInfoA
526 {
527     PSecPkgInfoA PackageInfo;
528 } SecPkgContext_PackageInfoA, *PSecPkgContext_PackageInfoA;
529
530 typedef struct _SecPkgContext_PackageInfoW
531 {
532     PSecPkgInfoW PackageInfo;
533 } SecPkgContext_PackageInfoW, *PSecPkgContext_PackageInfoW;
534
535 #define SecPkgContext_PackageInfo WINELIB_NAME_AW(SecPkgContext_PackageInfo)
536 #define PSecPkgContext_PackageInfo WINELIB_NAME_AW(PSecPkgContext_PackageInfo)
537
538 typedef struct _SecPkgContext_Flags
539 {
540     unsigned long Flags;
541 } SecPkgContext_Flags, *PSecPkgContext_Flags;
542
543 typedef struct _SecPkgContext_UserFlags
544 {
545     unsigned long UserFlags;
546 } SecPkgContext_UserFlags, *PSecPkgContext_UserFlags;
547
548 typedef struct _SecPkgContext_NegotiationInfoA
549 {
550     PSecPkgInfoA  PackageInfo;
551     unsigned long NegotiationState;
552 } SecPkgContext_NegotiationInfoA, *PSecPkgContext_NegotiationInfoA;
553
554 typedef struct _SecPkgContext_NegotiationInfoW
555 {
556     PSecPkgInfoW  PackageInfo;
557     unsigned long NegotiationState;
558 } SecPkgContext_NegotiationInfoW, *PSecPkgContext_NegotiationInfoW;
559
560 #define SecPkgContext_NegotiationInfo WINELIB_NAME_AW(SecPkgContext_NegotiationInfo)
561 #define PSecPkgContext_NegotiationInfo WINELIB_NAME_AW(PSecPkgContext_NegotiationInfo)
562
563 /* values for NegotiationState */
564 #define SECPKG_NEGOTIATION_COMPLETE      0
565 #define SECPKG_NEGOTIATION_OPTIMISTIC    1
566 #define SECPKG_NEGOTIATION_IN_PROGRESS   2
567 #define SECPKG_NEGOTIATION_DIRECT        3
568 #define SECPKG_NEGOTIATION_TRY_MULTICRED 4
569
570 typedef struct _SecPkgContext_NativeNamesA
571 {
572     SEC_CHAR *sClientName;
573     SEC_CHAR *sServerName;
574 } SecPkgContext_NativeNamesA, *PSecPkgContext_NativeNamesA;
575
576 typedef struct _SecPkgContext_NativeNamesW
577 {
578     SEC_WCHAR *sClientName;
579     SEC_WCHAR *sServerName;
580 } SecPkgContext_NativeNamesW, *PSecPkgContext_NativeNamesW;
581
582 #define SecPkgContext_NativeNames WINELIB_NAME_AW(SecPkgContext_NativeNames)
583 #define PSecPkgContext_NativeNames WINELIB_NAME_AW(PSecPkgContext_NativeNames)
584
585 typedef struct _SecPkgContext_CredentialNameA
586 {
587     unsigned long  CredentialType;
588     SEC_CHAR      *sCredentialName;
589 } SecPkgContext_CredentialNameA, *PSecPkgContext_CredentialNameA;
590
591 typedef struct _SecPkgContext_CredentialNameW
592 {
593     unsigned long  CredentialType;
594     SEC_WCHAR     *sCredentialName;
595 } SecPkgContext_CredentialNameW, *PSecPkgContext_CredentialNameW;
596
597 #define SecPkgContext_CredentialName WINELIB_NAME_AW(SecPkgContext_CredentialName)
598 #define PSecPkgContext_CredentialName WINELIB_NAME_AW(PSecPkgContext_CredentialName)
599
600 typedef struct _SecPkgContext_AccessToken
601 {
602     void *AccessToken;
603 } SecPkgContext_AccessToken, *PSecPkgContext_AccessToken;
604
605 typedef struct _SecPkgContext_TargetInformation
606 {
607     unsigned long  MarshalledTargetInfoLength;
608     unsigned char *MarshalledTargetInfo;
609 } SecPkgContext_TargetInformation, *PSecPkgContext_TargetInformation;
610
611 typedef struct _SecPkgContext_AuthzID
612 {
613     unsigned long  AuthzIDLength;
614     char          *AuthzID;
615 } SecPkgContext_AuthzID, *PSecPkgContext_AuthzID;
616
617 typedef struct _SecPkgContext_Target
618 {
619     unsigned long  TargetLength;
620     char          *Target;
621 } SecPkgContext_Target, *PSecPkgContext_Target;
622
623 SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext);
624
625 typedef SECURITY_STATUS (SEC_ENTRY *IMPERSONATE_SECURITY_CONTEXT_FN)
626  (PCtxtHandle);
627
628 SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext);
629
630 typedef SECURITY_STATUS (SEC_ENTRY *REVERT_SECURITY_CONTEXT_FN)(PCtxtHandle);
631
632 SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext,
633  ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo);
634
635 typedef SECURITY_STATUS (SEC_ENTRY *MAKE_SIGNATURE_FN)(PCtxtHandle,
636  ULONG, PSecBufferDesc, ULONG);
637
638 SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext,
639  PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
640
641 typedef SECURITY_STATUS (SEC_ENTRY *VERIFY_SIGNATURE_FN)(PCtxtHandle,
642  PSecBufferDesc, ULONG, PULONG);
643
644 SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(
645  SEC_CHAR *pszPackageName, PSecPkgInfoA *ppPackageInfo);
646 SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(
647  SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo);
648 #define QuerySecurityPackageInfo WINELIB_NAME_AW(QuerySecurityPackageInfo)
649
650 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_SECURITY_PACKAGE_INFO_FN_A)
651  (SEC_CHAR *, PSecPkgInfoA *);
652 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_SECURITY_PACKAGE_INFO_FN_W)
653  (SEC_WCHAR *, PSecPkgInfoW *);
654 #define QUERY_SECURITY_PACKAGE_INFO_FN WINELIB_NAME_AW(QUERY_SECURITY_PACKAGE_INFO_FN_)
655
656 SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext,
657  ULONG fFlags, PSecBuffer pPackedContext, void **pToken);
658
659 typedef SECURITY_STATUS (SEC_ENTRY *EXPORT_SECURITY_CONTEXT_FN)(PCtxtHandle,
660  ULONG, PSecBuffer, void **);
661
662 /* values for ExportSecurityContext fFlags */
663 #define SECPKG_CONTEXT_EXPORT_RESET_NEW  0x00000001
664 #define SECPKG_CONTEXT_EXPORT_DELETE_OLD 0x00000002
665
666 SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR *pszPackage,
667  PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext);
668 SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR *pszPackage,
669  PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext);
670 #define ImportSecurityContext WINELIB_NAME_AW(ImportSecurityContext)
671
672 typedef SECURITY_STATUS (SEC_ENTRY *IMPORT_SECURITY_CONTEXT_FN_A)(SEC_CHAR *,
673  PSecBuffer, void *, PCtxtHandle);
674 typedef SECURITY_STATUS (SEC_ENTRY *IMPORT_SECURITY_CONTEXT_FN_W)(SEC_WCHAR *,
675  PSecBuffer, void *, PCtxtHandle);
676 #define IMPORT_SECURITY_CONTEXT_FN WINELIB_NAME_AW(IMPORT_SECURITY_CONTEXT_FN_)
677
678 SECURITY_STATUS SEC_ENTRY AddCredentialsA(PCredHandle hCredentials,
679  SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, unsigned long fCredentialUse,
680  void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
681  PTimeStamp ptsExpiry);
682 SECURITY_STATUS SEC_ENTRY AddCredentialsW(PCredHandle hCredentials,
683  SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, unsigned long fCredentialUse,
684  void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
685  PTimeStamp ptsExpiry);
686 #define AddCredentials WINELIB_NAME_AW(AddCredentials)
687
688 typedef SECURITY_STATUS (SEC_ENTRY *ADD_CREDENTIALS_FN_A)(PCredHandle,
689  SEC_CHAR *, SEC_CHAR *, unsigned long, void *, SEC_GET_KEY_FN, void *,
690  PTimeStamp);
691 typedef SECURITY_STATUS (SEC_ENTRY *ADD_CREDENTIALS_FN_W)(PCredHandle,
692  SEC_WCHAR *, SEC_WCHAR *, unsigned long, void *, SEC_GET_KEY_FN, void *,
693  PTimeStamp);
694
695 SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext,
696  HANDLE *phToken);
697
698 typedef SECURITY_STATUS (SEC_ENTRY *QUERY_SECURITY_CONTEXT_TOKEN_FN)
699  (PCtxtHandle, HANDLE *);
700
701 SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
702  PSecBufferDesc pMessage, ULONG MessageSeqNo);
703 SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext,
704  PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP);
705
706 /* values for EncryptMessage fQOP */
707 #define SECQOP_WRAP_NO_ENCRYPT 0x80000001
708
709 typedef SECURITY_STATUS (SEC_ENTRY *ENCRYPT_MESSAGE_FN)(PCtxtHandle, ULONG,
710  PSecBufferDesc, ULONG);
711 typedef SECURITY_STATUS (SEC_ENTRY *DECRYPT_MESSAGE_FN)(PCtxtHandle,
712  PSecBufferDesc, ULONG, PULONG);
713
714 SECURITY_STATUS SEC_ENTRY SetContextAttributesA(PCtxtHandle phContext,
715  unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer);
716 SECURITY_STATUS SEC_ENTRY SetContextAttributesW(PCtxtHandle phContext,
717  unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer);
718 #define SetContextAttributes WINELIB_NAME_AW(SetContextAttributes)
719
720 typedef SECURITY_STATUS (SEC_ENTRY *SET_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle,
721  unsigned long, void *, unsigned long);
722 typedef SECURITY_STATUS (SEC_ENTRY *SET_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle,
723  unsigned long, void *, unsigned long);
724
725 #define SECURITY_ENTRYPOINT_ANSIA "InitSecurityInterfaceA"
726 #define SECURITY_ENTRYPOINT_ANSIW "InitSecurityInterfaceW"
727 #define SECURITY_ENTRYPOINT_ANSI WINELIB_NAME_AW(SECURITY_ENTRYPOINT_ANSI)
728
729 typedef struct _SECURITY_FUNCTION_TABLE_A
730 {
731     unsigned long                     dwVersion;
732     ENUMERATE_SECURITY_PACKAGES_FN_A  EnumerateSecurityPackagesA;
733     QUERY_CREDENTIALS_ATTRIBUTES_FN_A QueryCredentialsAttributesA;
734     ACQUIRE_CREDENTIALS_HANDLE_FN_A   AcquireCredentialsHandleA;
735     FREE_CREDENTIALS_HANDLE_FN        FreeCredentialsHandle;
736     void                             *Reserved2;
737     INITIALIZE_SECURITY_CONTEXT_FN_A  InitializeSecurityContextA;
738     ACCEPT_SECURITY_CONTEXT_FN        AcceptSecurityContext;
739     COMPLETE_AUTH_TOKEN_FN            CompleteAuthToken;
740     DELETE_SECURITY_CONTEXT_FN        DeleteSecurityContext;
741     APPLY_CONTROL_TOKEN_FN            ApplyControlToken;
742     QUERY_CONTEXT_ATTRIBUTES_FN_A     QueryContextAttributesA;
743     IMPERSONATE_SECURITY_CONTEXT_FN   ImpersonateSecurityContext;
744     REVERT_SECURITY_CONTEXT_FN        RevertSecurityContext;
745     MAKE_SIGNATURE_FN                 MakeSignature;
746     VERIFY_SIGNATURE_FN               VerifySignature;
747     FREE_CONTEXT_BUFFER_FN            FreeContextBuffer;
748     QUERY_SECURITY_PACKAGE_INFO_FN_A  QuerySecurityPackageInfoA;
749     void                             *Reserved3;
750     void                             *Reserved4;
751     EXPORT_SECURITY_CONTEXT_FN        ExportSecurityContext;
752     IMPORT_SECURITY_CONTEXT_FN_A      ImportSecurityContextA;
753     ADD_CREDENTIALS_FN_A              AddCredentialsA;
754     void                             *Reserved8;
755     QUERY_SECURITY_CONTEXT_TOKEN_FN   QuerySecurityContextToken;
756     ENCRYPT_MESSAGE_FN                EncryptMessage;
757     DECRYPT_MESSAGE_FN                DecryptMessage;
758     SET_CONTEXT_ATTRIBUTES_FN_A       SetContextAttributesA;
759 } SecurityFunctionTableA, *PSecurityFunctionTableA;
760
761 typedef struct _SECURITY_FUNCTION_TABLE_W
762 {
763     unsigned long                     dwVersion;
764     ENUMERATE_SECURITY_PACKAGES_FN_W  EnumerateSecurityPackagesW;
765     QUERY_CREDENTIALS_ATTRIBUTES_FN_W QueryCredentialsAttributesW;
766     ACQUIRE_CREDENTIALS_HANDLE_FN_W   AcquireCredentialsHandleW;
767     FREE_CREDENTIALS_HANDLE_FN        FreeCredentialsHandle;
768     void                             *Reserved2;
769     INITIALIZE_SECURITY_CONTEXT_FN_W  InitializeSecurityContextW;
770     ACCEPT_SECURITY_CONTEXT_FN        AcceptSecurityContext;
771     COMPLETE_AUTH_TOKEN_FN            CompleteAuthToken;
772     DELETE_SECURITY_CONTEXT_FN        DeleteSecurityContext;
773     APPLY_CONTROL_TOKEN_FN            ApplyControlToken;
774     QUERY_CONTEXT_ATTRIBUTES_FN_W     QueryContextAttributesW;
775     IMPERSONATE_SECURITY_CONTEXT_FN   ImpersonateSecurityContext;
776     REVERT_SECURITY_CONTEXT_FN        RevertSecurityContext;
777     MAKE_SIGNATURE_FN                 MakeSignature;
778     VERIFY_SIGNATURE_FN               VerifySignature;
779     FREE_CONTEXT_BUFFER_FN            FreeContextBuffer;
780     QUERY_SECURITY_PACKAGE_INFO_FN_W  QuerySecurityPackageInfoW;
781     void                             *Reserved3;
782     void                             *Reserved4;
783     EXPORT_SECURITY_CONTEXT_FN        ExportSecurityContext;
784     IMPORT_SECURITY_CONTEXT_FN_W      ImportSecurityContextW;
785     ADD_CREDENTIALS_FN_W              AddCredentialsW;
786     void                             *Reserved8;
787     QUERY_SECURITY_CONTEXT_TOKEN_FN   QuerySecurityContextToken;
788     ENCRYPT_MESSAGE_FN                EncryptMessage;
789     DECRYPT_MESSAGE_FN                DecryptMessage;
790     SET_CONTEXT_ATTRIBUTES_FN_W       SetContextAttributesW;
791 } SecurityFunctionTableW, *PSecurityFunctionTableW;
792
793 #define SecurityFunctionTable WINELIB_NAME_AW(SecurityFunctionTable)
794 #define PSecurityFunctionTable WINELIB_NAME_AW(PSecurityFunctionTable)
795
796 #define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION   1
797 #define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 2
798
799 PSecurityFunctionTableA SEC_ENTRY InitSecurityInterfaceA(void);
800 PSecurityFunctionTableW SEC_ENTRY InitSecurityInterfaceW(void);
801 #define InitSecurityInterface WINELIB_NAME_AW(InitSecurityInterface)
802
803 typedef PSecurityFunctionTableA (SEC_ENTRY *INIT_SECURITY_INTERFACE_A)(void);
804 typedef PSecurityFunctionTableW (SEC_ENTRY *INIT_SECURITY_INTERFACE_W)(void);
805 #define INIT_SECURITY_INTERFACE WINELIB_NAME_AW(INIT_SECURITY_INTERFACE_)
806
807 #ifdef __cplusplus
808 }
809 #endif
810
811 #endif /* ndef __WINE_SSPI_H__ */