2004-03-02 05:57:35 +01:00
|
|
|
/* Copyright (C) 2004 Juan Lang
|
|
|
|
*
|
|
|
|
* Implements secur32 functions that forward to (wrap) an SSP's implementation.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-02 05:57:35 +01:00
|
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "sspi.h"
|
|
|
|
#include "secur32_priv.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
|
|
|
|
|
|
|
|
/* Tries to allocate a new SecHandle, into which it stores package (in
|
|
|
|
* phSec->dwUpper) and a copy of realHandle (allocated with SECUR32_ALLOC,
|
|
|
|
* and stored in phSec->dwLower). SecHandle is equivalent to both a
|
|
|
|
* CredHandle and a CtxtHandle.
|
|
|
|
*/
|
|
|
|
static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
|
|
|
|
SecurePackage *package, PSecHandle realHandle)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2005-08-22 12:05:45 +02:00
|
|
|
TRACE("%p %p %p\n", phSec, package, realHandle);
|
|
|
|
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phSec && package && realHandle)
|
|
|
|
{
|
2007-12-05 21:52:20 +01:00
|
|
|
PSecHandle newSec = HeapAlloc(GetProcessHeap(), 0, sizeof(SecHandle));
|
2004-03-02 05:57:35 +01:00
|
|
|
|
|
|
|
if (newSec)
|
|
|
|
{
|
2008-03-16 00:25:42 +01:00
|
|
|
*newSec = *realHandle;
|
2004-03-02 05:57:35 +01:00
|
|
|
phSec->dwUpper = (ULONG_PTR)package;
|
|
|
|
phSec->dwLower = (ULONG_PTR)newSec;
|
|
|
|
ret = SEC_E_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INSUFFICIENT_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AcquireCredentialsHandleA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI AcquireCredentialsHandleA(
|
2004-03-02 05:57:35 +01:00
|
|
|
SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse,
|
|
|
|
PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
|
|
|
PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%s %s %d %p %p %p %p %p %p\n", debugstr_a(pszPrincipal),
|
2004-03-02 05:57:35 +01:00
|
|
|
debugstr_a(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
|
|
|
|
pvGetKeyArgument, phCredential, ptsExpiry);
|
|
|
|
if (pszPackage)
|
|
|
|
{
|
|
|
|
SecurePackage *package = SECUR32_findPackageA(pszPackage);
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableA.AcquireCredentialsHandleA)
|
|
|
|
{
|
|
|
|
CredHandle myCred;
|
|
|
|
|
|
|
|
ret = package->provider->fnTableA.AcquireCredentialsHandleA(
|
|
|
|
pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
|
|
|
|
pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
|
|
|
|
ptsExpiry);
|
|
|
|
if (ret == SEC_E_OK)
|
|
|
|
{
|
|
|
|
ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
|
|
|
|
if (ret != SEC_E_OK)
|
|
|
|
package->provider->fnTableW.FreeCredentialsHandle(
|
|
|
|
&myCred);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AcquireCredentialsHandleW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(
|
2004-03-02 05:57:35 +01:00
|
|
|
SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse,
|
|
|
|
PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
|
|
|
PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%s %s %d %p %p %p %p %p %p\n", debugstr_w(pszPrincipal),
|
2004-03-02 05:57:35 +01:00
|
|
|
debugstr_w(pszPackage), fCredentialsUse, pvLogonID, pAuthData, pGetKeyFn,
|
|
|
|
pvGetKeyArgument, phCredential, ptsExpiry);
|
|
|
|
if (pszPackage)
|
|
|
|
{
|
|
|
|
SecurePackage *package = SECUR32_findPackageW(pszPackage);
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.AcquireCredentialsHandleW)
|
|
|
|
{
|
|
|
|
CredHandle myCred;
|
|
|
|
|
|
|
|
ret = package->provider->fnTableW.AcquireCredentialsHandleW(
|
|
|
|
pszPrincipal, pszPackage, fCredentialsUse, pvLogonID,
|
|
|
|
pAuthData, pGetKeyFn, pvGetKeyArgument, &myCred,
|
|
|
|
ptsExpiry);
|
|
|
|
if (ret == SEC_E_OK)
|
|
|
|
{
|
|
|
|
ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
|
|
|
|
if (ret != SEC_E_OK)
|
|
|
|
package->provider->fnTableW.FreeCredentialsHandle(
|
|
|
|
&myCred);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FreeCredentialsHandle (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI FreeCredentialsHandle(
|
2004-03-02 05:57:35 +01:00
|
|
|
PCredHandle phCredential)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%p\n", phCredential);
|
|
|
|
if (phCredential)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
|
|
|
|
PCredHandle cred = (PCredHandle)phCredential->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider &&
|
|
|
|
package->provider->fnTableW.FreeCredentialsHandle)
|
|
|
|
ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
2007-12-05 21:52:20 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, cred);
|
2004-03-02 05:57:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* QueryCredentialsAttributesA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI QueryCredentialsAttributesA(
|
2006-10-15 14:51:52 +02:00
|
|
|
PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p\n", phCredential, ulAttribute, pBuffer);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phCredential)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
|
|
|
|
PCredHandle cred = (PCredHandle)phCredential->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableA.QueryCredentialsAttributesA)
|
|
|
|
ret = package->provider->fnTableA.QueryCredentialsAttributesA(
|
|
|
|
cred, ulAttribute, pBuffer);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* QueryCredentialsAttributesW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI QueryCredentialsAttributesW(
|
2006-10-15 14:51:52 +02:00
|
|
|
PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p\n", phCredential, ulAttribute, pBuffer);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phCredential)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
|
|
|
|
PCredHandle cred = (PCredHandle)phCredential->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.QueryCredentialsAttributesW)
|
|
|
|
ret = package->provider->fnTableW.QueryCredentialsAttributesW(
|
|
|
|
cred, ulAttribute, pBuffer);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InitializeSecurityContextA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI InitializeSecurityContextA(
|
2004-03-02 05:57:35 +01:00
|
|
|
PCredHandle phCredential, PCtxtHandle phContext,
|
2006-10-15 14:51:52 +02:00
|
|
|
SEC_CHAR *pszTargetName, ULONG fContextReq,
|
|
|
|
ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
|
|
|
|
ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
|
|
|
|
ULONG *pfContextAttr, PTimeStamp ptsExpiry)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
2007-05-24 21:01:21 +02:00
|
|
|
SecurePackage *package = NULL;
|
|
|
|
PCredHandle cred = NULL;
|
|
|
|
PCredHandle ctxt = NULL;
|
2004-03-02 05:57:35 +01:00
|
|
|
|
2010-10-22 01:37:53 +02:00
|
|
|
TRACE("%p %p %s 0x%08x %d %d %p %d %p %p %p %p\n", phCredential, phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
|
|
|
|
Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
2007-05-24 21:01:21 +02:00
|
|
|
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
}
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phCredential)
|
|
|
|
{
|
2007-05-24 21:01:21 +02:00
|
|
|
package = (SecurePackage *)phCredential->dwUpper;
|
|
|
|
cred = (PCredHandle)phCredential->dwLower;
|
|
|
|
}
|
2004-03-02 05:57:35 +01:00
|
|
|
|
2007-05-24 21:01:21 +02:00
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableA.InitializeSecurityContextA)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
2007-05-24 21:01:21 +02:00
|
|
|
CtxtHandle myCtxt;
|
2004-03-02 05:57:35 +01:00
|
|
|
|
2007-05-24 21:01:21 +02:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
myCtxt.dwUpper = realCtxt->dwUpper;
|
|
|
|
myCtxt.dwLower = realCtxt->dwLower;
|
|
|
|
}
|
2005-08-22 12:05:45 +02:00
|
|
|
|
2007-05-24 21:01:21 +02:00
|
|
|
ret = package->provider->fnTableA.InitializeSecurityContextA(
|
|
|
|
cred, ctxt, pszTargetName, fContextReq,
|
|
|
|
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
|
2004-03-02 05:57:35 +01:00
|
|
|
pOutput, pfContextAttr, ptsExpiry);
|
2009-12-29 20:06:43 +01:00
|
|
|
if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) &&
|
|
|
|
phNewContext && phNewContext != phContext)
|
2007-05-24 21:01:21 +02:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret2;
|
|
|
|
ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
|
|
|
|
if (ret2 != SEC_E_OK)
|
|
|
|
package->provider->fnTableA.DeleteSecurityContext(&myCtxt);
|
2004-03-02 05:57:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-05-24 21:01:21 +02:00
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
2004-03-02 05:57:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InitializeSecurityContextW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI InitializeSecurityContextW(
|
2004-03-02 05:57:35 +01:00
|
|
|
PCredHandle phCredential, PCtxtHandle phContext,
|
2006-10-15 14:51:52 +02:00
|
|
|
SEC_WCHAR *pszTargetName, ULONG fContextReq,
|
|
|
|
ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput,
|
|
|
|
ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput,
|
|
|
|
ULONG *pfContextAttr, PTimeStamp ptsExpiry)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
2007-05-24 21:01:21 +02:00
|
|
|
SecurePackage *package = NULL;
|
|
|
|
PCredHandle cred = NULL;
|
|
|
|
PCredHandle ctxt = NULL;
|
2004-03-02 05:57:35 +01:00
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
|
|
|
|
Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
2007-05-24 21:01:21 +02:00
|
|
|
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
}
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phCredential)
|
|
|
|
{
|
2007-05-24 21:01:21 +02:00
|
|
|
package = (SecurePackage *)phCredential->dwUpper;
|
|
|
|
cred = (PCredHandle)phCredential->dwLower;
|
|
|
|
}
|
2004-03-02 05:57:35 +01:00
|
|
|
|
2007-05-24 21:01:21 +02:00
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.InitializeSecurityContextW)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
2007-05-24 21:01:21 +02:00
|
|
|
CtxtHandle myCtxt;
|
2004-03-02 05:57:35 +01:00
|
|
|
|
2007-05-24 21:01:21 +02:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
myCtxt.dwUpper = realCtxt->dwUpper;
|
|
|
|
myCtxt.dwLower = realCtxt->dwLower;
|
|
|
|
}
|
2005-08-22 12:05:45 +02:00
|
|
|
|
2007-05-24 21:01:21 +02:00
|
|
|
ret = package->provider->fnTableW.InitializeSecurityContextW(
|
|
|
|
cred, ctxt, pszTargetName, fContextReq,
|
|
|
|
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
|
2004-03-02 05:57:35 +01:00
|
|
|
pOutput, pfContextAttr, ptsExpiry);
|
2009-12-29 20:06:43 +01:00
|
|
|
if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) &&
|
|
|
|
phNewContext && phNewContext != phContext)
|
2007-05-24 21:01:21 +02:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret2;
|
|
|
|
ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
|
|
|
|
if (ret2 != SEC_E_OK)
|
|
|
|
package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
|
2004-03-02 05:57:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-05-24 21:01:21 +02:00
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
2004-03-02 05:57:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AcceptSecurityContext (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI AcceptSecurityContext(
|
2004-03-02 05:57:35 +01:00
|
|
|
PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput,
|
2006-10-15 14:51:52 +02:00
|
|
|
ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
|
|
|
|
PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %p %p %d %d %p %p %p %p\n", phCredential, phContext, pInput,
|
2004-03-02 05:57:35 +01:00
|
|
|
fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
|
|
|
|
ptsExpiry);
|
|
|
|
if (phCredential)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phCredential->dwUpper;
|
|
|
|
PCredHandle cred = (PCredHandle)phCredential->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.AcceptSecurityContext)
|
|
|
|
{
|
|
|
|
CtxtHandle myCtxt;
|
|
|
|
|
2005-08-22 12:05:45 +02:00
|
|
|
if(phContext)
|
|
|
|
{
|
|
|
|
PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
TRACE("realCtx: %p\n", realCtxt);
|
|
|
|
myCtxt.dwUpper = realCtxt->dwUpper;
|
|
|
|
myCtxt.dwLower = realCtxt->dwLower;
|
|
|
|
}
|
|
|
|
|
2004-03-02 05:57:35 +01:00
|
|
|
ret = package->provider->fnTableW.AcceptSecurityContext(
|
|
|
|
cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
|
|
|
|
TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
|
2005-08-22 12:05:45 +02:00
|
|
|
if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
2005-08-22 12:05:45 +02:00
|
|
|
SECURITY_STATUS ret2;
|
|
|
|
ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
|
|
|
|
if (ret2 != SEC_E_OK)
|
2004-03-02 05:57:35 +01:00
|
|
|
package->provider->fnTableW.DeleteSecurityContext(
|
|
|
|
&myCtxt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CompleteAuthToken (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBufferDesc pToken)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", phContext, pToken);
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.CompleteAuthToken)
|
|
|
|
ret = package->provider->fnTableW.CompleteAuthToken(ctxt,
|
|
|
|
pToken);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DeleteSecurityContext (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%p\n", phContext);
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider &&
|
|
|
|
package->provider->fnTableW.DeleteSecurityContext)
|
|
|
|
ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
2007-12-05 21:52:20 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, ctxt);
|
2004-03-02 05:57:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ApplyControlToken (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI ApplyControlToken(PCtxtHandle phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBufferDesc pInput)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", phContext, pInput);
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.ApplyControlToken)
|
|
|
|
ret = package->provider->fnTableW.ApplyControlToken(
|
|
|
|
ctxt, pInput);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* QueryContextAttributesA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext,
|
2006-10-15 14:51:52 +02:00
|
|
|
ULONG ulAttribute, void *pBuffer)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableA.QueryContextAttributesA)
|
|
|
|
ret = package->provider->fnTableA.QueryContextAttributesA(
|
|
|
|
ctxt, ulAttribute, pBuffer);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* QueryContextAttributesW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext,
|
2006-10-15 14:51:52 +02:00
|
|
|
ULONG ulAttribute, void *pBuffer)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p\n", phContext, ulAttribute, pBuffer);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.QueryContextAttributesW)
|
|
|
|
ret = package->provider->fnTableW.QueryContextAttributesW(
|
|
|
|
ctxt, ulAttribute, pBuffer);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ImpersonateSecurityContext (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%p\n", phContext);
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.ImpersonateSecurityContext)
|
|
|
|
ret = package->provider->fnTableW.ImpersonateSecurityContext(
|
|
|
|
ctxt);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RevertSecurityContext (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%p\n", phContext);
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.RevertSecurityContext)
|
|
|
|
ret = package->provider->fnTableW.RevertSecurityContext(
|
|
|
|
ctxt);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MakeSignature (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.MakeSignature)
|
|
|
|
ret = package->provider->fnTableW.MakeSignature(
|
|
|
|
ctxt, fQOP, pMessage, MessageSeqNo);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* VerifySignature (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.VerifySignature)
|
|
|
|
ret = package->provider->fnTableW.VerifySignature(
|
|
|
|
ctxt, pMessage, MessageSeqNo, pfQOP);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* QuerySecurityPackageInfoA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecPkgInfoA *ppPackageInfo)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
|
|
|
|
if (pszPackageName)
|
|
|
|
{
|
|
|
|
SecurePackage *package = SECUR32_findPackageA(pszPackageName);
|
|
|
|
|
|
|
|
if (package)
|
|
|
|
{
|
|
|
|
size_t bytesNeeded = sizeof(SecPkgInfoA);
|
|
|
|
int nameLen = 0, commentLen = 0;
|
|
|
|
|
|
|
|
if (package->infoW.Name)
|
|
|
|
{
|
|
|
|
nameLen = WideCharToMultiByte(CP_ACP, 0,
|
|
|
|
package->infoW.Name, -1, NULL, 0, NULL, NULL);
|
|
|
|
bytesNeeded += nameLen;
|
|
|
|
}
|
|
|
|
if (package->infoW.Comment)
|
|
|
|
{
|
|
|
|
commentLen = WideCharToMultiByte(CP_ACP, 0,
|
|
|
|
package->infoW.Comment, -1, NULL, 0, NULL, NULL);
|
|
|
|
bytesNeeded += commentLen;
|
|
|
|
}
|
2007-12-05 21:52:20 +01:00
|
|
|
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (*ppPackageInfo)
|
|
|
|
{
|
|
|
|
PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
|
|
|
|
sizeof(SecPkgInfoA));
|
|
|
|
|
|
|
|
memcpy(*ppPackageInfo, &package->infoW, sizeof(package->infoW));
|
|
|
|
if (package->infoW.Name)
|
|
|
|
{
|
|
|
|
(*ppPackageInfo)->Name = nextString;
|
|
|
|
nextString += WideCharToMultiByte(CP_ACP, 0,
|
|
|
|
package->infoW.Name, -1, nextString, nameLen, NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(*ppPackageInfo)->Name = NULL;
|
|
|
|
if (package->infoW.Comment)
|
|
|
|
{
|
|
|
|
(*ppPackageInfo)->Comment = nextString;
|
|
|
|
nextString += WideCharToMultiByte(CP_ACP, 0,
|
|
|
|
package->infoW.Comment, -1, nextString, commentLen, NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(*ppPackageInfo)->Comment = NULL;
|
|
|
|
ret = SEC_E_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INSUFFICIENT_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* QuerySecurityPackageInfoW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecPkgInfoW *ppPackageInfo)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
SecurePackage *package = SECUR32_findPackageW(pszPackageName);
|
|
|
|
|
|
|
|
TRACE("%s %p\n", debugstr_w(pszPackageName), ppPackageInfo);
|
|
|
|
if (package)
|
|
|
|
{
|
|
|
|
size_t bytesNeeded = sizeof(SecPkgInfoW);
|
|
|
|
int nameLen = 0, commentLen = 0;
|
|
|
|
|
|
|
|
if (package->infoW.Name)
|
|
|
|
{
|
|
|
|
nameLen = lstrlenW(package->infoW.Name) + 1;
|
|
|
|
bytesNeeded += nameLen * sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
if (package->infoW.Comment)
|
|
|
|
{
|
|
|
|
commentLen = lstrlenW(package->infoW.Comment) + 1;
|
|
|
|
bytesNeeded += commentLen * sizeof(WCHAR);
|
|
|
|
}
|
2007-12-05 21:52:20 +01:00
|
|
|
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (*ppPackageInfo)
|
|
|
|
{
|
|
|
|
PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
|
|
|
|
sizeof(SecPkgInfoW));
|
|
|
|
|
2008-03-16 00:25:42 +01:00
|
|
|
**ppPackageInfo = package->infoW;
|
2004-03-02 05:57:35 +01:00
|
|
|
if (package->infoW.Name)
|
|
|
|
{
|
|
|
|
(*ppPackageInfo)->Name = nextString;
|
|
|
|
lstrcpynW(nextString, package->infoW.Name, nameLen);
|
|
|
|
nextString += nameLen;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(*ppPackageInfo)->Name = NULL;
|
|
|
|
if (package->infoW.Comment)
|
|
|
|
{
|
|
|
|
(*ppPackageInfo)->Comment = nextString;
|
|
|
|
lstrcpynW(nextString, package->infoW.Comment, commentLen);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(*ppPackageInfo)->Comment = NULL;
|
|
|
|
ret = SEC_E_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INSUFFICIENT_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExportSecurityContext (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI ExportSecurityContext(PCtxtHandle phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p %p\n", phContext, fFlags, pPackedContext, pToken);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.ExportSecurityContext)
|
|
|
|
ret = package->provider->fnTableW.ExportSecurityContext(
|
|
|
|
ctxt, fFlags, pPackedContext, pToken);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ImportSecurityContextA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
SecurePackage *package = SECUR32_findPackageA(pszPackage);
|
|
|
|
|
|
|
|
TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
|
|
|
|
phContext);
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableA.ImportSecurityContextA)
|
|
|
|
{
|
|
|
|
CtxtHandle myCtxt;
|
|
|
|
|
|
|
|
ret = package->provider->fnTableA.ImportSecurityContextA(
|
|
|
|
pszPackage, pPackedContext, Token, &myCtxt);
|
|
|
|
if (ret == SEC_E_OK)
|
|
|
|
{
|
|
|
|
ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
|
|
|
|
if (ret != SEC_E_OK)
|
|
|
|
package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ImportSecurityContextW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
SecurePackage *package = SECUR32_findPackageW(pszPackage);
|
|
|
|
|
|
|
|
TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
|
|
|
|
phContext);
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.ImportSecurityContextW)
|
|
|
|
{
|
|
|
|
CtxtHandle myCtxt;
|
|
|
|
|
|
|
|
ret = package->provider->fnTableW.ImportSecurityContextW(
|
|
|
|
pszPackage, pPackedContext, Token, &myCtxt);
|
|
|
|
if (ret == SEC_E_OK)
|
|
|
|
{
|
|
|
|
ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
|
|
|
|
if (ret != SEC_E_OK)
|
|
|
|
package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_SECPKG_NOT_FOUND;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AddCredentialsA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI AddCredentialsA(PCredHandle hCredentials,
|
2006-10-15 14:51:52 +02:00
|
|
|
SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse,
|
2004-03-02 05:57:35 +01:00
|
|
|
void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
|
|
|
|
PTimeStamp ptsExpiry)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_a(pszPrincipal),
|
2004-03-02 05:57:35 +01:00
|
|
|
debugstr_a(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
|
|
|
|
pvGetKeyArgument, ptsExpiry);
|
|
|
|
if (hCredentials)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
|
|
|
|
PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableA.AddCredentialsA)
|
|
|
|
ret = package->provider->fnTableA.AddCredentialsA(
|
|
|
|
cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
|
|
|
|
pGetKeyFn, pvGetKeyArgument, ptsExpiry);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AddCredentialsW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI AddCredentialsW(PCredHandle hCredentials,
|
2006-10-15 14:51:52 +02:00
|
|
|
SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse,
|
2004-03-02 05:57:35 +01:00
|
|
|
void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument,
|
|
|
|
PTimeStamp ptsExpiry)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %s %s %d %p %p %p %p\n", hCredentials, debugstr_w(pszPrincipal),
|
2004-03-02 05:57:35 +01:00
|
|
|
debugstr_w(pszPackage), fCredentialUse, pAuthData, pGetKeyFn,
|
|
|
|
pvGetKeyArgument, ptsExpiry);
|
|
|
|
if (hCredentials)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)hCredentials->dwUpper;
|
|
|
|
PCredHandle cred = (PCtxtHandle)hCredentials->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.AddCredentialsW)
|
|
|
|
ret = package->provider->fnTableW.AddCredentialsW(
|
|
|
|
cred, pszPrincipal, pszPackage, fCredentialUse, pAuthData,
|
|
|
|
pGetKeyFn, pvGetKeyArgument, ptsExpiry);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* QuerySecurityContextToken (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI QuerySecurityContextToken(PCtxtHandle phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
HANDLE *phToken)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", phContext, phToken);
|
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.QuerySecurityContextToken)
|
|
|
|
ret = package->provider->fnTableW.QuerySecurityContextToken(
|
|
|
|
ctxt, phToken);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* EncryptMessage (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p %d\n", phContext, fQOP, pMessage, MessageSeqNo);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.EncryptMessage)
|
|
|
|
ret = package->provider->fnTableW.EncryptMessage(
|
|
|
|
ctxt, fQOP, pMessage, MessageSeqNo);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DecryptMessage (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext,
|
2004-03-02 05:57:35 +01:00
|
|
|
PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
|
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %p %d %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.DecryptMessage)
|
|
|
|
ret = package->provider->fnTableW.DecryptMessage(
|
|
|
|
ctxt, pMessage, MessageSeqNo, pfQOP);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetContextAttributesA (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI SetContextAttributesA(PCtxtHandle phContext,
|
2006-10-15 14:51:52 +02:00
|
|
|
ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableA.SetContextAttributesA)
|
|
|
|
ret = package->provider->fnTableA.SetContextAttributesA(
|
|
|
|
ctxt, ulAttribute, pBuffer, cbBuffer);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-17 23:08:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetContextAttributesW (SECUR32.@)
|
|
|
|
*/
|
|
|
|
SECURITY_STATUS WINAPI SetContextAttributesW(PCtxtHandle phContext,
|
2006-10-15 14:51:52 +02:00
|
|
|
ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
|
2004-03-02 05:57:35 +01:00
|
|
|
{
|
|
|
|
SECURITY_STATUS ret;
|
|
|
|
|
2006-10-15 14:51:52 +02:00
|
|
|
TRACE("%p %d %p %d\n", phContext, ulAttribute, pBuffer, cbBuffer);
|
2004-03-02 05:57:35 +01:00
|
|
|
if (phContext)
|
|
|
|
{
|
|
|
|
SecurePackage *package = (SecurePackage *)phContext->dwUpper;
|
|
|
|
PCtxtHandle ctxt = (PCtxtHandle)phContext->dwLower;
|
|
|
|
|
|
|
|
if (package && package->provider)
|
|
|
|
{
|
|
|
|
if (package->provider->fnTableW.SetContextAttributesW)
|
|
|
|
ret = package->provider->fnTableW.SetContextAttributesW(
|
|
|
|
ctxt, ulAttribute, pBuffer, cbBuffer);
|
|
|
|
else
|
|
|
|
ret = SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = SEC_E_INVALID_HANDLE;
|
|
|
|
return ret;
|
|
|
|
}
|