Removed unused functions, fixed feature define guards
This commit is contained in:
parent
50a0968c6a
commit
a0b49f4e07
@ -3,7 +3,7 @@
|
||||
* Schannel Security Package
|
||||
*
|
||||
* Copyright 2012-2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@ -33,8 +33,8 @@ char* SCHANNEL_PACKAGE_NAME = "Schannel";
|
||||
SCHANNEL_CONTEXT* schannel_ContextNew()
|
||||
{
|
||||
SCHANNEL_CONTEXT* context;
|
||||
|
||||
context = (SCHANNEL_CONTEXT*) calloc(1, sizeof(SCHANNEL_CONTEXT));
|
||||
|
||||
if (!context)
|
||||
return NULL;
|
||||
|
||||
@ -55,16 +55,13 @@ void schannel_ContextFree(SCHANNEL_CONTEXT* context)
|
||||
return;
|
||||
|
||||
schannel_openssl_free(context->openssl);
|
||||
|
||||
free(context);
|
||||
}
|
||||
|
||||
SCHANNEL_CREDENTIALS* schannel_CredentialsNew()
|
||||
{
|
||||
SCHANNEL_CREDENTIALS* credentials;
|
||||
|
||||
credentials = (SCHANNEL_CREDENTIALS*) calloc(1, sizeof(SCHANNEL_CREDENTIALS));
|
||||
|
||||
return credentials;
|
||||
}
|
||||
|
||||
@ -82,57 +79,52 @@ static ALG_ID schannel_SupportedAlgs[] =
|
||||
CALG_DSS_SIGN, CALG_ECDSA
|
||||
};
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesW(PCredHandle phCredential,
|
||||
ULONG ulAttribute, void* pBuffer)
|
||||
{
|
||||
if (ulAttribute == SECPKG_ATTR_SUPPORTED_ALGS)
|
||||
{
|
||||
PSecPkgCred_SupportedAlgs SupportedAlgs = (PSecPkgCred_SupportedAlgs) pBuffer;
|
||||
|
||||
SupportedAlgs->cSupportedAlgs = sizeof(schannel_SupportedAlgs) / sizeof(ALG_ID);
|
||||
SupportedAlgs->palgSupportedAlgs = (ALG_ID*) schannel_SupportedAlgs;
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
else if (ulAttribute == SECPKG_ATTR_CIPHER_STRENGTHS)
|
||||
{
|
||||
PSecPkgCred_CipherStrengths CipherStrengths = (PSecPkgCred_CipherStrengths) pBuffer;
|
||||
|
||||
CipherStrengths->dwMinimumCipherStrength = 40;
|
||||
CipherStrengths->dwMaximumCipherStrength = 256;
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
else if (ulAttribute == SECPKG_ATTR_SUPPORTED_PROTOCOLS)
|
||||
{
|
||||
PSecPkgCred_SupportedProtocols SupportedProtocols = (PSecPkgCred_SupportedProtocols) pBuffer;
|
||||
|
||||
/* Observed SupportedProtocols: 0x208A0 */
|
||||
SupportedProtocols->grbitProtocol = (SP_PROT_CLIENTS | SP_PROT_SERVERS);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
return SEC_E_UNSUPPORTED_FUNCTION;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesA(PCredHandle phCredential,
|
||||
ULONG ulAttribute, void* pBuffer)
|
||||
{
|
||||
return schannel_QueryCredentialsAttributesW(phCredential, ulAttribute, pBuffer);
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
|
||||
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
||||
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal,
|
||||
SEC_WCHAR* pszPackage,
|
||||
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
||||
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
||||
{
|
||||
SCHANNEL_CREDENTIALS* credentials;
|
||||
|
||||
if (fCredentialUse == SECPKG_CRED_OUTBOUND)
|
||||
{
|
||||
SCHANNEL_CRED* cred;
|
||||
|
||||
credentials = schannel_CredentialsNew();
|
||||
credentials->fCredentialUse = fCredentialUse;
|
||||
|
||||
cred = (SCHANNEL_CRED*) pAuthData;
|
||||
|
||||
if (cred)
|
||||
@ -142,41 +134,35 @@ SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(SEC_WCHAR* pszPrinc
|
||||
|
||||
sspi_SecureHandleSetLowerPointer(phCredential, (void*) credentials);
|
||||
sspi_SecureHandleSetUpperPointer(phCredential, (void*) SCHANNEL_PACKAGE_NAME);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
else if (fCredentialUse == SECPKG_CRED_INBOUND)
|
||||
{
|
||||
credentials = schannel_CredentialsNew();
|
||||
credentials->fCredentialUse = fCredentialUse;
|
||||
|
||||
sspi_SecureHandleSetLowerPointer(phCredential, (void*) credentials);
|
||||
sspi_SecureHandleSetUpperPointer(phCredential, (void*) SCHANNEL_PACKAGE_NAME);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
|
||||
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
||||
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal,
|
||||
SEC_CHAR* pszPackage,
|
||||
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
||||
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
||||
{
|
||||
SECURITY_STATUS status;
|
||||
SEC_WCHAR* pszPrincipalW = NULL;
|
||||
SEC_WCHAR* pszPackageW = NULL;
|
||||
|
||||
ConvertToUnicode(CP_UTF8, 0, pszPrincipal, -1, &pszPrincipalW, 0);
|
||||
ConvertToUnicode(CP_UTF8, 0, pszPackage, -1, &pszPackageW, 0);
|
||||
|
||||
status = schannel_AcquireCredentialsHandleW(pszPrincipalW, pszPackageW, fCredentialUse, pvLogonID,
|
||||
pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
|
||||
|
||||
pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
|
||||
free(pszPrincipalW);
|
||||
free(pszPackageW);
|
||||
|
||||
return SEC_E_OK;
|
||||
return status;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_FreeCredentialsHandle(PCredHandle phCredential)
|
||||
@ -192,19 +178,18 @@ SECURITY_STATUS SEC_ENTRY schannel_FreeCredentialsHandle(PCredHandle phCredentia
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
|
||||
schannel_CredentialsFree(credentials);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_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)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_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)
|
||||
{
|
||||
SECURITY_STATUS status;
|
||||
SCHANNEL_CONTEXT* context;
|
||||
SCHANNEL_CREDENTIALS* credentials;
|
||||
|
||||
context = sspi_SecureHandleGetLowerPointer(phContext);
|
||||
|
||||
if (!context)
|
||||
@ -215,25 +200,22 @@ SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextW(PCredHandle phCred
|
||||
return SEC_E_INSUFFICIENT_MEMORY;
|
||||
|
||||
credentials = (SCHANNEL_CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
||||
|
||||
context->server = FALSE;
|
||||
CopyMemory(&context->cred, &credentials->cred, sizeof(SCHANNEL_CRED));
|
||||
|
||||
sspi_SecureHandleSetLowerPointer(phNewContext, context);
|
||||
sspi_SecureHandleSetUpperPointer(phNewContext, (void*) SCHANNEL_PACKAGE_NAME);
|
||||
|
||||
schannel_openssl_client_init(context->openssl);
|
||||
}
|
||||
|
||||
status = schannel_openssl_client_process_tokens(context->openssl, pInput, pOutput);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_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)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_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)
|
||||
{
|
||||
SECURITY_STATUS status;
|
||||
SEC_WCHAR* pszTargetNameW = NULL;
|
||||
@ -244,22 +226,18 @@ SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextA(PCredHandle phCred
|
||||
}
|
||||
|
||||
status = schannel_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq,
|
||||
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
||||
|
||||
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
||||
free(pszTargetNameW);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
|
||||
PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
|
||||
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(PCredHandle phCredential,
|
||||
PCtxtHandle phContext,
|
||||
PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
|
||||
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
|
||||
{
|
||||
SECURITY_STATUS status;
|
||||
SCHANNEL_CONTEXT* context;
|
||||
SCHANNEL_CREDENTIALS* credentials;
|
||||
|
||||
status = SEC_E_OK;
|
||||
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
|
||||
|
||||
if (!context)
|
||||
@ -269,36 +247,30 @@ SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(PCredHandle phCredentia
|
||||
if (!context)
|
||||
return SEC_E_INSUFFICIENT_MEMORY;
|
||||
|
||||
credentials = (SCHANNEL_CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
||||
|
||||
context->server = TRUE;
|
||||
|
||||
sspi_SecureHandleSetLowerPointer(phNewContext, context);
|
||||
sspi_SecureHandleSetUpperPointer(phNewContext, (void*) SCHANNEL_PACKAGE_NAME);
|
||||
|
||||
schannel_openssl_server_init(context->openssl);
|
||||
}
|
||||
|
||||
status = schannel_openssl_server_process_tokens(context->openssl, pInput, pOutput);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_DeleteSecurityContext(PCtxtHandle phContext)
|
||||
{
|
||||
SCHANNEL_CONTEXT* context;
|
||||
|
||||
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
|
||||
|
||||
if (!context)
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
|
||||
schannel_ContextFree(context);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_QueryContextAttributes(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_QueryContextAttributes(PCtxtHandle phContext, ULONG ulAttribute,
|
||||
void* pBuffer)
|
||||
{
|
||||
if (!phContext)
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
@ -309,67 +281,63 @@ SECURITY_STATUS SEC_ENTRY schannel_QueryContextAttributes(PCtxtHandle phContext,
|
||||
if (ulAttribute == SECPKG_ATTR_SIZES)
|
||||
{
|
||||
SecPkgContext_Sizes* Sizes = (SecPkgContext_Sizes*) pBuffer;
|
||||
|
||||
Sizes->cbMaxToken = 0x6000;
|
||||
Sizes->cbMaxSignature = 16;
|
||||
Sizes->cbBlockSize = 0;
|
||||
Sizes->cbSecurityTrailer = 16;
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
else if (ulAttribute == SECPKG_ATTR_STREAM_SIZES)
|
||||
{
|
||||
SecPkgContext_StreamSizes* StreamSizes = (SecPkgContext_StreamSizes*) pBuffer;
|
||||
|
||||
StreamSizes->cbHeader = 5;
|
||||
StreamSizes->cbTrailer = 36;
|
||||
StreamSizes->cbMaximumMessage = 0x4000;
|
||||
StreamSizes->cBuffers = 4;
|
||||
StreamSizes->cbBlockSize = 16;
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
return SEC_E_UNSUPPORTED_FUNCTION;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_MakeSignature(PCtxtHandle phContext, ULONG fQOP,
|
||||
PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
||||
{
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage,
|
||||
ULONG MessageSeqNo, ULONG* pfQOP)
|
||||
{
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
|
||||
PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
||||
{
|
||||
SECURITY_STATUS status;
|
||||
SCHANNEL_CONTEXT* context;
|
||||
|
||||
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
|
||||
|
||||
if (!context)
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
|
||||
status = schannel_openssl_encrypt_message(context->openssl, pMessage);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SECURITY_STATUS SEC_ENTRY schannel_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
|
||||
SECURITY_STATUS SEC_ENTRY schannel_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage,
|
||||
ULONG MessageSeqNo, ULONG* pfQOP)
|
||||
{
|
||||
SECURITY_STATUS status;
|
||||
SCHANNEL_CONTEXT* context;
|
||||
|
||||
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
|
||||
|
||||
if (!context)
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
|
||||
status = schannel_openssl_decrypt_message(context->openssl, pMessage);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -447,13 +415,13 @@ const SecPkgInfoA SCHANNEL_SecPkgInfoA =
|
||||
"Schannel Security Package" /* Comment */
|
||||
};
|
||||
|
||||
WCHAR SCHANNEL_SecPkgInfoW_Name[] = { 'S','c','h','a','n','n','e','l','\0' };
|
||||
WCHAR SCHANNEL_SecPkgInfoW_Name[] = { 'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l', '\0' };
|
||||
|
||||
WCHAR SCHANNEL_SecPkgInfoW_Comment[] =
|
||||
{
|
||||
'S','c','h','a','n','n','e','l',' ',
|
||||
'S','e','c','u','r','i','t','y',' ',
|
||||
'P','a','c','k','a','g','e','\0'
|
||||
'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l', ' ',
|
||||
'S', 'e', 'c', 'u', 'r', 'i', 't', 'y', ' ',
|
||||
'P', 'a', 'c', 'k', 'a', 'g', 'e', '\0'
|
||||
};
|
||||
|
||||
const SecPkgInfoW SCHANNEL_SecPkgInfoW =
|
||||
|
@ -114,11 +114,13 @@ BOOL InitializeSspiModule_Native(void)
|
||||
static BOOL CALLBACK InitializeSspiModuleInt(PINIT_ONCE once, PVOID param, PVOID* context)
|
||||
{
|
||||
BOOL status = FALSE;
|
||||
#if defined(WITH_NATIVE_SSPI)
|
||||
DWORD flags = 0;
|
||||
|
||||
if (param)
|
||||
flags = *(DWORD*)param;
|
||||
|
||||
#endif
|
||||
sspi_GlobalInit();
|
||||
g_Log = WLog_Get("com.winpr.sspi");
|
||||
#if defined(WITH_NATIVE_SSPI)
|
||||
|
@ -65,20 +65,20 @@ extern const SecurityFunctionTableW SCHANNEL_SecurityFunctionTableW;
|
||||
|
||||
static const SecPkgInfoA* SecPkgInfoA_LIST[] =
|
||||
{
|
||||
&NTLM_SecPkgInfoA,
|
||||
&KERBEROS_SecPkgInfoA,
|
||||
&NEGOTIATE_SecPkgInfoA,
|
||||
&CREDSSP_SecPkgInfoA,
|
||||
&SCHANNEL_SecPkgInfoA
|
||||
&NTLM_SecPkgInfoA,
|
||||
&KERBEROS_SecPkgInfoA,
|
||||
&NEGOTIATE_SecPkgInfoA,
|
||||
&CREDSSP_SecPkgInfoA,
|
||||
&SCHANNEL_SecPkgInfoA
|
||||
};
|
||||
|
||||
static const SecPkgInfoW* SecPkgInfoW_LIST[] =
|
||||
{
|
||||
&NTLM_SecPkgInfoW,
|
||||
&KERBEROS_SecPkgInfoW,
|
||||
&NEGOTIATE_SecPkgInfoW,
|
||||
&CREDSSP_SecPkgInfoW,
|
||||
&SCHANNEL_SecPkgInfoW
|
||||
&NTLM_SecPkgInfoW,
|
||||
&KERBEROS_SecPkgInfoW,
|
||||
&NEGOTIATE_SecPkgInfoW,
|
||||
&CREDSSP_SecPkgInfoW,
|
||||
&SCHANNEL_SecPkgInfoW
|
||||
};
|
||||
|
||||
static SecurityFunctionTableA winpr_SecurityFunctionTableA;
|
||||
@ -100,11 +100,11 @@ typedef struct _SecurityFunctionTableW_NAME SecurityFunctionTableW_NAME;
|
||||
|
||||
static const SecurityFunctionTableA_NAME SecurityFunctionTableA_NAME_LIST[] =
|
||||
{
|
||||
{ "NTLM", &NTLM_SecurityFunctionTableA },
|
||||
{ "Kerberos", &KERBEROS_SecurityFunctionTableA },
|
||||
{ "Negotiate", &NEGOTIATE_SecurityFunctionTableA },
|
||||
{ "CREDSSP", &CREDSSP_SecurityFunctionTableA },
|
||||
{ "Schannel", &SCHANNEL_SecurityFunctionTableA }
|
||||
{ "NTLM", &NTLM_SecurityFunctionTableA },
|
||||
{ "Kerberos", &KERBEROS_SecurityFunctionTableA },
|
||||
{ "Negotiate", &NEGOTIATE_SecurityFunctionTableA },
|
||||
{ "CREDSSP", &CREDSSP_SecurityFunctionTableA },
|
||||
{ "Schannel", &SCHANNEL_SecurityFunctionTableA }
|
||||
};
|
||||
|
||||
static const WCHAR NTLM_NAME_W[] = { 'N', 'T', 'L', 'M', '\0' };
|
||||
@ -115,11 +115,11 @@ static const WCHAR SCHANNEL_NAME_W[] = { 'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l',
|
||||
|
||||
static const SecurityFunctionTableW_NAME SecurityFunctionTableW_NAME_LIST[] =
|
||||
{
|
||||
{ NTLM_NAME_W, &NTLM_SecurityFunctionTableW },
|
||||
{ KERBEROS_NAME_W, &KERBEROS_SecurityFunctionTableW },
|
||||
{ NEGOTIATE_NAME_W, &NEGOTIATE_SecurityFunctionTableW },
|
||||
{ CREDSSP_NAME_W, &CREDSSP_SecurityFunctionTableW },
|
||||
{ SCHANNEL_NAME_W, &SCHANNEL_SecurityFunctionTableW }
|
||||
{ NTLM_NAME_W, &NTLM_SecurityFunctionTableW },
|
||||
{ KERBEROS_NAME_W, &KERBEROS_SecurityFunctionTableW },
|
||||
{ NEGOTIATE_NAME_W, &NEGOTIATE_SecurityFunctionTableW },
|
||||
{ CREDSSP_NAME_W, &CREDSSP_SecurityFunctionTableW },
|
||||
{ SCHANNEL_NAME_W, &SCHANNEL_SecurityFunctionTableW }
|
||||
};
|
||||
|
||||
#define SecHandle_LOWER_MAX 0xFFFFFFFF
|
||||
@ -353,18 +353,17 @@ int sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, co
|
||||
{
|
||||
int unicodePasswordLenW;
|
||||
LPWSTR unicodePassword = NULL;
|
||||
|
||||
unicodePasswordLenW = ConvertToUnicode(CP_UTF8, 0, password, -1, &unicodePassword, 0);
|
||||
|
||||
if (unicodePasswordLenW <= 0)
|
||||
return -1;
|
||||
|
||||
return sspi_SetAuthIdentityWithUnicodePassword(identity, user, domain, unicodePassword,
|
||||
(ULONG)(unicodePasswordLenW - 1));
|
||||
(ULONG)(unicodePasswordLenW - 1));
|
||||
}
|
||||
|
||||
int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity, const char *user,
|
||||
const char *domain, LPWSTR password, ULONG passwordLength)
|
||||
int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity, const char* user,
|
||||
const char* domain, LPWSTR password, ULONG passwordLength)
|
||||
{
|
||||
int status;
|
||||
identity->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
||||
@ -398,12 +397,12 @@ int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity, c
|
||||
|
||||
free(identity->Password);
|
||||
identity->Password = (UINT16*) calloc(1, (passwordLength + 1) * sizeof(WCHAR));
|
||||
|
||||
if (!identity->Password)
|
||||
return -1;
|
||||
|
||||
CopyMemory(identity->Password, password, passwordLength * sizeof(WCHAR));
|
||||
identity->PasswordLength = passwordLength;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -500,7 +499,6 @@ void sspi_GlobalInit(void)
|
||||
{
|
||||
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
|
||||
DWORD flags = 0;
|
||||
|
||||
InitOnceExecuteOnce(&once, sspi_init, &flags, NULL);
|
||||
}
|
||||
|
||||
@ -526,11 +524,6 @@ static SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_C
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameW(const SEC_WCHAR* Name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name)
|
||||
{
|
||||
int index;
|
||||
@ -583,13 +576,13 @@ static void sspi_ContextBufferFree(void* contextBuffer)
|
||||
|
||||
switch (allocatorIndex)
|
||||
{
|
||||
case EnumerateSecurityPackagesIndex:
|
||||
FreeContextBuffer_EnumerateSecurityPackages(contextBuffer);
|
||||
break;
|
||||
case EnumerateSecurityPackagesIndex:
|
||||
FreeContextBuffer_EnumerateSecurityPackages(contextBuffer);
|
||||
break;
|
||||
|
||||
case QuerySecurityPackageInfoIndex:
|
||||
FreeContextBuffer_QuerySecurityPackageInfo(contextBuffer);
|
||||
break;
|
||||
case QuerySecurityPackageInfoIndex:
|
||||
FreeContextBuffer_QuerySecurityPackageInfo(contextBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1552,64 +1545,64 @@ static SECURITY_STATUS SEC_ENTRY winpr_VerifySignature(PCtxtHandle phContext,
|
||||
|
||||
static SecurityFunctionTableA winpr_SecurityFunctionTableA =
|
||||
{
|
||||
1, /* dwVersion */
|
||||
winpr_EnumerateSecurityPackagesA, /* EnumerateSecurityPackages */
|
||||
winpr_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
|
||||
winpr_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
|
||||
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
||||
NULL, /* Reserved2 */
|
||||
winpr_InitializeSecurityContextA, /* InitializeSecurityContext */
|
||||
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
|
||||
winpr_CompleteAuthToken, /* CompleteAuthToken */
|
||||
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
|
||||
winpr_ApplyControlToken, /* ApplyControlToken */
|
||||
winpr_QueryContextAttributesA, /* QueryContextAttributes */
|
||||
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
|
||||
winpr_RevertSecurityContext, /* RevertSecurityContext */
|
||||
winpr_MakeSignature, /* MakeSignature */
|
||||
winpr_VerifySignature, /* VerifySignature */
|
||||
winpr_FreeContextBuffer, /* FreeContextBuffer */
|
||||
winpr_QuerySecurityPackageInfoA, /* QuerySecurityPackageInfo */
|
||||
NULL, /* Reserved3 */
|
||||
NULL, /* Reserved4 */
|
||||
winpr_ExportSecurityContext, /* ExportSecurityContext */
|
||||
winpr_ImportSecurityContextA, /* ImportSecurityContext */
|
||||
NULL, /* AddCredentials */
|
||||
NULL, /* Reserved8 */
|
||||
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
|
||||
winpr_EncryptMessage, /* EncryptMessage */
|
||||
winpr_DecryptMessage, /* DecryptMessage */
|
||||
winpr_SetContextAttributesA, /* SetContextAttributes */
|
||||
1, /* dwVersion */
|
||||
winpr_EnumerateSecurityPackagesA, /* EnumerateSecurityPackages */
|
||||
winpr_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
|
||||
winpr_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
|
||||
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
||||
NULL, /* Reserved2 */
|
||||
winpr_InitializeSecurityContextA, /* InitializeSecurityContext */
|
||||
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
|
||||
winpr_CompleteAuthToken, /* CompleteAuthToken */
|
||||
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
|
||||
winpr_ApplyControlToken, /* ApplyControlToken */
|
||||
winpr_QueryContextAttributesA, /* QueryContextAttributes */
|
||||
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
|
||||
winpr_RevertSecurityContext, /* RevertSecurityContext */
|
||||
winpr_MakeSignature, /* MakeSignature */
|
||||
winpr_VerifySignature, /* VerifySignature */
|
||||
winpr_FreeContextBuffer, /* FreeContextBuffer */
|
||||
winpr_QuerySecurityPackageInfoA, /* QuerySecurityPackageInfo */
|
||||
NULL, /* Reserved3 */
|
||||
NULL, /* Reserved4 */
|
||||
winpr_ExportSecurityContext, /* ExportSecurityContext */
|
||||
winpr_ImportSecurityContextA, /* ImportSecurityContext */
|
||||
NULL, /* AddCredentials */
|
||||
NULL, /* Reserved8 */
|
||||
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
|
||||
winpr_EncryptMessage, /* EncryptMessage */
|
||||
winpr_DecryptMessage, /* DecryptMessage */
|
||||
winpr_SetContextAttributesA, /* SetContextAttributes */
|
||||
};
|
||||
|
||||
static SecurityFunctionTableW winpr_SecurityFunctionTableW =
|
||||
{
|
||||
1, /* dwVersion */
|
||||
winpr_EnumerateSecurityPackagesW, /* EnumerateSecurityPackages */
|
||||
winpr_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
|
||||
winpr_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
|
||||
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
||||
NULL, /* Reserved2 */
|
||||
winpr_InitializeSecurityContextW, /* InitializeSecurityContext */
|
||||
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
|
||||
winpr_CompleteAuthToken, /* CompleteAuthToken */
|
||||
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
|
||||
winpr_ApplyControlToken, /* ApplyControlToken */
|
||||
winpr_QueryContextAttributesW, /* QueryContextAttributes */
|
||||
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
|
||||
winpr_RevertSecurityContext, /* RevertSecurityContext */
|
||||
winpr_MakeSignature, /* MakeSignature */
|
||||
winpr_VerifySignature, /* VerifySignature */
|
||||
winpr_FreeContextBuffer, /* FreeContextBuffer */
|
||||
winpr_QuerySecurityPackageInfoW, /* QuerySecurityPackageInfo */
|
||||
NULL, /* Reserved3 */
|
||||
NULL, /* Reserved4 */
|
||||
winpr_ExportSecurityContext, /* ExportSecurityContext */
|
||||
winpr_ImportSecurityContextW, /* ImportSecurityContext */
|
||||
NULL, /* AddCredentials */
|
||||
NULL, /* Reserved8 */
|
||||
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
|
||||
winpr_EncryptMessage, /* EncryptMessage */
|
||||
winpr_DecryptMessage, /* DecryptMessage */
|
||||
winpr_SetContextAttributesW, /* SetContextAttributes */
|
||||
1, /* dwVersion */
|
||||
winpr_EnumerateSecurityPackagesW, /* EnumerateSecurityPackages */
|
||||
winpr_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
|
||||
winpr_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
|
||||
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
||||
NULL, /* Reserved2 */
|
||||
winpr_InitializeSecurityContextW, /* InitializeSecurityContext */
|
||||
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
|
||||
winpr_CompleteAuthToken, /* CompleteAuthToken */
|
||||
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
|
||||
winpr_ApplyControlToken, /* ApplyControlToken */
|
||||
winpr_QueryContextAttributesW, /* QueryContextAttributes */
|
||||
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
|
||||
winpr_RevertSecurityContext, /* RevertSecurityContext */
|
||||
winpr_MakeSignature, /* MakeSignature */
|
||||
winpr_VerifySignature, /* VerifySignature */
|
||||
winpr_FreeContextBuffer, /* FreeContextBuffer */
|
||||
winpr_QuerySecurityPackageInfoW, /* QuerySecurityPackageInfo */
|
||||
NULL, /* Reserved3 */
|
||||
NULL, /* Reserved4 */
|
||||
winpr_ExportSecurityContext, /* ExportSecurityContext */
|
||||
winpr_ImportSecurityContextW, /* ImportSecurityContext */
|
||||
NULL, /* AddCredentials */
|
||||
NULL, /* Reserved8 */
|
||||
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
|
||||
winpr_EncryptMessage, /* EncryptMessage */
|
||||
winpr_DecryptMessage, /* DecryptMessage */
|
||||
winpr_SetContextAttributesW, /* SetContextAttributes */
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user