source: trunk/src/secur32/negotiate.c@ 22015

Last change on this file since 22015 was 21364, checked in by vladest, 16 years ago
  • Added SSP DLLs loader. Still under development. Do not use in working configurations
File size: 14.6 KB
Line 
1/*
2 * Copyright 2005 Kai Blin
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 * This file implements the negotiate provider.
19 * FIXME: So far, this beast doesn't do anything.
20 */
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"
28#include "winerror.h"
29
30WINE_DEFAULT_DEBUG_CHANNEL(secur32);
31
32static char nego_name_A[] = "Negotiate";
33static WCHAR nego_name_W[] = {'N', 'e', 'g', 'o', 't', 'i', 'a', 't', 'e', 0};
34
35static SECURITY_STATUS nego_QueryCredentialsAttributes(PCredHandle phCredential,
36 ULONG ulAttribute, PVOID pBuffer)
37{
38 SECURITY_STATUS ret;
39
40 /* FIXME: More attributes to be added here. Need to fix the sspi.h header
41 * for that, too.
42 */
43 switch(ulAttribute)
44 {
45 default:
46 ret = SEC_E_UNSUPPORTED_FUNCTION;
47 }
48 return ret;
49}
50
51/***********************************************************************
52 * QueryCredentialsAttributesA
53 */
54static SECURITY_STATUS SEC_ENTRY nego_QueryCredentialsAttributesA(
55 PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer)
56{
57 SECURITY_STATUS ret;
58
59 TRACE("(%p, %d, %p)\n", phCredential, ulAttribute, pBuffer);
60
61 switch(ulAttribute)
62 {
63 case SECPKG_CRED_ATTR_NAMES:
64 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
65 ret = SEC_E_UNSUPPORTED_FUNCTION;
66 break;
67 default:
68 ret = nego_QueryCredentialsAttributes(phCredential, ulAttribute,
69 pBuffer);
70 }
71 return ret;
72}
73
74/***********************************************************************
75 * QueryCredentialsAttributesW
76 */
77static SECURITY_STATUS SEC_ENTRY nego_QueryCredentialsAttributesW(
78 PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer)
79{
80 SECURITY_STATUS ret;
81
82 TRACE("(%p, %d, %p)\n", phCredential, ulAttribute, pBuffer);
83
84 switch(ulAttribute)
85 {
86 case SECPKG_CRED_ATTR_NAMES:
87 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
88 ret = SEC_E_UNSUPPORTED_FUNCTION;
89 break;
90 default:
91 ret = nego_QueryCredentialsAttributes(phCredential, ulAttribute,
92 pBuffer);
93 }
94 return ret;
95}
96
97
98/***********************************************************************
99 * AcquireCredentialsHandleA
100 */
101static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
102 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
103 PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
104 PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
105{
106 TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p) stub\n",
107 debugstr_a(pszPrincipal), debugstr_a(pszPackage), fCredentialUse,
108 pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
109 return SEC_E_UNSUPPORTED_FUNCTION;
110}
111
112/***********************************************************************
113 * AcquireCredentialsHandleW
114 */
115static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
116 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
117 PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
118 PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
119{
120 TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p) stub\n",
121 debugstr_w(pszPrincipal), debugstr_w(pszPackage), fCredentialUse,
122 pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
123 return SEC_E_UNSUPPORTED_FUNCTION;
124}
125
126/***********************************************************************
127 * InitializeSecurityContextA
128 */
129static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA(
130 PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName,
131 ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
132 PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
133 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
134{
135 SECURITY_STATUS ret;
136
137 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
138 debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
139 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
140 if(phCredential){
141 ret = SEC_E_UNSUPPORTED_FUNCTION;
142 }
143 else
144 {
145 ret = SEC_E_INVALID_HANDLE;
146 }
147 return ret;
148}
149
150/***********************************************************************
151 * InitializeSecurityContextW
152 */
153static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
154 PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName,
155 ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
156 PSecBufferDesc pInput,ULONG Reserved2, PCtxtHandle phNewContext,
157 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
158{
159 SECURITY_STATUS ret;
160
161 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
162 debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
163 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
164 if (phCredential)
165 {
166 ret = SEC_E_UNSUPPORTED_FUNCTION;
167 }
168 else
169 {
170 ret = SEC_E_INVALID_HANDLE;
171 }
172 return ret;
173}
174
175/***********************************************************************
176 * AcceptSecurityContext
177 */
178static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
179 PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
180 ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
181 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
182{
183 SECURITY_STATUS ret;
184
185 TRACE("%p %p %p %d %d %p %p %p %p\n", phCredential, phContext, pInput,
186 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
187 ptsExpiry);
188 if (phCredential)
189 {
190 ret = SEC_E_UNSUPPORTED_FUNCTION;
191 }
192 else
193 {
194 ret = SEC_E_INVALID_HANDLE;
195 }
196 return ret;
197}
198
199/***********************************************************************
200 * CompleteAuthToken
201 */
202static SECURITY_STATUS SEC_ENTRY nego_CompleteAuthToken(PCtxtHandle phContext,
203 PSecBufferDesc pToken)
204{
205 SECURITY_STATUS ret;
206
207 TRACE("%p %p\n", phContext, pToken);
208 if (phContext)
209 {
210 ret = SEC_E_UNSUPPORTED_FUNCTION;
211 }
212 else
213 {
214 ret = SEC_E_INVALID_HANDLE;
215 }
216 return ret;
217}
218
219/***********************************************************************
220 * DeleteSecurityContext
221 */
222static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContext)
223{
224 SECURITY_STATUS ret;
225
226 TRACE("%p\n", phContext);
227 if (phContext)
228 {
229 ret = SEC_E_UNSUPPORTED_FUNCTION;
230 }
231 else
232 {
233 ret = SEC_E_INVALID_HANDLE;
234 }
235 return ret;
236}
237
238/***********************************************************************
239 * ApplyControlToken
240 */
241static SECURITY_STATUS SEC_ENTRY nego_ApplyControlToken(PCtxtHandle phContext,
242 PSecBufferDesc pInput)
243{
244 SECURITY_STATUS ret;
245
246 TRACE("%p %p\n", phContext, pInput);
247 if (phContext)
248 {
249 ret = SEC_E_UNSUPPORTED_FUNCTION;
250 }
251 else
252 {
253 ret = SEC_E_INVALID_HANDLE;
254 }
255 return ret;
256}
257
258/***********************************************************************
259 * QueryContextAttributesW
260 */
261static SECURITY_STATUS SEC_ENTRY nego_QueryContextAttributesW(PCtxtHandle phContext,
262 ULONG ulAttribute, void *pBuffer)
263{
264 SECURITY_STATUS ret;
265
266 /* FIXME: From reading wrapper.h, I think the dwUpper part of a context is
267 * the SecurePackage part and the dwLower part is the actual context
268 * handle. It should be easy to extract the context attributes from that.
269 */
270 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
271 if (phContext)
272 {
273 ret = SEC_E_UNSUPPORTED_FUNCTION;
274 }
275 else
276 {
277 ret = SEC_E_INVALID_HANDLE;
278 }
279 return ret;
280}
281
282/***********************************************************************
283 * QueryContextAttributesA
284 */
285static SECURITY_STATUS SEC_ENTRY nego_QueryContextAttributesA(PCtxtHandle phContext,
286 ULONG ulAttribute, void *pBuffer)
287{
288 return nego_QueryContextAttributesW(phContext, ulAttribute, pBuffer);
289}
290
291/***********************************************************************
292 * ImpersonateSecurityContext
293 */
294static SECURITY_STATUS SEC_ENTRY nego_ImpersonateSecurityContext(PCtxtHandle phContext)
295{
296 SECURITY_STATUS ret;
297
298 TRACE("%p\n", phContext);
299 if (phContext)
300 {
301 ret = SEC_E_UNSUPPORTED_FUNCTION;
302 }
303 else
304 {
305 ret = SEC_E_INVALID_HANDLE;
306 }
307 return ret;
308}
309
310/***********************************************************************
311 * RevertSecurityContext
312 */
313static SECURITY_STATUS SEC_ENTRY nego_RevertSecurityContext(PCtxtHandle phContext)
314{
315 SECURITY_STATUS ret;
316
317 TRACE("%p\n", phContext);
318 if (phContext)
319 {
320 ret = SEC_E_UNSUPPORTED_FUNCTION;
321 }
322 else
323 {
324 ret = SEC_E_INVALID_HANDLE;
325 }
326 return ret;
327}
328
329/***********************************************************************
330 * MakeSignature
331 */
332static SECURITY_STATUS SEC_ENTRY nego_MakeSignature(PCtxtHandle phContext, ULONG fQOP,
333 PSecBufferDesc pMessage, ULONG MessageSeqNo)
334{
335 SECURITY_STATUS ret;
336
337 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
338 if (phContext)
339 {
340 ret = SEC_E_UNSUPPORTED_FUNCTION;
341 }
342 else
343 {
344 ret = SEC_E_INVALID_HANDLE;
345 }
346 return ret;
347}
348
349/***********************************************************************
350 * VerifySignature
351 */
352static SECURITY_STATUS SEC_ENTRY nego_VerifySignature(PCtxtHandle phContext,
353 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
354{
355 SECURITY_STATUS ret;
356
357 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
358 if (phContext)
359 {
360 ret = SEC_E_UNSUPPORTED_FUNCTION;
361 }
362 else
363 {
364 ret = SEC_E_INVALID_HANDLE;
365 }
366 return ret;
367}
368
369
370
371static const SecurityFunctionTableA negoTableA = {
372 1,
373 NULL, /* EnumerateSecurityPackagesA */
374 nego_QueryCredentialsAttributesA, /* QueryCredentialsAttributesA */
375 nego_AcquireCredentialsHandleA, /* AcquireCredentialsHandleA */
376 FreeCredentialsHandle, /* FreeCredentialsHandle */
377 NULL, /* Reserved2 */
378 nego_InitializeSecurityContextA, /* InitializeSecurityContextA */
379 nego_AcceptSecurityContext, /* AcceptSecurityContext */
380 nego_CompleteAuthToken, /* CompleteAuthToken */
381 nego_DeleteSecurityContext, /* DeleteSecurityContext */
382 nego_ApplyControlToken, /* ApplyControlToken */
383 nego_QueryContextAttributesA, /* QueryContextAttributesA */
384 nego_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
385 nego_RevertSecurityContext, /* RevertSecurityContext */
386 nego_MakeSignature, /* MakeSignature */
387 nego_VerifySignature, /* VerifySignature */
388 FreeContextBuffer, /* FreeContextBuffer */
389 NULL, /* QuerySecurityPackageInfoA */
390 NULL, /* Reserved3 */
391 NULL, /* Reserved4 */
392 NULL, /* ExportSecurityContext */
393 NULL, /* ImportSecurityContextA */
394 NULL, /* AddCredentialsA */
395 NULL, /* Reserved8 */
396 NULL, /* QuerySecurityContextToken */
397 NULL, /* EncryptMessage */
398 NULL, /* DecryptMessage */
399 NULL, /* SetContextAttributesA */
400};
401
402static const SecurityFunctionTableW negoTableW = {
403 1,
404 NULL, /* EnumerateSecurityPackagesW */
405 nego_QueryCredentialsAttributesW, /* QueryCredentialsAttributesW */
406 nego_AcquireCredentialsHandleW, /* AcquireCredentialsHandleW */
407 FreeCredentialsHandle, /* FreeCredentialsHandle */
408 NULL, /* Reserved2 */
409 nego_InitializeSecurityContextW, /* InitializeSecurityContextW */
410 nego_AcceptSecurityContext, /* AcceptSecurityContext */
411 nego_CompleteAuthToken, /* CompleteAuthToken */
412 nego_DeleteSecurityContext, /* DeleteSecurityContext */
413 nego_ApplyControlToken, /* ApplyControlToken */
414 nego_QueryContextAttributesW, /* QueryContextAttributesW */
415 nego_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
416 nego_RevertSecurityContext, /* RevertSecurityContext */
417 nego_MakeSignature, /* MakeSignature */
418 nego_VerifySignature, /* VerifySignature */
419 FreeContextBuffer, /* FreeContextBuffer */
420 NULL, /* QuerySecurityPackageInfoW */
421 NULL, /* Reserved3 */
422 NULL, /* Reserved4 */
423 NULL, /* ExportSecurityContext */
424 NULL, /* ImportSecurityContextW */
425 NULL, /* AddCredentialsW */
426 NULL, /* Reserved8 */
427 NULL, /* QuerySecurityContextToken */
428 NULL, /* EncryptMessage */
429 NULL, /* DecryptMessage */
430 NULL, /* SetContextAttributesW */
431};
432
433static WCHAR negotiate_comment_W[] = { 'M', 'i', 'c', 'r', 'o', 's', 'o',
434 'f', 't', ' ', 'P', 'a', 'c', 'k', 'a', 'g', 'e', ' ', 'N', 'e', 'g', 'o',
435 't', 'i', 'a', 't', 'o', 'r', 0};
436
437static CHAR negotiate_comment_A[] = "Microsoft Package Negotiator";
438
439
440
441void SECUR32_initNegotiateSP(void)
442{
443 SecureProvider *provider = SECUR32_addProvider(&negoTableA, &negoTableW,
444 NULL);
445 /* According to Windows, Negotiate has the following capabilities.
446 */
447
448 static const LONG caps =
449 SECPKG_FLAG_INTEGRITY |
450 SECPKG_FLAG_PRIVACY |
451 SECPKG_FLAG_CONNECTION |
452 SECPKG_FLAG_MULTI_REQUIRED |
453 SECPKG_FLAG_EXTENDED_ERROR |
454 SECPKG_FLAG_IMPERSONATION |
455 SECPKG_FLAG_ACCEPT_WIN32_NAME |
456 SECPKG_FLAG_READONLY_WITH_CHECKSUM;
457
458 static const USHORT version = 1;
459 static const USHORT rpcid = 15;
460 static const ULONG max_token = 12000;
461 const SecPkgInfoW infoW = { caps, version, rpcid, max_token, nego_name_W,
462 negotiate_comment_W};
463 const SecPkgInfoA infoA = { caps, version, rpcid, max_token, nego_name_A,
464 negotiate_comment_A};
465
466 SECUR32_addPackages(provider, 1L, &infoA, &infoW);
467}
Note: See TracBrowser for help on using the repository browser.