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 = HeapAlloc(GetProcessHeap(), 0, sizeof(SecHandle));
48 *newSec = *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;
172 HeapFree(GetProcessHeap(), 0, cred);
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)
250 SecurePackage *package = NULL;
251 PCredHandle cred = NULL;
252 PCredHandle ctxt = NULL;
254 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
255 debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
256 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
260 package = (SecurePackage *)phContext->dwUpper;
261 ctxt = (PCtxtHandle)phContext->dwLower;
265 package = (SecurePackage *)phCredential->dwUpper;
266 cred = (PCredHandle)phCredential->dwLower;
269 if (package && package->provider)
271 if (package->provider->fnTableA.InitializeSecurityContextA)
277 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
278 myCtxt.dwUpper = realCtxt->dwUpper;
279 myCtxt.dwLower = realCtxt->dwLower;
282 ret = package->provider->fnTableA.InitializeSecurityContextA(
283 cred, ctxt, pszTargetName, fContextReq,
284 Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
285 pOutput, pfContextAttr, ptsExpiry);
286 if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) &&
287 phNewContext && phNewContext != phContext)
289 SECURITY_STATUS ret2;
290 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
291 if (ret2 != SEC_E_OK)
292 package->provider->fnTableA.DeleteSecurityContext(&myCtxt);
296 ret = SEC_E_UNSUPPORTED_FUNCTION;
299 ret = SEC_E_INVALID_HANDLE;
303 /***********************************************************************
304 * InitializeSecurityContextW (SECUR32.@)
306 SECURITY_STATUS WINAPI InitializeSecurityContextW(
307 PCredHandle phCredential, PCtxtHandle phContext,
308 SEC_WCHAR *pszTargetName, ULONG fContextReq,
309 ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
310 ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
311 ULONG *pfContextAttr, PTimeStamp ptsExpiry)
314 SecurePackage *package = NULL;
315 PCredHandle cred = NULL;
316 PCredHandle ctxt = NULL;
318 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
319 debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
320 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
324 package = (SecurePackage *)phContext->dwUpper;
325 ctxt = (PCtxtHandle)phContext->dwLower;
329 package = (SecurePackage *)phCredential->dwUpper;
330 cred = (PCredHandle)phCredential->dwLower;
333 if (package && package->provider)
335 if (package->provider->fnTableW.InitializeSecurityContextW)
341 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
342 myCtxt.dwUpper = realCtxt->dwUpper;
343 myCtxt.dwLower = realCtxt->dwLower;
346 ret = package->provider->fnTableW.InitializeSecurityContextW(
347 cred, ctxt, pszTargetName, fContextReq,
348 Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
349 pOutput, pfContextAttr, ptsExpiry);
350 if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) &&
351 phNewContext && phNewContext != phContext)
353 SECURITY_STATUS ret2;
354 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
355 if (ret2 != SEC_E_OK)
356 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
360 ret = SEC_E_UNSUPPORTED_FUNCTION;
363 ret = SEC_E_INVALID_HANDLE;
367 /***********************************************************************
368 * AcceptSecurityContext (SECUR32.@)
370 SECURITY_STATUS WINAPI AcceptSecurityContext(
371 PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
372 ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
373 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
377 TRACE("%p %p %p %d %d %p %p %p %p\n", phCredential, phContext, pInput,
378 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
382 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
383 PCredHandle cred = (PCredHandle)phCredential->dwLower;
385 if (package && package->provider)
387 if (package->provider->fnTableW.AcceptSecurityContext)
393 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
394 TRACE("realCtx: %p\n", realCtxt);
395 myCtxt.dwUpper = realCtxt->dwUpper;
396 myCtxt.dwLower = realCtxt->dwLower;
399 ret = package->provider->fnTableW.AcceptSecurityContext(
400 cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
401 TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
402 if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
404 SECURITY_STATUS ret2;
405 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
406 if (ret2 != SEC_E_OK)
407 package->provider->fnTableW.DeleteSecurityContext(
412 ret = SEC_E_UNSUPPORTED_FUNCTION;
415 ret = SEC_E_INVALID_HANDLE;
418 ret = SEC_E_INVALID_HANDLE;
422 /***********************************************************************
423 * CompleteAuthToken (SECUR32.@)
425 SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext,
426 PSecBufferDesc pToken)
430 TRACE("%p %p\n", phContext, pToken);
433 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
434 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
436 if (package && package->provider)
438 if (package->provider->fnTableW.CompleteAuthToken)
439 ret = package->provider->fnTableW.CompleteAuthToken(ctxt,
442 ret = SEC_E_UNSUPPORTED_FUNCTION;
445 ret = SEC_E_INVALID_HANDLE;
448 ret = SEC_E_INVALID_HANDLE;
452 /***********************************************************************
453 * DeleteSecurityContext (SECUR32.@)
455 SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
459 TRACE("%p\n", phContext);
462 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
463 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
465 if (package && package->provider &&
466 package->provider->fnTableW.DeleteSecurityContext)
467 ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
469 ret = SEC_E_INVALID_HANDLE;
470 HeapFree(GetProcessHeap(), 0, ctxt);
473 ret = SEC_E_INVALID_HANDLE;
477 /***********************************************************************
478 * ApplyControlToken (SECUR32.@)
480 SECURITY_STATUS WINAPI ApplyControlToken(PCtxtHandle phContext,
481 PSecBufferDesc pInput)
485 TRACE("%p %p\n", phContext, pInput);
488 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
489 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
491 if (package && package->provider)
493 if (package->provider->fnTableW.ApplyControlToken)
494 ret = package->provider->fnTableW.ApplyControlToken(
497 ret = SEC_E_UNSUPPORTED_FUNCTION;
500 ret = SEC_E_INVALID_HANDLE;
503 ret = SEC_E_INVALID_HANDLE;
507 /***********************************************************************
508 * QueryContextAttributesA (SECUR32.@)
510 SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext,
511 ULONG ulAttribute, void *pBuffer)
515 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
518 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
519 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
521 if (package && package->provider)
523 if (package->provider->fnTableA.QueryContextAttributesA)
524 ret = package->provider->fnTableA.QueryContextAttributesA(
525 ctxt, ulAttribute, pBuffer);
527 ret = SEC_E_UNSUPPORTED_FUNCTION;
530 ret = SEC_E_INVALID_HANDLE;
533 ret = SEC_E_INVALID_HANDLE;
537 /***********************************************************************
538 * QueryContextAttributesW (SECUR32.@)
540 SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext,
541 ULONG ulAttribute, void *pBuffer)
545 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
548 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
549 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
551 if (package && package->provider)
553 if (package->provider->fnTableW.QueryContextAttributesW)
554 ret = package->provider->fnTableW.QueryContextAttributesW(
555 ctxt, ulAttribute, pBuffer);
557 ret = SEC_E_UNSUPPORTED_FUNCTION;
560 ret = SEC_E_INVALID_HANDLE;
563 ret = SEC_E_INVALID_HANDLE;
567 /***********************************************************************
568 * ImpersonateSecurityContext (SECUR32.@)
570 SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
574 TRACE("%p\n", phContext);
577 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
578 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
580 if (package && package->provider)
582 if (package->provider->fnTableW.ImpersonateSecurityContext)
583 ret = package->provider->fnTableW.ImpersonateSecurityContext(
586 ret = SEC_E_UNSUPPORTED_FUNCTION;
589 ret = SEC_E_INVALID_HANDLE;
592 ret = SEC_E_INVALID_HANDLE;
596 /***********************************************************************
597 * RevertSecurityContext (SECUR32.@)
599 SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
603 TRACE("%p\n", phContext);
606 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
607 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
609 if (package && package->provider)
611 if (package->provider->fnTableW.RevertSecurityContext)
612 ret = package->provider->fnTableW.RevertSecurityContext(
615 ret = SEC_E_UNSUPPORTED_FUNCTION;
618 ret = SEC_E_INVALID_HANDLE;
621 ret = SEC_E_INVALID_HANDLE;
625 /***********************************************************************
626 * MakeSignature (SECUR32.@)
628 SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP,
629 PSecBufferDesc pMessage, ULONG MessageSeqNo)
633 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
636 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
637 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
639 if (package && package->provider)
641 if (package->provider->fnTableW.MakeSignature)
642 ret = package->provider->fnTableW.MakeSignature(
643 ctxt, fQOP, pMessage, MessageSeqNo);
645 ret = SEC_E_UNSUPPORTED_FUNCTION;
648 ret = SEC_E_INVALID_HANDLE;
651 ret = SEC_E_INVALID_HANDLE;
655 /***********************************************************************
656 * VerifySignature (SECUR32.@)
658 SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext,
659 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
663 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
666 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
667 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
669 if (package && package->provider)
671 if (package->provider->fnTableW.VerifySignature)
672 ret = package->provider->fnTableW.VerifySignature(
673 ctxt, pMessage, MessageSeqNo, pfQOP);
675 ret = SEC_E_UNSUPPORTED_FUNCTION;
678 ret = SEC_E_INVALID_HANDLE;
681 ret = SEC_E_INVALID_HANDLE;
685 /***********************************************************************
686 * QuerySecurityPackageInfoA (SECUR32.@)
688 SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
689 PSecPkgInfoA *ppPackageInfo)
693 TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
696 SecurePackage *package = SECUR32_findPackageA(pszPackageName);
700 size_t bytesNeeded = sizeof(SecPkgInfoA);
701 int nameLen = 0, commentLen = 0;
703 if (package->infoW.Name)
705 nameLen = WideCharToMultiByte(CP_ACP, 0,
706 package->infoW.Name, -1, NULL, 0, NULL, NULL);
707 bytesNeeded += nameLen;
709 if (package->infoW.Comment)
711 commentLen = WideCharToMultiByte(CP_ACP, 0,
712 package->infoW.Comment, -1, NULL, 0, NULL, NULL);
713 bytesNeeded += commentLen;
715 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
718 PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
719 sizeof(SecPkgInfoA));
721 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
722 if (package->infoW.Name)
724 (*ppPackageInfo)->Name = nextString;
725 nextString += WideCharToMultiByte(CP_ACP, 0,
726 package->infoW.Name, -1, nextString, nameLen, NULL, NULL);
729 (*ppPackageInfo)->Name = NULL;
730 if (package->infoW.Comment)
732 (*ppPackageInfo)->Comment = nextString;
733 nextString += WideCharToMultiByte(CP_ACP, 0,
734 package->infoW.Comment, -1, nextString, commentLen, NULL,
738 (*ppPackageInfo)->Comment = NULL;
742 ret = SEC_E_INSUFFICIENT_MEMORY;
745 ret = SEC_E_SECPKG_NOT_FOUND;
748 ret = SEC_E_SECPKG_NOT_FOUND;
752 /***********************************************************************
753 * QuerySecurityPackageInfoW (SECUR32.@)
755 SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
756 PSecPkgInfoW *ppPackageInfo)
759 SecurePackage *package = SECUR32_findPackageW(pszPackageName);
761 TRACE("%s %p\n", debugstr_w(pszPackageName), ppPackageInfo);
764 size_t bytesNeeded = sizeof(SecPkgInfoW);
765 int nameLen = 0, commentLen = 0;
767 if (package->infoW.Name)
769 nameLen = lstrlenW(package->infoW.Name) + 1;
770 bytesNeeded += nameLen * sizeof(WCHAR);
772 if (package->infoW.Comment)
774 commentLen = lstrlenW(package->infoW.Comment) + 1;
775 bytesNeeded += commentLen * sizeof(WCHAR);
777 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
780 PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
781 sizeof(SecPkgInfoW));
783 **ppPackageInfo = package->infoW;
784 if (package->infoW.Name)
786 (*ppPackageInfo)->Name = nextString;
787 lstrcpynW(nextString, package->infoW.Name, nameLen);
788 nextString += nameLen;
791 (*ppPackageInfo)->Name = NULL;
792 if (package->infoW.Comment)
794 (*ppPackageInfo)->Comment = nextString;
795 lstrcpynW(nextString, package->infoW.Comment, commentLen);
796 nextString += commentLen;
799 (*ppPackageInfo)->Comment = NULL;
803 ret = SEC_E_INSUFFICIENT_MEMORY;
806 ret = SEC_E_SECPKG_NOT_FOUND;
810 /***********************************************************************
811 * ExportSecurityContext (SECUR32.@)
813 SECURITY_STATUS WINAPI ExportSecurityContext(PCtxtHandle phContext,
814 ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
818 TRACE("%p %d %p %p\n", phContext, fFlags, pPackedContext, pToken);
821 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
822 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
824 if (package && package->provider)
826 if (package->provider->fnTableW.ExportSecurityContext)
827 ret = package->provider->fnTableW.ExportSecurityContext(
828 ctxt, fFlags, pPackedContext, pToken);
830 ret = SEC_E_UNSUPPORTED_FUNCTION;
833 ret = SEC_E_INVALID_HANDLE;
836 ret = SEC_E_INVALID_HANDLE;
840 /***********************************************************************
841 * ImportSecurityContextA (SECUR32.@)
843 SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
844 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
847 SecurePackage *package = SECUR32_findPackageA(pszPackage);
849 TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
851 if (package && package->provider)
853 if (package->provider->fnTableA.ImportSecurityContextA)
857 ret = package->provider->fnTableA.ImportSecurityContextA(
858 pszPackage, pPackedContext, Token, &myCtxt);
861 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
863 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
867 ret = SEC_E_UNSUPPORTED_FUNCTION;
870 ret = SEC_E_SECPKG_NOT_FOUND;
875 /***********************************************************************
876 * ImportSecurityContextW (SECUR32.@)
878 SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage,
879 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
882 SecurePackage *package = SECUR32_findPackageW(pszPackage);
884 TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
886 if (package && package->provider)
888 if (package->provider->fnTableW.ImportSecurityContextW)
892 ret = package->provider->fnTableW.ImportSecurityContextW(
893 pszPackage, pPackedContext, Token, &myCtxt);
896 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
898 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
902 ret = SEC_E_UNSUPPORTED_FUNCTION;
905 ret = SEC_E_SECPKG_NOT_FOUND;
909 /***********************************************************************
910 * AddCredentialsA (SECUR32.@)
912 SECURITY_STATUS WINAPI AddCredentialsA(PCredHandle hCredentials,
913 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
914 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
915 PTimeStamp ptsExpiry)
919 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_a(pszPrincipal),
920 debugstr_a(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
921 pvGetKeyArgument, ptsExpiry);
924 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
925 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
927 if (package && package->provider)
929 if (package->provider->fnTableA.AddCredentialsA)
930 ret = package->provider->fnTableA.AddCredentialsA(
931 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
932 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
934 ret = SEC_E_UNSUPPORTED_FUNCTION;
937 ret = SEC_E_INVALID_HANDLE;
940 ret = SEC_E_INVALID_HANDLE;
944 /***********************************************************************
945 * AddCredentialsW (SECUR32.@)
947 SECURITY_STATUS WINAPI AddCredentialsW(PCredHandle hCredentials,
948 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
949 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
950 PTimeStamp ptsExpiry)
954 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_w(pszPrincipal),
955 debugstr_w(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
956 pvGetKeyArgument, ptsExpiry);
959 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
960 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
962 if (package && package->provider)
964 if (package->provider->fnTableW.AddCredentialsW)
965 ret = package->provider->fnTableW.AddCredentialsW(
966 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
967 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
969 ret = SEC_E_UNSUPPORTED_FUNCTION;
972 ret = SEC_E_INVALID_HANDLE;
975 ret = SEC_E_INVALID_HANDLE;
979 /***********************************************************************
980 * QuerySecurityContextToken (SECUR32.@)
982 SECURITY_STATUS WINAPI QuerySecurityContextToken(PCtxtHandle phContext,
987 TRACE("%p %p\n", phContext, phToken);
990 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
991 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
993 if (package && package->provider)
995 if (package->provider->fnTableW.QuerySecurityContextToken)
996 ret = package->provider->fnTableW.QuerySecurityContextToken(
999 ret = SEC_E_UNSUPPORTED_FUNCTION;
1002 ret = SEC_E_INVALID_HANDLE;
1005 ret = SEC_E_INVALID_HANDLE;
1009 /***********************************************************************
1010 * EncryptMessage (SECUR32.@)
1012 SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
1013 PSecBufferDesc pMessage, ULONG MessageSeqNo)
1015 SECURITY_STATUS ret;
1017 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
1020 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1021 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1023 if (package && package->provider)
1025 if (package->provider->fnTableW.EncryptMessage)
1026 ret = package->provider->fnTableW.EncryptMessage(
1027 ctxt, fQOP, pMessage, MessageSeqNo);
1029 ret = SEC_E_UNSUPPORTED_FUNCTION;
1032 ret = SEC_E_INVALID_HANDLE;
1035 ret = SEC_E_INVALID_HANDLE;
1039 /***********************************************************************
1040 * DecryptMessage (SECUR32.@)
1042 SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext,
1043 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
1045 SECURITY_STATUS ret;
1047 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
1050 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1051 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1053 if (package && package->provider)
1055 if (package->provider->fnTableW.DecryptMessage)
1056 ret = package->provider->fnTableW.DecryptMessage(
1057 ctxt, pMessage, MessageSeqNo, pfQOP);
1059 ret = SEC_E_UNSUPPORTED_FUNCTION;
1062 ret = SEC_E_INVALID_HANDLE;
1065 ret = SEC_E_INVALID_HANDLE;
1069 /***********************************************************************
1070 * SetContextAttributesA (SECUR32.@)
1072 SECURITY_STATUS WINAPI SetContextAttributesA(PCtxtHandle phContext,
1073 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1075 SECURITY_STATUS ret;
1077 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1080 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1081 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1083 if (package && package->provider)
1085 if (package->provider->fnTableA.SetContextAttributesA)
1086 ret = package->provider->fnTableA.SetContextAttributesA(
1087 ctxt, ulAttribute, pBuffer, cbBuffer);
1089 ret = SEC_E_UNSUPPORTED_FUNCTION;
1092 ret = SEC_E_INVALID_HANDLE;
1095 ret = SEC_E_INVALID_HANDLE;
1099 /***********************************************************************
1100 * SetContextAttributesW (SECUR32.@)
1102 SECURITY_STATUS WINAPI SetContextAttributesW(PCtxtHandle phContext,
1103 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1105 SECURITY_STATUS ret;
1107 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1110 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1111 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1113 if (package && package->provider)
1115 if (package->provider->fnTableW.SetContextAttributesW)
1116 ret = package->provider->fnTableW.SetContextAttributesW(
1117 ctxt, ulAttribute, pBuffer, cbBuffer);
1119 ret = SEC_E_UNSUPPORTED_FUNCTION;
1122 ret = SEC_E_INVALID_HANDLE;
1125 ret = SEC_E_INVALID_HANDLE;