ddraw/tests: Rewrite LimitTest().
[wine.git] / dlls / secur32 / kerberos.c
blob753e9748d20ee70812aa24bd60346eee862b3390
1 /*
2 * Copyright 2005, 2006 Kai Blin
3 * Copyright 2016 Jacek Caban for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <assert.h>
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "rpc.h"
27 #include "sspi.h"
29 #include "secur32_priv.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(secur32);
35 #define KERBEROS_MAX_BUF 12000
37 /***********************************************************************
38 * QueryCredentialsAttributesA
40 static SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesA(CredHandle *phCredential, ULONG ulAttribute, void *pBuffer)
42 FIXME("(%p %d %p)\n", phCredential, ulAttribute, pBuffer);
43 return SEC_E_UNSUPPORTED_FUNCTION;
46 /***********************************************************************
47 * QueryCredentialsAttributesW
49 static SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesW(CredHandle *phCredential, ULONG ulAttribute, void *pBuffer)
51 FIXME("(%p, %d, %p)\n", phCredential, ulAttribute, pBuffer);
52 return SEC_E_UNSUPPORTED_FUNCTION;
55 /***********************************************************************
56 * AcquireCredentialsHandleW
58 static SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
59 LUID *pLogonID, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pGetKeyArgument, CredHandle *phCredential, TimeStamp *ptsExpiry)
61 FIXME("(%s %s 0x%08x %p %p %p %p %p %p)\n", debugstr_w(pszPrincipal), debugstr_w(pszPackage), fCredentialUse,
62 pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
63 return SEC_E_NO_CREDENTIALS;
66 /***********************************************************************
67 * AcquireCredentialsHandleA
69 static SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleA(SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
70 LUID *pLogonID, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pGetKeyArgument, CredHandle *phCredential, TimeStamp *ptsExpiry)
72 FIXME("(%s %s 0x%08x %p %p %p %p %p %p)\n", debugstr_a(pszPrincipal), debugstr_a(pszPackage), fCredentialUse,
73 pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
74 return SEC_E_UNSUPPORTED_FUNCTION;
77 /***********************************************************************
78 * InitializeSecurityContextW
80 static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextW(CredHandle *phCredential, CtxtHandle *phContext, SEC_WCHAR *pszTargetName,
81 ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, SecBufferDesc *pInput, ULONG Reserved2, CtxtHandle *phNewContext,
82 SecBufferDesc *pOutput, ULONG *pfContextAttr, TimeStamp *ptsExpiry)
84 FIXME("(%p %p %s 0x%08x %d %d %p %d %p %p %p %p)\n", phCredential, phContext, debugstr_w(pszTargetName),
85 fContextReq, Reserved1, TargetDataRep, pInput, Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
86 return SEC_E_UNSUPPORTED_FUNCTION;
89 /***********************************************************************
90 * InitializeSecurityContextA
92 static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(CredHandle *phCredential, CtxtHandle *phContext, SEC_CHAR *pszTargetName,
93 ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, SecBufferDesc *pInput, ULONG Reserved2, CtxtHandle *phNewContext,
94 SecBufferDesc *pOutput, ULONG *pfContextAttr, TimeStamp *ptsExpiry)
96 FIXME("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext, debugstr_a(pszTargetName), fContextReq,
97 Reserved1, TargetDataRep, pInput, Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
98 return SEC_E_UNSUPPORTED_FUNCTION;
101 /***********************************************************************
102 * AcceptSecurityContext
104 static SECURITY_STATUS SEC_ENTRY kerberos_AcceptSecurityContext(CredHandle *phCredential, CtxtHandle *phContext, SecBufferDesc *pInput,
105 ULONG fContextReq, ULONG TargetDataRep, CtxtHandle *phNewContext, SecBufferDesc *pOutput, ULONG *pfContextAttr, TimeStamp *ptsExpiry)
107 FIXME("(%p %p %p %d %d %p %p %p %p)\n", phCredential, phContext, pInput, fContextReq, TargetDataRep, phNewContext, pOutput,
108 pfContextAttr, ptsExpiry);
109 return SEC_E_UNSUPPORTED_FUNCTION;
112 /***********************************************************************
113 * CompleteAuthToken
115 static SECURITY_STATUS SEC_ENTRY kerberos_CompleteAuthToken(CtxtHandle *phContext, SecBufferDesc *pToken)
117 FIXME("(%p %p)\n", phContext, pToken);
118 return SEC_E_UNSUPPORTED_FUNCTION;
121 /***********************************************************************
122 * DeleteSecurityContext
124 static SECURITY_STATUS SEC_ENTRY kerberos_DeleteSecurityContext(CtxtHandle *phContext)
126 FIXME("(%p)\n", phContext);
127 return SEC_E_UNSUPPORTED_FUNCTION;
130 /***********************************************************************
131 * QueryContextAttributesW
133 static SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesW(CtxtHandle *phContext, ULONG ulAttribute, void *pBuffer)
135 FIXME("(%p %d %p)\n", phContext, ulAttribute, pBuffer);
136 return SEC_E_UNSUPPORTED_FUNCTION;
139 /***********************************************************************
140 * QueryContextAttributesA
142 static SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesA(CtxtHandle *phContext, ULONG ulAttribute, void *pBuffer)
144 FIXME("(%p %d %p)\n", phContext, ulAttribute, pBuffer);
145 return SEC_E_UNSUPPORTED_FUNCTION;
148 /***********************************************************************
149 * ImpersonateSecurityContext
151 static SECURITY_STATUS SEC_ENTRY kerberos_ImpersonateSecurityContext(CtxtHandle *phContext)
153 FIXME("(%p)\n", phContext);
154 return SEC_E_UNSUPPORTED_FUNCTION;
157 /***********************************************************************
158 * RevertSecurityContext
160 static SECURITY_STATUS SEC_ENTRY kerberos_RevertSecurityContext(CtxtHandle *phContext)
162 FIXME("(%p)\n", phContext);
163 return SEC_E_UNSUPPORTED_FUNCTION;
166 /***********************************************************************
167 * MakeSignature
169 static SECURITY_STATUS SEC_ENTRY kerberos_MakeSignature(CtxtHandle *phContext, ULONG fQOP, SecBufferDesc *pMessage, ULONG MessageSeqNo)
171 FIXME("(%p %d %p %d)\n", phContext, fQOP, pMessage, MessageSeqNo);
172 return SEC_E_UNSUPPORTED_FUNCTION;
175 /***********************************************************************
176 * VerifySignature
178 static SECURITY_STATUS SEC_ENTRY kerberos_VerifySignature(CtxtHandle *phContext, SecBufferDesc *pMessage, ULONG MessageSeqNo, PULONG pfQOP)
180 FIXME("(%p %p %d %p)\n", phContext, pMessage, MessageSeqNo, pfQOP);
181 return SEC_E_UNSUPPORTED_FUNCTION;
184 /***********************************************************************
185 * FreeCredentialsHandle
187 static SECURITY_STATUS SEC_ENTRY kerberos_FreeCredentialsHandle(PCredHandle phCredential)
189 FIXME("(%p)\n", phCredential);
190 return SEC_E_UNSUPPORTED_FUNCTION;
193 /***********************************************************************
194 * EncryptMessage
196 static SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(CtxtHandle *phContext, ULONG fQOP, SecBufferDesc *pMessage, ULONG MessageSeqNo)
198 FIXME("(%p %d %p %d)\n", phContext, fQOP, pMessage, MessageSeqNo);
199 return SEC_E_UNSUPPORTED_FUNCTION;
202 /***********************************************************************
203 * DecryptMessage
205 static SECURITY_STATUS SEC_ENTRY kerberos_DecryptMessage(CtxtHandle *phContext, SecBufferDesc *pMessage, ULONG MessageSeqNo, PULONG pfQOP)
207 FIXME("(%p %p %d %p)\n", phContext, pMessage, MessageSeqNo, pfQOP);
208 return SEC_E_UNSUPPORTED_FUNCTION;
211 static const SecurityFunctionTableA kerberosTableA = {
213 NULL, /* EnumerateSecurityPackagesA */
214 kerberos_QueryCredentialsAttributesA, /* QueryCredentialsAttributesA */
215 kerberos_AcquireCredentialsHandleA, /* AcquireCredentialsHandleA */
216 kerberos_FreeCredentialsHandle, /* FreeCredentialsHandle */
217 NULL, /* Reserved2 */
218 kerberos_InitializeSecurityContextA, /* InitializeSecurityContextA */
219 kerberos_AcceptSecurityContext, /* AcceptSecurityContext */
220 kerberos_CompleteAuthToken, /* CompleteAuthToken */
221 kerberos_DeleteSecurityContext, /* DeleteSecurityContext */
222 NULL, /* ApplyControlToken */
223 kerberos_QueryContextAttributesA, /* QueryContextAttributesA */
224 kerberos_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
225 kerberos_RevertSecurityContext, /* RevertSecurityContext */
226 kerberos_MakeSignature, /* MakeSignature */
227 kerberos_VerifySignature, /* VerifySignature */
228 FreeContextBuffer, /* FreeContextBuffer */
229 NULL, /* QuerySecurityPackageInfoA */
230 NULL, /* Reserved3 */
231 NULL, /* Reserved4 */
232 NULL, /* ExportSecurityContext */
233 NULL, /* ImportSecurityContextA */
234 NULL, /* AddCredentialsA */
235 NULL, /* Reserved8 */
236 NULL, /* QuerySecurityContextToken */
237 kerberos_EncryptMessage, /* EncryptMessage */
238 kerberos_DecryptMessage, /* DecryptMessage */
239 NULL, /* SetContextAttributesA */
242 static const SecurityFunctionTableW kerberosTableW = {
244 NULL, /* EnumerateSecurityPackagesW */
245 kerberos_QueryCredentialsAttributesW, /* QueryCredentialsAttributesW */
246 kerberos_AcquireCredentialsHandleW, /* AcquireCredentialsHandleW */
247 kerberos_FreeCredentialsHandle, /* FreeCredentialsHandle */
248 NULL, /* Reserved2 */
249 kerberos_InitializeSecurityContextW, /* InitializeSecurityContextW */
250 kerberos_AcceptSecurityContext, /* AcceptSecurityContext */
251 kerberos_CompleteAuthToken, /* CompleteAuthToken */
252 kerberos_DeleteSecurityContext, /* DeleteSecurityContext */
253 NULL, /* ApplyControlToken */
254 kerberos_QueryContextAttributesW, /* QueryContextAttributesW */
255 kerberos_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
256 kerberos_RevertSecurityContext, /* RevertSecurityContext */
257 kerberos_MakeSignature, /* MakeSignature */
258 kerberos_VerifySignature, /* VerifySignature */
259 FreeContextBuffer, /* FreeContextBuffer */
260 NULL, /* QuerySecurityPackageInfoW */
261 NULL, /* Reserved3 */
262 NULL, /* Reserved4 */
263 NULL, /* ExportSecurityContext */
264 NULL, /* ImportSecurityContextW */
265 NULL, /* AddCredentialsW */
266 NULL, /* Reserved8 */
267 NULL, /* QuerySecurityContextToken */
268 kerberos_EncryptMessage, /* EncryptMessage */
269 kerberos_DecryptMessage, /* DecryptMessage */
270 NULL, /* SetContextAttributesW */
273 #define KERBEROS_COMMENT \
274 {'M','i','c','r','o','s','o','f','t',' ','K','e','r','b','e','r','o','s',' ','V','1','.','0',0}
275 static CHAR kerberos_comment_A[] = KERBEROS_COMMENT;
276 static WCHAR kerberos_comment_W[] = KERBEROS_COMMENT;
278 #define KERBEROS_NAME {'K','e','r','b','e','r','o','s',0}
279 static char kerberos_name_A[] = KERBEROS_NAME;
280 static WCHAR kerberos_name_W[] = KERBEROS_NAME;
282 #define CAPS \
283 ( SECPKG_FLAG_INTEGRITY \
284 | SECPKG_FLAG_PRIVACY \
285 | SECPKG_FLAG_TOKEN_ONLY \
286 | SECPKG_FLAG_DATAGRAM \
287 | SECPKG_FLAG_CONNECTION \
288 | SECPKG_FLAG_MULTI_REQUIRED \
289 | SECPKG_FLAG_EXTENDED_ERROR \
290 | SECPKG_FLAG_IMPERSONATION \
291 | SECPKG_FLAG_ACCEPT_WIN32_NAME \
292 | SECPKG_FLAG_NEGOTIABLE \
293 | SECPKG_FLAG_GSS_COMPATIBLE \
294 | SECPKG_FLAG_LOGON \
295 | SECPKG_FLAG_MUTUAL_AUTH \
296 | SECPKG_FLAG_DELEGATION \
297 | SECPKG_FLAG_READONLY_WITH_CHECKSUM \
298 | SECPKG_FLAG_RESTRICTED_TOKENS \
299 | SECPKG_FLAG_APPCONTAINER_CHECKS)
301 static const SecPkgInfoW infoW = {
302 CAPS,
304 RPC_C_AUTHN_GSS_KERBEROS,
305 KERBEROS_MAX_BUF,
306 kerberos_name_W,
307 kerberos_comment_W
310 static const SecPkgInfoA infoA = {
311 CAPS,
313 RPC_C_AUTHN_GSS_KERBEROS,
314 KERBEROS_MAX_BUF,
315 kerberos_name_A,
316 kerberos_comment_A
319 void SECUR32_initKerberosSP(void)
321 SecureProvider *provider = SECUR32_addProvider(&kerberosTableA, &kerberosTableW, NULL);
322 SECUR32_addPackages(provider, 1, &infoA, &infoW);