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 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;
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) && phNewContext)
288 SECURITY_STATUS ret2;
289 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
290 if (ret2 != SEC_E_OK)
291 package->provider->fnTableA.DeleteSecurityContext(&myCtxt);
295 ret = SEC_E_UNSUPPORTED_FUNCTION;
298 ret = SEC_E_INVALID_HANDLE;
302 /***********************************************************************
303 * InitializeSecurityContextW (SECUR32.@)
305 SECURITY_STATUS WINAPI InitializeSecurityContextW(
306 PCredHandle phCredential, PCtxtHandle phContext,
307 SEC_WCHAR *pszTargetName, ULONG fContextReq,
308 ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
309 ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
310 ULONG *pfContextAttr, PTimeStamp ptsExpiry)
313 SecurePackage *package = NULL;
314 PCredHandle cred = NULL;
315 PCredHandle ctxt = NULL;
317 TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
318 debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
319 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
323 package = (SecurePackage *)phContext->dwUpper;
324 ctxt = (PCtxtHandle)phContext->dwLower;
328 package = (SecurePackage *)phCredential->dwUpper;
329 cred = (PCredHandle)phCredential->dwLower;
332 if (package && package->provider)
334 if (package->provider->fnTableW.InitializeSecurityContextW)
340 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
341 myCtxt.dwUpper = realCtxt->dwUpper;
342 myCtxt.dwLower = realCtxt->dwLower;
345 ret = package->provider->fnTableW.InitializeSecurityContextW(
346 cred, ctxt, pszTargetName, fContextReq,
347 Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
348 pOutput, pfContextAttr, ptsExpiry);
349 if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) && phNewContext)
351 SECURITY_STATUS ret2;
352 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
353 if (ret2 != SEC_E_OK)
354 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
358 ret = SEC_E_UNSUPPORTED_FUNCTION;
361 ret = SEC_E_INVALID_HANDLE;
365 /***********************************************************************
366 * AcceptSecurityContext (SECUR32.@)
368 SECURITY_STATUS WINAPI AcceptSecurityContext(
369 PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
370 ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
371 PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
375 TRACE("%p %p %p %d %d %p %p %p %p\n", phCredential, phContext, pInput,
376 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
380 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
381 PCredHandle cred = (PCredHandle)phCredential->dwLower;
383 if (package && package->provider)
385 if (package->provider->fnTableW.AcceptSecurityContext)
391 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
392 TRACE("realCtx: %p\n", realCtxt);
393 myCtxt.dwUpper = realCtxt->dwUpper;
394 myCtxt.dwLower = realCtxt->dwLower;
397 ret = package->provider->fnTableW.AcceptSecurityContext(
398 cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
399 TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
400 if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
402 SECURITY_STATUS ret2;
403 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
404 if (ret2 != SEC_E_OK)
405 package->provider->fnTableW.DeleteSecurityContext(
410 ret = SEC_E_UNSUPPORTED_FUNCTION;
413 ret = SEC_E_INVALID_HANDLE;
416 ret = SEC_E_INVALID_HANDLE;
420 /***********************************************************************
421 * CompleteAuthToken (SECUR32.@)
423 SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext,
424 PSecBufferDesc pToken)
428 TRACE("%p %p\n", phContext, pToken);
431 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
432 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
434 if (package && package->provider)
436 if (package->provider->fnTableW.CompleteAuthToken)
437 ret = package->provider->fnTableW.CompleteAuthToken(ctxt,
440 ret = SEC_E_UNSUPPORTED_FUNCTION;
443 ret = SEC_E_INVALID_HANDLE;
446 ret = SEC_E_INVALID_HANDLE;
450 /***********************************************************************
451 * DeleteSecurityContext (SECUR32.@)
453 SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
457 TRACE("%p\n", phContext);
460 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
461 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
463 if (package && package->provider &&
464 package->provider->fnTableW.DeleteSecurityContext)
465 ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
467 ret = SEC_E_INVALID_HANDLE;
468 HeapFree(GetProcessHeap(), 0, ctxt);
471 ret = SEC_E_INVALID_HANDLE;
475 /***********************************************************************
476 * ApplyControlToken (SECUR32.@)
478 SECURITY_STATUS WINAPI ApplyControlToken(PCtxtHandle phContext,
479 PSecBufferDesc pInput)
483 TRACE("%p %p\n", phContext, pInput);
486 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
487 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
489 if (package && package->provider)
491 if (package->provider->fnTableW.ApplyControlToken)
492 ret = package->provider->fnTableW.ApplyControlToken(
495 ret = SEC_E_UNSUPPORTED_FUNCTION;
498 ret = SEC_E_INVALID_HANDLE;
501 ret = SEC_E_INVALID_HANDLE;
505 /***********************************************************************
506 * QueryContextAttributesA (SECUR32.@)
508 SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext,
509 ULONG ulAttribute, void *pBuffer)
513 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
516 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
517 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
519 if (package && package->provider)
521 if (package->provider->fnTableA.QueryContextAttributesA)
522 ret = package->provider->fnTableA.QueryContextAttributesA(
523 ctxt, ulAttribute, pBuffer);
525 ret = SEC_E_UNSUPPORTED_FUNCTION;
528 ret = SEC_E_INVALID_HANDLE;
531 ret = SEC_E_INVALID_HANDLE;
535 /***********************************************************************
536 * QueryContextAttributesW (SECUR32.@)
538 SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext,
539 ULONG ulAttribute, void *pBuffer)
543 TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
546 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
547 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
549 if (package && package->provider)
551 if (package->provider->fnTableW.QueryContextAttributesW)
552 ret = package->provider->fnTableW.QueryContextAttributesW(
553 ctxt, ulAttribute, pBuffer);
555 ret = SEC_E_UNSUPPORTED_FUNCTION;
558 ret = SEC_E_INVALID_HANDLE;
561 ret = SEC_E_INVALID_HANDLE;
565 /***********************************************************************
566 * ImpersonateSecurityContext (SECUR32.@)
568 SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
572 TRACE("%p\n", phContext);
575 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
576 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
578 if (package && package->provider)
580 if (package->provider->fnTableW.ImpersonateSecurityContext)
581 ret = package->provider->fnTableW.ImpersonateSecurityContext(
584 ret = SEC_E_UNSUPPORTED_FUNCTION;
587 ret = SEC_E_INVALID_HANDLE;
590 ret = SEC_E_INVALID_HANDLE;
594 /***********************************************************************
595 * RevertSecurityContext (SECUR32.@)
597 SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
601 TRACE("%p\n", phContext);
604 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
605 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
607 if (package && package->provider)
609 if (package->provider->fnTableW.RevertSecurityContext)
610 ret = package->provider->fnTableW.RevertSecurityContext(
613 ret = SEC_E_UNSUPPORTED_FUNCTION;
616 ret = SEC_E_INVALID_HANDLE;
619 ret = SEC_E_INVALID_HANDLE;
623 /***********************************************************************
624 * MakeSignature (SECUR32.@)
626 SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP,
627 PSecBufferDesc pMessage, ULONG MessageSeqNo)
631 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
634 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
635 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
637 if (package && package->provider)
639 if (package->provider->fnTableW.MakeSignature)
640 ret = package->provider->fnTableW.MakeSignature(
641 ctxt, fQOP, pMessage, MessageSeqNo);
643 ret = SEC_E_UNSUPPORTED_FUNCTION;
646 ret = SEC_E_INVALID_HANDLE;
649 ret = SEC_E_INVALID_HANDLE;
653 /***********************************************************************
654 * VerifySignature (SECUR32.@)
656 SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext,
657 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
661 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
664 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
665 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
667 if (package && package->provider)
669 if (package->provider->fnTableW.VerifySignature)
670 ret = package->provider->fnTableW.VerifySignature(
671 ctxt, pMessage, MessageSeqNo, pfQOP);
673 ret = SEC_E_UNSUPPORTED_FUNCTION;
676 ret = SEC_E_INVALID_HANDLE;
679 ret = SEC_E_INVALID_HANDLE;
683 /***********************************************************************
684 * QuerySecurityPackageInfoA (SECUR32.@)
686 SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
687 PSecPkgInfoA *ppPackageInfo)
691 TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
694 SecurePackage *package = SECUR32_findPackageA(pszPackageName);
698 size_t bytesNeeded = sizeof(SecPkgInfoA);
699 int nameLen = 0, commentLen = 0;
701 if (package->infoW.Name)
703 nameLen = WideCharToMultiByte(CP_ACP, 0,
704 package->infoW.Name, -1, NULL, 0, NULL, NULL);
705 bytesNeeded += nameLen;
707 if (package->infoW.Comment)
709 commentLen = WideCharToMultiByte(CP_ACP, 0,
710 package->infoW.Comment, -1, NULL, 0, NULL, NULL);
711 bytesNeeded += commentLen;
713 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
716 PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
717 sizeof(SecPkgInfoA));
719 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
720 if (package->infoW.Name)
722 (*ppPackageInfo)->Name = nextString;
723 nextString += WideCharToMultiByte(CP_ACP, 0,
724 package->infoW.Name, -1, nextString, nameLen, NULL, NULL);
727 (*ppPackageInfo)->Name = NULL;
728 if (package->infoW.Comment)
730 (*ppPackageInfo)->Comment = nextString;
731 nextString += WideCharToMultiByte(CP_ACP, 0,
732 package->infoW.Comment, -1, nextString, commentLen, NULL,
736 (*ppPackageInfo)->Comment = NULL;
740 ret = SEC_E_INSUFFICIENT_MEMORY;
743 ret = SEC_E_SECPKG_NOT_FOUND;
746 ret = SEC_E_SECPKG_NOT_FOUND;
750 /***********************************************************************
751 * QuerySecurityPackageInfoW (SECUR32.@)
753 SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
754 PSecPkgInfoW *ppPackageInfo)
757 SecurePackage *package = SECUR32_findPackageW(pszPackageName);
759 TRACE("%s %p\n", debugstr_w(pszPackageName), ppPackageInfo);
762 size_t bytesNeeded = sizeof(SecPkgInfoW);
763 int nameLen = 0, commentLen = 0;
765 if (package->infoW.Name)
767 nameLen = lstrlenW(package->infoW.Name) + 1;
768 bytesNeeded += nameLen * sizeof(WCHAR);
770 if (package->infoW.Comment)
772 commentLen = lstrlenW(package->infoW.Comment) + 1;
773 bytesNeeded += commentLen * sizeof(WCHAR);
775 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
778 PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
779 sizeof(SecPkgInfoW));
781 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
782 if (package->infoW.Name)
784 (*ppPackageInfo)->Name = nextString;
785 lstrcpynW(nextString, package->infoW.Name, nameLen);
786 nextString += nameLen;
789 (*ppPackageInfo)->Name = NULL;
790 if (package->infoW.Comment)
792 (*ppPackageInfo)->Comment = nextString;
793 lstrcpynW(nextString, package->infoW.Comment, commentLen);
794 nextString += commentLen;
797 (*ppPackageInfo)->Comment = NULL;
801 ret = SEC_E_INSUFFICIENT_MEMORY;
804 ret = SEC_E_SECPKG_NOT_FOUND;
808 /***********************************************************************
809 * ExportSecurityContext (SECUR32.@)
811 SECURITY_STATUS WINAPI ExportSecurityContext(PCtxtHandle phContext,
812 ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
816 TRACE("%p %d %p %p\n", phContext, fFlags, pPackedContext, pToken);
819 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
820 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
822 if (package && package->provider)
824 if (package->provider->fnTableW.ExportSecurityContext)
825 ret = package->provider->fnTableW.ExportSecurityContext(
826 ctxt, fFlags, pPackedContext, pToken);
828 ret = SEC_E_UNSUPPORTED_FUNCTION;
831 ret = SEC_E_INVALID_HANDLE;
834 ret = SEC_E_INVALID_HANDLE;
838 /***********************************************************************
839 * ImportSecurityContextA (SECUR32.@)
841 SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
842 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
845 SecurePackage *package = SECUR32_findPackageA(pszPackage);
847 TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
849 if (package && package->provider)
851 if (package->provider->fnTableA.ImportSecurityContextA)
855 ret = package->provider->fnTableA.ImportSecurityContextA(
856 pszPackage, pPackedContext, Token, &myCtxt);
859 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
861 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
865 ret = SEC_E_UNSUPPORTED_FUNCTION;
868 ret = SEC_E_SECPKG_NOT_FOUND;
873 /***********************************************************************
874 * ImportSecurityContextW (SECUR32.@)
876 SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage,
877 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
880 SecurePackage *package = SECUR32_findPackageW(pszPackage);
882 TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
884 if (package && package->provider)
886 if (package->provider->fnTableW.ImportSecurityContextW)
890 ret = package->provider->fnTableW.ImportSecurityContextW(
891 pszPackage, pPackedContext, Token, &myCtxt);
894 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
896 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
900 ret = SEC_E_UNSUPPORTED_FUNCTION;
903 ret = SEC_E_SECPKG_NOT_FOUND;
907 /***********************************************************************
908 * AddCredentialsA (SECUR32.@)
910 SECURITY_STATUS WINAPI AddCredentialsA(PCredHandle hCredentials,
911 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
912 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
913 PTimeStamp ptsExpiry)
917 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_a(pszPrincipal),
918 debugstr_a(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
919 pvGetKeyArgument, ptsExpiry);
922 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
923 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
925 if (package && package->provider)
927 if (package->provider->fnTableA.AddCredentialsA)
928 ret = package->provider->fnTableA.AddCredentialsA(
929 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
930 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
932 ret = SEC_E_UNSUPPORTED_FUNCTION;
935 ret = SEC_E_INVALID_HANDLE;
938 ret = SEC_E_INVALID_HANDLE;
942 /***********************************************************************
943 * AddCredentialsW (SECUR32.@)
945 SECURITY_STATUS WINAPI AddCredentialsW(PCredHandle hCredentials,
946 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
947 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
948 PTimeStamp ptsExpiry)
952 TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_w(pszPrincipal),
953 debugstr_w(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
954 pvGetKeyArgument, ptsExpiry);
957 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
958 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
960 if (package && package->provider)
962 if (package->provider->fnTableW.AddCredentialsW)
963 ret = package->provider->fnTableW.AddCredentialsW(
964 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
965 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
967 ret = SEC_E_UNSUPPORTED_FUNCTION;
970 ret = SEC_E_INVALID_HANDLE;
973 ret = SEC_E_INVALID_HANDLE;
977 /***********************************************************************
978 * QuerySecurityContextToken (SECUR32.@)
980 SECURITY_STATUS WINAPI QuerySecurityContextToken(PCtxtHandle phContext,
985 TRACE("%p %p\n", phContext, phToken);
988 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
989 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
991 if (package && package->provider)
993 if (package->provider->fnTableW.QuerySecurityContextToken)
994 ret = package->provider->fnTableW.QuerySecurityContextToken(
997 ret = SEC_E_UNSUPPORTED_FUNCTION;
1000 ret = SEC_E_INVALID_HANDLE;
1003 ret = SEC_E_INVALID_HANDLE;
1007 /***********************************************************************
1008 * EncryptMessage (SECUR32.@)
1010 SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
1011 PSecBufferDesc pMessage, ULONG MessageSeqNo)
1013 SECURITY_STATUS ret;
1015 TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
1018 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1019 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1021 if (package && package->provider)
1023 if (package->provider->fnTableW.EncryptMessage)
1024 ret = package->provider->fnTableW.EncryptMessage(
1025 ctxt, fQOP, pMessage, MessageSeqNo);
1027 ret = SEC_E_UNSUPPORTED_FUNCTION;
1030 ret = SEC_E_INVALID_HANDLE;
1033 ret = SEC_E_INVALID_HANDLE;
1037 /***********************************************************************
1038 * DecryptMessage (SECUR32.@)
1040 SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext,
1041 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
1043 SECURITY_STATUS ret;
1045 TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
1048 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1049 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1051 if (package && package->provider)
1053 if (package->provider->fnTableW.DecryptMessage)
1054 ret = package->provider->fnTableW.DecryptMessage(
1055 ctxt, pMessage, MessageSeqNo, pfQOP);
1057 ret = SEC_E_UNSUPPORTED_FUNCTION;
1060 ret = SEC_E_INVALID_HANDLE;
1063 ret = SEC_E_INVALID_HANDLE;
1067 /***********************************************************************
1068 * SetContextAttributesA (SECUR32.@)
1070 SECURITY_STATUS WINAPI SetContextAttributesA(PCtxtHandle phContext,
1071 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1073 SECURITY_STATUS ret;
1075 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1078 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1079 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1081 if (package && package->provider)
1083 if (package->provider->fnTableA.SetContextAttributesA)
1084 ret = package->provider->fnTableA.SetContextAttributesA(
1085 ctxt, ulAttribute, pBuffer, cbBuffer);
1087 ret = SEC_E_UNSUPPORTED_FUNCTION;
1090 ret = SEC_E_INVALID_HANDLE;
1093 ret = SEC_E_INVALID_HANDLE;
1097 /***********************************************************************
1098 * SetContextAttributesW (SECUR32.@)
1100 SECURITY_STATUS WINAPI SetContextAttributesW(PCtxtHandle phContext,
1101 ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
1103 SECURITY_STATUS ret;
1105 TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
1108 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1109 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1111 if (package && package->provider)
1113 if (package->provider->fnTableW.SetContextAttributesW)
1114 ret = package->provider->fnTableW.SetContextAttributesW(
1115 ctxt, ulAttribute, pBuffer, cbBuffer);
1117 ret = SEC_E_UNSUPPORTED_FUNCTION;
1120 ret = SEC_E_INVALID_HANDLE;
1123 ret = SEC_E_INVALID_HANDLE;