jscript: Update Italian translation.
[wine/multimedia.git] / dlls / secur32 / negotiate.c
blob830bc5d6c212c2840b4c034bba8165577b05cd25
1 /*
2 * Copyright 2005 Kai Blin
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.
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.
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
18 * This file implements the negotiate provider.
19 * FIXME: So far, this beast doesn't do anything.
21 #include <assert.h>
22 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "sspi.h"
26 #include "secur32_priv.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(secur32);
31 /* Disable for now, see longer comment for SECUR32_initNegotiateSP below */
32 #if 0
33 static char nego_name_A[] = "Negotiate";
34 static WCHAR nego_name_W[] = {'N', 'e', 'g', 'o', 't', 'i', 'a', 't', 'e', 0};
35 #endif
37 static SECURITY_STATUS nego_QueryCredentialsAttributes(PCredHandle phCredential,
38 ULONG ulAttribute, PVOID pBuffer)
40 SECURITY_STATUS ret;
42 /* FIXME: More attributes to be added here. Need to fix the sspi.h header
43 * for that, too.
45 switch(ulAttribute)
47 default:
48 ret = SEC_E_UNSUPPORTED_FUNCTION;
50 return ret;
53 /***********************************************************************
54 * QueryCredentialsAttributesA
56 static SECURITY_STATUS SEC_ENTRY nego_QueryCredentialsAttributesA(
57 PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer)
59 SECURITY_STATUS ret;
61 TRACE("(%p, %d, %p)\n", phCredential, ulAttribute, pBuffer);
63 switch(ulAttribute)
65 case SECPKG_CRED_ATTR_NAMES:
66 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
67 ret = SEC_E_UNSUPPORTED_FUNCTION;
68 break;
69 default:
70 ret = nego_QueryCredentialsAttributes(phCredential, ulAttribute,
71 pBuffer);
73 return ret;
76 /***********************************************************************
77 * QueryCredentialsAttributesW
79 static SECURITY_STATUS SEC_ENTRY nego_QueryCredentialsAttributesW(
80 PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer)
82 SECURITY_STATUS ret;
84 TRACE("(%p, %d, %p)\n", phCredential, ulAttribute, pBuffer);
86 switch(ulAttribute)
88 case SECPKG_CRED_ATTR_NAMES:
89 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
90 ret = SEC_E_UNSUPPORTED_FUNCTION;
91 break;
92 default:
93 ret = nego_QueryCredentialsAttributes(phCredential, ulAttribute,
94 pBuffer);
96 return ret;
100 /***********************************************************************
101 * AcquireCredentialsHandleA
103 static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
104 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
105 PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
106 PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
108 TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p) stub\n",
109 debugstr_a(pszPrincipal), debugstr_a(pszPackage), fCredentialUse,
110 pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
111 return SEC_E_UNSUPPORTED_FUNCTION;
114 /***********************************************************************
115 * AcquireCredentialsHandleW
117 static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
118 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
119 PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
120 PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
122 TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p) stub\n",
123 debugstr_w(pszPrincipal), debugstr_w(pszPackage), fCredentialUse,
124 pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
125 return SEC_E_UNSUPPORTED_FUNCTION;
128 /***********************************************************************
129 * InitializeSecurityContextA
131 static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA(
132 PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName,
133 ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
134 PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
135 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
137 SECURITY_STATUS ret;
139 TRACE("%p %p %s 0x%08x %d %d %p %d %p %p %p %p\n", phCredential, phContext,
140 debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
141 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
142 if(phCredential){
143 ret = SEC_E_UNSUPPORTED_FUNCTION;
145 else
147 ret = SEC_E_INVALID_HANDLE;
149 return ret;
152 /***********************************************************************
153 * InitializeSecurityContextW
155 static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
156 PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName,
157 ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
158 PSecBufferDesc pInput,ULONG Reserved2, PCtxtHandle phNewContext,
159 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
161 SECURITY_STATUS ret;
163 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
164 debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
165 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
166 if (phCredential)
168 ret = SEC_E_UNSUPPORTED_FUNCTION;
170 else
172 ret = SEC_E_INVALID_HANDLE;
174 return ret;
177 /***********************************************************************
178 * AcceptSecurityContext
180 static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
181 PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
182 ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
183 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
185 SECURITY_STATUS ret;
187 TRACE("%p %p %p %d %d %p %p %p %p\n", phCredential, phContext, pInput,
188 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
189 ptsExpiry);
190 if (phCredential)
192 ret = SEC_E_UNSUPPORTED_FUNCTION;
194 else
196 ret = SEC_E_INVALID_HANDLE;
198 return ret;
201 /***********************************************************************
202 * CompleteAuthToken
204 static SECURITY_STATUS SEC_ENTRY nego_CompleteAuthToken(PCtxtHandle phContext,
205 PSecBufferDesc pToken)
207 SECURITY_STATUS ret;
209 TRACE("%p %p\n", phContext, pToken);
210 if (phContext)
212 ret = SEC_E_UNSUPPORTED_FUNCTION;
214 else
216 ret = SEC_E_INVALID_HANDLE;
218 return ret;
221 /***********************************************************************
222 * DeleteSecurityContext
224 static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContext)
226 SECURITY_STATUS ret;
228 TRACE("%p\n", phContext);
229 if (phContext)
231 ret = SEC_E_UNSUPPORTED_FUNCTION;
233 else
235 ret = SEC_E_INVALID_HANDLE;
237 return ret;
240 /***********************************************************************
241 * ApplyControlToken
243 static SECURITY_STATUS SEC_ENTRY nego_ApplyControlToken(PCtxtHandle phContext,
244 PSecBufferDesc pInput)
246 SECURITY_STATUS ret;
248 TRACE("%p %p\n", phContext, pInput);
249 if (phContext)
251 ret = SEC_E_UNSUPPORTED_FUNCTION;
253 else
255 ret = SEC_E_INVALID_HANDLE;
257 return ret;
260 /***********************************************************************
261 * QueryContextAttributesW
263 static SECURITY_STATUS SEC_ENTRY nego_QueryContextAttributesW(PCtxtHandle phContext,
264 ULONG ulAttribute, void *pBuffer)
266 SECURITY_STATUS ret;
268 /* FIXME: From reading wrapper.h, I think the dwUpper part of a context is
269 * the SecurePackage part and the dwLower part is the actual context
270 * handle. It should be easy to extract the context attributes from that.
272 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
273 if (phContext)
275 ret = SEC_E_UNSUPPORTED_FUNCTION;
277 else
279 ret = SEC_E_INVALID_HANDLE;
281 return ret;
284 /***********************************************************************
285 * QueryContextAttributesA
287 static SECURITY_STATUS SEC_ENTRY nego_QueryContextAttributesA(PCtxtHandle phContext,
288 ULONG ulAttribute, void *pBuffer)
290 return nego_QueryContextAttributesW(phContext, ulAttribute, pBuffer);
293 /***********************************************************************
294 * ImpersonateSecurityContext
296 static SECURITY_STATUS SEC_ENTRY nego_ImpersonateSecurityContext(PCtxtHandle phContext)
298 SECURITY_STATUS ret;
300 TRACE("%p\n", phContext);
301 if (phContext)
303 ret = SEC_E_UNSUPPORTED_FUNCTION;
305 else
307 ret = SEC_E_INVALID_HANDLE;
309 return ret;
312 /***********************************************************************
313 * RevertSecurityContext
315 static SECURITY_STATUS SEC_ENTRY nego_RevertSecurityContext(PCtxtHandle phContext)
317 SECURITY_STATUS ret;
319 TRACE("%p\n", phContext);
320 if (phContext)
322 ret = SEC_E_UNSUPPORTED_FUNCTION;
324 else
326 ret = SEC_E_INVALID_HANDLE;
328 return ret;
331 /***********************************************************************
332 * MakeSignature
334 static SECURITY_STATUS SEC_ENTRY nego_MakeSignature(PCtxtHandle phContext, ULONG fQOP,
335 PSecBufferDesc pMessage, ULONG MessageSeqNo)
337 SECURITY_STATUS ret;
339 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
340 if (phContext)
342 ret = SEC_E_UNSUPPORTED_FUNCTION;
344 else
346 ret = SEC_E_INVALID_HANDLE;
348 return ret;
351 /***********************************************************************
352 * VerifySignature
354 static SECURITY_STATUS SEC_ENTRY nego_VerifySignature(PCtxtHandle phContext,
355 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
357 SECURITY_STATUS ret;
359 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
360 if (phContext)
362 ret = SEC_E_UNSUPPORTED_FUNCTION;
364 else
366 ret = SEC_E_INVALID_HANDLE;
368 return ret;
373 static const SecurityFunctionTableA negoTableA = {
375 NULL, /* EnumerateSecurityPackagesA */
376 nego_QueryCredentialsAttributesA, /* QueryCredentialsAttributesA */
377 nego_AcquireCredentialsHandleA, /* AcquireCredentialsHandleA */
378 FreeCredentialsHandle, /* FreeCredentialsHandle */
379 NULL, /* Reserved2 */
380 nego_InitializeSecurityContextA, /* InitializeSecurityContextA */
381 nego_AcceptSecurityContext, /* AcceptSecurityContext */
382 nego_CompleteAuthToken, /* CompleteAuthToken */
383 nego_DeleteSecurityContext, /* DeleteSecurityContext */
384 nego_ApplyControlToken, /* ApplyControlToken */
385 nego_QueryContextAttributesA, /* QueryContextAttributesA */
386 nego_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
387 nego_RevertSecurityContext, /* RevertSecurityContext */
388 nego_MakeSignature, /* MakeSignature */
389 nego_VerifySignature, /* VerifySignature */
390 FreeContextBuffer, /* FreeContextBuffer */
391 NULL, /* QuerySecurityPackageInfoA */
392 NULL, /* Reserved3 */
393 NULL, /* Reserved4 */
394 NULL, /* ExportSecurityContext */
395 NULL, /* ImportSecurityContextA */
396 NULL, /* AddCredentialsA */
397 NULL, /* Reserved8 */
398 NULL, /* QuerySecurityContextToken */
399 NULL, /* EncryptMessage */
400 NULL, /* DecryptMessage */
401 NULL, /* SetContextAttributesA */
404 static const SecurityFunctionTableW negoTableW = {
406 NULL, /* EnumerateSecurityPackagesW */
407 nego_QueryCredentialsAttributesW, /* QueryCredentialsAttributesW */
408 nego_AcquireCredentialsHandleW, /* AcquireCredentialsHandleW */
409 FreeCredentialsHandle, /* FreeCredentialsHandle */
410 NULL, /* Reserved2 */
411 nego_InitializeSecurityContextW, /* InitializeSecurityContextW */
412 nego_AcceptSecurityContext, /* AcceptSecurityContext */
413 nego_CompleteAuthToken, /* CompleteAuthToken */
414 nego_DeleteSecurityContext, /* DeleteSecurityContext */
415 nego_ApplyControlToken, /* ApplyControlToken */
416 nego_QueryContextAttributesW, /* QueryContextAttributesW */
417 nego_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
418 nego_RevertSecurityContext, /* RevertSecurityContext */
419 nego_MakeSignature, /* MakeSignature */
420 nego_VerifySignature, /* VerifySignature */
421 FreeContextBuffer, /* FreeContextBuffer */
422 NULL, /* QuerySecurityPackageInfoW */
423 NULL, /* Reserved3 */
424 NULL, /* Reserved4 */
425 NULL, /* ExportSecurityContext */
426 NULL, /* ImportSecurityContextW */
427 NULL, /* AddCredentialsW */
428 NULL, /* Reserved8 */
429 NULL, /* QuerySecurityContextToken */
430 NULL, /* EncryptMessage */
431 NULL, /* DecryptMessage */
432 NULL, /* SetContextAttributesW */
435 /* Disable for now, see comment below.*/
436 #if 0
437 static WCHAR negotiate_comment_W[] = { 'M', 'i', 'c', 'r', 'o', 's', 'o',
438 'f', 't', ' ', 'P', 'a', 'c', 'k', 'a', 'g', 'e', ' ', 'N', 'e', 'g', 'o',
439 't', 'i', 'a', 't', 'o', 'r', 0};
441 static CHAR negotiate_comment_A[] = "Microsoft Package Negotiator";
442 #endif
445 void SECUR32_initNegotiateSP(void)
447 /* Disable until we really implement a Negotiate provider.
448 * For now, the NTLM provider will pretend to be the Negotiate provider as well.
449 * Windows seems to be able to deal with it, and it makes several programs
450 * happy. */
451 #if 0
452 SecureProvider *provider = SECUR32_addProvider(&negoTableA, &negoTableW,
453 NULL);
454 /* According to Windows, Negotiate has the following capabilities.
457 static const LONG caps =
458 SECPKG_FLAG_INTEGRITY |
459 SECPKG_FLAG_PRIVACY |
460 SECPKG_FLAG_CONNECTION |
461 SECPKG_FLAG_MULTI_REQUIRED |
462 SECPKG_FLAG_EXTENDED_ERROR |
463 SECPKG_FLAG_IMPERSONATION |
464 SECPKG_FLAG_ACCEPT_WIN32_NAME |
465 SECPKG_FLAG_READONLY_WITH_CHECKSUM;
467 static const USHORT version = 1;
468 static const USHORT rpcid = 15;
469 static const ULONG max_token = 12000;
470 const SecPkgInfoW infoW = { caps, version, rpcid, max_token, nego_name_W,
471 negotiate_comment_W};
472 const SecPkgInfoA infoA = { caps, version, rpcid, max_token, nego_name_A,
473 negotiate_comment_A};
475 SECUR32_addPackages(provider, 1L, &infoA, &infoW);
476 #endif