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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 if (phSec && package && realHandle)
42 PSecHandle newSec = (PSecHandle)SECUR32_ALLOC(sizeof(SecHandle));
46 memcpy(newSec, realHandle, sizeof(*realHandle));
47 phSec->dwUpper = (ULONG_PTR)package;
48 phSec->dwLower = (ULONG_PTR)newSec;
52 ret = SEC_E_INSUFFICIENT_MEMORY;
55 ret = SEC_E_INVALID_HANDLE;
59 SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA(
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)
66 TRACE("%s %s %ld %p %p %p %p %p %p\n", debugstr_a(pszPrincipal),
67 debugstr_a(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
68 pvGetKeyArgument, phCredential, ptsExpiry);
71 SecurePackage *package = SECUR32_findPackageA(pszPackage);
73 if (package && package->provider)
75 if (package->provider->fnTableA.AcquireCredentialsHandleA)
79 ret = package->provider->fnTableA.AcquireCredentialsHandleA(
80 pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
81 pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
85 ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
87 package->provider->fnTableW.FreeCredentialsHandle(
92 ret = SEC_E_UNSUPPORTED_FUNCTION;
95 ret = SEC_E_SECPKG_NOT_FOUND;
98 ret = SEC_E_SECPKG_NOT_FOUND;
102 SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW(
103 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse,
104 PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
105 PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
109 TRACE("%s %s %ld %p %p %p %p %p %p\n", debugstr_w(pszPrincipal),
110 debugstr_w(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
111 pvGetKeyArgument, phCredential, ptsExpiry);
114 SecurePackage *package = SECUR32_findPackageW(pszPackage);
116 if (package && package->provider)
118 if (package->provider->fnTableW.AcquireCredentialsHandleW)
122 ret = package->provider->fnTableW.AcquireCredentialsHandleW(
123 pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
124 pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
128 ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
130 package->provider->fnTableW.FreeCredentialsHandle(
135 ret = SEC_E_UNSUPPORTED_FUNCTION;
138 ret = SEC_E_SECPKG_NOT_FOUND;
141 ret = SEC_E_SECPKG_NOT_FOUND;
145 SECURITY_STATUS SEC_ENTRY FreeCredentialsHandle(
146 PCredHandle phCredential)
150 TRACE("%p\n", phCredential);
153 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
154 PCredHandle cred = (PCredHandle)phCredential->dwLower;
156 if (package && package->provider &&
157 package->provider->fnTableW.FreeCredentialsHandle)
158 ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
160 ret = SEC_E_INVALID_HANDLE;
164 ret = SEC_E_INVALID_HANDLE;
168 SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(
169 PCredHandle phCredential, unsigned long ulAttribute, void *pBuffer)
173 TRACE("%p %ld %p\n", phCredential, ulAttribute, pBuffer);
176 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
177 PCredHandle cred = (PCredHandle)phCredential->dwLower;
179 if (package && package->provider)
181 if (package->provider->fnTableA.QueryCredentialsAttributesA)
182 ret = package->provider->fnTableA.QueryCredentialsAttributesA(
183 cred, ulAttribute, pBuffer);
185 ret = SEC_E_UNSUPPORTED_FUNCTION;
188 ret = SEC_E_INVALID_HANDLE;
191 ret = SEC_E_INVALID_HANDLE;
195 SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(
196 PCredHandle phCredential, unsigned long ulAttribute, void *pBuffer)
200 TRACE("%p %ld %p\n", phCredential, ulAttribute, pBuffer);
203 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
204 PCredHandle cred = (PCredHandle)phCredential->dwLower;
206 if (package && package->provider)
208 if (package->provider->fnTableW.QueryCredentialsAttributesW)
209 ret = package->provider->fnTableW.QueryCredentialsAttributesW(
210 cred, ulAttribute, pBuffer);
212 ret = SEC_E_UNSUPPORTED_FUNCTION;
215 ret = SEC_E_INVALID_HANDLE;
218 ret = SEC_E_INVALID_HANDLE;
222 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA(
223 PCredHandle phCredential, PCtxtHandle phContext,
224 SEC_CHAR *pszTargetName, unsigned long fContextReq,
225 unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
226 unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
227 unsigned long *pfContextAttr, PTimeStamp ptsExpiry)
231 TRACE("%p %p %s %ld %ld %ld %p %ld %p %p %p %p\n", phCredential, phContext,
232 debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
233 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
236 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
237 PCredHandle cred = (PCredHandle)phCredential->dwLower;
239 if (package && package->provider)
241 if (package->provider->fnTableA.InitializeSecurityContextA)
245 ret = package->provider->fnTableA.InitializeSecurityContextA(
246 cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq,
247 Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt,
248 pOutput, pfContextAttr, ptsExpiry);
251 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
253 package->provider->fnTableW.DeleteSecurityContext(
258 ret = SEC_E_UNSUPPORTED_FUNCTION;
261 ret = SEC_E_INVALID_HANDLE;
264 ret = SEC_E_INVALID_HANDLE;
268 SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW(
269 PCredHandle phCredential, PCtxtHandle phContext,
270 SEC_WCHAR *pszTargetName, unsigned long fContextReq,
271 unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
272 unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
273 unsigned long *pfContextAttr, PTimeStamp ptsExpiry)
277 TRACE("%p %p %s %ld %ld %ld %p %ld %p %p %p %p\n", phCredential, phContext,
278 debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
279 Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
282 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
283 PCredHandle cred = (PCredHandle)phCredential->dwLower;
285 if (package && package->provider)
287 if (package->provider->fnTableW.QueryCredentialsAttributesW)
291 ret = package->provider->fnTableW.InitializeSecurityContextW(
292 cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq,
293 Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt,
294 pOutput, pfContextAttr, ptsExpiry);
297 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
299 package->provider->fnTableW.DeleteSecurityContext(
304 ret = SEC_E_UNSUPPORTED_FUNCTION;
307 ret = SEC_E_INVALID_HANDLE;
310 ret = SEC_E_INVALID_HANDLE;
314 SECURITY_STATUS SEC_ENTRY AcceptSecurityContext(
315 PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
316 unsigned long fContextReq, unsigned long TargetDataRep,
317 PCtxtHandle phNewContext, PSecBufferDesc pOutput,
318 unsigned long *pfContextAttr, PTimeStamp ptsExpiry)
322 TRACE("%p %p %p %ld %ld %p %p %p %p\n", phCredential, phContext, pInput,
323 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
327 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
328 PCredHandle cred = (PCredHandle)phCredential->dwLower;
330 if (package && package->provider)
332 if (package->provider->fnTableW.AcceptSecurityContext)
336 ret = package->provider->fnTableW.AcceptSecurityContext(
337 cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
338 TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
341 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
343 package->provider->fnTableW.DeleteSecurityContext(
348 ret = SEC_E_UNSUPPORTED_FUNCTION;
351 ret = SEC_E_INVALID_HANDLE;
354 ret = SEC_E_INVALID_HANDLE;
358 SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext,
359 PSecBufferDesc pToken)
363 TRACE("%p %p\n", phContext, pToken);
366 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
367 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
369 if (package && package->provider)
371 if (package->provider->fnTableW.CompleteAuthToken)
372 ret = package->provider->fnTableW.CompleteAuthToken(ctxt,
375 ret = SEC_E_UNSUPPORTED_FUNCTION;
378 ret = SEC_E_INVALID_HANDLE;
381 ret = SEC_E_INVALID_HANDLE;
385 SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext)
389 TRACE("%p\n", phContext);
392 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
393 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
395 if (package && package->provider &&
396 package->provider->fnTableW.DeleteSecurityContext)
397 ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
399 ret = SEC_E_INVALID_HANDLE;
403 ret = SEC_E_INVALID_HANDLE;
407 SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext,
408 PSecBufferDesc pInput)
412 TRACE("%p %p\n", phContext, pInput);
415 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
416 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
418 if (package && package->provider)
420 if (package->provider->fnTableW.ApplyControlToken)
421 ret = package->provider->fnTableW.ApplyControlToken(
424 ret = SEC_E_UNSUPPORTED_FUNCTION;
427 ret = SEC_E_INVALID_HANDLE;
430 ret = SEC_E_INVALID_HANDLE;
434 SECURITY_STATUS SEC_ENTRY QueryContextAttributesA(PCtxtHandle phContext,
435 unsigned long ulAttribute, void *pBuffer)
439 TRACE("%p %ld %p\n", phContext, ulAttribute, pBuffer);
442 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
443 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
445 if (package && package->provider)
447 if (package->provider->fnTableA.QueryContextAttributesA)
448 ret = package->provider->fnTableA.QueryContextAttributesA(
449 ctxt, ulAttribute, pBuffer);
451 ret = SEC_E_UNSUPPORTED_FUNCTION;
454 ret = SEC_E_INVALID_HANDLE;
457 ret = SEC_E_INVALID_HANDLE;
461 SECURITY_STATUS SEC_ENTRY QueryContextAttributesW(PCtxtHandle phContext,
462 unsigned long ulAttribute, void *pBuffer)
466 TRACE("%p %ld %p\n", phContext, ulAttribute, pBuffer);
469 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
470 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
472 if (package && package->provider)
474 if (package->provider->fnTableW.QueryContextAttributesW)
475 ret = package->provider->fnTableW.QueryContextAttributesW(
476 ctxt, ulAttribute, pBuffer);
478 ret = SEC_E_UNSUPPORTED_FUNCTION;
481 ret = SEC_E_INVALID_HANDLE;
484 ret = SEC_E_INVALID_HANDLE;
488 SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext)
492 TRACE("%p\n", phContext);
495 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
496 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
498 if (package && package->provider)
500 if (package->provider->fnTableW.ImpersonateSecurityContext)
501 ret = package->provider->fnTableW.ImpersonateSecurityContext(
504 ret = SEC_E_UNSUPPORTED_FUNCTION;
507 ret = SEC_E_INVALID_HANDLE;
510 ret = SEC_E_INVALID_HANDLE;
514 SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext)
518 TRACE("%p\n", phContext);
521 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
522 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
524 if (package && package->provider)
526 if (package->provider->fnTableW.RevertSecurityContext)
527 ret = package->provider->fnTableW.RevertSecurityContext(
530 ret = SEC_E_UNSUPPORTED_FUNCTION;
533 ret = SEC_E_INVALID_HANDLE;
536 ret = SEC_E_INVALID_HANDLE;
540 SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, ULONG fQOP,
541 PSecBufferDesc pMessage, ULONG MessageSeqNo)
545 TRACE("%p %ld %p %ld\n", phContext, fQOP, pMessage, MessageSeqNo);
548 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
549 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
551 if (package && package->provider)
553 if (package->provider->fnTableW.MakeSignature)
554 ret = package->provider->fnTableW.MakeSignature(
555 ctxt, fQOP, pMessage, MessageSeqNo);
557 ret = SEC_E_UNSUPPORTED_FUNCTION;
560 ret = SEC_E_INVALID_HANDLE;
563 ret = SEC_E_INVALID_HANDLE;
567 SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext,
568 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
572 TRACE("%p %p %ld %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
575 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
576 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
578 if (package && package->provider)
580 if (package->provider->fnTableW.VerifySignature)
581 ret = package->provider->fnTableW.VerifySignature(
582 ctxt, pMessage, MessageSeqNo, pfQOP);
584 ret = SEC_E_UNSUPPORTED_FUNCTION;
587 ret = SEC_E_INVALID_HANDLE;
590 ret = SEC_E_INVALID_HANDLE;
594 SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
595 PSecPkgInfoA *ppPackageInfo)
599 TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
602 SecurePackage *package = SECUR32_findPackageA(pszPackageName);
606 size_t bytesNeeded = sizeof(SecPkgInfoA);
607 int nameLen = 0, commentLen = 0;
609 if (package->infoW.Name)
611 nameLen = WideCharToMultiByte(CP_ACP, 0,
612 package->infoW.Name, -1, NULL, 0, NULL, NULL);
613 bytesNeeded += nameLen;
615 if (package->infoW.Comment)
617 commentLen = WideCharToMultiByte(CP_ACP, 0,
618 package->infoW.Comment, -1, NULL, 0, NULL, NULL);
619 bytesNeeded += commentLen;
621 *ppPackageInfo = (PSecPkgInfoA)SECUR32_ALLOC(bytesNeeded);
624 PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
625 sizeof(SecPkgInfoA));
627 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
628 if (package->infoW.Name)
630 (*ppPackageInfo)->Name = nextString;
631 nextString += WideCharToMultiByte(CP_ACP, 0,
632 package->infoW.Name, -1, nextString, nameLen, NULL, NULL);
635 (*ppPackageInfo)->Name = NULL;
636 if (package->infoW.Comment)
638 (*ppPackageInfo)->Comment = nextString;
639 nextString += WideCharToMultiByte(CP_ACP, 0,
640 package->infoW.Comment, -1, nextString, commentLen, NULL,
644 (*ppPackageInfo)->Comment = NULL;
648 ret = SEC_E_INSUFFICIENT_MEMORY;
651 ret = SEC_E_SECPKG_NOT_FOUND;
654 ret = SEC_E_SECPKG_NOT_FOUND;
658 SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
659 PSecPkgInfoW *ppPackageInfo)
662 SecurePackage *package = SECUR32_findPackageW(pszPackageName);
664 TRACE("%s %p\n", debugstr_w(pszPackageName), ppPackageInfo);
667 size_t bytesNeeded = sizeof(SecPkgInfoW);
668 int nameLen = 0, commentLen = 0;
670 if (package->infoW.Name)
672 nameLen = lstrlenW(package->infoW.Name) + 1;
673 bytesNeeded += nameLen * sizeof(WCHAR);
675 if (package->infoW.Comment)
677 commentLen = lstrlenW(package->infoW.Comment) + 1;
678 bytesNeeded += commentLen * sizeof(WCHAR);
680 *ppPackageInfo = (PSecPkgInfoW)SECUR32_ALLOC(bytesNeeded);
683 PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
684 sizeof(SecPkgInfoW));
686 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
687 if (package->infoW.Name)
689 (*ppPackageInfo)->Name = nextString;
690 lstrcpynW(nextString, package->infoW.Name, nameLen);
691 nextString += nameLen;
694 (*ppPackageInfo)->Name = NULL;
695 if (package->infoW.Comment)
697 (*ppPackageInfo)->Comment = nextString;
698 lstrcpynW(nextString, package->infoW.Comment, commentLen);
699 nextString += commentLen;
702 (*ppPackageInfo)->Comment = NULL;
706 ret = SEC_E_INSUFFICIENT_MEMORY;
709 ret = SEC_E_SECPKG_NOT_FOUND;
713 SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext,
714 ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
718 TRACE("%p %ld %p %p\n", phContext, fFlags, pPackedContext, pToken);
721 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
722 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
724 if (package && package->provider)
726 if (package->provider->fnTableW.ExportSecurityContext)
727 ret = package->provider->fnTableW.ExportSecurityContext(
728 ctxt, fFlags, pPackedContext, pToken);
730 ret = SEC_E_UNSUPPORTED_FUNCTION;
733 ret = SEC_E_INVALID_HANDLE;
736 ret = SEC_E_INVALID_HANDLE;
740 SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR *pszPackage,
741 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
744 SecurePackage *package = SECUR32_findPackageA(pszPackage);
746 TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
748 if (package && package->provider)
750 if (package->provider->fnTableA.ImportSecurityContextA)
754 ret = package->provider->fnTableA.ImportSecurityContextA(
755 pszPackage, pPackedContext, Token, &myCtxt);
758 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
760 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
764 ret = SEC_E_UNSUPPORTED_FUNCTION;
767 ret = SEC_E_SECPKG_NOT_FOUND;
772 SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR *pszPackage,
773 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
776 SecurePackage *package = SECUR32_findPackageW(pszPackage);
778 TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
780 if (package && package->provider)
782 if (package->provider->fnTableW.ImportSecurityContextW)
786 ret = package->provider->fnTableW.ImportSecurityContextW(
787 pszPackage, pPackedContext, Token, &myCtxt);
790 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
792 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
796 ret = SEC_E_UNSUPPORTED_FUNCTION;
799 ret = SEC_E_SECPKG_NOT_FOUND;
803 SECURITY_STATUS SEC_ENTRY AddCredentialsA(PCredHandle hCredentials,
804 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, unsigned long fCredentialUse,
805 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
806 PTimeStamp ptsExpiry)
810 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials, debugstr_a(pszPrincipal),
811 debugstr_a(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
812 pvGetKeyArgument, ptsExpiry);
815 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
816 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
818 if (package && package->provider)
820 if (package->provider->fnTableA.AddCredentialsA)
821 ret = package->provider->fnTableA.AddCredentialsA(
822 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
823 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
825 ret = SEC_E_UNSUPPORTED_FUNCTION;
828 ret = SEC_E_INVALID_HANDLE;
831 ret = SEC_E_INVALID_HANDLE;
835 SECURITY_STATUS SEC_ENTRY AddCredentialsW(PCredHandle hCredentials,
836 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, unsigned long fCredentialUse,
837 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
838 PTimeStamp ptsExpiry)
842 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials, debugstr_w(pszPrincipal),
843 debugstr_w(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
844 pvGetKeyArgument, ptsExpiry);
847 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
848 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
850 if (package && package->provider)
852 if (package->provider->fnTableW.AddCredentialsW)
853 ret = package->provider->fnTableW.AddCredentialsW(
854 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
855 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
857 ret = SEC_E_UNSUPPORTED_FUNCTION;
860 ret = SEC_E_INVALID_HANDLE;
863 ret = SEC_E_INVALID_HANDLE;
867 SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext,
872 TRACE("%p %p\n", phContext, phToken);
875 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
876 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
878 if (package && package->provider)
880 if (package->provider->fnTableW.QuerySecurityContextToken)
881 ret = package->provider->fnTableW.QuerySecurityContextToken(
884 ret = SEC_E_UNSUPPORTED_FUNCTION;
887 ret = SEC_E_INVALID_HANDLE;
890 ret = SEC_E_INVALID_HANDLE;
894 SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
895 PSecBufferDesc pMessage, ULONG MessageSeqNo)
899 TRACE("%p %ld %p %ld\n", phContext, fQOP, pMessage, MessageSeqNo);
902 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
903 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
905 if (package && package->provider)
907 if (package->provider->fnTableW.EncryptMessage)
908 ret = package->provider->fnTableW.EncryptMessage(
909 ctxt, fQOP, pMessage, MessageSeqNo);
911 ret = SEC_E_UNSUPPORTED_FUNCTION;
914 ret = SEC_E_INVALID_HANDLE;
917 ret = SEC_E_INVALID_HANDLE;
921 SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext,
922 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
926 TRACE("%p %p %ld %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
929 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
930 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
932 if (package && package->provider)
934 if (package->provider->fnTableW.DecryptMessage)
935 ret = package->provider->fnTableW.DecryptMessage(
936 ctxt, pMessage, MessageSeqNo, pfQOP);
938 ret = SEC_E_UNSUPPORTED_FUNCTION;
941 ret = SEC_E_INVALID_HANDLE;
944 ret = SEC_E_INVALID_HANDLE;
948 SECURITY_STATUS SEC_ENTRY SetContextAttributesA(PCtxtHandle phContext,
949 unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer)
953 TRACE("%p %ld %p %ld\n", phContext, ulAttribute, pBuffer, cbBuffer);
956 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
957 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
959 if (package && package->provider)
961 if (package->provider->fnTableA.SetContextAttributesA)
962 ret = package->provider->fnTableA.SetContextAttributesA(
963 ctxt, ulAttribute, pBuffer, cbBuffer);
965 ret = SEC_E_UNSUPPORTED_FUNCTION;
968 ret = SEC_E_INVALID_HANDLE;
971 ret = SEC_E_INVALID_HANDLE;
975 SECURITY_STATUS SEC_ENTRY SetContextAttributesW(PCtxtHandle phContext,
976 unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer)
980 TRACE("%p %ld %p %ld\n", phContext, ulAttribute, pBuffer, cbBuffer);
983 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
984 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
986 if (package && package->provider)
988 if (package->provider->fnTableW.SetContextAttributesW)
989 ret = package->provider->fnTableW.SetContextAttributesW(
990 ctxt, ulAttribute, pBuffer, cbBuffer);
992 ret = SEC_E_UNSUPPORTED_FUNCTION;
995 ret = SEC_E_INVALID_HANDLE;
998 ret = SEC_E_INVALID_HANDLE;