1 /* Copyright (C) 2004 Juan Lang
3 * Implements secur32 functions that forward to (wrap) an SSP's implementation.
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
24 #include "secur32_priv.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(secur32);
30 /* Tries to allocate a new SecHandle, into which it stores package (in
31 * phSec->dwUpper) and a copy of realHandle (allocated with SECUR32_ALLOC,
32 * and stored in phSec->dwLower). SecHandle is equivalent to both a
33 * CredHandle and a CtxtHandle.
35 static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
36 SecurePackage *package, PSecHandle realHandle)
40 TRACE("%p %p %p\n", phSec, package, realHandle);
42 if (phSec && package && realHandle)
44 PSecHandle newSec = (PSecHandle)SECUR32_ALLOC(sizeof(SecHandle));
48 memcpy(newSec, realHandle, sizeof(*realHandle));
49 phSec->dwUpper = (ULONG_PTR)package;
50 phSec->dwLower = (ULONG_PTR)newSec;
54 ret = SEC_E_INSUFFICIENT_MEMORY;
57 ret = SEC_E_INVALID_HANDLE;
61 /***********************************************************************
62 * AcquireCredentialsHandleA (SECUR32.@)
64 SECURITY_STATUS WINAPI AcquireCredentialsHandleA(
65 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse,
66 PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
67 PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
71 TRACE("%s %s %d %p %p %p %p %p %p\n", debugstr_a(pszPrincipal),
72 debugstr_a(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
73 pvGetKeyArgument, phCredential, ptsExpiry);
76 SecurePackage *package = SECUR32_findPackageA(pszPackage);
78 if (package && package->provider)
80 if (package->provider->fnTableA.AcquireCredentialsHandleA)
84 ret = package->provider->fnTableA.AcquireCredentialsHandleA(
85 pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
86 pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
90 ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
92 package->provider->fnTableW.FreeCredentialsHandle(
97 ret = SEC_E_UNSUPPORTED_FUNCTION;
100 ret = SEC_E_SECPKG_NOT_FOUND;
103 ret = SEC_E_SECPKG_NOT_FOUND;
107 /***********************************************************************
108 * AcquireCredentialsHandleW (SECUR32.@)
110 SECURITY_STATUS WINAPI AcquireCredentialsHandleW(
111 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse,
112 PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
113 PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
117 TRACE("%s %s %d %p %p %p %p %p %p\n", debugstr_w(pszPrincipal),
118 debugstr_w(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
119 pvGetKeyArgument, phCredential, ptsExpiry);
122 SecurePackage *package = SECUR32_findPackageW(pszPackage);
124 if (package && package->provider)
126 if (package->provider->fnTableW.AcquireCredentialsHandleW)
130 ret = package->provider->fnTableW.AcquireCredentialsHandleW(
131 pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
132 pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
136 ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
138 package->provider->fnTableW.FreeCredentialsHandle(
143 ret = SEC_E_UNSUPPORTED_FUNCTION;
146 ret = SEC_E_SECPKG_NOT_FOUND;
149 ret = SEC_E_SECPKG_NOT_FOUND;
153 /***********************************************************************
154 * FreeCredentialsHandle (SECUR32.@)
156 SECURITY_STATUS WINAPI FreeCredentialsHandle(
157 PCredHandle phCredential)
161 TRACE("%p\n", phCredential);
164 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
165 PCredHandle cred = (PCredHandle)phCredential->dwLower;
167 if (package && package->provider &&
168 package->provider->fnTableW.FreeCredentialsHandle)
169 ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
171 ret = SEC_E_INVALID_HANDLE;
175 ret = SEC_E_INVALID_HANDLE;
179 /***********************************************************************
180 * QueryCredentialsAttributesA (SECUR32.@)
182 SECURITY_STATUS WINAPI QueryCredentialsAttributesA(
183 PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
187 TRACE("%p %d %p\n", phCredential, ulAttribute, pBuffer);
190 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
191 PCredHandle cred = (PCredHandle)phCredential->dwLower;
193 if (package && package->provider)
195 if (package->provider->fnTableA.QueryCredentialsAttributesA)
196 ret = package->provider->fnTableA.QueryCredentialsAttributesA(
197 cred, ulAttribute, pBuffer);
199 ret = SEC_E_UNSUPPORTED_FUNCTION;
202 ret = SEC_E_INVALID_HANDLE;
205 ret = SEC_E_INVALID_HANDLE;
209 /***********************************************************************
210 * QueryCredentialsAttributesW (SECUR32.@)
212 SECURITY_STATUS WINAPI QueryCredentialsAttributesW(
213 PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
217 TRACE("%p %d %p\n", phCredential, ulAttribute, pBuffer);
220 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
221 PCredHandle cred = (PCredHandle)phCredential->dwLower;
223 if (package && package->provider)
225 if (package->provider->fnTableW.QueryCredentialsAttributesW)
226 ret = package->provider->fnTableW.QueryCredentialsAttributesW(
227 cred, ulAttribute, pBuffer);
229 ret = SEC_E_UNSUPPORTED_FUNCTION;
232 ret = SEC_E_INVALID_HANDLE;
235 ret = SEC_E_INVALID_HANDLE;
239 /***********************************************************************
240 * InitializeSecurityContextA (SECUR32.@)
242 SECURITY_STATUS WINAPI InitializeSecurityContextA(
243 PCredHandle phCredential, PCtxtHandle phContext,
244 SEC_CHAR *pszTargetName, ULONG fContextReq,
245 ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
246 ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
247 ULONG *pfContextAttr, PTimeStamp ptsExpiry)
251 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
252 debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
253 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
256 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
257 PCredHandle cred = (PCredHandle)phCredential->dwLower;
259 if (package && package->provider)
261 if (package->provider->fnTableA.InitializeSecurityContextA)
267 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
268 myCtxt.dwUpper = realCtxt->dwUpper;
269 myCtxt.dwLower = realCtxt->dwLower;
272 ret = package->provider->fnTableA.InitializeSecurityContextA(
273 cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq,
274 Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt,
275 pOutput, pfContextAttr, ptsExpiry);
276 if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
278 SECURITY_STATUS ret2;
279 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
280 if (ret2 != SEC_E_OK)
281 package->provider->fnTableW.DeleteSecurityContext(
286 ret = SEC_E_UNSUPPORTED_FUNCTION;
289 ret = SEC_E_INVALID_HANDLE;
292 ret = SEC_E_INVALID_HANDLE;
296 /***********************************************************************
297 * InitializeSecurityContextW (SECUR32.@)
299 SECURITY_STATUS WINAPI InitializeSecurityContextW(
300 PCredHandle phCredential, PCtxtHandle phContext,
301 SEC_WCHAR *pszTargetName, ULONG fContextReq,
302 ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
303 ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
304 ULONG *pfContextAttr, PTimeStamp ptsExpiry)
308 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
309 debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
310 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
313 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
314 PCredHandle cred = (PCredHandle)phCredential->dwLower;
316 if (package && package->provider)
318 if (package->provider->fnTableW.QueryCredentialsAttributesW)
324 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
325 myCtxt.dwUpper = realCtxt->dwUpper;
326 myCtxt.dwLower = realCtxt->dwLower;
329 ret = package->provider->fnTableW.InitializeSecurityContextW(
330 cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq,
331 Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt,
332 pOutput, pfContextAttr, ptsExpiry);
333 if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
335 SECURITY_STATUS ret2;
336 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
337 if (ret2 != SEC_E_OK)
338 package->provider->fnTableW.DeleteSecurityContext(
343 ret = SEC_E_UNSUPPORTED_FUNCTION;
346 ret = SEC_E_INVALID_HANDLE;
349 ret = SEC_E_INVALID_HANDLE;
353 /***********************************************************************
354 * AcceptSecurityContext (SECUR32.@)
356 SECURITY_STATUS WINAPI AcceptSecurityContext(
357 PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
358 ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
359 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
363 TRACE("%p %p %p %d %d %p %p %p %p\n", phCredential, phContext, pInput,
364 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
368 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
369 PCredHandle cred = (PCredHandle)phCredential->dwLower;
371 if (package && package->provider)
373 if (package->provider->fnTableW.AcceptSecurityContext)
379 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
380 TRACE("realCtx: %p\n", realCtxt);
381 myCtxt.dwUpper = realCtxt->dwUpper;
382 myCtxt.dwLower = realCtxt->dwLower;
385 ret = package->provider->fnTableW.AcceptSecurityContext(
386 cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
387 TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
388 if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
390 SECURITY_STATUS ret2;
391 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
392 if (ret2 != SEC_E_OK)
393 package->provider->fnTableW.DeleteSecurityContext(
398 ret = SEC_E_UNSUPPORTED_FUNCTION;
401 ret = SEC_E_INVALID_HANDLE;
404 ret = SEC_E_INVALID_HANDLE;
408 /***********************************************************************
409 * CompleteAuthToken (SECUR32.@)
411 SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext,
412 PSecBufferDesc pToken)
416 TRACE("%p %p\n", phContext, pToken);
419 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
420 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
422 if (package && package->provider)
424 if (package->provider->fnTableW.CompleteAuthToken)
425 ret = package->provider->fnTableW.CompleteAuthToken(ctxt,
428 ret = SEC_E_UNSUPPORTED_FUNCTION;
431 ret = SEC_E_INVALID_HANDLE;
434 ret = SEC_E_INVALID_HANDLE;
438 /***********************************************************************
439 * DeleteSecurityContext (SECUR32.@)
441 SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
445 TRACE("%p\n", phContext);
448 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
449 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
451 if (package && package->provider &&
452 package->provider->fnTableW.DeleteSecurityContext)
453 ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
455 ret = SEC_E_INVALID_HANDLE;
459 ret = SEC_E_INVALID_HANDLE;
463 /***********************************************************************
464 * ApplyControlToken (SECUR32.@)
466 SECURITY_STATUS WINAPI ApplyControlToken(PCtxtHandle phContext,
467 PSecBufferDesc pInput)
471 TRACE("%p %p\n", phContext, pInput);
474 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
475 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
477 if (package && package->provider)
479 if (package->provider->fnTableW.ApplyControlToken)
480 ret = package->provider->fnTableW.ApplyControlToken(
483 ret = SEC_E_UNSUPPORTED_FUNCTION;
486 ret = SEC_E_INVALID_HANDLE;
489 ret = SEC_E_INVALID_HANDLE;
493 /***********************************************************************
494 * QueryContextAttributesA (SECUR32.@)
496 SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext,
497 ULONG ulAttribute, void *pBuffer)
501 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
504 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
505 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
507 if (package && package->provider)
509 if (package->provider->fnTableA.QueryContextAttributesA)
510 ret = package->provider->fnTableA.QueryContextAttributesA(
511 ctxt, ulAttribute, pBuffer);
513 ret = SEC_E_UNSUPPORTED_FUNCTION;
516 ret = SEC_E_INVALID_HANDLE;
519 ret = SEC_E_INVALID_HANDLE;
523 /***********************************************************************
524 * QueryContextAttributesW (SECUR32.@)
526 SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext,
527 ULONG ulAttribute, void *pBuffer)
531 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
534 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
535 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
537 if (package && package->provider)
539 if (package->provider->fnTableW.QueryContextAttributesW)
540 ret = package->provider->fnTableW.QueryContextAttributesW(
541 ctxt, ulAttribute, pBuffer);
543 ret = SEC_E_UNSUPPORTED_FUNCTION;
546 ret = SEC_E_INVALID_HANDLE;
549 ret = SEC_E_INVALID_HANDLE;
553 /***********************************************************************
554 * ImpersonateSecurityContext (SECUR32.@)
556 SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
560 TRACE("%p\n", phContext);
563 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
564 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
566 if (package && package->provider)
568 if (package->provider->fnTableW.ImpersonateSecurityContext)
569 ret = package->provider->fnTableW.ImpersonateSecurityContext(
572 ret = SEC_E_UNSUPPORTED_FUNCTION;
575 ret = SEC_E_INVALID_HANDLE;
578 ret = SEC_E_INVALID_HANDLE;
582 /***********************************************************************
583 * RevertSecurityContext (SECUR32.@)
585 SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
589 TRACE("%p\n", phContext);
592 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
593 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
595 if (package && package->provider)
597 if (package->provider->fnTableW.RevertSecurityContext)
598 ret = package->provider->fnTableW.RevertSecurityContext(
601 ret = SEC_E_UNSUPPORTED_FUNCTION;
604 ret = SEC_E_INVALID_HANDLE;
607 ret = SEC_E_INVALID_HANDLE;
611 /***********************************************************************
612 * MakeSignature (SECUR32.@)
614 SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP,
615 PSecBufferDesc pMessage, ULONG MessageSeqNo)
619 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
622 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
623 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
625 if (package && package->provider)
627 if (package->provider->fnTableW.MakeSignature)
628 ret = package->provider->fnTableW.MakeSignature(
629 ctxt, fQOP, pMessage, MessageSeqNo);
631 ret = SEC_E_UNSUPPORTED_FUNCTION;
634 ret = SEC_E_INVALID_HANDLE;
637 ret = SEC_E_INVALID_HANDLE;
641 /***********************************************************************
642 * VerifySignature (SECUR32.@)
644 SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext,
645 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
649 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
652 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
653 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
655 if (package && package->provider)
657 if (package->provider->fnTableW.VerifySignature)
658 ret = package->provider->fnTableW.VerifySignature(
659 ctxt, pMessage, MessageSeqNo, pfQOP);
661 ret = SEC_E_UNSUPPORTED_FUNCTION;
664 ret = SEC_E_INVALID_HANDLE;
667 ret = SEC_E_INVALID_HANDLE;
671 /***********************************************************************
672 * QuerySecurityPackageInfoA (SECUR32.@)
674 SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
675 PSecPkgInfoA *ppPackageInfo)
679 TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
682 SecurePackage *package = SECUR32_findPackageA(pszPackageName);
686 size_t bytesNeeded = sizeof(SecPkgInfoA);
687 int nameLen = 0, commentLen = 0;
689 if (package->infoW.Name)
691 nameLen = WideCharToMultiByte(CP_ACP, 0,
692 package->infoW.Name, -1, NULL, 0, NULL, NULL);
693 bytesNeeded += nameLen;
695 if (package->infoW.Comment)
697 commentLen = WideCharToMultiByte(CP_ACP, 0,
698 package->infoW.Comment, -1, NULL, 0, NULL, NULL);
699 bytesNeeded += commentLen;
701 *ppPackageInfo = (PSecPkgInfoA)SECUR32_ALLOC(bytesNeeded);
704 PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
705 sizeof(SecPkgInfoA));
707 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
708 if (package->infoW.Name)
710 (*ppPackageInfo)->Name = nextString;
711 nextString += WideCharToMultiByte(CP_ACP, 0,
712 package->infoW.Name, -1, nextString, nameLen, NULL, NULL);
715 (*ppPackageInfo)->Name = NULL;
716 if (package->infoW.Comment)
718 (*ppPackageInfo)->Comment = nextString;
719 nextString += WideCharToMultiByte(CP_ACP, 0,
720 package->infoW.Comment, -1, nextString, commentLen, NULL,
724 (*ppPackageInfo)->Comment = NULL;
728 ret = SEC_E_INSUFFICIENT_MEMORY;
731 ret = SEC_E_SECPKG_NOT_FOUND;
734 ret = SEC_E_SECPKG_NOT_FOUND;
738 /***********************************************************************
739 * QuerySecurityPackageInfoW (SECUR32.@)
741 SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
742 PSecPkgInfoW *ppPackageInfo)
745 SecurePackage *package = SECUR32_findPackageW(pszPackageName);
747 TRACE("%s %p\n", debugstr_w(pszPackageName), ppPackageInfo);
750 size_t bytesNeeded = sizeof(SecPkgInfoW);
751 int nameLen = 0, commentLen = 0;
753 if (package->infoW.Name)
755 nameLen = lstrlenW(package->infoW.Name) + 1;
756 bytesNeeded += nameLen * sizeof(WCHAR);
758 if (package->infoW.Comment)
760 commentLen = lstrlenW(package->infoW.Comment) + 1;
761 bytesNeeded += commentLen * sizeof(WCHAR);
763 *ppPackageInfo = (PSecPkgInfoW)SECUR32_ALLOC(bytesNeeded);
766 PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
767 sizeof(SecPkgInfoW));
769 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
770 if (package->infoW.Name)
772 (*ppPackageInfo)->Name = nextString;
773 lstrcpynW(nextString, package->infoW.Name, nameLen);
774 nextString += nameLen;
777 (*ppPackageInfo)->Name = NULL;
778 if (package->infoW.Comment)
780 (*ppPackageInfo)->Comment = nextString;
781 lstrcpynW(nextString, package->infoW.Comment, commentLen);
782 nextString += commentLen;
785 (*ppPackageInfo)->Comment = NULL;
789 ret = SEC_E_INSUFFICIENT_MEMORY;
792 ret = SEC_E_SECPKG_NOT_FOUND;
796 /***********************************************************************
797 * ExportSecurityContext (SECUR32.@)
799 SECURITY_STATUS WINAPI ExportSecurityContext(PCtxtHandle phContext,
800 ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
804 TRACE("%p %d %p %p\n", phContext, fFlags, pPackedContext, pToken);
807 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
808 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
810 if (package && package->provider)
812 if (package->provider->fnTableW.ExportSecurityContext)
813 ret = package->provider->fnTableW.ExportSecurityContext(
814 ctxt, fFlags, pPackedContext, pToken);
816 ret = SEC_E_UNSUPPORTED_FUNCTION;
819 ret = SEC_E_INVALID_HANDLE;
822 ret = SEC_E_INVALID_HANDLE;
826 /***********************************************************************
827 * ImportSecurityContextA (SECUR32.@)
829 SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
830 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
833 SecurePackage *package = SECUR32_findPackageA(pszPackage);
835 TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
837 if (package && package->provider)
839 if (package->provider->fnTableA.ImportSecurityContextA)
843 ret = package->provider->fnTableA.ImportSecurityContextA(
844 pszPackage, pPackedContext, Token, &myCtxt);
847 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
849 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
853 ret = SEC_E_UNSUPPORTED_FUNCTION;
856 ret = SEC_E_SECPKG_NOT_FOUND;
861 /***********************************************************************
862 * ImportSecurityContextW (SECUR32.@)
864 SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage,
865 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
868 SecurePackage *package = SECUR32_findPackageW(pszPackage);
870 TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
872 if (package && package->provider)
874 if (package->provider->fnTableW.ImportSecurityContextW)
878 ret = package->provider->fnTableW.ImportSecurityContextW(
879 pszPackage, pPackedContext, Token, &myCtxt);
882 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
884 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
888 ret = SEC_E_UNSUPPORTED_FUNCTION;
891 ret = SEC_E_SECPKG_NOT_FOUND;
895 /***********************************************************************
896 * AddCredentialsA (SECUR32.@)
898 SECURITY_STATUS WINAPI AddCredentialsA(PCredHandle hCredentials,
899 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
900 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
901 PTimeStamp ptsExpiry)
905 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_a(pszPrincipal),
906 debugstr_a(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
907 pvGetKeyArgument, ptsExpiry);
910 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
911 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
913 if (package && package->provider)
915 if (package->provider->fnTableA.AddCredentialsA)
916 ret = package->provider->fnTableA.AddCredentialsA(
917 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
918 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
920 ret = SEC_E_UNSUPPORTED_FUNCTION;
923 ret = SEC_E_INVALID_HANDLE;
926 ret = SEC_E_INVALID_HANDLE;
930 /***********************************************************************
931 * AddCredentialsW (SECUR32.@)
933 SECURITY_STATUS WINAPI AddCredentialsW(PCredHandle hCredentials,
934 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
935 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
936 PTimeStamp ptsExpiry)
940 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_w(pszPrincipal),
941 debugstr_w(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
942 pvGetKeyArgument, ptsExpiry);
945 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
946 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
948 if (package && package->provider)
950 if (package->provider->fnTableW.AddCredentialsW)
951 ret = package->provider->fnTableW.AddCredentialsW(
952 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
953 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
955 ret = SEC_E_UNSUPPORTED_FUNCTION;
958 ret = SEC_E_INVALID_HANDLE;
961 ret = SEC_E_INVALID_HANDLE;
965 /***********************************************************************
966 * QuerySecurityContextToken (SECUR32.@)
968 SECURITY_STATUS WINAPI QuerySecurityContextToken(PCtxtHandle phContext,
973 TRACE("%p %p\n", phContext, phToken);
976 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
977 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
979 if (package && package->provider)
981 if (package->provider->fnTableW.QuerySecurityContextToken)
982 ret = package->provider->fnTableW.QuerySecurityContextToken(
985 ret = SEC_E_UNSUPPORTED_FUNCTION;
988 ret = SEC_E_INVALID_HANDLE;
991 ret = SEC_E_INVALID_HANDLE;
995 /***********************************************************************
996 * EncryptMessage (SECUR32.@)
998 SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
999 PSecBufferDesc pMessage, ULONG MessageSeqNo)
1001 SECURITY_STATUS ret;
1003 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
1006 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1007 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1009 if (package && package->provider)
1011 if (package->provider->fnTableW.EncryptMessage)
1012 ret = package->provider->fnTableW.EncryptMessage(
1013 ctxt, fQOP, pMessage, MessageSeqNo);
1015 ret = SEC_E_UNSUPPORTED_FUNCTION;
1018 ret = SEC_E_INVALID_HANDLE;
1021 ret = SEC_E_INVALID_HANDLE;
1025 /***********************************************************************
1026 * DecryptMessage (SECUR32.@)
1028 SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext,
1029 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
1031 SECURITY_STATUS ret;
1033 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
1036 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1037 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1039 if (package && package->provider)
1041 if (package->provider->fnTableW.DecryptMessage)
1042 ret = package->provider->fnTableW.DecryptMessage(
1043 ctxt, pMessage, MessageSeqNo, pfQOP);
1045 ret = SEC_E_UNSUPPORTED_FUNCTION;
1048 ret = SEC_E_INVALID_HANDLE;
1051 ret = SEC_E_INVALID_HANDLE;
1055 /***********************************************************************
1056 * SetContextAttributesA (SECUR32.@)
1058 SECURITY_STATUS WINAPI SetContextAttributesA(PCtxtHandle phContext,
1059 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1061 SECURITY_STATUS ret;
1063 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1066 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1067 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1069 if (package && package->provider)
1071 if (package->provider->fnTableA.SetContextAttributesA)
1072 ret = package->provider->fnTableA.SetContextAttributesA(
1073 ctxt, ulAttribute, pBuffer, cbBuffer);
1075 ret = SEC_E_UNSUPPORTED_FUNCTION;
1078 ret = SEC_E_INVALID_HANDLE;
1081 ret = SEC_E_INVALID_HANDLE;
1085 /***********************************************************************
1086 * SetContextAttributesW (SECUR32.@)
1088 SECURITY_STATUS WINAPI SetContextAttributesW(PCtxtHandle phContext,
1089 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1091 SECURITY_STATUS ret;
1093 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1096 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1097 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1099 if (package && package->provider)
1101 if (package->provider->fnTableW.SetContextAttributesW)
1102 ret = package->provider->fnTableW.SetContextAttributesW(
1103 ctxt, ulAttribute, pBuffer, cbBuffer);
1105 ret = SEC_E_UNSUPPORTED_FUNCTION;
1108 ret = SEC_E_INVALID_HANDLE;
1111 ret = SEC_E_INVALID_HANDLE;