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
28 #include "wine/debug.h"
29 #include "secur32_priv.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(secur32
);
33 /***********************************************************************
34 * AcquireCredentialsHandleA (SECUR32.@)
36 SECURITY_STATUS WINAPI
AcquireCredentialsHandleA(
37 SEC_CHAR
*pszPrincipal
, SEC_CHAR
*pszPackage
, ULONG fCredentialsUse
,
38 PLUID pvLogonID
, PVOID pAuthData
, SEC_GET_KEY_FN pGetKeyFn
,
39 PVOID pvGetKeyArgument
, PCredHandle phCredential
, PTimeStamp ptsExpiry
)
43 TRACE("%s %s %ld %p %p %p %p %p %p\n", debugstr_a(pszPrincipal
),
44 debugstr_a(pszPackage
), fCredentialsUse
, pvLogonID
, pAuthData
, pGetKeyFn
,
45 pvGetKeyArgument
, phCredential
, ptsExpiry
);
48 SecurePackage
*package
= SECUR32_findPackageA(pszPackage
);
49 if (package
&& package
->provider
)
51 if (package
->provider
->fnTableA
.AcquireCredentialsHandleA
)
53 ret
= package
->provider
->fnTableA
.AcquireCredentialsHandleA(
54 pszPrincipal
, pszPackage
, fCredentialsUse
, pvLogonID
,
55 pAuthData
, pGetKeyFn
, pvGetKeyArgument
, phCredential
,
58 phCredential
->dwUpper
= (ULONG_PTR
)package
;
61 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
64 ret
= SEC_E_SECPKG_NOT_FOUND
;
67 ret
= SEC_E_SECPKG_NOT_FOUND
;
71 /***********************************************************************
72 * AcquireCredentialsHandleW (SECUR32.@)
74 SECURITY_STATUS WINAPI
AcquireCredentialsHandleW(
75 SEC_WCHAR
*pszPrincipal
, SEC_WCHAR
*pszPackage
, ULONG fCredentialsUse
,
76 PLUID pvLogonID
, PVOID pAuthData
, SEC_GET_KEY_FN pGetKeyFn
,
77 PVOID pvGetKeyArgument
, PCredHandle phCredential
, PTimeStamp ptsExpiry
)
81 TRACE("%s %s %ld %p %p %p %p %p %p\n", debugstr_w(pszPrincipal
),
82 debugstr_w(pszPackage
), fCredentialsUse
, pvLogonID
, pAuthData
, pGetKeyFn
,
83 pvGetKeyArgument
, phCredential
, ptsExpiry
);
86 SecurePackage
*package
= SECUR32_findPackageW(pszPackage
);
87 if (package
&& package
->provider
)
89 if (package
->provider
->fnTableW
.AcquireCredentialsHandleW
)
91 ret
= package
->provider
->fnTableW
.AcquireCredentialsHandleW(
92 pszPrincipal
, pszPackage
, fCredentialsUse
, pvLogonID
,
93 pAuthData
, pGetKeyFn
, pvGetKeyArgument
, phCredential
,
96 phCredential
->dwUpper
= (ULONG_PTR
)package
;
99 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
102 ret
= SEC_E_SECPKG_NOT_FOUND
;
105 ret
= SEC_E_SECPKG_NOT_FOUND
;
109 /***********************************************************************
110 * FreeCredentialsHandle (SECUR32.@)
112 SECURITY_STATUS WINAPI
FreeCredentialsHandle(
113 PCredHandle phCredential
)
117 TRACE("%p\n", phCredential
);
120 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
121 if (package
&& package
->provider
&& package
->provider
->fnTableW
.FreeCredentialsHandle
)
122 ret
= package
->provider
->fnTableW
.FreeCredentialsHandle(phCredential
);
124 ret
= SEC_E_INVALID_HANDLE
;
127 ret
= SEC_E_INVALID_HANDLE
;
131 /***********************************************************************
132 * QueryCredentialsAttributesA (SECUR32.@)
134 SECURITY_STATUS WINAPI
QueryCredentialsAttributesA(
135 PCredHandle phCredential
, ULONG ulAttribute
, void *pBuffer
)
139 TRACE("%p %ld %p\n", phCredential
, ulAttribute
, pBuffer
);
142 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
143 if (package
&& package
->provider
)
145 if (package
->provider
->fnTableA
.QueryCredentialsAttributesA
)
146 ret
= package
->provider
->fnTableA
.QueryCredentialsAttributesA(
147 phCredential
, ulAttribute
, pBuffer
);
149 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
152 ret
= SEC_E_INVALID_HANDLE
;
155 ret
= SEC_E_INVALID_HANDLE
;
159 /***********************************************************************
160 * QueryCredentialsAttributesW (SECUR32.@)
162 SECURITY_STATUS WINAPI
QueryCredentialsAttributesW(
163 PCredHandle phCredential
, ULONG ulAttribute
, void *pBuffer
)
167 TRACE("%p %ld %p\n", phCredential
, ulAttribute
, pBuffer
);
170 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
171 if (package
&& package
->provider
)
173 if (package
->provider
->fnTableW
.QueryCredentialsAttributesW
)
174 ret
= package
->provider
->fnTableW
.QueryCredentialsAttributesW(phCredential
, ulAttribute
, pBuffer
);
176 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
179 ret
= SEC_E_INVALID_HANDLE
;
182 ret
= SEC_E_INVALID_HANDLE
;
186 /***********************************************************************
187 * InitializeSecurityContextA (SECUR32.@)
189 SECURITY_STATUS WINAPI
InitializeSecurityContextA(
190 PCredHandle phCredential
, PCtxtHandle phContext
,
191 SEC_CHAR
*pszTargetName
, ULONG fContextReq
,
192 ULONG Reserved1
, ULONG TargetDataRep
, PSecBufferDesc pInput
,
193 ULONG Reserved2
, PCtxtHandle phNewContext
, PSecBufferDesc pOutput
,
194 ULONG
*pfContextAttr
, PTimeStamp ptsExpiry
)
197 SecurePackage
*package
= NULL
;
199 TRACE("%p %p %s 0x%08lx %ld %ld %p %ld %p %p %p %p\n", phCredential
, phContext
,
200 debugstr_a(pszTargetName
), fContextReq
, Reserved1
, TargetDataRep
, pInput
,
201 Reserved1
, phNewContext
, pOutput
, pfContextAttr
, ptsExpiry
);
203 if (phContext
) package
= (SecurePackage
*)phContext
->dwUpper
;
204 else if (phCredential
) package
= (SecurePackage
*)phCredential
->dwUpper
;
206 if (package
&& package
->provider
)
208 if (package
->provider
->fnTableA
.InitializeSecurityContextA
)
210 ret
= package
->provider
->fnTableA
.InitializeSecurityContextA(
211 phCredential
, phContext
, pszTargetName
, fContextReq
,
212 Reserved1
, TargetDataRep
, pInput
, Reserved2
, phNewContext
,
213 pOutput
, pfContextAttr
, ptsExpiry
);
214 if ((ret
== SEC_E_OK
|| ret
== SEC_I_CONTINUE_NEEDED
) && phNewContext
)
215 phNewContext
->dwUpper
= (ULONG_PTR
)package
;
218 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
221 ret
= SEC_E_INVALID_HANDLE
;
225 /***********************************************************************
226 * InitializeSecurityContextW (SECUR32.@)
228 SECURITY_STATUS WINAPI
InitializeSecurityContextW(
229 PCredHandle phCredential
, PCtxtHandle phContext
,
230 SEC_WCHAR
*pszTargetName
, ULONG fContextReq
,
231 ULONG Reserved1
, ULONG TargetDataRep
, PSecBufferDesc pInput
,
232 ULONG Reserved2
, PCtxtHandle phNewContext
, PSecBufferDesc pOutput
,
233 ULONG
*pfContextAttr
, PTimeStamp ptsExpiry
)
236 SecurePackage
*package
= NULL
;
238 TRACE("%p %p %s 0x%08lx %ld %ld %p %ld %p %p %p %p\n", phCredential
, phContext
,
239 debugstr_w(pszTargetName
), fContextReq
, Reserved1
, TargetDataRep
, pInput
,
240 Reserved1
, phNewContext
, pOutput
, pfContextAttr
, ptsExpiry
);
242 if (phContext
) package
= (SecurePackage
*)phContext
->dwUpper
;
243 else if (phCredential
) package
= (SecurePackage
*)phCredential
->dwUpper
;
245 if (package
&& package
->provider
)
247 if (package
->provider
->fnTableW
.InitializeSecurityContextW
)
249 ret
= package
->provider
->fnTableW
.InitializeSecurityContextW(
250 phCredential
, phContext
, pszTargetName
, fContextReq
,
251 Reserved1
, TargetDataRep
, pInput
, Reserved2
, phNewContext
,
252 pOutput
, pfContextAttr
, ptsExpiry
);
253 if ((ret
== SEC_E_OK
|| ret
== SEC_I_CONTINUE_NEEDED
) && phNewContext
)
254 phNewContext
->dwUpper
= (ULONG_PTR
)package
;
257 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
260 ret
= SEC_E_INVALID_HANDLE
;
264 /***********************************************************************
265 * AcceptSecurityContext (SECUR32.@)
267 SECURITY_STATUS WINAPI
AcceptSecurityContext(
268 PCredHandle phCredential
, PCtxtHandle phContext
, PSecBufferDesc pInput
,
269 ULONG fContextReq
, ULONG TargetDataRep
, PCtxtHandle phNewContext
,
270 PSecBufferDesc pOutput
, ULONG
*pfContextAttr
, PTimeStamp ptsExpiry
)
274 TRACE("%p %p %p %ld %ld %p %p %p %p\n", phCredential
, phContext
, pInput
,
275 fContextReq
, TargetDataRep
, phNewContext
, pOutput
, pfContextAttr
,
279 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
280 if (package
&& package
->provider
)
282 if (package
->provider
->fnTableW
.AcceptSecurityContext
)
284 ret
= package
->provider
->fnTableW
.AcceptSecurityContext(
285 phCredential
, phContext
, pInput
, fContextReq
,
286 TargetDataRep
, phNewContext
, pOutput
, pfContextAttr
, ptsExpiry
);
287 if ((ret
== SEC_E_OK
|| ret
== SEC_I_CONTINUE_NEEDED
) && phNewContext
)
288 phNewContext
->dwUpper
= (ULONG_PTR
)package
;
291 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
294 ret
= SEC_E_INVALID_HANDLE
;
297 ret
= SEC_E_INVALID_HANDLE
;
301 /***********************************************************************
302 * CompleteAuthToken (SECUR32.@)
304 SECURITY_STATUS WINAPI
CompleteAuthToken(PCtxtHandle phContext
,
305 PSecBufferDesc pToken
)
309 TRACE("%p %p\n", phContext
, pToken
);
312 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
313 if (package
&& package
->provider
)
315 if (package
->provider
->fnTableW
.CompleteAuthToken
)
316 ret
= package
->provider
->fnTableW
.CompleteAuthToken(phContext
, pToken
);
318 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
321 ret
= SEC_E_INVALID_HANDLE
;
324 ret
= SEC_E_INVALID_HANDLE
;
328 /***********************************************************************
329 * DeleteSecurityContext (SECUR32.@)
331 SECURITY_STATUS WINAPI
DeleteSecurityContext(PCtxtHandle phContext
)
335 TRACE("%p\n", phContext
);
338 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
339 if (package
&& package
->provider
&& package
->provider
->fnTableW
.DeleteSecurityContext
)
340 ret
= package
->provider
->fnTableW
.DeleteSecurityContext(phContext
);
342 ret
= SEC_E_INVALID_HANDLE
;
345 ret
= SEC_E_INVALID_HANDLE
;
349 /***********************************************************************
350 * ApplyControlToken (SECUR32.@)
352 SECURITY_STATUS WINAPI
ApplyControlToken(PCtxtHandle phContext
,
353 PSecBufferDesc pInput
)
357 TRACE("%p %p\n", phContext
, pInput
);
360 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
361 if (package
&& package
->provider
)
363 if (package
->provider
->fnTableW
.ApplyControlToken
)
364 ret
= package
->provider
->fnTableW
.ApplyControlToken(phContext
, pInput
);
366 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
369 ret
= SEC_E_INVALID_HANDLE
;
372 ret
= SEC_E_INVALID_HANDLE
;
376 /***********************************************************************
377 * QueryContextAttributesA (SECUR32.@)
379 SECURITY_STATUS WINAPI
QueryContextAttributesA(PCtxtHandle phContext
,
380 ULONG ulAttribute
, void *pBuffer
)
384 TRACE("%p %ld %p\n", phContext
, ulAttribute
, pBuffer
);
387 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
388 if (package
&& package
->provider
)
390 if (package
->provider
->fnTableA
.QueryContextAttributesA
)
391 ret
= package
->provider
->fnTableA
.QueryContextAttributesA(phContext
, ulAttribute
, pBuffer
);
393 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
396 ret
= SEC_E_INVALID_HANDLE
;
399 ret
= SEC_E_INVALID_HANDLE
;
403 /***********************************************************************
404 * QueryContextAttributesW (SECUR32.@)
406 SECURITY_STATUS WINAPI
QueryContextAttributesW(PCtxtHandle phContext
,
407 ULONG ulAttribute
, void *pBuffer
)
411 TRACE("%p %ld %p\n", phContext
, ulAttribute
, pBuffer
);
414 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
415 if (package
&& package
->provider
)
417 if (package
->provider
->fnTableW
.QueryContextAttributesW
)
418 ret
= package
->provider
->fnTableW
.QueryContextAttributesW(phContext
, ulAttribute
, pBuffer
);
420 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
423 ret
= SEC_E_INVALID_HANDLE
;
426 ret
= SEC_E_INVALID_HANDLE
;
430 /***********************************************************************
431 * ImpersonateSecurityContext (SECUR32.@)
433 SECURITY_STATUS WINAPI
ImpersonateSecurityContext(PCtxtHandle phContext
)
437 TRACE("%p\n", phContext
);
440 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
441 if (package
&& package
->provider
)
443 if (package
->provider
->fnTableW
.ImpersonateSecurityContext
)
444 ret
= package
->provider
->fnTableW
.ImpersonateSecurityContext(phContext
);
446 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
449 ret
= SEC_E_INVALID_HANDLE
;
452 ret
= SEC_E_INVALID_HANDLE
;
456 /***********************************************************************
457 * RevertSecurityContext (SECUR32.@)
459 SECURITY_STATUS WINAPI
RevertSecurityContext(PCtxtHandle phContext
)
463 TRACE("%p\n", phContext
);
466 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
467 if (package
&& package
->provider
)
469 if (package
->provider
->fnTableW
.RevertSecurityContext
)
470 ret
= package
->provider
->fnTableW
.RevertSecurityContext(phContext
);
472 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
475 ret
= SEC_E_INVALID_HANDLE
;
478 ret
= SEC_E_INVALID_HANDLE
;
482 /***********************************************************************
483 * MakeSignature (SECUR32.@)
485 SECURITY_STATUS WINAPI
MakeSignature(PCtxtHandle phContext
, ULONG fQOP
,
486 PSecBufferDesc pMessage
, ULONG MessageSeqNo
)
490 TRACE("%p %ld %p %ld\n", phContext
, fQOP
, pMessage
, MessageSeqNo
);
493 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
494 if (package
&& package
->provider
)
496 if (package
->provider
->fnTableW
.MakeSignature
)
497 ret
= package
->provider
->fnTableW
.MakeSignature(phContext
, fQOP
, pMessage
, MessageSeqNo
);
499 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
502 ret
= SEC_E_INVALID_HANDLE
;
505 ret
= SEC_E_INVALID_HANDLE
;
509 /***********************************************************************
510 * VerifySignature (SECUR32.@)
512 SECURITY_STATUS WINAPI
VerifySignature(PCtxtHandle phContext
,
513 PSecBufferDesc pMessage
, ULONG MessageSeqNo
, PULONG pfQOP
)
517 TRACE("%p %p %ld %p\n", phContext
, pMessage
, MessageSeqNo
, pfQOP
);
520 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
521 if (package
&& package
->provider
)
523 if (package
->provider
->fnTableW
.VerifySignature
)
524 ret
= package
->provider
->fnTableW
.VerifySignature(phContext
, pMessage
, MessageSeqNo
, pfQOP
);
526 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
529 ret
= SEC_E_INVALID_HANDLE
;
532 ret
= SEC_E_INVALID_HANDLE
;
536 /***********************************************************************
537 * QuerySecurityPackageInfoA (SECUR32.@)
539 SECURITY_STATUS WINAPI
QuerySecurityPackageInfoA(SEC_CHAR
*pszPackageName
,
540 PSecPkgInfoA
*ppPackageInfo
)
544 TRACE("%s %p\n", debugstr_a(pszPackageName
), ppPackageInfo
);
547 SecurePackage
*package
= SECUR32_findPackageA(pszPackageName
);
551 size_t bytesNeeded
= sizeof(SecPkgInfoA
);
552 int nameLen
= 0, commentLen
= 0;
554 if (package
->infoW
.Name
)
556 nameLen
= WideCharToMultiByte(CP_ACP
, 0,
557 package
->infoW
.Name
, -1, NULL
, 0, NULL
, NULL
);
558 bytesNeeded
+= nameLen
;
560 if (package
->infoW
.Comment
)
562 commentLen
= WideCharToMultiByte(CP_ACP
, 0,
563 package
->infoW
.Comment
, -1, NULL
, 0, NULL
, NULL
);
564 bytesNeeded
+= commentLen
;
566 /* freed with FreeContextBuffer */
567 if ((*ppPackageInfo
= RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded
)))
569 PSTR nextString
= (PSTR
)((PBYTE
)*ppPackageInfo
+
570 sizeof(SecPkgInfoA
));
572 memcpy(*ppPackageInfo
, &package
->infoW
, sizeof(package
->infoW
));
573 if (package
->infoW
.Name
)
575 (*ppPackageInfo
)->Name
= nextString
;
576 nextString
+= WideCharToMultiByte(CP_ACP
, 0,
577 package
->infoW
.Name
, -1, nextString
, nameLen
, NULL
, NULL
);
580 (*ppPackageInfo
)->Name
= NULL
;
581 if (package
->infoW
.Comment
)
583 (*ppPackageInfo
)->Comment
= nextString
;
584 nextString
+= WideCharToMultiByte(CP_ACP
, 0,
585 package
->infoW
.Comment
, -1, nextString
, commentLen
, NULL
,
589 (*ppPackageInfo
)->Comment
= NULL
;
593 ret
= SEC_E_INSUFFICIENT_MEMORY
;
596 ret
= SEC_E_SECPKG_NOT_FOUND
;
599 ret
= SEC_E_SECPKG_NOT_FOUND
;
603 /***********************************************************************
604 * QuerySecurityPackageInfoW (SECUR32.@)
606 SECURITY_STATUS WINAPI
QuerySecurityPackageInfoW(SEC_WCHAR
*pszPackageName
,
607 PSecPkgInfoW
*ppPackageInfo
)
610 SecurePackage
*package
= SECUR32_findPackageW(pszPackageName
);
612 TRACE("%s %p\n", debugstr_w(pszPackageName
), ppPackageInfo
);
615 size_t bytesNeeded
= sizeof(SecPkgInfoW
);
616 int nameLen
= 0, commentLen
= 0;
618 if (package
->infoW
.Name
)
620 nameLen
= lstrlenW(package
->infoW
.Name
) + 1;
621 bytesNeeded
+= nameLen
* sizeof(WCHAR
);
623 if (package
->infoW
.Comment
)
625 commentLen
= lstrlenW(package
->infoW
.Comment
) + 1;
626 bytesNeeded
+= commentLen
* sizeof(WCHAR
);
628 /* freed with FreeContextBuffer */
629 if ((*ppPackageInfo
= RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded
)))
631 PWSTR nextString
= (PWSTR
)((PBYTE
)*ppPackageInfo
+
632 sizeof(SecPkgInfoW
));
634 **ppPackageInfo
= package
->infoW
;
635 if (package
->infoW
.Name
)
637 (*ppPackageInfo
)->Name
= nextString
;
638 lstrcpynW(nextString
, package
->infoW
.Name
, nameLen
);
639 nextString
+= nameLen
;
642 (*ppPackageInfo
)->Name
= NULL
;
643 if (package
->infoW
.Comment
)
645 (*ppPackageInfo
)->Comment
= nextString
;
646 lstrcpynW(nextString
, package
->infoW
.Comment
, commentLen
);
649 (*ppPackageInfo
)->Comment
= NULL
;
653 ret
= SEC_E_INSUFFICIENT_MEMORY
;
656 ret
= SEC_E_SECPKG_NOT_FOUND
;
660 /***********************************************************************
661 * ExportSecurityContext (SECUR32.@)
663 SECURITY_STATUS WINAPI
ExportSecurityContext(PCtxtHandle phContext
,
664 ULONG fFlags
, PSecBuffer pPackedContext
, void **pToken
)
668 TRACE("%p %ld %p %p\n", phContext
, fFlags
, pPackedContext
, pToken
);
671 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
672 if (package
&& package
->provider
)
674 if (package
->provider
->fnTableW
.ExportSecurityContext
)
675 ret
= package
->provider
->fnTableW
.ExportSecurityContext(phContext
, fFlags
, pPackedContext
, pToken
);
677 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
680 ret
= SEC_E_INVALID_HANDLE
;
683 ret
= SEC_E_INVALID_HANDLE
;
687 /***********************************************************************
688 * ImportSecurityContextA (SECUR32.@)
690 SECURITY_STATUS WINAPI
ImportSecurityContextA(SEC_CHAR
*pszPackage
,
691 PSecBuffer pPackedContext
, void *Token
, PCtxtHandle phContext
)
694 SecurePackage
*package
= SECUR32_findPackageA(pszPackage
);
696 TRACE("%s %p %p %p\n", debugstr_a(pszPackage
), pPackedContext
, Token
, phContext
);
697 if (package
&& package
->provider
)
699 if (package
->provider
->fnTableA
.ImportSecurityContextA
)
701 ret
= package
->provider
->fnTableA
.ImportSecurityContextA(pszPackage
, pPackedContext
, Token
, phContext
);
703 phContext
->dwUpper
= (ULONG_PTR
)package
;
706 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
709 ret
= SEC_E_SECPKG_NOT_FOUND
;
714 /***********************************************************************
715 * ImportSecurityContextW (SECUR32.@)
717 SECURITY_STATUS WINAPI
ImportSecurityContextW(SEC_WCHAR
*pszPackage
,
718 PSecBuffer pPackedContext
, void *Token
, PCtxtHandle phContext
)
721 SecurePackage
*package
= SECUR32_findPackageW(pszPackage
);
723 TRACE("%s %p %p %p\n", debugstr_w(pszPackage
), pPackedContext
, Token
, phContext
);
724 if (package
&& package
->provider
)
726 if (package
->provider
->fnTableW
.ImportSecurityContextW
)
728 ret
= package
->provider
->fnTableW
.ImportSecurityContextW(pszPackage
, pPackedContext
, Token
, phContext
);
730 phContext
->dwUpper
= (ULONG_PTR
)package
;
733 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
736 ret
= SEC_E_SECPKG_NOT_FOUND
;
740 /***********************************************************************
741 * AddCredentialsA (SECUR32.@)
743 SECURITY_STATUS WINAPI
AddCredentialsA(PCredHandle hCredentials
,
744 SEC_CHAR
*pszPrincipal
, SEC_CHAR
*pszPackage
, ULONG fCredentialUse
,
745 void *pAuthData
, SEC_GET_KEY_FN pGetKeyFn
, void *pvGetKeyArgument
,
746 PTimeStamp ptsExpiry
)
750 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials
, debugstr_a(pszPrincipal
),
751 debugstr_a(pszPackage
), fCredentialUse
, pAuthData
, pGetKeyFn
,
752 pvGetKeyArgument
, ptsExpiry
);
755 SecurePackage
*package
= (SecurePackage
*)hCredentials
->dwUpper
;
756 if (package
&& package
->provider
)
758 if (package
->provider
->fnTableA
.AddCredentialsA
)
759 ret
= package
->provider
->fnTableA
.AddCredentialsA(hCredentials
, pszPrincipal
, pszPackage
,
760 fCredentialUse
, pAuthData
, pGetKeyFn
,
761 pvGetKeyArgument
, ptsExpiry
);
763 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
766 ret
= SEC_E_INVALID_HANDLE
;
769 ret
= SEC_E_INVALID_HANDLE
;
773 /***********************************************************************
774 * AddCredentialsW (SECUR32.@)
776 SECURITY_STATUS WINAPI
AddCredentialsW(PCredHandle hCredentials
,
777 SEC_WCHAR
*pszPrincipal
, SEC_WCHAR
*pszPackage
, ULONG fCredentialUse
,
778 void *pAuthData
, SEC_GET_KEY_FN pGetKeyFn
, void *pvGetKeyArgument
,
779 PTimeStamp ptsExpiry
)
783 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials
, debugstr_w(pszPrincipal
),
784 debugstr_w(pszPackage
), fCredentialUse
, pAuthData
, pGetKeyFn
,
785 pvGetKeyArgument
, ptsExpiry
);
788 SecurePackage
*package
= (SecurePackage
*)hCredentials
->dwUpper
;
789 if (package
&& package
->provider
)
791 if (package
->provider
->fnTableW
.AddCredentialsW
)
792 ret
= package
->provider
->fnTableW
.AddCredentialsW(hCredentials
, pszPrincipal
, pszPackage
,
793 fCredentialUse
, pAuthData
, pGetKeyFn
,
794 pvGetKeyArgument
, ptsExpiry
);
796 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
799 ret
= SEC_E_INVALID_HANDLE
;
802 ret
= SEC_E_INVALID_HANDLE
;
806 /***********************************************************************
807 * QuerySecurityContextToken (SECUR32.@)
809 SECURITY_STATUS WINAPI
QuerySecurityContextToken(PCtxtHandle phContext
,
814 TRACE("%p %p\n", phContext
, phToken
);
817 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
818 if (package
&& package
->provider
)
820 if (package
->provider
->fnTableW
.QuerySecurityContextToken
)
821 ret
= package
->provider
->fnTableW
.QuerySecurityContextToken(phContext
, phToken
);
823 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
826 ret
= SEC_E_INVALID_HANDLE
;
829 ret
= SEC_E_INVALID_HANDLE
;
833 /***********************************************************************
834 * EncryptMessage (SECUR32.@)
836 SECURITY_STATUS WINAPI
EncryptMessage(PCtxtHandle phContext
, ULONG fQOP
,
837 PSecBufferDesc pMessage
, ULONG MessageSeqNo
)
841 TRACE("%p %ld %p %ld\n", phContext
, fQOP
, pMessage
, MessageSeqNo
);
844 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
845 if (package
&& package
->provider
)
847 if (package
->provider
->fnTableW
.EncryptMessage
)
848 ret
= package
->provider
->fnTableW
.EncryptMessage(phContext
, fQOP
, pMessage
, MessageSeqNo
);
850 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
853 ret
= SEC_E_INVALID_HANDLE
;
856 ret
= SEC_E_INVALID_HANDLE
;
860 /***********************************************************************
861 * DecryptMessage (SECUR32.@)
863 SECURITY_STATUS WINAPI
DecryptMessage(PCtxtHandle phContext
,
864 PSecBufferDesc pMessage
, ULONG MessageSeqNo
, PULONG pfQOP
)
868 TRACE("%p %p %ld %p\n", phContext
, pMessage
, MessageSeqNo
, pfQOP
);
871 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
872 if (package
&& package
->provider
)
874 if (package
->provider
->fnTableW
.DecryptMessage
)
875 ret
= package
->provider
->fnTableW
.DecryptMessage(phContext
, pMessage
, MessageSeqNo
, pfQOP
);
877 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
880 ret
= SEC_E_INVALID_HANDLE
;
883 ret
= SEC_E_INVALID_HANDLE
;
887 /***********************************************************************
888 * SetContextAttributesA (SECUR32.@)
890 SECURITY_STATUS WINAPI
SetContextAttributesA(PCtxtHandle phContext
,
891 ULONG ulAttribute
, void *pBuffer
, ULONG cbBuffer
)
895 TRACE("%p %ld %p %ld\n", phContext
, ulAttribute
, pBuffer
, cbBuffer
);
898 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
899 if (package
&& package
->provider
)
901 if (package
->provider
->fnTableA
.SetContextAttributesA
)
902 ret
= package
->provider
->fnTableA
.SetContextAttributesA(phContext
, ulAttribute
, pBuffer
, cbBuffer
);
904 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
907 ret
= SEC_E_INVALID_HANDLE
;
910 ret
= SEC_E_INVALID_HANDLE
;
914 /***********************************************************************
915 * SetContextAttributesW (SECUR32.@)
917 SECURITY_STATUS WINAPI
SetContextAttributesW(PCtxtHandle phContext
,
918 ULONG ulAttribute
, void *pBuffer
, ULONG cbBuffer
)
922 TRACE("%p %ld %p %ld\n", phContext
, ulAttribute
, pBuffer
, cbBuffer
);
925 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
926 if (package
&& package
->provider
)
928 if (package
->provider
->fnTableW
.SetContextAttributesW
)
929 ret
= package
->provider
->fnTableW
.SetContextAttributesW(phContext
, ulAttribute
, pBuffer
, cbBuffer
);
931 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
934 ret
= SEC_E_INVALID_HANDLE
;
937 ret
= SEC_E_INVALID_HANDLE
;