2012-02-21 01:17:57 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Security Support Provider Interface (SSPI)
|
|
|
|
*
|
2014-06-06 06:10:08 +04:00
|
|
|
* Copyright 2012-2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2012-02-21 01:17:57 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:20:53 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-06-07 18:50:51 +04:00
|
|
|
#define _NO_KSECDD_IMPORT_ 1
|
|
|
|
|
|
|
|
#include <winpr/sspi.h>
|
|
|
|
|
2014-06-06 23:34:12 +04:00
|
|
|
#include <winpr/crt.h>
|
2017-02-13 20:04:42 +03:00
|
|
|
#include <winpr/synch.h>
|
2014-06-07 01:20:34 +04:00
|
|
|
#include <winpr/wlog.h>
|
2014-06-06 23:34:12 +04:00
|
|
|
#include <winpr/library.h>
|
2014-06-07 18:50:51 +04:00
|
|
|
#include <winpr/environment.h>
|
2014-06-06 23:34:12 +04:00
|
|
|
|
2012-02-24 00:56:50 +04:00
|
|
|
#include "sspi.h"
|
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
static wLog* g_Log = NULL;
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
static INIT_ONCE g_Initialized = INIT_ONCE_STATIC_INIT;
|
2015-06-23 17:02:53 +03:00
|
|
|
#if defined(WITH_NATIVE_SSPI)
|
2014-06-06 23:34:12 +04:00
|
|
|
static HMODULE g_SspiModule = NULL;
|
2015-06-23 17:02:53 +03:00
|
|
|
#endif
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
static SecurityFunctionTableW* g_SspiW = NULL;
|
|
|
|
static SecurityFunctionTableA* g_SspiA = NULL;
|
|
|
|
|
2015-06-17 14:24:11 +03:00
|
|
|
#if defined(WITH_NATIVE_SSPI)
|
2015-06-23 17:02:53 +03:00
|
|
|
static BOOL ShouldUseNativeSspi(void);
|
2015-06-17 14:24:11 +03:00
|
|
|
static BOOL InitializeSspiModule_Native(void);
|
|
|
|
#endif
|
2014-06-06 23:34:12 +04:00
|
|
|
|
2015-06-23 17:02:53 +03:00
|
|
|
#if defined(WITH_NATIVE_SSPI)
|
2015-06-17 14:24:11 +03:00
|
|
|
BOOL ShouldUseNativeSspi(void)
|
2014-06-06 23:34:12 +04:00
|
|
|
{
|
2014-06-07 18:50:51 +04:00
|
|
|
BOOL status = FALSE;
|
2014-06-06 23:34:12 +04:00
|
|
|
#ifdef _WIN32
|
2017-03-03 14:37:27 +03:00
|
|
|
LPCSTR sspi = "WINPR_NATIVE_SSPI";
|
2014-06-07 18:50:51 +04:00
|
|
|
DWORD nSize;
|
|
|
|
char* env = NULL;
|
2017-03-03 14:37:27 +03:00
|
|
|
nSize = GetEnvironmentVariableA(sspi, NULL, 0);
|
2014-06-07 18:50:51 +04:00
|
|
|
|
|
|
|
if (!nSize)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
env = (LPSTR) malloc(nSize);
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2015-04-03 17:21:01 +03:00
|
|
|
if (!env)
|
|
|
|
return TRUE;
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2017-03-03 14:37:27 +03:00
|
|
|
if (GetEnvironmentVariableA(sspi, env, nSize) != nSize - 1)
|
|
|
|
{
|
|
|
|
free(env);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2014-06-07 18:50:51 +04:00
|
|
|
|
|
|
|
if (strcmp(env, "0") == 0)
|
|
|
|
status = FALSE;
|
|
|
|
else
|
|
|
|
status = TRUE;
|
|
|
|
|
|
|
|
free(env);
|
|
|
|
#endif
|
|
|
|
return status;
|
|
|
|
}
|
2015-06-23 17:02:53 +03:00
|
|
|
#endif
|
2014-06-07 18:50:51 +04:00
|
|
|
|
2015-06-17 14:24:11 +03:00
|
|
|
#if defined(WITH_NATIVE_SSPI)
|
2014-06-07 18:50:51 +04:00
|
|
|
BOOL InitializeSspiModule_Native(void)
|
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
INIT_SECURITY_INTERFACE_W pInitSecurityInterfaceW;
|
|
|
|
INIT_SECURITY_INTERFACE_A pInitSecurityInterfaceA;
|
|
|
|
g_SspiModule = LoadLibraryA("secur32.dll");
|
|
|
|
|
|
|
|
if (!g_SspiModule)
|
|
|
|
g_SspiModule = LoadLibraryA("security.dll");
|
|
|
|
|
|
|
|
if (!g_SspiModule)
|
|
|
|
return FALSE;
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
pInitSecurityInterfaceW = (INIT_SECURITY_INTERFACE_W) GetProcAddress(g_SspiModule,
|
|
|
|
"InitSecurityInterfaceW");
|
|
|
|
pInitSecurityInterfaceA = (INIT_SECURITY_INTERFACE_A) GetProcAddress(g_SspiModule,
|
|
|
|
"InitSecurityInterfaceA");
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (pInitSecurityInterfaceW)
|
|
|
|
g_SspiW = pInitSecurityInterfaceW();
|
|
|
|
|
|
|
|
if (pInitSecurityInterfaceA)
|
|
|
|
g_SspiA = pInitSecurityInterfaceA();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-06-17 14:24:11 +03:00
|
|
|
#endif
|
2014-06-06 23:34:12 +04:00
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
static BOOL CALLBACK InitializeSspiModuleInt(PINIT_ONCE once, PVOID param, PVOID* context)
|
2014-06-06 23:34:12 +04:00
|
|
|
{
|
2014-06-07 18:50:51 +04:00
|
|
|
BOOL status = FALSE;
|
2017-12-21 13:30:21 +03:00
|
|
|
#if defined(WITH_NATIVE_SSPI)
|
2017-02-13 20:04:42 +03:00
|
|
|
DWORD flags = 0;
|
2014-06-07 18:50:51 +04:00
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
if (param)
|
|
|
|
flags = *(DWORD*)param;
|
2014-06-06 23:34:12 +04:00
|
|
|
|
2017-12-21 13:30:21 +03:00
|
|
|
#endif
|
2014-06-07 18:50:51 +04:00
|
|
|
sspi_GlobalInit();
|
2014-06-07 01:20:34 +04:00
|
|
|
g_Log = WLog_Get("com.winpr.sspi");
|
2015-06-17 14:24:11 +03:00
|
|
|
#if defined(WITH_NATIVE_SSPI)
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 18:50:51 +04:00
|
|
|
if (flags && (flags & SSPI_INTERFACE_NATIVE))
|
|
|
|
{
|
|
|
|
status = InitializeSspiModule_Native();
|
|
|
|
}
|
|
|
|
else if (flags && (flags & SSPI_INTERFACE_WINPR))
|
|
|
|
{
|
|
|
|
g_SspiW = winpr_InitSecurityInterfaceW();
|
|
|
|
g_SspiA = winpr_InitSecurityInterfaceA();
|
|
|
|
status = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!status && ShouldUseNativeSspi())
|
|
|
|
{
|
|
|
|
status = InitializeSspiModule_Native();
|
|
|
|
}
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2015-06-17 14:24:11 +03:00
|
|
|
#endif
|
2014-06-07 18:50:51 +04:00
|
|
|
|
|
|
|
if (!status)
|
2014-06-06 23:34:12 +04:00
|
|
|
{
|
|
|
|
g_SspiW = winpr_InitSecurityInterfaceW();
|
|
|
|
g_SspiA = winpr_InitSecurityInterfaceA();
|
|
|
|
}
|
2017-02-13 20:04:42 +03:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
const char* GetSecurityStatusString(SECURITY_STATUS status)
|
|
|
|
{
|
|
|
|
switch (status)
|
2014-06-06 23:34:12 +04:00
|
|
|
{
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_OK:
|
|
|
|
return "SEC_E_OK";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_INSUFFICIENT_MEMORY:
|
|
|
|
return "SEC_E_INSUFFICIENT_MEMORY";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_INVALID_HANDLE:
|
|
|
|
return "SEC_E_INVALID_HANDLE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_UNSUPPORTED_FUNCTION:
|
|
|
|
return "SEC_E_UNSUPPORTED_FUNCTION";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_TARGET_UNKNOWN:
|
|
|
|
return "SEC_E_TARGET_UNKNOWN";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_INTERNAL_ERROR:
|
|
|
|
return "SEC_E_INTERNAL_ERROR";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_SECPKG_NOT_FOUND:
|
|
|
|
return "SEC_E_SECPKG_NOT_FOUND";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NOT_OWNER:
|
|
|
|
return "SEC_E_NOT_OWNER";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CANNOT_INSTALL:
|
|
|
|
return "SEC_E_CANNOT_INSTALL";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_INVALID_TOKEN:
|
|
|
|
return "SEC_E_INVALID_TOKEN";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CANNOT_PACK:
|
|
|
|
return "SEC_E_CANNOT_PACK";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_QOP_NOT_SUPPORTED:
|
|
|
|
return "SEC_E_QOP_NOT_SUPPORTED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_IMPERSONATION:
|
|
|
|
return "SEC_E_NO_IMPERSONATION";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_LOGON_DENIED:
|
|
|
|
return "SEC_E_LOGON_DENIED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_UNKNOWN_CREDENTIALS:
|
|
|
|
return "SEC_E_UNKNOWN_CREDENTIALS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_CREDENTIALS:
|
|
|
|
return "SEC_E_NO_CREDENTIALS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_MESSAGE_ALTERED:
|
|
|
|
return "SEC_E_MESSAGE_ALTERED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_OUT_OF_SEQUENCE:
|
|
|
|
return "SEC_E_OUT_OF_SEQUENCE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_AUTHENTICATING_AUTHORITY:
|
|
|
|
return "SEC_E_NO_AUTHENTICATING_AUTHORITY";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_BAD_PKGID:
|
|
|
|
return "SEC_E_BAD_PKGID";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CONTEXT_EXPIRED:
|
|
|
|
return "SEC_E_CONTEXT_EXPIRED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_INCOMPLETE_MESSAGE:
|
|
|
|
return "SEC_E_INCOMPLETE_MESSAGE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_INCOMPLETE_CREDENTIALS:
|
|
|
|
return "SEC_E_INCOMPLETE_CREDENTIALS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_BUFFER_TOO_SMALL:
|
|
|
|
return "SEC_E_BUFFER_TOO_SMALL";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_WRONG_PRINCIPAL:
|
|
|
|
return "SEC_E_WRONG_PRINCIPAL";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_TIME_SKEW:
|
|
|
|
return "SEC_E_TIME_SKEW";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_UNTRUSTED_ROOT:
|
|
|
|
return "SEC_E_UNTRUSTED_ROOT";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_ILLEGAL_MESSAGE:
|
|
|
|
return "SEC_E_ILLEGAL_MESSAGE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CERT_UNKNOWN:
|
|
|
|
return "SEC_E_CERT_UNKNOWN";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CERT_EXPIRED:
|
|
|
|
return "SEC_E_CERT_EXPIRED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_ENCRYPT_FAILURE:
|
|
|
|
return "SEC_E_ENCRYPT_FAILURE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_DECRYPT_FAILURE:
|
|
|
|
return "SEC_E_DECRYPT_FAILURE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_ALGORITHM_MISMATCH:
|
|
|
|
return "SEC_E_ALGORITHM_MISMATCH";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_SECURITY_QOS_FAILED:
|
|
|
|
return "SEC_E_SECURITY_QOS_FAILED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_UNFINISHED_CONTEXT_DELETED:
|
|
|
|
return "SEC_E_UNFINISHED_CONTEXT_DELETED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_TGT_REPLY:
|
|
|
|
return "SEC_E_NO_TGT_REPLY";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_IP_ADDRESSES:
|
|
|
|
return "SEC_E_NO_IP_ADDRESSES";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_WRONG_CREDENTIAL_HANDLE:
|
|
|
|
return "SEC_E_WRONG_CREDENTIAL_HANDLE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CRYPTO_SYSTEM_INVALID:
|
|
|
|
return "SEC_E_CRYPTO_SYSTEM_INVALID";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_MAX_REFERRALS_EXCEEDED:
|
|
|
|
return "SEC_E_MAX_REFERRALS_EXCEEDED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_MUST_BE_KDC:
|
|
|
|
return "SEC_E_MUST_BE_KDC";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_STRONG_CRYPTO_NOT_SUPPORTED:
|
|
|
|
return "SEC_E_STRONG_CRYPTO_NOT_SUPPORTED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_TOO_MANY_PRINCIPALS:
|
|
|
|
return "SEC_E_TOO_MANY_PRINCIPALS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_PA_DATA:
|
|
|
|
return "SEC_E_NO_PA_DATA";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_PKINIT_NAME_MISMATCH:
|
|
|
|
return "SEC_E_PKINIT_NAME_MISMATCH";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_SMARTCARD_LOGON_REQUIRED:
|
|
|
|
return "SEC_E_SMARTCARD_LOGON_REQUIRED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_SHUTDOWN_IN_PROGRESS:
|
|
|
|
return "SEC_E_SHUTDOWN_IN_PROGRESS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_KDC_INVALID_REQUEST:
|
|
|
|
return "SEC_E_KDC_INVALID_REQUEST";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_KDC_UNABLE_TO_REFER:
|
|
|
|
return "SEC_E_KDC_UNABLE_TO_REFER";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_KDC_UNKNOWN_ETYPE:
|
|
|
|
return "SEC_E_KDC_UNKNOWN_ETYPE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_UNSUPPORTED_PREAUTH:
|
|
|
|
return "SEC_E_UNSUPPORTED_PREAUTH";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_DELEGATION_REQUIRED:
|
|
|
|
return "SEC_E_DELEGATION_REQUIRED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_BAD_BINDINGS:
|
|
|
|
return "SEC_E_BAD_BINDINGS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_MULTIPLE_ACCOUNTS:
|
|
|
|
return "SEC_E_MULTIPLE_ACCOUNTS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_KERB_KEY:
|
|
|
|
return "SEC_E_NO_KERB_KEY";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CERT_WRONG_USAGE:
|
|
|
|
return "SEC_E_CERT_WRONG_USAGE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_DOWNGRADE_DETECTED:
|
|
|
|
return "SEC_E_DOWNGRADE_DETECTED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_SMARTCARD_CERT_REVOKED:
|
|
|
|
return "SEC_E_SMARTCARD_CERT_REVOKED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_ISSUING_CA_UNTRUSTED:
|
|
|
|
return "SEC_E_ISSUING_CA_UNTRUSTED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_REVOCATION_OFFLINE_C:
|
|
|
|
return "SEC_E_REVOCATION_OFFLINE_C";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_PKINIT_CLIENT_FAILURE:
|
|
|
|
return "SEC_E_PKINIT_CLIENT_FAILURE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_SMARTCARD_CERT_EXPIRED:
|
|
|
|
return "SEC_E_SMARTCARD_CERT_EXPIRED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_S4U_PROT_SUPPORT:
|
|
|
|
return "SEC_E_NO_S4U_PROT_SUPPORT";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_CROSSREALM_DELEGATION_FAILURE:
|
|
|
|
return "SEC_E_CROSSREALM_DELEGATION_FAILURE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_REVOCATION_OFFLINE_KDC:
|
|
|
|
return "SEC_E_REVOCATION_OFFLINE_KDC";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_ISSUING_CA_UNTRUSTED_KDC:
|
|
|
|
return "SEC_E_ISSUING_CA_UNTRUSTED_KDC";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_KDC_CERT_EXPIRED:
|
|
|
|
return "SEC_E_KDC_CERT_EXPIRED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_KDC_CERT_REVOKED:
|
|
|
|
return "SEC_E_KDC_CERT_REVOKED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_INVALID_PARAMETER:
|
|
|
|
return "SEC_E_INVALID_PARAMETER";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_DELEGATION_POLICY:
|
|
|
|
return "SEC_E_DELEGATION_POLICY";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_POLICY_NLTM_ONLY:
|
|
|
|
return "SEC_E_POLICY_NLTM_ONLY";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_NO_CONTEXT:
|
|
|
|
return "SEC_E_NO_CONTEXT";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_PKU2U_CERT_FAILURE:
|
|
|
|
return "SEC_E_PKU2U_CERT_FAILURE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_E_MUTUAL_AUTH_FAILED:
|
|
|
|
return "SEC_E_MUTUAL_AUTH_FAILED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_CONTINUE_NEEDED:
|
|
|
|
return "SEC_I_CONTINUE_NEEDED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_COMPLETE_NEEDED:
|
|
|
|
return "SEC_I_COMPLETE_NEEDED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_COMPLETE_AND_CONTINUE:
|
|
|
|
return "SEC_I_COMPLETE_AND_CONTINUE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_LOCAL_LOGON:
|
|
|
|
return "SEC_I_LOCAL_LOGON";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_CONTEXT_EXPIRED:
|
|
|
|
return "SEC_I_CONTEXT_EXPIRED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_INCOMPLETE_CREDENTIALS:
|
|
|
|
return "SEC_I_INCOMPLETE_CREDENTIALS";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_RENEGOTIATE:
|
|
|
|
return "SEC_I_RENEGOTIATE";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_NO_LSA_CONTEXT:
|
|
|
|
return "SEC_I_NO_LSA_CONTEXT";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_SIGNATURE_NEEDED:
|
|
|
|
return "SEC_I_SIGNATURE_NEEDED";
|
2017-02-13 20:04:42 +03:00
|
|
|
|
2014-06-07 01:20:34 +04:00
|
|
|
case SEC_I_NO_RENEGOTIATION:
|
|
|
|
return "SEC_I_NO_RENEGOTIATION";
|
2014-06-06 23:34:12 +04:00
|
|
|
}
|
2014-06-07 01:20:34 +04:00
|
|
|
|
|
|
|
return "SEC_E_UNKNOWN";
|
2014-06-06 23:34:12 +04:00
|
|
|
}
|
|
|
|
|
2015-09-17 18:16:20 +03:00
|
|
|
BOOL IsSecurityStatusError(SECURITY_STATUS status)
|
|
|
|
{
|
|
|
|
BOOL error = TRUE;
|
|
|
|
|
|
|
|
switch (status)
|
|
|
|
{
|
|
|
|
case SEC_E_OK:
|
|
|
|
case SEC_I_CONTINUE_NEEDED:
|
|
|
|
case SEC_I_COMPLETE_NEEDED:
|
|
|
|
case SEC_I_COMPLETE_AND_CONTINUE:
|
|
|
|
case SEC_I_LOCAL_LOGON:
|
|
|
|
case SEC_I_CONTEXT_EXPIRED:
|
|
|
|
case SEC_I_INCOMPLETE_CREDENTIALS:
|
|
|
|
case SEC_I_RENEGOTIATE:
|
|
|
|
case SEC_I_NO_LSA_CONTEXT:
|
|
|
|
case SEC_I_SIGNATURE_NEEDED:
|
|
|
|
case SEC_I_NO_RENEGOTIATION:
|
|
|
|
error = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2014-06-07 18:50:51 +04:00
|
|
|
SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceExW(DWORD flags)
|
|
|
|
{
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, &flags, NULL);
|
2014-06-07 18:50:51 +04:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceExW");
|
2015-06-17 14:24:11 +03:00
|
|
|
return g_SspiW;
|
2014-06-07 18:50:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceExA(DWORD flags)
|
|
|
|
{
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, &flags, NULL);
|
2014-06-07 18:50:51 +04:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceExA");
|
2015-06-17 14:24:11 +03:00
|
|
|
return g_SspiA;
|
2014-06-07 18:50:51 +04:00
|
|
|
}
|
|
|
|
|
2014-06-06 23:34:12 +04:00
|
|
|
/**
|
|
|
|
* Standard SSPI API
|
|
|
|
*/
|
2012-03-24 02:53:10 +04:00
|
|
|
|
2012-02-21 02:33:21 +04:00
|
|
|
/* Package Management */
|
2012-02-21 01:17:57 +04:00
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_EnumerateSecurityPackagesW(ULONG* pcPackages,
|
|
|
|
PSecPkgInfoW* ppPackageInfo)
|
2012-02-21 01:17:57 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->EnumerateSecurityPackagesW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->EnumerateSecurityPackagesW(pcPackages, ppPackageInfo);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "EnumerateSecurityPackagesW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_EnumerateSecurityPackagesA(ULONG* pcPackages,
|
|
|
|
PSecPkgInfoA* ppPackageInfo)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->EnumerateSecurityPackagesA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->EnumerateSecurityPackagesA(pcPackages, ppPackageInfo);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "EnumerateSecurityPackagesA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 01:17:57 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SecurityFunctionTableW* SEC_ENTRY sspi_InitSecurityInterfaceW(void)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-07 01:20:34 +04:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceW");
|
2015-06-17 14:24:11 +03:00
|
|
|
return g_SspiW;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SecurityFunctionTableA* SEC_ENTRY sspi_InitSecurityInterfaceA(void)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-07 01:20:34 +04:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceA");
|
2015-06-17 14:24:11 +03:00
|
|
|
return g_SspiA;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName,
|
|
|
|
PSecPkgInfoW* ppPackageInfo)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->QuerySecurityPackageInfoW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->QuerySecurityPackageInfoW(pszPackageName, ppPackageInfo);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "QuerySecurityPackageInfoW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName,
|
|
|
|
PSecPkgInfoA* ppPackageInfo)
|
2012-02-21 01:17:57 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->QuerySecurityPackageInfoA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->QuerySecurityPackageInfoA(pszPackageName, ppPackageInfo);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "QuerySecurityPackageInfoA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-25 00:00:49 +04:00
|
|
|
}
|
|
|
|
|
2012-02-21 02:04:45 +04:00
|
|
|
/* Credential Management */
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal,
|
|
|
|
SEC_WCHAR* pszPackage,
|
|
|
|
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
|
|
|
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->AcquireCredentialsHandleW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->AcquireCredentialsHandleW(pszPrincipal, pszPackage, fCredentialUse,
|
2017-02-13 20:04:42 +03:00
|
|
|
pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
|
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "AcquireCredentialsHandleW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal,
|
|
|
|
SEC_CHAR* pszPackage,
|
|
|
|
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
|
|
|
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->AcquireCredentialsHandleA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->AcquireCredentialsHandleA(pszPrincipal, pszPackage, fCredentialUse,
|
2017-02-13 20:04:42 +03:00
|
|
|
pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
|
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "AcquireCredentialsHandleA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_ExportSecurityContext(PCtxtHandle phContext, ULONG fFlags,
|
|
|
|
PSecBuffer pPackedContext, HANDLE* pToken)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->ExportSecurityContext))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->ExportSecurityContext(phContext, fFlags, pPackedContext, pToken);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "ExportSecurityContext: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_FreeCredentialsHandle(PCredHandle phCredential)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->FreeCredentialsHandle))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->FreeCredentialsHandle(phCredential);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "FreeCredentialsHandle: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_ImportSecurityContextW(SEC_WCHAR* pszPackage,
|
|
|
|
PSecBuffer pPackedContext, HANDLE pToken, PCtxtHandle phContext)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->ImportSecurityContextW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->ImportSecurityContextW(pszPackage, pPackedContext, pToken, phContext);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "ImportSecurityContextW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_ImportSecurityContextA(SEC_CHAR* pszPackage,
|
|
|
|
PSecBuffer pPackedContext, HANDLE pToken, PCtxtHandle phContext)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->ImportSecurityContextA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->ImportSecurityContextA(pszPackage, pPackedContext, pToken, phContext);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "ImportSecurityContextA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_QueryCredentialsAttributesW(PCredHandle phCredential,
|
|
|
|
ULONG ulAttribute, void* pBuffer)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->QueryCredentialsAttributesW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->QueryCredentialsAttributesW(phCredential, ulAttribute, pBuffer);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "QueryCredentialsAttributesW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_QueryCredentialsAttributesA(PCredHandle phCredential,
|
|
|
|
ULONG ulAttribute, void* pBuffer)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->QueryCredentialsAttributesA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->QueryCredentialsAttributesA(phCredential, ulAttribute, pBuffer);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "QueryCredentialsAttributesA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2012-02-21 02:04:45 +04:00
|
|
|
/* Context Management */
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_AcceptSecurityContext(PCredHandle phCredential,
|
|
|
|
PCtxtHandle phContext,
|
|
|
|
PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
|
|
|
|
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->AcceptSecurityContext))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->AcceptSecurityContext(phCredential, phContext, pInput, fContextReq,
|
2017-02-13 20:04:42 +03:00
|
|
|
TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsTimeStamp);
|
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "AcceptSecurityContext: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->ApplyControlToken))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->ApplyControlToken(phContext, pInput);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "ApplyControlToken: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->CompleteAuthToken))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->CompleteAuthToken(phContext, pToken);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "CompleteAuthToken: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_DeleteSecurityContext(PCtxtHandle phContext)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->DeleteSecurityContext))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->DeleteSecurityContext(phContext);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "DeleteSecurityContext: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_FreeContextBuffer(void* pvContextBuffer)
|
2012-02-21 01:17:57 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->FreeContextBuffer))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->FreeContextBuffer(pvContextBuffer);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "FreeContextBuffer: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 01:17:57 +04:00
|
|
|
}
|
2012-02-21 02:04:45 +04:00
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_ImpersonateSecurityContext(PCtxtHandle phContext)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->ImpersonateSecurityContext))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->ImpersonateSecurityContext(phContext);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "ImpersonateSecurityContext: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextW(PCredHandle phCredential,
|
|
|
|
PCtxtHandle phContext,
|
|
|
|
SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
|
|
|
|
PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
|
|
|
|
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->InitializeSecurityContextW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->InitializeSecurityContextW(phCredential, phContext,
|
2017-02-13 20:04:42 +03:00
|
|
|
pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
|
|
|
|
Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "InitializeSecurityContextW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextA(PCredHandle phCredential,
|
|
|
|
PCtxtHandle phContext,
|
|
|
|
SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
|
|
|
|
PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
|
|
|
|
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->InitializeSecurityContextA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->InitializeSecurityContextA(phCredential, phContext,
|
2017-02-13 20:04:42 +03:00
|
|
|
pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
|
|
|
|
Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "InitializeSecurityContextA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute,
|
|
|
|
void* pBuffer)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->QueryContextAttributesW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->QueryContextAttributesW(phContext, ulAttribute, pBuffer);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "QueryContextAttributesW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-03-24 23:47:16 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute,
|
|
|
|
void* pBuffer)
|
2012-03-24 23:47:16 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->QueryContextAttributesA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->QueryContextAttributesA(phContext, ulAttribute, pBuffer);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "QueryContextAttributesA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityContextToken(PCtxtHandle phContext, HANDLE* phToken)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->QuerySecurityContextToken))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->QuerySecurityContextToken(phContext, phToken);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "QuerySecurityContextToken: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_SetContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute,
|
|
|
|
void* pBuffer, ULONG cbBuffer)
|
2014-06-06 23:34:12 +04:00
|
|
|
{
|
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->SetContextAttributesW))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->SetContextAttributesW(phContext, ulAttribute, pBuffer, cbBuffer);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "SetContextAttributesW: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_SetContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute,
|
|
|
|
void* pBuffer, ULONG cbBuffer)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiA && g_SspiA->SetContextAttributesA))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiA->SetContextAttributesA(phContext, ulAttribute, pBuffer, cbBuffer);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "SetContextAttributesA: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 22:43:02 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_RevertSecurityContext(PCtxtHandle phContext)
|
2012-02-21 02:33:21 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->RevertSecurityContext))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->RevertSecurityContext(phContext);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "RevertSecurityContext: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:33:21 +04:00
|
|
|
}
|
|
|
|
|
2012-02-21 02:04:45 +04:00
|
|
|
/* Message Support */
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage,
|
|
|
|
ULONG MessageSeqNo, PULONG pfQOP)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->DecryptMessage))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->DecryptMessage(phContext, pMessage, MessageSeqNo, pfQOP);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "DecryptMessage: %s (0x%08"PRIX32")", GetSecurityStatusString(status),
|
|
|
|
status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
|
|
|
|
PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->EncryptMessage))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->EncryptMessage(phContext, fQOP, pMessage, MessageSeqNo);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "EncryptMessage: %s (0x%08"PRIX32")", GetSecurityStatusString(status),
|
|
|
|
status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_MakeSignature(PCtxtHandle phContext, ULONG fQOP,
|
|
|
|
PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->MakeSignature))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->MakeSignature(phContext, fQOP, pMessage, MessageSeqNo);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "MakeSignature: %s (0x%08"PRIX32")", GetSecurityStatusString(status),
|
|
|
|
status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
|
|
|
|
2017-02-13 20:04:42 +03:00
|
|
|
SECURITY_STATUS SEC_ENTRY sspi_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage,
|
|
|
|
ULONG MessageSeqNo, PULONG pfQOP)
|
2012-02-21 02:04:45 +04:00
|
|
|
{
|
2014-06-06 23:34:12 +04:00
|
|
|
SECURITY_STATUS status;
|
2017-02-13 20:04:42 +03:00
|
|
|
InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
|
2014-06-06 23:34:12 +04:00
|
|
|
|
|
|
|
if (!(g_SspiW && g_SspiW->VerifySignature))
|
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
status = g_SspiW->VerifySignature(phContext, pMessage, MessageSeqNo, pfQOP);
|
2017-02-13 20:04:42 +03:00
|
|
|
WLog_Print(g_Log, WLOG_DEBUG, "VerifySignature: %s (0x%08"PRIX32")",
|
|
|
|
GetSecurityStatusString(status), status);
|
2014-06-06 23:34:12 +04:00
|
|
|
return status;
|
2012-02-21 02:04:45 +04:00
|
|
|
}
|
2012-02-23 08:41:22 +04:00
|
|
|
|
2014-06-06 23:34:12 +04:00
|
|
|
SecurityFunctionTableA sspi_SecurityFunctionTableA =
|
|
|
|
{
|
|
|
|
1, /* dwVersion */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_EnumerateSecurityPackagesA, /* EnumerateSecurityPackages */
|
|
|
|
sspi_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
|
|
|
|
sspi_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
|
|
|
|
sspi_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
2014-06-06 23:34:12 +04:00
|
|
|
NULL, /* Reserved2 */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_InitializeSecurityContextA, /* InitializeSecurityContext */
|
|
|
|
sspi_AcceptSecurityContext, /* AcceptSecurityContext */
|
|
|
|
sspi_CompleteAuthToken, /* CompleteAuthToken */
|
|
|
|
sspi_DeleteSecurityContext, /* DeleteSecurityContext */
|
|
|
|
sspi_ApplyControlToken, /* ApplyControlToken */
|
|
|
|
sspi_QueryContextAttributesA, /* QueryContextAttributes */
|
|
|
|
sspi_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
|
|
|
|
sspi_RevertSecurityContext, /* RevertSecurityContext */
|
|
|
|
sspi_MakeSignature, /* MakeSignature */
|
|
|
|
sspi_VerifySignature, /* VerifySignature */
|
|
|
|
sspi_FreeContextBuffer, /* FreeContextBuffer */
|
|
|
|
sspi_QuerySecurityPackageInfoA, /* QuerySecurityPackageInfo */
|
2014-06-06 23:34:12 +04:00
|
|
|
NULL, /* Reserved3 */
|
|
|
|
NULL, /* Reserved4 */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_ExportSecurityContext, /* ExportSecurityContext */
|
|
|
|
sspi_ImportSecurityContextA, /* ImportSecurityContext */
|
2014-06-06 23:34:12 +04:00
|
|
|
NULL, /* AddCredentials */
|
|
|
|
NULL, /* Reserved8 */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_QuerySecurityContextToken, /* QuerySecurityContextToken */
|
|
|
|
sspi_EncryptMessage, /* EncryptMessage */
|
|
|
|
sspi_DecryptMessage, /* DecryptMessage */
|
|
|
|
sspi_SetContextAttributesA, /* SetContextAttributes */
|
2014-06-06 23:34:12 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
SecurityFunctionTableW sspi_SecurityFunctionTableW =
|
|
|
|
{
|
|
|
|
1, /* dwVersion */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_EnumerateSecurityPackagesW, /* EnumerateSecurityPackages */
|
|
|
|
sspi_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
|
|
|
|
sspi_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
|
|
|
|
sspi_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
2014-06-06 23:34:12 +04:00
|
|
|
NULL, /* Reserved2 */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_InitializeSecurityContextW, /* InitializeSecurityContext */
|
|
|
|
sspi_AcceptSecurityContext, /* AcceptSecurityContext */
|
|
|
|
sspi_CompleteAuthToken, /* CompleteAuthToken */
|
|
|
|
sspi_DeleteSecurityContext, /* DeleteSecurityContext */
|
|
|
|
sspi_ApplyControlToken, /* ApplyControlToken */
|
|
|
|
sspi_QueryContextAttributesW, /* QueryContextAttributes */
|
|
|
|
sspi_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
|
|
|
|
sspi_RevertSecurityContext, /* RevertSecurityContext */
|
|
|
|
sspi_MakeSignature, /* MakeSignature */
|
|
|
|
sspi_VerifySignature, /* VerifySignature */
|
|
|
|
sspi_FreeContextBuffer, /* FreeContextBuffer */
|
|
|
|
sspi_QuerySecurityPackageInfoW, /* QuerySecurityPackageInfo */
|
2014-06-06 23:34:12 +04:00
|
|
|
NULL, /* Reserved3 */
|
|
|
|
NULL, /* Reserved4 */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_ExportSecurityContext, /* ExportSecurityContext */
|
|
|
|
sspi_ImportSecurityContextW, /* ImportSecurityContext */
|
2014-06-06 23:34:12 +04:00
|
|
|
NULL, /* AddCredentials */
|
|
|
|
NULL, /* Reserved8 */
|
2014-06-07 22:43:02 +04:00
|
|
|
sspi_QuerySecurityContextToken, /* QuerySecurityContextToken */
|
|
|
|
sspi_EncryptMessage, /* EncryptMessage */
|
|
|
|
sspi_DecryptMessage, /* DecryptMessage */
|
|
|
|
sspi_SetContextAttributesW, /* SetContextAttributes */
|
2014-06-06 23:34:12 +04:00
|
|
|
};
|