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 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 %ld %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 %ld %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, unsigned long ulAttribute, void *pBuffer)
187 TRACE("%p %ld %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, unsigned long ulAttribute, void *pBuffer)
217 TRACE("%p %ld %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, unsigned long fContextReq,
245 unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
246 unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
247 unsigned long *pfContextAttr, PTimeStamp ptsExpiry)
251 TRACE("%p %p %s %ld %ld %ld %p %ld %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, unsigned long fContextReq,
302 unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput,
303 unsigned long Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
304 unsigned long *pfContextAttr, PTimeStamp ptsExpiry)
308 TRACE("%p %p %s %ld %ld %ld %p %ld %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 unsigned long fContextReq, unsigned long TargetDataRep,
359 PCtxtHandle phNewContext, PSecBufferDesc pOutput,
360 unsigned long *pfContextAttr, PTimeStamp ptsExpiry)
364 TRACE("%p %p %p %ld %ld %p %p %p %p\n", phCredential, phContext, pInput,
365 fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
369 SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
370 PCredHandle cred = (PCredHandle)phCredential->dwLower;
372 if (package && package->provider)
374 if (package->provider->fnTableW.AcceptSecurityContext)
380 PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
381 TRACE("realCtx: %p\n", realCtxt);
382 myCtxt.dwUpper = realCtxt->dwUpper;
383 myCtxt.dwLower = realCtxt->dwLower;
386 ret = package->provider->fnTableW.AcceptSecurityContext(
387 cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
388 TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
389 if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
391 SECURITY_STATUS ret2;
392 ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
393 if (ret2 != SEC_E_OK)
394 package->provider->fnTableW.DeleteSecurityContext(
399 ret = SEC_E_UNSUPPORTED_FUNCTION;
402 ret = SEC_E_INVALID_HANDLE;
405 ret = SEC_E_INVALID_HANDLE;
409 /***********************************************************************
410 * CompleteAuthToken (SECUR32.@)
412 SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext,
413 PSecBufferDesc pToken)
417 TRACE("%p %p\n", phContext, pToken);
420 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
421 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
423 if (package && package->provider)
425 if (package->provider->fnTableW.CompleteAuthToken)
426 ret = package->provider->fnTableW.CompleteAuthToken(ctxt,
429 ret = SEC_E_UNSUPPORTED_FUNCTION;
432 ret = SEC_E_INVALID_HANDLE;
435 ret = SEC_E_INVALID_HANDLE;
439 /***********************************************************************
440 * DeleteSecurityContext (SECUR32.@)
442 SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
446 TRACE("%p\n", phContext);
449 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
450 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
452 if (package && package->provider &&
453 package->provider->fnTableW.DeleteSecurityContext)
454 ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
456 ret = SEC_E_INVALID_HANDLE;
460 ret = SEC_E_INVALID_HANDLE;
464 /***********************************************************************
465 * ApplyControlToken (SECUR32.@)
467 SECURITY_STATUS WINAPI ApplyControlToken(PCtxtHandle phContext,
468 PSecBufferDesc pInput)
472 TRACE("%p %p\n", phContext, pInput);
475 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
476 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
478 if (package && package->provider)
480 if (package->provider->fnTableW.ApplyControlToken)
481 ret = package->provider->fnTableW.ApplyControlToken(
484 ret = SEC_E_UNSUPPORTED_FUNCTION;
487 ret = SEC_E_INVALID_HANDLE;
490 ret = SEC_E_INVALID_HANDLE;
494 /***********************************************************************
495 * QueryContextAttributesA (SECUR32.@)
497 SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext,
498 unsigned long ulAttribute, void *pBuffer)
502 TRACE("%p %ld %p\n", phContext, ulAttribute, pBuffer);
505 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
506 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
508 if (package && package->provider)
510 if (package->provider->fnTableA.QueryContextAttributesA)
511 ret = package->provider->fnTableA.QueryContextAttributesA(
512 ctxt, ulAttribute, pBuffer);
514 ret = SEC_E_UNSUPPORTED_FUNCTION;
517 ret = SEC_E_INVALID_HANDLE;
520 ret = SEC_E_INVALID_HANDLE;
524 /***********************************************************************
525 * QueryContextAttributesW (SECUR32.@)
527 SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext,
528 unsigned long ulAttribute, void *pBuffer)
532 TRACE("%p %ld %p\n", phContext, ulAttribute, pBuffer);
535 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
536 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
538 if (package && package->provider)
540 if (package->provider->fnTableW.QueryContextAttributesW)
541 ret = package->provider->fnTableW.QueryContextAttributesW(
542 ctxt, ulAttribute, pBuffer);
544 ret = SEC_E_UNSUPPORTED_FUNCTION;
547 ret = SEC_E_INVALID_HANDLE;
550 ret = SEC_E_INVALID_HANDLE;
554 /***********************************************************************
555 * ImpersonateSecurityContext (SECUR32.@)
557 SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
561 TRACE("%p\n", phContext);
564 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
565 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
567 if (package && package->provider)
569 if (package->provider->fnTableW.ImpersonateSecurityContext)
570 ret = package->provider->fnTableW.ImpersonateSecurityContext(
573 ret = SEC_E_UNSUPPORTED_FUNCTION;
576 ret = SEC_E_INVALID_HANDLE;
579 ret = SEC_E_INVALID_HANDLE;
583 /***********************************************************************
584 * RevertSecurityContext (SECUR32.@)
586 SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
590 TRACE("%p\n", phContext);
593 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
594 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
596 if (package && package->provider)
598 if (package->provider->fnTableW.RevertSecurityContext)
599 ret = package->provider->fnTableW.RevertSecurityContext(
602 ret = SEC_E_UNSUPPORTED_FUNCTION;
605 ret = SEC_E_INVALID_HANDLE;
608 ret = SEC_E_INVALID_HANDLE;
612 /***********************************************************************
613 * MakeSignature (SECUR32.@)
615 SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP,
616 PSecBufferDesc pMessage, ULONG MessageSeqNo)
620 TRACE("%p %ld %p %ld\n", phContext, fQOP, pMessage, MessageSeqNo);
623 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
624 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
626 if (package && package->provider)
628 if (package->provider->fnTableW.MakeSignature)
629 ret = package->provider->fnTableW.MakeSignature(
630 ctxt, fQOP, pMessage, MessageSeqNo);
632 ret = SEC_E_UNSUPPORTED_FUNCTION;
635 ret = SEC_E_INVALID_HANDLE;
638 ret = SEC_E_INVALID_HANDLE;
642 /***********************************************************************
643 * VerifySignature (SECUR32.@)
645 SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext,
646 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
650 TRACE("%p %p %ld %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
653 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
654 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
656 if (package && package->provider)
658 if (package->provider->fnTableW.VerifySignature)
659 ret = package->provider->fnTableW.VerifySignature(
660 ctxt, pMessage, MessageSeqNo, pfQOP);
662 ret = SEC_E_UNSUPPORTED_FUNCTION;
665 ret = SEC_E_INVALID_HANDLE;
668 ret = SEC_E_INVALID_HANDLE;
672 /***********************************************************************
673 * QuerySecurityPackageInfoA (SECUR32.@)
675 SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
676 PSecPkgInfoA *ppPackageInfo)
680 TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
683 SecurePackage *package = SECUR32_findPackageA(pszPackageName);
687 size_t bytesNeeded = sizeof(SecPkgInfoA);
688 int nameLen = 0, commentLen = 0;
690 if (package->infoW.Name)
692 nameLen = WideCharToMultiByte(CP_ACP, 0,
693 package->infoW.Name, -1, NULL, 0, NULL, NULL);
694 bytesNeeded += nameLen;
696 if (package->infoW.Comment)
698 commentLen = WideCharToMultiByte(CP_ACP, 0,
699 package->infoW.Comment, -1, NULL, 0, NULL, NULL);
700 bytesNeeded += commentLen;
702 *ppPackageInfo = (PSecPkgInfoA)SECUR32_ALLOC(bytesNeeded);
705 PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
706 sizeof(SecPkgInfoA));
708 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
709 if (package->infoW.Name)
711 (*ppPackageInfo)->Name = nextString;
712 nextString += WideCharToMultiByte(CP_ACP, 0,
713 package->infoW.Name, -1, nextString, nameLen, NULL, NULL);
716 (*ppPackageInfo)->Name = NULL;
717 if (package->infoW.Comment)
719 (*ppPackageInfo)->Comment = nextString;
720 nextString += WideCharToMultiByte(CP_ACP, 0,
721 package->infoW.Comment, -1, nextString, commentLen, NULL,
725 (*ppPackageInfo)->Comment = NULL;
729 ret = SEC_E_INSUFFICIENT_MEMORY;
732 ret = SEC_E_SECPKG_NOT_FOUND;
735 ret = SEC_E_SECPKG_NOT_FOUND;
739 /***********************************************************************
740 * QuerySecurityPackageInfoW (SECUR32.@)
742 SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
743 PSecPkgInfoW *ppPackageInfo)
746 SecurePackage *package = SECUR32_findPackageW(pszPackageName);
748 TRACE("%s %p\n", debugstr_w(pszPackageName), ppPackageInfo);
751 size_t bytesNeeded = sizeof(SecPkgInfoW);
752 int nameLen = 0, commentLen = 0;
754 if (package->infoW.Name)
756 nameLen = lstrlenW(package->infoW.Name) + 1;
757 bytesNeeded += nameLen * sizeof(WCHAR);
759 if (package->infoW.Comment)
761 commentLen = lstrlenW(package->infoW.Comment) + 1;
762 bytesNeeded += commentLen * sizeof(WCHAR);
764 *ppPackageInfo = (PSecPkgInfoW)SECUR32_ALLOC(bytesNeeded);
767 PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
768 sizeof(SecPkgInfoW));
770 memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
771 if (package->infoW.Name)
773 (*ppPackageInfo)->Name = nextString;
774 lstrcpynW(nextString, package->infoW.Name, nameLen);
775 nextString += nameLen;
778 (*ppPackageInfo)->Name = NULL;
779 if (package->infoW.Comment)
781 (*ppPackageInfo)->Comment = nextString;
782 lstrcpynW(nextString, package->infoW.Comment, commentLen);
783 nextString += commentLen;
786 (*ppPackageInfo)->Comment = NULL;
790 ret = SEC_E_INSUFFICIENT_MEMORY;
793 ret = SEC_E_SECPKG_NOT_FOUND;
797 /***********************************************************************
798 * ExportSecurityContext (SECUR32.@)
800 SECURITY_STATUS WINAPI ExportSecurityContext(PCtxtHandle phContext,
801 ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
805 TRACE("%p %ld %p %p\n", phContext, fFlags, pPackedContext, pToken);
808 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
809 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
811 if (package && package->provider)
813 if (package->provider->fnTableW.ExportSecurityContext)
814 ret = package->provider->fnTableW.ExportSecurityContext(
815 ctxt, fFlags, pPackedContext, pToken);
817 ret = SEC_E_UNSUPPORTED_FUNCTION;
820 ret = SEC_E_INVALID_HANDLE;
823 ret = SEC_E_INVALID_HANDLE;
827 /***********************************************************************
828 * ImportSecurityContextA (SECUR32.@)
830 SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
831 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
834 SecurePackage *package = SECUR32_findPackageA(pszPackage);
836 TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
838 if (package && package->provider)
840 if (package->provider->fnTableA.ImportSecurityContextA)
844 ret = package->provider->fnTableA.ImportSecurityContextA(
845 pszPackage, pPackedContext, Token, &myCtxt);
848 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
850 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
854 ret = SEC_E_UNSUPPORTED_FUNCTION;
857 ret = SEC_E_SECPKG_NOT_FOUND;
862 /***********************************************************************
863 * ImportSecurityContextW (SECUR32.@)
865 SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage,
866 PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
869 SecurePackage *package = SECUR32_findPackageW(pszPackage);
871 TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
873 if (package && package->provider)
875 if (package->provider->fnTableW.ImportSecurityContextW)
879 ret = package->provider->fnTableW.ImportSecurityContextW(
880 pszPackage, pPackedContext, Token, &myCtxt);
883 ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
885 package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
889 ret = SEC_E_UNSUPPORTED_FUNCTION;
892 ret = SEC_E_SECPKG_NOT_FOUND;
896 /***********************************************************************
897 * AddCredentialsA (SECUR32.@)
899 SECURITY_STATUS WINAPI AddCredentialsA(PCredHandle hCredentials,
900 SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, unsigned long fCredentialUse,
901 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
902 PTimeStamp ptsExpiry)
906 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials, debugstr_a(pszPrincipal),
907 debugstr_a(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
908 pvGetKeyArgument, ptsExpiry);
911 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
912 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
914 if (package && package->provider)
916 if (package->provider->fnTableA.AddCredentialsA)
917 ret = package->provider->fnTableA.AddCredentialsA(
918 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
919 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
921 ret = SEC_E_UNSUPPORTED_FUNCTION;
924 ret = SEC_E_INVALID_HANDLE;
927 ret = SEC_E_INVALID_HANDLE;
931 /***********************************************************************
932 * AddCredentialsW (SECUR32.@)
934 SECURITY_STATUS WINAPI AddCredentialsW(PCredHandle hCredentials,
935 SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, unsigned long fCredentialUse,
936 void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
937 PTimeStamp ptsExpiry)
941 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials, debugstr_w(pszPrincipal),
942 debugstr_w(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
943 pvGetKeyArgument, ptsExpiry);
946 SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
947 PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
949 if (package && package->provider)
951 if (package->provider->fnTableW.AddCredentialsW)
952 ret = package->provider->fnTableW.AddCredentialsW(
953 cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
954 pGetKeyFn, pvGetKeyArgument, ptsExpiry);
956 ret = SEC_E_UNSUPPORTED_FUNCTION;
959 ret = SEC_E_INVALID_HANDLE;
962 ret = SEC_E_INVALID_HANDLE;
966 /***********************************************************************
967 * QuerySecurityContextToken (SECUR32.@)
969 SECURITY_STATUS WINAPI QuerySecurityContextToken(PCtxtHandle phContext,
974 TRACE("%p %p\n", phContext, phToken);
977 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
978 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
980 if (package && package->provider)
982 if (package->provider->fnTableW.QuerySecurityContextToken)
983 ret = package->provider->fnTableW.QuerySecurityContextToken(
986 ret = SEC_E_UNSUPPORTED_FUNCTION;
989 ret = SEC_E_INVALID_HANDLE;
992 ret = SEC_E_INVALID_HANDLE;
996 /***********************************************************************
997 * EncryptMessage (SECUR32.@)
999 SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
1000 PSecBufferDesc pMessage, ULONG MessageSeqNo)
1002 SECURITY_STATUS ret;
1004 TRACE("%p %ld %p %ld\n", phContext, fQOP, pMessage, MessageSeqNo);
1007 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1008 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1010 if (package && package->provider)
1012 if (package->provider->fnTableW.EncryptMessage)
1013 ret = package->provider->fnTableW.EncryptMessage(
1014 ctxt, fQOP, pMessage, MessageSeqNo);
1016 ret = SEC_E_UNSUPPORTED_FUNCTION;
1019 ret = SEC_E_INVALID_HANDLE;
1022 ret = SEC_E_INVALID_HANDLE;
1026 /***********************************************************************
1027 * DecryptMessage (SECUR32.@)
1029 SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext,
1030 PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
1032 SECURITY_STATUS ret;
1034 TRACE("%p %p %ld %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
1037 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1038 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1040 if (package && package->provider)
1042 if (package->provider->fnTableW.DecryptMessage)
1043 ret = package->provider->fnTableW.DecryptMessage(
1044 ctxt, pMessage, MessageSeqNo, pfQOP);
1046 ret = SEC_E_UNSUPPORTED_FUNCTION;
1049 ret = SEC_E_INVALID_HANDLE;
1052 ret = SEC_E_INVALID_HANDLE;
1056 /***********************************************************************
1057 * SetContextAttributesA (SECUR32.@)
1059 SECURITY_STATUS WINAPI SetContextAttributesA(PCtxtHandle phContext,
1060 unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer)
1062 SECURITY_STATUS ret;
1064 TRACE("%p %ld %p %ld\n", phContext, ulAttribute, pBuffer, cbBuffer);
1067 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1068 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1070 if (package && package->provider)
1072 if (package->provider->fnTableA.SetContextAttributesA)
1073 ret = package->provider->fnTableA.SetContextAttributesA(
1074 ctxt, ulAttribute, pBuffer, cbBuffer);
1076 ret = SEC_E_UNSUPPORTED_FUNCTION;
1079 ret = SEC_E_INVALID_HANDLE;
1082 ret = SEC_E_INVALID_HANDLE;
1086 /***********************************************************************
1087 * SetContextAttributesW (SECUR32.@)
1089 SECURITY_STATUS WINAPI SetContextAttributesW(PCtxtHandle phContext,
1090 unsigned long ulAttribute, void *pBuffer, unsigned long cbBuffer)
1092 SECURITY_STATUS ret;
1094 TRACE("%p %ld %p %ld\n", phContext, ulAttribute, pBuffer, cbBuffer);
1097 SecurePackage *package = (SecurePackage *)phContext->dwUpper;
1098 PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
1100 if (package && package->provider)
1102 if (package->provider->fnTableW.SetContextAttributesW)
1103 ret = package->provider->fnTableW.SetContextAttributesW(
1104 ctxt, ulAttribute, pBuffer, cbBuffer);
1106 ret = SEC_E_UNSUPPORTED_FUNCTION;
1109 ret = SEC_E_INVALID_HANDLE;
1112 ret = SEC_E_INVALID_HANDLE;