ReactOS 0.4.15-dev-7953-g1f49173
wrapper.c
Go to the documentation of this file.
1/* Copyright (C) 2004 Juan Lang
2 *
3 * Implements secur32 functions that forward to (wrap) an SSP's implementation.
4 *
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.
9 *
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.
14 *
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
18 */
19#include "precomp.h"
20
21#include "wine/debug.h"
22
24
25/* Tries to allocate a new SecHandle, into which it stores package (in
26 * phSec->dwUpper) and a copy of realHandle (allocated with SECUR32_ALLOC,
27 * and stored in phSec->dwLower). SecHandle is equivalent to both a
28 * CredHandle and a CtxtHandle.
29 */
31 SecurePackage *package, PSecHandle realHandle)
32{
34
35 TRACE("%p %p %p\n", phSec, package, realHandle);
36
37 if (phSec && package && realHandle)
38 {
39 PSecHandle newSec = HeapAlloc(GetProcessHeap(), 0, sizeof(SecHandle));
40
41 if (newSec)
42 {
43 *newSec = *realHandle;
44 phSec->dwUpper = (ULONG_PTR)package;
45 phSec->dwLower = (ULONG_PTR)newSec;
46 ret = SEC_E_OK;
47 }
48 else
50 }
51 else
53 return ret;
54}
55
56/***********************************************************************
57 * AcquireCredentialsHandleA (SECUR32.@)
58 */
60 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse,
61 PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
62 PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
63{
65
66 TRACE("%s %s %d %p %p %p %p %p %p\n", debugstr_a(pszPrincipal),
67 debugstr_a(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
68 pvGetKeyArgument, phCredential, ptsExpiry);
69 if (pszPackage)
70 {
71 SecurePackage *package = SECUR32_findPackageA(pszPackage);
72
73 if (package && package->provider)
74 {
75 if (package->provider->fnTableA.AcquireCredentialsHandleA)
76 {
77 CredHandle myCred;
78
79 ret = package->provider->fnTableA.AcquireCredentialsHandleA(
80 pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
81 pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
82 ptsExpiry);
83 if (ret == SEC_E_OK)
84 {
85 ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
86 if (ret != SEC_E_OK)
87 package->provider->fnTableW.FreeCredentialsHandle(
88 &myCred);
89 }
90 }
91 else
93 }
94 else
96 }
97 else
99 return ret;
100}
101
102/***********************************************************************
103 * AcquireCredentialsHandleW (SECUR32.@)
104 */
106 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse,
107 PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
108 PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
109{
111
112 TRACE("%s %s %d %p %p %p %p %p %p\n", debugstr_w(pszPrincipal),
113 debugstr_w(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
114 pvGetKeyArgument, phCredential, ptsExpiry);
115 if (pszPackage)
116 {
117 SecurePackage *package = SECUR32_findPackageW(pszPackage);
118
119 if (package && package->provider)
120 {
121 if (package->provider->fnTableW.AcquireCredentialsHandleW)
122 {
123 CredHandle myCred;
124
125 ret = package->provider->fnTableW.AcquireCredentialsHandleW(
126 pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
127 pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
128 ptsExpiry);
129 if (ret == SEC_E_OK)
130 {
131 ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
132 if (ret != SEC_E_OK)
133 package->provider->fnTableW.FreeCredentialsHandle(
134 &myCred);
135 }
136 }
137 else
139 }
140 else
142 }
143 else
145 return ret;
146}
147
148/***********************************************************************
149 * FreeCredentialsHandle (SECUR32.@)
150 */
152 PCredHandle phCredential)
153{
155
156 TRACE("%p\n", phCredential);
157 if (phCredential)
158 {
159 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
160 PCredHandle cred = (PCredHandle)phCredential->dwLower;
161
162 if (package && package->provider &&
163 package->provider->fnTableW.FreeCredentialsHandle)
164 ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
165 else
167 HeapFree(GetProcessHeap(), 0, cred);
168 }
169 else
171 return ret;
172}
173
174/***********************************************************************
175 * QueryCredentialsAttributesA (SECUR32.@)
176 */
178 PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
179{
181
182 TRACE("%p %d %p\n", phCredential, ulAttribute, pBuffer);
183 if (phCredential)
184 {
185 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
186 PCredHandle cred = (PCredHandle)phCredential->dwLower;
187
188 if (package && package->provider)
189 {
190 if (package->provider->fnTableA.QueryCredentialsAttributesA)
191 ret = package->provider->fnTableA.QueryCredentialsAttributesA(
192 cred, ulAttribute, pBuffer);
193 else
195 }
196 else
198 }
199 else
201 return ret;
202}
203
204/***********************************************************************
205 * QueryCredentialsAttributesW (SECUR32.@)
206 */
208 PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
209{
211
212 TRACE("%p %d %p\n", phCredential, ulAttribute, pBuffer);
213 if (phCredential)
214 {
215 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
216 PCredHandle cred = (PCredHandle)phCredential->dwLower;
217
218 if (package && package->provider)
219 {
220 if (package->provider->fnTableW.QueryCredentialsAttributesW)
221 ret = package->provider->fnTableW.QueryCredentialsAttributesW(
222 cred, ulAttribute, pBuffer);
223 else
225 }
226 else
228 }
229 else
231 return ret;
232}
233
234/***********************************************************************
235 * InitializeSecurityContextA (SECUR32.@)
236 */
238 PCredHandle phCredential, PCtxtHandle phContext,
239 SEC_CHAR *pszTargetName, ULONG fContextReq,
240 ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
241 ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
242 ULONG *pfContextAttr, PTimeStamp ptsExpiry)
243{
245 SecurePackage *package = NULL;
246 PCredHandle cred = NULL;
247 PCredHandle ctxt = NULL;
248
249 TRACE("%p %p %s 0x%08x %d %d %p %d %p %p %p %p\n", phCredential, phContext,
250 debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
251 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
252
253 if (phContext)
254 {
255 package = (SecurePackage *)phContext->dwUpper;
256 ctxt = (PCtxtHandle)phContext->dwLower;
257 }
258 if (phCredential)
259 {
260 package = (SecurePackage *)phCredential->dwUpper;
261 cred = (PCredHandle)phCredential->dwLower;
262 }
263
264 if (package && package->provider)
265 {
266 if (package->provider->fnTableA.InitializeSecurityContextA)
267 {
268 CtxtHandle myCtxt;
269
270 if (phContext)
271 {
272 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
273 myCtxt.dwUpper = realCtxt->dwUpper;
274 myCtxt.dwLower = realCtxt->dwLower;
275 }
276
277 ret = package->provider->fnTableA.InitializeSecurityContextA(
278 cred, ctxt, pszTargetName, fContextReq,
279 Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
280 pOutput, pfContextAttr, ptsExpiry);
281 if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) &&
282 phNewContext && phNewContext != phContext)
283 {
284 SECURITY_STATUS ret2;
285 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
286 if (ret2 != SEC_E_OK)
287 package->provider->fnTableA.DeleteSecurityContext(&myCtxt);
288 }
289 }
290 else
292 }
293 else
295 return ret;
296}
297
298/***********************************************************************
299 * InitializeSecurityContextW (SECUR32.@)
300 */
302 PCredHandle phCredential, PCtxtHandle phContext,
303 SEC_WCHAR *pszTargetName, ULONG fContextReq,
304 ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
305 ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
306 ULONG *pfContextAttr, PTimeStamp ptsExpiry)
307{
309 SecurePackage *package = NULL;
310 PCredHandle cred = NULL;
311 PCredHandle ctxt = NULL;
312
313 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
314 debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
315 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
316
317 if (phContext)
318 {
319 package = (SecurePackage *)phContext->dwUpper;
320 ctxt = (PCtxtHandle)phContext->dwLower;
321 }
322 if (phCredential)
323 {
324 package = (SecurePackage *)phCredential->dwUpper;
325 cred = (PCredHandle)phCredential->dwLower;
326 }
327
328 if (package && package->provider)
329 {
330 if (package->provider->fnTableW.InitializeSecurityContextW)
331 {
332 CtxtHandle myCtxt;
333
334 if (phContext)
335 {
336 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
337 myCtxt.dwUpper = realCtxt->dwUpper;
338 myCtxt.dwLower = realCtxt->dwLower;
339 }
340
341 ret = package->provider->fnTableW.InitializeSecurityContextW(
342 cred, ctxt, pszTargetName, fContextReq,
343 Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
344 pOutput, pfContextAttr, ptsExpiry);
345 if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) &&
346 phNewContext && phNewContext != phContext)
347 {
348 SECURITY_STATUS ret2;
349 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
350 if (ret2 != SEC_E_OK)
351 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
352 }
353 }
354 else
356 }
357 else
359 return ret;
360}
361
362/***********************************************************************
363 * AcceptSecurityContext (SECUR32.@)
364 */
366 PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
367 ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
368 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
369{
371
372 TRACE("%p %p %p %d %d %p %p %p %p\n", phCredential, phContext, pInput,
373 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
374 ptsExpiry);
375 if (phCredential)
376 {
377 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
378 PCredHandle cred = (PCredHandle)phCredential->dwLower;
379
380 if (package && package->provider)
381 {
382 if (package->provider->fnTableW.AcceptSecurityContext)
383 {
384 CtxtHandle myCtxt;
385
386 if(phContext)
387 {
388 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
389 TRACE("realCtx: %p\n", realCtxt);
390 myCtxt.dwUpper = realCtxt->dwUpper;
391 myCtxt.dwLower = realCtxt->dwLower;
392 }
393
394 ret = package->provider->fnTableW.AcceptSecurityContext(
395 cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
396 TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
398 {
399 SECURITY_STATUS ret2;
400 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
401 if (ret2 != SEC_E_OK)
402 package->provider->fnTableW.DeleteSecurityContext(
403 &myCtxt);
404 }
405 }
406 else
408 }
409 else
411 }
412 else
414 return ret;
415}
416
417/***********************************************************************
418 * CompleteAuthToken (SECUR32.@)
419 */
421 PSecBufferDesc pToken)
422{
424
425 TRACE("%p %p\n", phContext, pToken);
426 if (phContext)
427 {
428 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
429 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
430
431 if (package && package->provider)
432 {
433 if (package->provider->fnTableW.CompleteAuthToken)
434 ret = package->provider->fnTableW.CompleteAuthToken(ctxt,
435 pToken);
436 else
438 }
439 else
441 }
442 else
444 return ret;
445}
446
447/***********************************************************************
448 * DeleteSecurityContext (SECUR32.@)
449 */
451{
453
454 TRACE("%p\n", phContext);
455 if (phContext)
456 {
457 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
458 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
459
460 if (package && package->provider &&
461 package->provider->fnTableW.DeleteSecurityContext)
462 ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
463 else
465 HeapFree(GetProcessHeap(), 0, ctxt);
466 }
467 else
469 return ret;
470}
471
472/***********************************************************************
473 * ApplyControlToken (SECUR32.@)
474 */
476 PSecBufferDesc pInput)
477{
479
480 TRACE("%p %p\n", phContext, pInput);
481 if (phContext)
482 {
483 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
484 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
485
486 if (package && package->provider)
487 {
488 if (package->provider->fnTableW.ApplyControlToken)
489 ret = package->provider->fnTableW.ApplyControlToken(
490 ctxt, pInput);
491 else
493 }
494 else
496 }
497 else
499 return ret;
500}
501
502/***********************************************************************
503 * QueryContextAttributesA (SECUR32.@)
504 */
506 ULONG ulAttribute, void *pBuffer)
507{
509
510 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
511 if (phContext)
512 {
513 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
514 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
515
516 if (package && package->provider)
517 {
518 if (package->provider->fnTableA.QueryContextAttributesA)
519 ret = package->provider->fnTableA.QueryContextAttributesA(
520 ctxt, ulAttribute, pBuffer);
521 else
523 }
524 else
526 }
527 else
529 return ret;
530}
531
532/***********************************************************************
533 * QueryContextAttributesW (SECUR32.@)
534 */
536 ULONG ulAttribute, void *pBuffer)
537{
539
540 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
541 if (phContext)
542 {
543 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
544 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
545
546 if (package && package->provider)
547 {
548 if (package->provider->fnTableW.QueryContextAttributesW)
549 ret = package->provider->fnTableW.QueryContextAttributesW(
550 ctxt, ulAttribute, pBuffer);
551 else
553 }
554 else
556 }
557 else
559 return ret;
560}
561
562/***********************************************************************
563 * ImpersonateSecurityContext (SECUR32.@)
564 */
566{
568
569 TRACE("%p\n", phContext);
570 if (phContext)
571 {
572 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
573 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
574
575 if (package && package->provider)
576 {
577 if (package->provider->fnTableW.ImpersonateSecurityContext)
578 ret = package->provider->fnTableW.ImpersonateSecurityContext(
579 ctxt);
580 else
582 }
583 else
585 }
586 else
588 return ret;
589}
590
591/***********************************************************************
592 * RevertSecurityContext (SECUR32.@)
593 */
595{
597
598 TRACE("%p\n", phContext);
599 if (phContext)
600 {
601 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
602 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
603
604 if (package && package->provider)
605 {
606 if (package->provider->fnTableW.RevertSecurityContext)
607 ret = package->provider->fnTableW.RevertSecurityContext(
608 ctxt);
609 else
611 }
612 else
614 }
615 else
617 return ret;
618}
619
620/***********************************************************************
621 * MakeSignature (SECUR32.@)
622 */
624 PSecBufferDesc pMessage, ULONG MessageSeqNo)
625{
627
628 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
629 if (phContext)
630 {
631 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
632 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
633
634 if (package && package->provider)
635 {
636 if (package->provider->fnTableW.MakeSignature)
637 ret = package->provider->fnTableW.MakeSignature(
638 ctxt, fQOP, pMessage, MessageSeqNo);
639 else
641 }
642 else
644 }
645 else
647 return ret;
648}
649
650/***********************************************************************
651 * VerifySignature (SECUR32.@)
652 */
654 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
655{
657
658 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
659 if (phContext)
660 {
661 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
662 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
663
664 if (package && package->provider)
665 {
666 if (package->provider->fnTableW.VerifySignature)
667 ret = package->provider->fnTableW.VerifySignature(
668 ctxt, pMessage, MessageSeqNo, pfQOP);
669 else
671 }
672 else
674 }
675 else
677 return ret;
678}
679
680/***********************************************************************
681 * QuerySecurityPackageInfoA (SECUR32.@)
682 */
684 PSecPkgInfoA *ppPackageInfo)
685{
687
688 TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
689 if (pszPackageName)
690 {
691 SecurePackage *package = SECUR32_findPackageA(pszPackageName);
692
693 if (package)
694 {
695 size_t bytesNeeded = sizeof(SecPkgInfoA);
696 int nameLen = 0, commentLen = 0;
697
698 if (package->infoW.Name)
699 {
700 nameLen = WideCharToMultiByte(CP_ACP, 0,
701 package->infoW.Name, -1, NULL, 0, NULL, NULL);
702 bytesNeeded += nameLen;
703 }
704 if (package->infoW.Comment)
705 {
706 commentLen = WideCharToMultiByte(CP_ACP, 0,
707 package->infoW.Comment, -1, NULL, 0, NULL, NULL);
708 bytesNeeded += commentLen;
709 }
710 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
711 if (*ppPackageInfo)
712 {
713 PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
714 sizeof(SecPkgInfoA));
715
716 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
717 if (package->infoW.Name)
718 {
719 (*ppPackageInfo)->Name = nextString;
720 nextString += WideCharToMultiByte(CP_ACP, 0,
721 package->infoW.Name, -1, nextString, nameLen, NULL, NULL);
722 }
723 else
724 (*ppPackageInfo)->Name = NULL;
725 if (package->infoW.Comment)
726 {
727 (*ppPackageInfo)->Comment = nextString;
728 nextString += WideCharToMultiByte(CP_ACP, 0,
729 package->infoW.Comment, -1, nextString, commentLen, NULL,
730 NULL);
731 }
732 else
733 (*ppPackageInfo)->Comment = NULL;
734 ret = SEC_E_OK;
735 }
736 else
738 }
739 else
741 }
742 else
744 return ret;
745}
746
747/***********************************************************************
748 * QuerySecurityPackageInfoW (SECUR32.@)
749 */
751 PSecPkgInfoW *ppPackageInfo)
752{
754 SecurePackage *package = SECUR32_findPackageW(pszPackageName);
755
756 TRACE("%s %p\n", debugstr_w(pszPackageName), ppPackageInfo);
757 if (package)
758 {
759 size_t bytesNeeded = sizeof(SecPkgInfoW);
760 int nameLen = 0, commentLen = 0;
761
762 if (package->infoW.Name)
763 {
764 nameLen = lstrlenW(package->infoW.Name) + 1;
765 bytesNeeded += nameLen * sizeof(WCHAR);
766 }
767 if (package->infoW.Comment)
768 {
769 commentLen = lstrlenW(package->infoW.Comment) + 1;
770 bytesNeeded += commentLen * sizeof(WCHAR);
771 }
772 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
773 if (*ppPackageInfo)
774 {
775 PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
776 sizeof(SecPkgInfoW));
777
778 **ppPackageInfo = package->infoW;
779 if (package->infoW.Name)
780 {
781 (*ppPackageInfo)->Name = nextString;
782 lstrcpynW(nextString, package->infoW.Name, nameLen);
783 nextString += nameLen;
784 }
785 else
786 (*ppPackageInfo)->Name = NULL;
787 if (package->infoW.Comment)
788 {
789 (*ppPackageInfo)->Comment = nextString;
790 lstrcpynW(nextString, package->infoW.Comment, commentLen);
791 }
792 else
793 (*ppPackageInfo)->Comment = NULL;
794 ret = SEC_E_OK;
795 }
796 else
798 }
799 else
801 return ret;
802}
803
804/***********************************************************************
805 * ExportSecurityContext (SECUR32.@)
806 */
808 ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
809{
811
812 TRACE("%p %d %p %p\n", phContext, fFlags, pPackedContext, pToken);
813 if (phContext)
814 {
815 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
816 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
817
818 if (package && package->provider)
819 {
820 if (package->provider->fnTableW.ExportSecurityContext)
821 ret = package->provider->fnTableW.ExportSecurityContext(
822 ctxt, fFlags, pPackedContext, pToken);
823 else
825 }
826 else
828 }
829 else
831 return ret;
832}
833
834/***********************************************************************
835 * ImportSecurityContextA (SECUR32.@)
836 */
838 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
839{
841 SecurePackage *package = SECUR32_findPackageA(pszPackage);
842
843 TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
844 phContext);
845 if (package && package->provider)
846 {
847 if (package->provider->fnTableA.ImportSecurityContextA)
848 {
849 CtxtHandle myCtxt;
850
851 ret = package->provider->fnTableA.ImportSecurityContextA(
852 pszPackage, pPackedContext, Token, &myCtxt);
853 if (ret == SEC_E_OK)
854 {
855 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
856 if (ret != SEC_E_OK)
857 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
858 }
859 }
860 else
862 }
863 else
865 return ret;
866
867}
868
869/***********************************************************************
870 * ImportSecurityContextW (SECUR32.@)
871 */
873 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
874{
876 SecurePackage *package = SECUR32_findPackageW(pszPackage);
877
878 TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
879 phContext);
880 if (package && package->provider)
881 {
882 if (package->provider->fnTableW.ImportSecurityContextW)
883 {
884 CtxtHandle myCtxt;
885
886 ret = package->provider->fnTableW.ImportSecurityContextW(
887 pszPackage, pPackedContext, Token, &myCtxt);
888 if (ret == SEC_E_OK)
889 {
890 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
891 if (ret != SEC_E_OK)
892 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
893 }
894 }
895 else
897 }
898 else
900 return ret;
901}
902
903/***********************************************************************
904 * AddCredentialsA (SECUR32.@)
905 */
907 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
908 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
909 PTimeStamp ptsExpiry)
910{
912
913 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_a(pszPrincipal),
914 debugstr_a(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
915 pvGetKeyArgument, ptsExpiry);
916 if (hCredentials)
917 {
918 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
919 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
920
921 if (package && package->provider)
922 {
923 if (package->provider->fnTableA.AddCredentialsA)
924 ret = package->provider->fnTableA.AddCredentialsA(
925 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
926 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
927 else
929 }
930 else
932 }
933 else
935 return ret;
936}
937
938/***********************************************************************
939 * AddCredentialsW (SECUR32.@)
940 */
942 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
943 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
944 PTimeStamp ptsExpiry)
945{
947
948 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_w(pszPrincipal),
949 debugstr_w(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
950 pvGetKeyArgument, ptsExpiry);
951 if (hCredentials)
952 {
953 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
954 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
955
956 if (package && package->provider)
957 {
958 if (package->provider->fnTableW.AddCredentialsW)
959 ret = package->provider->fnTableW.AddCredentialsW(
960 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
961 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
962 else
964 }
965 else
967 }
968 else
970 return ret;
971}
972
973/***********************************************************************
974 * QuerySecurityContextToken (SECUR32.@)
975 */
978{
980
981 TRACE("%p %p\n", phContext, phToken);
982 if (phContext)
983 {
984 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
985 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
986
987 if (package && package->provider)
988 {
989 if (package->provider->fnTableW.QuerySecurityContextToken)
990 ret = package->provider->fnTableW.QuerySecurityContextToken(
991 ctxt, phToken);
992 else
994 }
995 else
997 }
998 else
1000 return ret;
1001}
1002
1003/***********************************************************************
1004 * EncryptMessage (SECUR32.@)
1005 */
1007 PSecBufferDesc pMessage, ULONG MessageSeqNo)
1008{
1010
1011 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
1012 if (phContext)
1013 {
1014 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1015 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1016
1017 if (package && package->provider)
1018 {
1019 if (package->provider->fnTableW.EncryptMessage)
1020 ret = package->provider->fnTableW.EncryptMessage(
1021 ctxt, fQOP, pMessage, MessageSeqNo);
1022 else
1024 }
1025 else
1027 }
1028 else
1030 return ret;
1031}
1032
1033/***********************************************************************
1034 * DecryptMessage (SECUR32.@)
1035 */
1037 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
1038{
1040
1041 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
1042 if (phContext)
1043 {
1044 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1045 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1046
1047 if (package && package->provider)
1048 {
1049 if (package->provider->fnTableW.DecryptMessage)
1050 ret = package->provider->fnTableW.DecryptMessage(
1051 ctxt, pMessage, MessageSeqNo, pfQOP);
1052 else
1054 }
1055 else
1057 }
1058 else
1060 return ret;
1061}
1062
1063/***********************************************************************
1064 * SetContextAttributesA (SECUR32.@)
1065 */
1067 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1068{
1070
1071 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1072 if (phContext)
1073 {
1074 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1075 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1076
1077 if (package && package->provider)
1078 {
1079 if (package->provider->fnTableA.SetContextAttributesA)
1080 ret = package->provider->fnTableA.SetContextAttributesA(
1081 ctxt, ulAttribute, pBuffer, cbBuffer);
1082 else
1084 }
1085 else
1087 }
1088 else
1090 return ret;
1091}
1092
1093/***********************************************************************
1094 * SetContextAttributesW (SECUR32.@)
1095 */
1097 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1098{
1100
1101 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1102 if (phContext)
1103 {
1104 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1105 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1106
1107 if (package && package->provider)
1108 {
1109 if (package->provider->fnTableW.SetContextAttributesW)
1110 ret = package->provider->fnTableW.SetContextAttributesW(
1111 ctxt, ulAttribute, pBuffer, cbBuffer);
1112 else
1114 }
1115 else
1117 }
1118 else
1120 return ret;
1121}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
@ Reserved2
Definition: bcd.h:202
@ Reserved1
Definition: bcd.h:201
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
#define ULONG_PTR
Definition: config.h:101
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PVOID *typedef PSecBuffer
Definition: ntsecpkg.h:440
BYTE * PBYTE
Definition: pedump.c:66
struct _SecPkgInfoW SecPkgInfoW
LONG SECURITY_STATUS
Definition: sspi.h:34
struct _SecPkgInfoA SecPkgInfoA
CHAR SEC_CHAR
Definition: sspi.h:30
void(SEC_ENTRY * SEC_GET_KEY_FN)(void *Arg, void *Principal, ULONG KeyVer, void **Key, SECURITY_STATUS *Status)
Definition: sspi.h:189
PSecHandle PCtxtHandle
Definition: sspi.h:71
PSecHandle PCredHandle
Definition: sspi.h:68
WCHAR SEC_WCHAR
Definition: sspi.h:29
PVOID pBuffer
#define TRACE(s)
Definition: solgame.cpp:4
ULONG_PTR dwLower
Definition: sspi.h:53
ULONG_PTR dwUpper
Definition: sspi.h:54
SEC_WCHAR * Name
Definition: sspi.h:118
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
char * PSTR
Definition: typedefs.h:51
uint32_t ULONG
Definition: typedefs.h:59
int ret
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2715
#define WINAPI
Definition: msvc.h:6
#define SEC_E_OK
Definition: winerror.h:2356
#define SEC_E_INVALID_HANDLE
Definition: winerror.h:2910
#define SEC_E_UNSUPPORTED_FUNCTION
Definition: winerror.h:2911
#define SEC_E_SECPKG_NOT_FOUND
Definition: winerror.h:2914
#define SEC_E_INSUFFICIENT_MEMORY
Definition: winerror.h:2909
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: wrapper.c:1006
SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: wrapper.c:623
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:105
SECURITY_STATUS WINAPI ExportSecurityContext(PCtxtHandle phContext, ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
Definition: wrapper.c:807
SECURITY_STATUS WINAPI AddCredentialsW(PCredHandle hCredentials, SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PTimeStamp ptsExpiry)
Definition: wrapper.c:941
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:301
SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
Definition: wrapper.c:420
SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage, PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
Definition: wrapper.c:837
SECURITY_STATUS WINAPI SetContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
Definition: wrapper.c:1096
SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: wrapper.c:1036
SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: wrapper.c:653
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
SECURITY_STATUS WINAPI ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput)
Definition: wrapper.c:475
SECURITY_STATUS WINAPI SetContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
Definition: wrapper.c:1066
SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage, PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
Definition: wrapper.c:872
SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:505
SECURITY_STATUS WINAPI AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:365
SECURITY_STATUS WINAPI AcquireCredentialsHandleA(SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:59
SECURITY_STATUS WINAPI QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:177
SECURITY_STATUS WINAPI InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:237
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750
static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec, SecurePackage *package, PSecHandle realHandle)
Definition: wrapper.c:30
SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:565
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName, PSecPkgInfoA *ppPackageInfo)
Definition: wrapper.c:683
SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:594
SECURITY_STATUS WINAPI QuerySecurityContextToken(PCtxtHandle phContext, HANDLE *phToken)
Definition: wrapper.c:976
SECURITY_STATUS WINAPI QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:207
SECURITY_STATUS WINAPI AddCredentialsA(PCredHandle hCredentials, SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PTimeStamp ptsExpiry)
Definition: wrapper.c:906
__wchar_t WCHAR
Definition: xmlstorage.h:180