2012-05-25 01:19:58 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Schannel Security Package
|
|
|
|
*
|
2014-06-06 06:10:08 +04:00
|
|
|
* Copyright 2012-2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2012-05-25 01:19:58 +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
|
|
|
|
|
2012-05-25 01:19:58 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/sspi.h>
|
|
|
|
|
|
|
|
#include "schannel.h"
|
|
|
|
|
|
|
|
#include "../sspi.h"
|
|
|
|
|
|
|
|
char* SCHANNEL_PACKAGE_NAME = "Schannel";
|
|
|
|
|
|
|
|
SCHANNEL_CONTEXT* schannel_ContextNew()
|
|
|
|
{
|
|
|
|
SCHANNEL_CONTEXT* context;
|
|
|
|
|
2015-06-14 01:55:09 +03:00
|
|
|
context = (SCHANNEL_CONTEXT*) calloc(1, sizeof(SCHANNEL_CONTEXT));
|
|
|
|
if (!context)
|
|
|
|
return NULL;
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2015-06-14 01:55:09 +03:00
|
|
|
context->openssl = schannel_openssl_new();
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2015-06-14 01:55:09 +03:00
|
|
|
if (!context->openssl)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2015-06-14 01:55:09 +03:00
|
|
|
free(context);
|
|
|
|
return NULL;
|
2012-05-25 01:19:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void schannel_ContextFree(SCHANNEL_CONTEXT* context)
|
|
|
|
{
|
|
|
|
if (!context)
|
|
|
|
return;
|
|
|
|
|
2012-12-24 05:20:41 +04:00
|
|
|
schannel_openssl_free(context->openssl);
|
|
|
|
|
2012-05-25 01:19:58 +04:00
|
|
|
free(context);
|
|
|
|
}
|
|
|
|
|
2012-12-22 21:18:13 +04:00
|
|
|
SCHANNEL_CREDENTIALS* schannel_CredentialsNew()
|
|
|
|
{
|
|
|
|
SCHANNEL_CREDENTIALS* credentials;
|
|
|
|
|
2015-06-14 01:55:09 +03:00
|
|
|
credentials = (SCHANNEL_CREDENTIALS*) calloc(1, sizeof(SCHANNEL_CREDENTIALS));
|
2012-12-22 21:18:13 +04:00
|
|
|
|
|
|
|
return credentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
void schannel_CredentialsFree(SCHANNEL_CREDENTIALS* credentials)
|
|
|
|
{
|
|
|
|
free(credentials);
|
|
|
|
}
|
|
|
|
|
2012-12-23 23:38:58 +04:00
|
|
|
static ALG_ID schannel_SupportedAlgs[] =
|
|
|
|
{
|
|
|
|
CALG_AES_128, CALG_AES_256, CALG_RC4, CALG_DES, CALG_3DES,
|
|
|
|
CALG_MD5, CALG_SHA1, CALG_SHA_256, CALG_SHA_384, CALG_SHA_512,
|
|
|
|
CALG_RSA_SIGN, CALG_DH_EPHEM,
|
|
|
|
(ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RESERVED7 | 6), /* what is this? */
|
|
|
|
CALG_DSS_SIGN, CALG_ECDSA
|
|
|
|
};
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2012-12-22 21:18:13 +04:00
|
|
|
if (ulAttribute == SECPKG_ATTR_SUPPORTED_ALGS)
|
|
|
|
{
|
|
|
|
PSecPkgCred_SupportedAlgs SupportedAlgs = (PSecPkgCred_SupportedAlgs) pBuffer;
|
|
|
|
|
2012-12-23 23:38:58 +04:00
|
|
|
SupportedAlgs->cSupportedAlgs = sizeof(schannel_SupportedAlgs) / sizeof(ALG_ID);
|
|
|
|
SupportedAlgs->palgSupportedAlgs = (ALG_ID*) schannel_SupportedAlgs;
|
2012-12-22 21:18:13 +04:00
|
|
|
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
else if (ulAttribute == SECPKG_ATTR_CIPHER_STRENGTHS)
|
|
|
|
{
|
|
|
|
PSecPkgCred_CipherStrengths CipherStrengths = (PSecPkgCred_CipherStrengths) pBuffer;
|
|
|
|
|
2012-12-23 23:38:58 +04:00
|
|
|
CipherStrengths->dwMinimumCipherStrength = 40;
|
2012-12-22 21:18:13 +04:00
|
|
|
CipherStrengths->dwMaximumCipherStrength = 256;
|
|
|
|
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
else if (ulAttribute == SECPKG_ATTR_SUPPORTED_PROTOCOLS)
|
|
|
|
{
|
|
|
|
PSecPkgCred_SupportedProtocols SupportedProtocols = (PSecPkgCred_SupportedProtocols) pBuffer;
|
|
|
|
|
2012-12-23 23:38:58 +04:00
|
|
|
/* Observed SupportedProtocols: 0x208A0 */
|
2012-12-22 21:18:13 +04:00
|
|
|
SupportedProtocols->grbitProtocol = (SP_PROT_CLIENTS | SP_PROT_SERVERS);
|
|
|
|
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
|
|
|
|
{
|
2012-12-22 21:18:13 +04:00
|
|
|
return schannel_QueryCredentialsAttributesW(phCredential, ulAttribute, pBuffer);
|
2012-05-25 01:19:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
|
2012-08-23 06:38:27 +04:00
|
|
|
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
2012-05-25 01:19:58 +04:00
|
|
|
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
|
|
|
{
|
2012-12-22 21:18:13 +04:00
|
|
|
SCHANNEL_CREDENTIALS* credentials;
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
if (fCredentialUse == SECPKG_CRED_OUTBOUND)
|
|
|
|
{
|
2012-12-22 21:18:13 +04:00
|
|
|
SCHANNEL_CRED* cred;
|
|
|
|
|
|
|
|
credentials = schannel_CredentialsNew();
|
|
|
|
credentials->fCredentialUse = fCredentialUse;
|
|
|
|
|
|
|
|
cred = (SCHANNEL_CRED*) pAuthData;
|
|
|
|
|
|
|
|
if (cred)
|
|
|
|
{
|
|
|
|
CopyMemory(&credentials->cred, cred, sizeof(SCHANNEL_CRED));
|
|
|
|
}
|
|
|
|
|
|
|
|
sspi_SecureHandleSetLowerPointer(phCredential, (void*) credentials);
|
|
|
|
sspi_SecureHandleSetUpperPointer(phCredential, (void*) SCHANNEL_PACKAGE_NAME);
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
else if (fCredentialUse == SECPKG_CRED_INBOUND)
|
|
|
|
{
|
2012-12-22 21:18:13 +04:00
|
|
|
credentials = schannel_CredentialsNew();
|
|
|
|
credentials->fCredentialUse = fCredentialUse;
|
|
|
|
|
|
|
|
sspi_SecureHandleSetLowerPointer(phCredential, (void*) credentials);
|
|
|
|
sspi_SecureHandleSetUpperPointer(phCredential, (void*) SCHANNEL_PACKAGE_NAME);
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-25 01:19:58 +04:00
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
|
2012-08-23 06:38:27 +04:00
|
|
|
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
|
2012-05-25 01:19:58 +04:00
|
|
|
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
|
2012-12-22 12:58:09 +04:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
free(pszPrincipalW);
|
|
|
|
free(pszPackageW);
|
|
|
|
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_FreeCredentialsHandle(PCredHandle phCredential)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2012-12-22 21:18:13 +04:00
|
|
|
SCHANNEL_CREDENTIALS* credentials;
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
if (!phCredential)
|
|
|
|
return SEC_E_INVALID_HANDLE;
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 21:18:13 +04:00
|
|
|
credentials = (SCHANNEL_CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
if (!credentials)
|
|
|
|
return SEC_E_INVALID_HANDLE;
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 21:18:13 +04:00
|
|
|
schannel_CredentialsFree(credentials);
|
2012-05-25 01:19:58 +04:00
|
|
|
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
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)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2013-01-03 22:36:19 +04:00
|
|
|
SECURITY_STATUS status;
|
2012-12-22 12:58:09 +04:00
|
|
|
SCHANNEL_CONTEXT* context;
|
2012-12-22 21:18:13 +04:00
|
|
|
SCHANNEL_CREDENTIALS* credentials;
|
2012-12-22 12:58:09 +04:00
|
|
|
|
|
|
|
context = sspi_SecureHandleGetLowerPointer(phContext);
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
context = schannel_ContextNew();
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return SEC_E_INSUFFICIENT_MEMORY;
|
|
|
|
|
2012-12-22 21:18:13 +04:00
|
|
|
credentials = (SCHANNEL_CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
|
|
|
|
|
|
|
context->server = FALSE;
|
|
|
|
CopyMemory(&context->cred, &credentials->cred, sizeof(SCHANNEL_CRED));
|
2012-12-22 12:58:09 +04:00
|
|
|
|
|
|
|
sspi_SecureHandleSetLowerPointer(phNewContext, context);
|
|
|
|
sspi_SecureHandleSetUpperPointer(phNewContext, (void*) SCHANNEL_PACKAGE_NAME);
|
2012-12-24 05:20:41 +04:00
|
|
|
|
|
|
|
schannel_openssl_client_init(context->openssl);
|
2012-12-22 12:58:09 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 21:19:07 +04:00
|
|
|
status = schannel_openssl_client_process_tokens(context->openssl, pInput, pOutput);
|
|
|
|
|
|
|
|
return status;
|
2012-05-25 01:19:58 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
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)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS status;
|
|
|
|
SEC_WCHAR* pszTargetNameW = NULL;
|
|
|
|
|
|
|
|
if (pszTargetName != NULL)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2012-12-22 12:58:09 +04:00
|
|
|
ConvertToUnicode(CP_UTF8, 0, pszTargetName, -1, &pszTargetNameW, 0);
|
|
|
|
}
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
status = schannel_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq,
|
|
|
|
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2015-05-11 10:07:39 +03:00
|
|
|
free(pszTargetNameW);
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
return status;
|
2012-05-25 01:19:58 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 21:18:13 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
|
|
|
|
PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
|
|
|
|
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
|
|
|
|
{
|
2013-01-03 22:36:19 +04:00
|
|
|
SECURITY_STATUS status;
|
2012-12-22 21:18:13 +04:00
|
|
|
SCHANNEL_CONTEXT* context;
|
|
|
|
SCHANNEL_CREDENTIALS* credentials;
|
|
|
|
|
2013-01-11 02:12:27 +04:00
|
|
|
status = SEC_E_OK;
|
2012-12-22 21:18:13 +04:00
|
|
|
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
context = schannel_ContextNew();
|
|
|
|
|
|
|
|
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);
|
2013-01-03 22:36:19 +04:00
|
|
|
|
|
|
|
schannel_openssl_server_init(context->openssl);
|
2012-12-22 21:18:13 +04:00
|
|
|
}
|
|
|
|
|
2013-01-11 02:12:27 +04:00
|
|
|
status = schannel_openssl_server_process_tokens(context->openssl, pInput, pOutput);
|
|
|
|
|
|
|
|
return status;
|
2012-12-22 21:18:13 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_DeleteSecurityContext(PCtxtHandle phContext)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2012-12-22 12:58:09 +04:00
|
|
|
SCHANNEL_CONTEXT* context;
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
|
|
|
|
|
|
|
|
if (!context)
|
2012-05-25 01:19:58 +04:00
|
|
|
return SEC_E_INVALID_HANDLE;
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
schannel_ContextFree(context);
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_QueryContextAttributes(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
|
|
|
|
{
|
|
|
|
if (!phContext)
|
2012-05-25 01:19:58 +04:00
|
|
|
return SEC_E_INVALID_HANDLE;
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
if (!pBuffer)
|
|
|
|
return SEC_E_INSUFFICIENT_MEMORY;
|
2012-05-25 01:19:58 +04:00
|
|
|
|
2012-12-22 21:18:13 +04:00
|
|
|
if (ulAttribute == SECPKG_ATTR_SIZES)
|
|
|
|
{
|
2013-02-19 06:50:33 +04:00
|
|
|
SecPkgContext_Sizes* Sizes = (SecPkgContext_Sizes*) pBuffer;
|
2012-12-22 21:18:13 +04:00
|
|
|
|
2013-02-19 06:50:33 +04:00
|
|
|
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;
|
2012-12-22 21:18:13 +04:00
|
|
|
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
return SEC_E_UNSUPPORTED_FUNCTION;
|
2012-05-25 01:19:58 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
|
|
|
return SEC_E_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2013-01-11 23:23:54 +04:00
|
|
|
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;
|
2012-05-25 01:19:58 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 12:58:09 +04:00
|
|
|
SECURITY_STATUS SEC_ENTRY schannel_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
|
2012-05-25 01:19:58 +04:00
|
|
|
{
|
2013-02-19 06:50:33 +04:00
|
|
|
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;
|
2012-05-25 01:19:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const SecurityFunctionTableA SCHANNEL_SecurityFunctionTableA =
|
|
|
|
{
|
|
|
|
1, /* dwVersion */
|
|
|
|
NULL, /* EnumerateSecurityPackages */
|
|
|
|
schannel_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
|
|
|
|
schannel_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
|
|
|
|
schannel_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
|
|
|
NULL, /* Reserved2 */
|
|
|
|
schannel_InitializeSecurityContextA, /* InitializeSecurityContext */
|
2012-12-22 21:18:13 +04:00
|
|
|
schannel_AcceptSecurityContext, /* AcceptSecurityContext */
|
2012-05-25 01:19:58 +04:00
|
|
|
NULL, /* CompleteAuthToken */
|
2012-12-22 12:58:09 +04:00
|
|
|
schannel_DeleteSecurityContext, /* DeleteSecurityContext */
|
2012-05-25 01:19:58 +04:00
|
|
|
NULL, /* ApplyControlToken */
|
|
|
|
schannel_QueryContextAttributes, /* QueryContextAttributes */
|
|
|
|
NULL, /* ImpersonateSecurityContext */
|
|
|
|
NULL, /* RevertSecurityContext */
|
|
|
|
schannel_MakeSignature, /* MakeSignature */
|
|
|
|
schannel_VerifySignature, /* VerifySignature */
|
|
|
|
NULL, /* FreeContextBuffer */
|
|
|
|
NULL, /* QuerySecurityPackageInfo */
|
|
|
|
NULL, /* Reserved3 */
|
|
|
|
NULL, /* Reserved4 */
|
|
|
|
NULL, /* ExportSecurityContext */
|
|
|
|
NULL, /* ImportSecurityContext */
|
|
|
|
NULL, /* AddCredentials */
|
|
|
|
NULL, /* Reserved8 */
|
|
|
|
NULL, /* QuerySecurityContextToken */
|
|
|
|
schannel_EncryptMessage, /* EncryptMessage */
|
|
|
|
schannel_DecryptMessage, /* DecryptMessage */
|
|
|
|
NULL, /* SetContextAttributes */
|
|
|
|
};
|
|
|
|
|
|
|
|
const SecurityFunctionTableW SCHANNEL_SecurityFunctionTableW =
|
|
|
|
{
|
|
|
|
1, /* dwVersion */
|
|
|
|
NULL, /* EnumerateSecurityPackages */
|
|
|
|
schannel_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
|
|
|
|
schannel_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
|
|
|
|
schannel_FreeCredentialsHandle, /* FreeCredentialsHandle */
|
|
|
|
NULL, /* Reserved2 */
|
|
|
|
schannel_InitializeSecurityContextW, /* InitializeSecurityContext */
|
2012-12-22 21:18:13 +04:00
|
|
|
schannel_AcceptSecurityContext, /* AcceptSecurityContext */
|
2012-05-25 01:19:58 +04:00
|
|
|
NULL, /* CompleteAuthToken */
|
2012-12-22 12:58:09 +04:00
|
|
|
schannel_DeleteSecurityContext, /* DeleteSecurityContext */
|
2012-05-25 01:19:58 +04:00
|
|
|
NULL, /* ApplyControlToken */
|
|
|
|
schannel_QueryContextAttributes, /* QueryContextAttributes */
|
|
|
|
NULL, /* ImpersonateSecurityContext */
|
|
|
|
NULL, /* RevertSecurityContext */
|
|
|
|
schannel_MakeSignature, /* MakeSignature */
|
|
|
|
schannel_VerifySignature, /* VerifySignature */
|
|
|
|
NULL, /* FreeContextBuffer */
|
|
|
|
NULL, /* QuerySecurityPackageInfo */
|
|
|
|
NULL, /* Reserved3 */
|
|
|
|
NULL, /* Reserved4 */
|
|
|
|
NULL, /* ExportSecurityContext */
|
|
|
|
NULL, /* ImportSecurityContext */
|
|
|
|
NULL, /* AddCredentials */
|
|
|
|
NULL, /* Reserved8 */
|
|
|
|
NULL, /* QuerySecurityContextToken */
|
|
|
|
schannel_EncryptMessage, /* EncryptMessage */
|
|
|
|
schannel_DecryptMessage, /* DecryptMessage */
|
|
|
|
NULL, /* SetContextAttributes */
|
|
|
|
};
|
2012-05-25 09:50:46 +04:00
|
|
|
|
|
|
|
const SecPkgInfoA SCHANNEL_SecPkgInfoA =
|
|
|
|
{
|
|
|
|
0x000107B3, /* fCapabilities */
|
|
|
|
1, /* wVersion */
|
|
|
|
0x000E, /* wRPCID */
|
2012-12-24 05:20:41 +04:00
|
|
|
SCHANNEL_CB_MAX_TOKEN, /* cbMaxToken */
|
2012-05-25 09:50:46 +04:00
|
|
|
"Schannel", /* Name */
|
|
|
|
"Schannel Security Package" /* Comment */
|
|
|
|
};
|
|
|
|
|
2012-06-04 03:59:35 +04:00
|
|
|
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'
|
|
|
|
};
|
|
|
|
|
2012-05-25 09:50:46 +04:00
|
|
|
const SecPkgInfoW SCHANNEL_SecPkgInfoW =
|
|
|
|
{
|
|
|
|
0x000107B3, /* fCapabilities */
|
|
|
|
1, /* wVersion */
|
|
|
|
0x000E, /* wRPCID */
|
2012-12-24 05:20:41 +04:00
|
|
|
SCHANNEL_CB_MAX_TOKEN, /* cbMaxToken */
|
2012-06-04 03:59:35 +04:00
|
|
|
SCHANNEL_SecPkgInfoW_Name, /* Name */
|
|
|
|
SCHANNEL_SecPkgInfoW_Comment /* Comment */
|
2012-05-25 09:50:46 +04:00
|
|
|
};
|