Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
a18529f3bb
@ -44,6 +44,7 @@ int add_sspi_suite(void)
|
||||
add_test_function(EnumerateSecurityPackages);
|
||||
add_test_function(QuerySecurityPackageInfo);
|
||||
add_test_function(AcquireCredentialsHandle);
|
||||
add_test_function(InitializeSecurityContext);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -95,6 +96,7 @@ void test_AcquireCredentialsHandle(void)
|
||||
SEC_TIMESTAMP expiration;
|
||||
SEC_AUTH_IDENTITY identity;
|
||||
SECURITY_FUNCTION_TABLE* table;
|
||||
SEC_PKG_CREDENTIALS_NAMES credential_names;
|
||||
|
||||
table = InitSecurityInterface();
|
||||
|
||||
@ -111,10 +113,91 @@ void test_AcquireCredentialsHandle(void)
|
||||
|
||||
if (status == SEC_E_OK)
|
||||
{
|
||||
status = table->QueryCredentialsAttributes(&credentials, SECPKG_CRED_ATTR_NAMES, &credential_names);
|
||||
|
||||
if (status == SEC_E_OK)
|
||||
{
|
||||
printf("\nQueryCredentialsAttributes: %s\n", credential_names.sUserName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_InitializeSecurityContext(void)
|
||||
{
|
||||
uint32 cbMaxLen;
|
||||
uint32 fContextReq;
|
||||
void* output_buffer;
|
||||
CTXT_HANDLE context;
|
||||
uint32 pfContextAttr;
|
||||
SECURITY_STATUS status;
|
||||
CRED_HANDLE credentials;
|
||||
SEC_TIMESTAMP expiration;
|
||||
SEC_PKG_INFO* pPackageInfo;
|
||||
SEC_AUTH_IDENTITY identity;
|
||||
SECURITY_FUNCTION_TABLE* table;
|
||||
SEC_BUFFER* p_sec_buffer;
|
||||
SEC_BUFFER output_sec_buffer;
|
||||
SEC_BUFFER_DESC output_sec_buffer_desc;
|
||||
|
||||
table = InitSecurityInterface();
|
||||
|
||||
status = QuerySecurityPackageInfo(NTLM_PACKAGE_NAME, &pPackageInfo);
|
||||
|
||||
if (status != SEC_E_OK)
|
||||
{
|
||||
printf("QuerySecurityPackageInfo status: 0x%08X\n", status);
|
||||
return;
|
||||
}
|
||||
|
||||
cbMaxLen = pPackageInfo->cbMaxToken;
|
||||
|
||||
identity.User = (uint16*) xstrdup(test_User);
|
||||
identity.UserLength = sizeof(test_User);
|
||||
identity.Domain = (uint16*) xstrdup(test_Domain);
|
||||
identity.DomainLength = sizeof(test_Domain);
|
||||
identity.Password = (uint16*) xstrdup(test_Password);
|
||||
identity.PasswordLength = sizeof(test_Password);
|
||||
identity.Flags = SEC_AUTH_IDENTITY_ANSI;
|
||||
|
||||
status = table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME,
|
||||
SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration);
|
||||
|
||||
if (status != SEC_E_OK)
|
||||
{
|
||||
printf("AcquireCredentialsHandle status: 0x%08X\n", status);
|
||||
return;
|
||||
}
|
||||
|
||||
fContextReq = ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONFIDENTIALITY | ISC_REQ_DELEGATE;
|
||||
|
||||
output_buffer = xmalloc(cbMaxLen);
|
||||
|
||||
output_sec_buffer_desc.ulVersion = 0;
|
||||
output_sec_buffer_desc.cBuffers = 1;
|
||||
output_sec_buffer_desc.pBuffers = &output_sec_buffer;
|
||||
|
||||
output_sec_buffer.cbBuffer = cbMaxLen;
|
||||
output_sec_buffer.BufferType = SECBUFFER_TOKEN;
|
||||
output_sec_buffer.pvBuffer = output_buffer;
|
||||
|
||||
status = table->InitializeSecurityContext(&credentials, NULL, NULL, fContextReq, 0, 0, NULL, 0,
|
||||
&context, &output_sec_buffer_desc, &pfContextAttr, &expiration);
|
||||
|
||||
if (status != SEC_I_CONTINUE_NEEDED)
|
||||
{
|
||||
printf("InitializeSecurityContext status: 0x%08X\n", status);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("cBuffers: %d ulVersion: %d\n", output_sec_buffer_desc.cBuffers, output_sec_buffer_desc.ulVersion);
|
||||
|
||||
p_sec_buffer = &output_sec_buffer_desc.pBuffers[0];
|
||||
|
||||
printf("BufferType: 0x%04X cbBuffer:%d\n", p_sec_buffer->BufferType, p_sec_buffer->cbBuffer);
|
||||
|
||||
freerdp_hexdump((uint8*) p_sec_buffer->pvBuffer, p_sec_buffer->cbBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -131,4 +214,3 @@ void test_AcquireCredentialsHandle(void)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -26,3 +26,4 @@ int add_sspi_suite(void);
|
||||
void test_EnumerateSecurityPackages(void);
|
||||
void test_QuerySecurityPackageInfo(void);
|
||||
void test_AcquireCredentialsHandle(void);
|
||||
void test_InitializeSecurityContext(void);
|
||||
|
@ -136,12 +136,163 @@ typedef uint32 SECURITY_STATUS;
|
||||
#define SEC_I_SIGNATURE_NEEDED 0x0009035C
|
||||
#define SEC_I_NO_RENEGOTIATION 0x00090360
|
||||
|
||||
#define SECURITY_NATIVE_DREP 0x00000010
|
||||
#define SECURITY_NETWORK_DREP 0x00000000
|
||||
|
||||
#define SECPKG_CRED_INBOUND 0x00000001
|
||||
#define SECPKG_CRED_OUTBOUND 0x00000002
|
||||
#define SECPKG_CRED_BOTH 0x00000003
|
||||
#define SECPKG_CRED_AUTOLOGON_RESTRICTED 0x00000010
|
||||
#define SECPKG_CRED_PROCESS_POLICY_ONLY 0x00000020
|
||||
|
||||
/* Security Context Attributes */
|
||||
|
||||
#define SECPKG_ATTR_SIZES 0
|
||||
#define SECPKG_ATTR_NAMES 1
|
||||
#define SECPKG_ATTR_LIFESPAN 2
|
||||
#define SECPKG_ATTR_DCE_INFO 3
|
||||
#define SECPKG_ATTR_STREAM_SIZES 4
|
||||
#define SECPKG_ATTR_KEY_INFO 5
|
||||
#define SECPKG_ATTR_AUTHORITY 6
|
||||
#define SECPKG_ATTR_PROTO_INFO 7
|
||||
#define SECPKG_ATTR_PASSWORD_EXPIRY 8
|
||||
#define SECPKG_ATTR_SESSION_KEY 9
|
||||
#define SECPKG_ATTR_PACKAGE_INFO 10
|
||||
#define SECPKG_ATTR_USER_FLAGS 11
|
||||
#define SECPKG_ATTR_NEGOTIATION_INFO 12
|
||||
#define SECPKG_ATTR_NATIVE_NAMES 13
|
||||
#define SECPKG_ATTR_FLAGS 14
|
||||
#define SECPKG_ATTR_USE_VALIDATED 15
|
||||
#define SECPKG_ATTR_CREDENTIAL_NAME 16
|
||||
#define SECPKG_ATTR_TARGET_INFORMATION 17
|
||||
#define SECPKG_ATTR_ACCESS_TOKEN 18
|
||||
#define SECPKG_ATTR_TARGET 19
|
||||
#define SECPKG_ATTR_AUTHENTICATION_ID 20
|
||||
#define SECPKG_ATTR_LOGOFF_TIME 21
|
||||
#define SECPKG_ATTR_NEGO_KEYS 22
|
||||
#define SECPKG_ATTR_PROMPTING_NEEDED 24
|
||||
#define SECPKG_ATTR_UNIQUE_BINDINGS 25
|
||||
#define SECPKG_ATTR_ENDPOINT_BINDINGS 26
|
||||
#define SECPKG_ATTR_CLIENT_SPECIFIED_TARGET 27
|
||||
#define SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS 30
|
||||
#define SECPKG_ATTR_NEGO_PKG_INFO 31
|
||||
#define SECPKG_ATTR_NEGO_STATUS 32
|
||||
#define SECPKG_ATTR_CONTEXT_DELETED 33
|
||||
|
||||
/* Security Credentials Attributes */
|
||||
|
||||
#define SECPKG_CRED_ATTR_NAMES 1
|
||||
|
||||
struct _SEC_PKG_CREDENTIALS_NAMES
|
||||
{
|
||||
char* sUserName;
|
||||
};
|
||||
typedef struct _SEC_PKG_CREDENTIALS_NAMES SEC_PKG_CREDENTIALS_NAMES;
|
||||
|
||||
/* InitializeSecurityContext Flags */
|
||||
|
||||
#define ISC_REQ_DELEGATE 0x00000001
|
||||
#define ISC_REQ_MUTUAL_AUTH 0x00000002
|
||||
#define ISC_REQ_REPLAY_DETECT 0x00000004
|
||||
#define ISC_REQ_SEQUENCE_DETECT 0x00000008
|
||||
#define ISC_REQ_CONFIDENTIALITY 0x00000010
|
||||
#define ISC_REQ_USE_SESSION_KEY 0x00000020
|
||||
#define ISC_REQ_PROMPT_FOR_CREDS 0x00000040
|
||||
#define ISC_REQ_USE_SUPPLIED_CREDS 0x00000080
|
||||
#define ISC_REQ_ALLOCATE_MEMORY 0x00000100
|
||||
#define ISC_REQ_USE_DCE_STYLE 0x00000200
|
||||
#define ISC_REQ_DATAGRAM 0x00000400
|
||||
#define ISC_REQ_CONNECTION 0x00000800
|
||||
#define ISC_REQ_CALL_LEVEL 0x00001000
|
||||
#define ISC_REQ_FRAGMENT_SUPPLIED 0x00002000
|
||||
#define ISC_REQ_EXTENDED_ERROR 0x00004000
|
||||
#define ISC_REQ_STREAM 0x00008000
|
||||
#define ISC_REQ_INTEGRITY 0x00010000
|
||||
#define ISC_REQ_IDENTIFY 0x00020000
|
||||
#define ISC_REQ_NULL_SESSION 0x00040000
|
||||
#define ISC_REQ_MANUAL_CRED_VALIDATION 0x00080000
|
||||
#define ISC_REQ_RESERVED1 0x00100000
|
||||
#define ISC_REQ_FRAGMENT_TO_FIT 0x00200000
|
||||
#define ISC_REQ_FORWARD_CREDENTIALS 0x00400000
|
||||
#define ISC_REQ_NO_INTEGRITY 0x00800000
|
||||
#define ISC_REQ_USE_HTTP_STYLE 0x01000000
|
||||
|
||||
#define ISC_RET_DELEGATE 0x00000001
|
||||
#define ISC_RET_MUTUAL_AUTH 0x00000002
|
||||
#define ISC_RET_REPLAY_DETECT 0x00000004
|
||||
#define ISC_RET_SEQUENCE_DETECT 0x00000008
|
||||
#define ISC_RET_CONFIDENTIALITY 0x00000010
|
||||
#define ISC_RET_USE_SESSION_KEY 0x00000020
|
||||
#define ISC_RET_USED_COLLECTED_CREDS 0x00000040
|
||||
#define ISC_RET_USED_SUPPLIED_CREDS 0x00000080
|
||||
#define ISC_RET_ALLOCATED_MEMORY 0x00000100
|
||||
#define ISC_RET_USED_DCE_STYLE 0x00000200
|
||||
#define ISC_RET_DATAGRAM 0x00000400
|
||||
#define ISC_RET_CONNECTION 0x00000800
|
||||
#define ISC_RET_INTERMEDIATE_RETURN 0x00001000
|
||||
#define ISC_RET_CALL_LEVEL 0x00002000
|
||||
#define ISC_RET_EXTENDED_ERROR 0x00004000
|
||||
#define ISC_RET_STREAM 0x00008000
|
||||
#define ISC_RET_INTEGRITY 0x00010000
|
||||
#define ISC_RET_IDENTIFY 0x00020000
|
||||
#define ISC_RET_NULL_SESSION 0x00040000
|
||||
#define ISC_RET_MANUAL_CRED_VALIDATION 0x00080000
|
||||
#define ISC_RET_RESERVED1 0x00100000
|
||||
#define ISC_RET_FRAGMENT_ONLY 0x00200000
|
||||
#define ISC_RET_FORWARD_CREDENTIALS 0x00400000
|
||||
#define ISC_RET_USED_HTTP_STYLE 0x01000000
|
||||
|
||||
/* AcceptSecurityContext Flags */
|
||||
|
||||
#define ASC_REQ_DELEGATE 0x00000001
|
||||
#define ASC_REQ_MUTUAL_AUTH 0x00000002
|
||||
#define ASC_REQ_REPLAY_DETECT 0x00000004
|
||||
#define ASC_REQ_SEQUENCE_DETECT 0x00000008
|
||||
#define ASC_REQ_CONFIDENTIALITY 0x00000010
|
||||
#define ASC_REQ_USE_SESSION_KEY 0x00000020
|
||||
#define ASC_REQ_ALLOCATE_MEMORY 0x00000100
|
||||
#define ASC_REQ_USE_DCE_STYLE 0x00000200
|
||||
#define ASC_REQ_DATAGRAM 0x00000400
|
||||
#define ASC_REQ_CONNECTION 0x00000800
|
||||
#define ASC_REQ_CALL_LEVEL 0x00001000
|
||||
#define ASC_REQ_EXTENDED_ERROR 0x00008000
|
||||
#define ASC_REQ_STREAM 0x00010000
|
||||
#define ASC_REQ_INTEGRITY 0x00020000
|
||||
#define ASC_REQ_LICENSING 0x00040000
|
||||
#define ASC_REQ_IDENTIFY 0x00080000
|
||||
#define ASC_REQ_ALLOW_NULL_SESSION 0x00100000
|
||||
#define ASC_REQ_ALLOW_NON_USER_LOGONS 0x00200000
|
||||
#define ASC_REQ_ALLOW_CONTEXT_REPLAY 0x00400000
|
||||
#define ASC_REQ_FRAGMENT_TO_FIT 0x00800000
|
||||
#define ASC_REQ_FRAGMENT_SUPPLIED 0x00002000
|
||||
#define ASC_REQ_NO_TOKEN 0x01000000
|
||||
#define ASC_REQ_PROXY_BINDINGS 0x04000000
|
||||
#define ASC_REQ_ALLOW_MISSING_BINDINGS 0x10000000
|
||||
|
||||
#define ASC_RET_DELEGATE 0x00000001
|
||||
#define ASC_RET_MUTUAL_AUTH 0x00000002
|
||||
#define ASC_RET_REPLAY_DETECT 0x00000004
|
||||
#define ASC_RET_SEQUENCE_DETECT 0x00000008
|
||||
#define ASC_RET_CONFIDENTIALITY 0x00000010
|
||||
#define ASC_RET_USE_SESSION_KEY 0x00000020
|
||||
#define ASC_RET_ALLOCATED_MEMORY 0x00000100
|
||||
#define ASC_RET_USED_DCE_STYLE 0x00000200
|
||||
#define ASC_RET_DATAGRAM 0x00000400
|
||||
#define ASC_RET_CONNECTION 0x00000800
|
||||
#define ASC_RET_CALL_LEVEL 0x00002000
|
||||
#define ASC_RET_THIRD_LEG_FAILED 0x00004000
|
||||
#define ASC_RET_EXTENDED_ERROR 0x00008000
|
||||
#define ASC_RET_STREAM 0x00010000
|
||||
#define ASC_RET_INTEGRITY 0x00020000
|
||||
#define ASC_RET_LICENSING 0x00040000
|
||||
#define ASC_RET_IDENTIFY 0x00080000
|
||||
#define ASC_RET_NULL_SESSION 0x00100000
|
||||
#define ASC_RET_ALLOW_NON_USER_LOGONS 0x00200000
|
||||
#define ASC_RET_FRAGMENT_ONLY 0x00800000
|
||||
#define ASC_RET_NO_TOKEN 0x01000000
|
||||
#define ASC_RET_NO_PROXY_BINDINGS 0x04000000
|
||||
#define ASC_RET_MISSING_BINDINGS 0x10000000
|
||||
|
||||
struct _SEC_PKG_INFO
|
||||
{
|
||||
uint32 fCapabilities;
|
||||
@ -187,6 +338,34 @@ typedef struct _SEC_INTEGER SEC_INTEGER;
|
||||
|
||||
typedef SEC_INTEGER SEC_TIMESTAMP;
|
||||
|
||||
#define SECBUFFER_VERSION 0
|
||||
|
||||
/* Buffer Types */
|
||||
#define SECBUFFER_EMPTY 0
|
||||
#define SECBUFFER_DATA 1
|
||||
#define SECBUFFER_TOKEN 2
|
||||
#define SECBUFFER_PKG_PARAMS 3
|
||||
#define SECBUFFER_MISSING 4
|
||||
#define SECBUFFER_EXTRA 5
|
||||
#define SECBUFFER_STREAM_TRAILER 6
|
||||
#define SECBUFFER_STREAM_HEADER 7
|
||||
#define SECBUFFER_NEGOTIATION_INFO 8
|
||||
#define SECBUFFER_PADDING 9
|
||||
#define SECBUFFER_STREAM 10
|
||||
#define SECBUFFER_MECHLIST 11
|
||||
#define SECBUFFER_MECHLIST_SIGNATURE 12
|
||||
#define SECBUFFER_TARGET 13
|
||||
#define SECBUFFER_CHANNEL_BINDINGS 14
|
||||
#define SECBUFFER_CHANGE_PASS_RESPONSE 15
|
||||
#define SECBUFFER_TARGET_HOST 16
|
||||
#define SECBUFFER_ALERT 17
|
||||
|
||||
/* Security Buffer Flags */
|
||||
#define SECBUFFER_ATTRMASK 0xF0000000
|
||||
#define SECBUFFER_READONLY 0x80000000
|
||||
#define SECBUFFER_READONLY_WITH_CHECKSUM 0x10000000
|
||||
#define SECBUFFER_RESERVED 0x60000000
|
||||
|
||||
struct _SEC_BUFFER
|
||||
{
|
||||
uint32 cbBuffer;
|
||||
|
@ -18,7 +18,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
set(FREERDP_AUTH_SRCS
|
||||
NTLM/ntlm.c
|
||||
NTLM/ntlm.h
|
||||
NTLM/ntlm_message.c
|
||||
NTLM/ntlm_message.h
|
||||
sspi.c
|
||||
sspi.h
|
||||
credssp.c
|
||||
ntlmssp.c)
|
||||
|
||||
|
185
libfreerdp-auth/NTLM/ntlm.c
Normal file
185
libfreerdp-auth/NTLM/ntlm.c
Normal file
@ -0,0 +1,185 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* NTLM Security Package
|
||||
*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/md4.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/engine.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
|
||||
#include <freerdp/auth/sspi.h>
|
||||
#include <freerdp/auth/credssp.h>
|
||||
|
||||
#include "ntlm.h"
|
||||
#include "../sspi.h"
|
||||
|
||||
#include "ntlm_message.h"
|
||||
|
||||
char* NTLM_PACKAGE_NAME = "NTLM";
|
||||
|
||||
NTLM_CONTEXT* ntlm_ContextNew()
|
||||
{
|
||||
NTLM_CONTEXT* context;
|
||||
|
||||
context = xnew(NTLM_CONTEXT);
|
||||
|
||||
if (context != NULL)
|
||||
{
|
||||
context->ntlm_v2 = false;
|
||||
context->NegotiateFlags = 0;
|
||||
context->state = NTLM_STATE_INITIAL;
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
void ntlm_ContextFree(NTLM_CONTEXT* context)
|
||||
{
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
xfree(context);
|
||||
}
|
||||
|
||||
SECURITY_STATUS ntlm_AcquireCredentialsHandle(char* pszPrincipal, char* pszPackage,
|
||||
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
|
||||
void* pvGetKeyArgument, CRED_HANDLE* phCredential, SEC_TIMESTAMP* ptsExpiry)
|
||||
{
|
||||
CREDENTIALS* credentials;
|
||||
SEC_AUTH_IDENTITY* identity;
|
||||
|
||||
if (fCredentialUse == SECPKG_CRED_OUTBOUND)
|
||||
{
|
||||
credentials = sspi_CredentialsNew();
|
||||
identity = (SEC_AUTH_IDENTITY*) pAuthData;
|
||||
|
||||
memcpy(&(credentials->identity), identity, sizeof(SEC_AUTH_IDENTITY));
|
||||
|
||||
sspi_SecureHandleSetLowerPointer(phCredential, (void*) credentials);
|
||||
sspi_SecureHandleSetUpperPointer(phCredential, (void*) NTLM_PACKAGE_NAME);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
SECURITY_STATUS ntlm_QueryCredentialsAttributes(CRED_HANDLE* phCredential, uint32 ulAttribute, void* pBuffer)
|
||||
{
|
||||
if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
|
||||
{
|
||||
CREDENTIALS* credentials;
|
||||
SEC_PKG_CREDENTIALS_NAMES* credential_names = (SEC_PKG_CREDENTIALS_NAMES*) pBuffer;
|
||||
|
||||
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
||||
|
||||
if (credentials->identity.Flags == SEC_AUTH_IDENTITY_ANSI)
|
||||
credential_names->sUserName = xstrdup((char*) credentials->identity.User);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
return SEC_E_UNSUPPORTED_FUNCTION;
|
||||
}
|
||||
|
||||
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa375512/ */
|
||||
|
||||
SECURITY_STATUS ntlm_InitializeSecurityContext(CRED_HANDLE* phCredential, CTXT_HANDLE* phContext,
|
||||
char* pszTargetName, uint32 fContextReq, uint32 Reserved1, uint32 TargetDataRep,
|
||||
SEC_BUFFER_DESC* pInput, uint32 Reserved2, CTXT_HANDLE* phNewContext,
|
||||
SEC_BUFFER_DESC* pOutput, uint32* pfContextAttr, SEC_TIMESTAMP* ptsExpiry)
|
||||
{
|
||||
NTLM_CONTEXT* context;
|
||||
SEC_BUFFER* sec_buffer;
|
||||
|
||||
if (pInput == NULL)
|
||||
{
|
||||
context = ntlm_ContextNew();
|
||||
|
||||
if (!pOutput)
|
||||
return SEC_E_INVALID_TOKEN;
|
||||
|
||||
if (pOutput->cBuffers < 1)
|
||||
return SEC_E_INVALID_TOKEN;
|
||||
|
||||
sec_buffer = &pOutput->pBuffers[0];
|
||||
|
||||
if (sec_buffer->BufferType != SECBUFFER_TOKEN)
|
||||
return SEC_E_INVALID_TOKEN;
|
||||
|
||||
if (sec_buffer->cbBuffer < 1)
|
||||
return SEC_E_INSUFFICIENT_MEMORY;
|
||||
|
||||
return ntlm_write_NegotiateMessage(context, sec_buffer);
|
||||
}
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa379337/ */
|
||||
|
||||
SECURITY_STATUS ntlm_QueryContextAttributes(CTXT_HANDLE* phContext, uint32 ulAttribute, void* pBuffer)
|
||||
{
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
const SEC_PKG_INFO NTLM_SEC_PKG_INFO =
|
||||
{
|
||||
0x00082B37, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x000A, /* wRPCID */
|
||||
0x00000B48, /* cbMaxToken */
|
||||
"NTLM", /* Name */
|
||||
"NTLM Security Package" /* Comment */
|
||||
};
|
||||
|
||||
const SECURITY_FUNCTION_TABLE NTLM_SECURITY_FUNCTION_TABLE =
|
||||
{
|
||||
1, /* dwVersion */
|
||||
NULL, /* EnumerateSecurityPackages */
|
||||
NULL, /* Reserved1 */
|
||||
ntlm_QueryCredentialsAttributes, /* QueryCredentialsAttributes */
|
||||
ntlm_AcquireCredentialsHandle, /* AcquireCredentialsHandle */
|
||||
NULL, /* FreeCredentialsHandle */
|
||||
NULL, /* Reserved2 */
|
||||
ntlm_InitializeSecurityContext, /* InitializeSecurityContext */
|
||||
NULL, /* AcceptSecurityContext */
|
||||
NULL, /* CompleteAuthToken */
|
||||
NULL, /* DeleteSecurityContext */
|
||||
NULL, /* ApplyControlToken */
|
||||
ntlm_QueryContextAttributes, /* QueryContextAttributes */
|
||||
NULL, /* ImpersonateSecurityContext */
|
||||
NULL, /* RevertSecurityContext */
|
||||
NULL, /* MakeSignature */
|
||||
NULL, /* VerifySignature */
|
||||
NULL, /* FreeContextBuffer */
|
||||
NULL, /* QuerySecurityPackageInfo */
|
||||
NULL, /* Reserved3 */
|
||||
NULL, /* Reserved4 */
|
||||
NULL, /* ExportSecurityContext */
|
||||
NULL, /* ImportSecurityContext */
|
||||
NULL, /* AddCredentials */
|
||||
NULL, /* Reserved8 */
|
||||
NULL, /* QuerySecurityContextToken */
|
||||
NULL, /* EncryptMessage */
|
||||
NULL, /* DecryptMessage */
|
||||
NULL, /* SetContextAttributes */
|
||||
};
|
49
libfreerdp-auth/NTLM/ntlm.h
Normal file
49
libfreerdp-auth/NTLM/ntlm.h
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* NTLM Security Package
|
||||
*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_AUTH_NTLM_PRIVATE_H
|
||||
#define FREERDP_AUTH_NTLM_PRIVATE_H
|
||||
|
||||
#include <freerdp/auth/sspi.h>
|
||||
#include <freerdp/auth/credssp.h>
|
||||
|
||||
#include "../sspi.h"
|
||||
|
||||
enum _NTLM_STATE
|
||||
{
|
||||
NTLM_STATE_INITIAL,
|
||||
NTLM_STATE_NEGOTIATE,
|
||||
NTLM_STATE_CHALLENGE,
|
||||
NTLM_STATE_AUTHENTICATE,
|
||||
NTLM_STATE_FINAL
|
||||
};
|
||||
typedef enum _NTLM_STATE NTLM_STATE;
|
||||
|
||||
struct _NTLM_CONTEXT
|
||||
{
|
||||
boolean ntlm_v2;
|
||||
NTLM_STATE state;
|
||||
uint32 NegotiateFlags;
|
||||
SEC_BUFFER NegotiateMessage;
|
||||
SEC_BUFFER ChallengeMessage;
|
||||
SEC_BUFFER AuthenticateMessage;
|
||||
};
|
||||
typedef struct _NTLM_CONTEXT NTLM_CONTEXT;
|
||||
|
||||
#endif /* FREERDP_AUTH_NTLM_PRIVATE_H */
|
164
libfreerdp-auth/NTLM/ntlm_message.c
Normal file
164
libfreerdp-auth/NTLM/ntlm_message.c
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* NTLM Security Package (Message)
|
||||
*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "ntlm.h"
|
||||
#include "../sspi.h"
|
||||
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
#include "ntlm_message.h"
|
||||
|
||||
#define NTLMSSP_NEGOTIATE_56 0x80000000 /* W (0) */
|
||||
#define NTLMSSP_NEGOTIATE_KEY_EXCH 0x40000000 /* V (1) */
|
||||
#define NTLMSSP_NEGOTIATE_128 0x20000000 /* U (2) */
|
||||
#define NTLMSSP_RESERVED1 0x10000000 /* r1 (3) */
|
||||
#define NTLMSSP_RESERVED2 0x08000000 /* r2 (4) */
|
||||
#define NTLMSSP_RESERVED3 0x04000000 /* r3 (5) */
|
||||
#define NTLMSSP_NEGOTIATE_VERSION 0x02000000 /* T (6) */
|
||||
#define NTLMSSP_RESERVED4 0x01000000 /* r4 (7) */
|
||||
#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000 /* S (8) */
|
||||
#define NTLMSSP_RESERVEDEQUEST_NON_NT_SESSION_KEY 0x00400000 /* R (9) */
|
||||
#define NTLMSSP_RESERVED5 0x00200000 /* r5 (10) */
|
||||
#define NTLMSSP_NEGOTIATE_IDENTIFY 0x00100000 /* Q (11) */
|
||||
#define NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY 0x00080000 /* P (12) */
|
||||
#define NTLMSSP_RESERVED6 0x00040000 /* r6 (13) */
|
||||
#define NTLMSSP_TARGET_TYPE_SERVER 0x00020000 /* O (14) */
|
||||
#define NTLMSSP_TARGET_TYPE_DOMAIN 0x00010000 /* N (15) */
|
||||
#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000 /* M (16) */
|
||||
#define NTLMSSP_RESERVED7 0x00004000 /* r7 (17) */
|
||||
#define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x00002000 /* L (18) */
|
||||
#define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x00001000 /* K (19) */
|
||||
#define NTLMSSP_NEGOTIATE_ANONYMOUS 0x00000800 /* J (20) */
|
||||
#define NTLMSSP_RESERVED8 0x00000400 /* r8 (21) */
|
||||
#define NTLMSSP_NEGOTIATE_NTLM 0x00000200 /* H (22) */
|
||||
#define NTLMSSP_RESERVED9 0x00000100 /* r9 (23) */
|
||||
#define NTLMSSP_NEGOTIATE_LM_KEY 0x00000080 /* G (24) */
|
||||
#define NTLMSSP_NEGOTIATE_DATAGRAM 0x00000040 /* F (25) */
|
||||
#define NTLMSSP_NEGOTIATE_SEAL 0x00000020 /* E (26) */
|
||||
#define NTLMSSP_NEGOTIATE_SIGN 0x00000010 /* D (27) */
|
||||
#define NTLMSSP_RESERVED10 0x00000008 /* r10 (28) */
|
||||
#define NTLMSSP_REQUEST_TARGET 0x00000004 /* C (29) */
|
||||
#define NTLMSSP_NEGOTIATE_OEM 0x00000002 /* B (30) */
|
||||
#define NTLMSSP_NEGOTIATE_UNICODE 0x00000001 /* A (31) */
|
||||
|
||||
#define WINDOWS_MAJOR_VERSION_5 0x05
|
||||
#define WINDOWS_MAJOR_VERSION_6 0x06
|
||||
#define WINDOWS_MINOR_VERSION_0 0x00
|
||||
#define WINDOWS_MINOR_VERSION_1 0x01
|
||||
#define WINDOWS_MINOR_VERSION_2 0x02
|
||||
#define NTLMSSP_REVISION_W2K3 0x0F
|
||||
|
||||
#define MESSAGE_TYPE_NEGOTIATE 1
|
||||
#define MESSAGE_TYPE_CHALLENGE 2
|
||||
#define MESSAGE_TYPE_AUTHENTICATE 3
|
||||
|
||||
static const char NTLM_SIGNATURE[] = "NTLMSSP";
|
||||
|
||||
/**
|
||||
* Output VERSION structure.\n
|
||||
* VERSION @msdn{cc236654}
|
||||
* @param s
|
||||
*/
|
||||
|
||||
void ntlm_output_version(STREAM* s)
|
||||
{
|
||||
/* The following version information was observed with Windows 7 */
|
||||
|
||||
stream_write_uint8(s, WINDOWS_MAJOR_VERSION_6); /* ProductMajorVersion (1 byte) */
|
||||
stream_write_uint8(s, WINDOWS_MINOR_VERSION_1); /* ProductMinorVersion (1 byte) */
|
||||
stream_write_uint16(s, 7600); /* ProductBuild (2 bytes) */
|
||||
stream_write_zero(s, 3); /* Reserved (3 bytes) */
|
||||
stream_write_uint8(s, NTLMSSP_REVISION_W2K3); /* NTLMRevisionCurrent (1 byte) */
|
||||
}
|
||||
|
||||
SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, SEC_BUFFER* buffer)
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
uint32 negotiateFlags = 0;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, buffer->pvBuffer, buffer->cbBuffer);
|
||||
|
||||
stream_write(s, NTLM_SIGNATURE, 8); /* Signature (8 bytes) */
|
||||
stream_write_uint32(s, MESSAGE_TYPE_NEGOTIATE); /* MessageType */
|
||||
|
||||
if (context->ntlm_v2)
|
||||
{
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_56;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_KEY_EXCH;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_128;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_VERSION;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_NTLM;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_LM_KEY;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_SEAL;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_SIGN;
|
||||
negotiateFlags |= NTLMSSP_REQUEST_TARGET;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_OEM;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_UNICODE;
|
||||
}
|
||||
else
|
||||
{
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_KEY_EXCH;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_128;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_NTLM;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_SEAL;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_SIGN;
|
||||
negotiateFlags |= NTLMSSP_REQUEST_TARGET;
|
||||
negotiateFlags |= NTLMSSP_NEGOTIATE_UNICODE;
|
||||
}
|
||||
|
||||
context->NegotiateFlags = negotiateFlags;
|
||||
|
||||
stream_write_uint32(s, negotiateFlags); /* NegotiateFlags (4 bytes) */
|
||||
|
||||
/* only set if NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED is set */
|
||||
|
||||
/* DomainNameFields (8 bytes) */
|
||||
stream_write_uint16(s, 0); /* DomainNameLen */
|
||||
stream_write_uint16(s, 0); /* DomainNameMaxLen */
|
||||
stream_write_uint32(s, 0); /* DomainNameBufferOffset */
|
||||
|
||||
/* only set if NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED is set */
|
||||
|
||||
/* WorkstationFields (8 bytes) */
|
||||
stream_write_uint16(s, 0); /* WorkstationLen */
|
||||
stream_write_uint16(s, 0); /* WorkstationMaxLen */
|
||||
stream_write_uint32(s, 0); /* WorkstationBufferOffset */
|
||||
|
||||
if (negotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
|
||||
{
|
||||
/* Only present if NTLMSSP_NEGOTIATE_VERSION is set */
|
||||
ntlm_output_version(s);
|
||||
}
|
||||
|
||||
length = s->p - s->data;
|
||||
buffer->cbBuffer = length;
|
||||
|
||||
//freerdp_blob_alloc(&context->negotiate_message, length);
|
||||
//memcpy(context->negotiate_message.data, s->data, length);
|
||||
|
||||
context->state = NTLM_STATE_CHALLENGE;
|
||||
|
||||
return SEC_I_CONTINUE_NEEDED;
|
||||
}
|
22
libfreerdp-auth/NTLM/ntlm_message.h
Normal file
22
libfreerdp-auth/NTLM/ntlm_message.h
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* NTLM Security Package (Message)
|
||||
*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "ntlm.h"
|
||||
|
||||
SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, SEC_BUFFER* buffer);
|
@ -28,6 +28,8 @@
|
||||
#include <freerdp/auth/sspi.h>
|
||||
#include <freerdp/auth/credssp.h>
|
||||
|
||||
#include "sspi.h"
|
||||
|
||||
#include <freerdp/auth/ntlmssp.h>
|
||||
|
||||
#define NTLMSSP_NEGOTIATE_56 0x80000000 /* W (0) */
|
||||
@ -2224,60 +2226,3 @@ void ntlmssp_free(NTLMSSP* ntlmssp)
|
||||
crypto_rc4_free(ntlmssp->recv_rc4_seal);
|
||||
xfree(ntlmssp);
|
||||
}
|
||||
|
||||
/* SSPI */
|
||||
|
||||
SECURITY_STATUS ntlm_AcquireCredentialsHandle(char* pszPrincipal, char* pszPackage,
|
||||
uint32 fCredentialUse, void* pvLogonID, void* pAuthData, void* pGetKeyFn,
|
||||
void* pvGetKeyArgument, CRED_HANDLE* phCredential, SEC_TIMESTAMP* ptsExpiry)
|
||||
{
|
||||
if (fCredentialUse == SECPKG_CRED_OUTBOUND)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
const SEC_PKG_INFO NTLM_SEC_PKG_INFO =
|
||||
{
|
||||
0x00082B37, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x000A, /* wRPCID */
|
||||
0x00000B48, /* cbMaxToken */
|
||||
"NTLM", /* Name */
|
||||
"NTLM Security Package" /* Comment */
|
||||
};
|
||||
|
||||
const SECURITY_FUNCTION_TABLE NTLM_SECURITY_FUNCTION_TABLE =
|
||||
{
|
||||
1, /* dwVersion */
|
||||
NULL, /* EnumerateSecurityPackages */
|
||||
NULL, /* Reserved1 */
|
||||
NULL, /* QueryCredentialsAttributes */
|
||||
ntlm_AcquireCredentialsHandle, /* AcquireCredentialsHandle */
|
||||
NULL, /* FreeCredentialsHandle */
|
||||
NULL, /* Reserved2 */
|
||||
NULL, /* InitializeSecurityContext */
|
||||
NULL, /* AcceptSecurityContext */
|
||||
NULL, /* CompleteAuthToken */
|
||||
NULL, /* DeleteSecurityContext */
|
||||
NULL, /* ApplyControlToken */
|
||||
NULL, /* QueryContextAttributes */
|
||||
NULL, /* ImpersonateSecurityContext */
|
||||
NULL, /* RevertSecurityContext */
|
||||
NULL, /* MakeSignature */
|
||||
NULL, /* VerifySignature */
|
||||
NULL, /* FreeContextBuffer */
|
||||
NULL, /* QuerySecurityPackageInfo */
|
||||
NULL, /* Reserved3 */
|
||||
NULL, /* Reserved4 */
|
||||
NULL, /* ExportSecurityContext */
|
||||
NULL, /* ImportSecurityContext */
|
||||
NULL, /* AddCredentials */
|
||||
NULL, /* Reserved8 */
|
||||
NULL, /* QuerySecurityContextToken */
|
||||
NULL, /* EncryptMessage */
|
||||
NULL, /* DecryptMessage */
|
||||
NULL, /* SetContextAttributes */
|
||||
};
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <freerdp/auth/sspi.h>
|
||||
|
||||
#include "sspi.h"
|
||||
|
||||
/* Authentication Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa374731/ */
|
||||
|
||||
extern const SEC_PKG_INFO NTLM_SEC_PKG_INFO;
|
||||
@ -52,6 +54,99 @@ const SECURITY_FUNCTION_TABLE_NAME SECURITY_FUNCTION_TABLE_NAME_LIST[] =
|
||||
#define SEC_HANDLE_LOWER_MAX 0xFFFFFFFF
|
||||
#define SEC_HANDLE_UPPER_MAX 0xFFFFFFFE
|
||||
|
||||
CREDENTIALS* sspi_CredentialsNew()
|
||||
{
|
||||
CREDENTIALS* credentials;
|
||||
|
||||
credentials = xnew(CREDENTIALS);
|
||||
|
||||
if (credentials != NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return credentials;
|
||||
}
|
||||
|
||||
void sspi_CredentialsFree(CREDENTIALS* credentials)
|
||||
{
|
||||
if (!credentials)
|
||||
return;
|
||||
|
||||
xfree(credentials);
|
||||
}
|
||||
|
||||
SEC_HANDLE* sspi_SecureHandleAlloc()
|
||||
{
|
||||
SEC_HANDLE* handle = xmalloc(sizeof(SEC_HANDLE));
|
||||
sspi_SecureHandleInit(handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sspi_SecureHandleInit(SEC_HANDLE* handle)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
memset(handle, 0xFF, sizeof(SEC_HANDLE));
|
||||
}
|
||||
|
||||
void sspi_SecureHandleInvalidate(SEC_HANDLE* handle)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
sspi_SecureHandleInit(handle);
|
||||
}
|
||||
|
||||
void* sspi_SecureHandleGetLowerPointer(SEC_HANDLE* handle)
|
||||
{
|
||||
void* pointer;
|
||||
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
pointer = (void*) ~((size_t) handle->dwLower);
|
||||
|
||||
return pointer;
|
||||
}
|
||||
|
||||
void sspi_SecureHandleSetLowerPointer(SEC_HANDLE* handle, void* pointer)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
handle->dwLower = (uint32*) (~((size_t) pointer));
|
||||
}
|
||||
|
||||
void* sspi_SecureHandleGetUpperPointer(SEC_HANDLE* handle)
|
||||
{
|
||||
void* pointer;
|
||||
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
pointer = (void*) ~((size_t) handle->dwUpper);
|
||||
|
||||
return pointer;
|
||||
}
|
||||
|
||||
void sspi_SecureHandleSetUpperPointer(SEC_HANDLE* handle, void* pointer)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
handle->dwUpper = (uint32*) (~((size_t) pointer));
|
||||
}
|
||||
|
||||
void sspi_SecureHandleFree(SEC_HANDLE* handle)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
xfree(handle);
|
||||
}
|
||||
|
||||
SECURITY_FUNCTION_TABLE* sspi_GetSecurityFunctionTableByName(const char* Name)
|
||||
{
|
||||
int index;
|
||||
@ -228,6 +323,18 @@ SECURITY_STATUS ExportSecurityContext(CTXT_HANDLE* phContext, uint32 fFlags, SEC
|
||||
|
||||
SECURITY_STATUS FreeCredentialsHandle(CRED_HANDLE* phCredential)
|
||||
{
|
||||
CREDENTIALS* credentials;
|
||||
|
||||
if (!phCredential)
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
|
||||
credentials = (CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
|
||||
|
||||
if (!credentials)
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
|
||||
sspi_CredentialsFree(credentials);
|
||||
|
||||
return SEC_E_OK;
|
||||
}
|
||||
|
||||
@ -238,7 +345,23 @@ SECURITY_STATUS ImportSecurityContext(char* pszPackage, SEC_BUFFER* pPackedConte
|
||||
|
||||
SECURITY_STATUS QueryCredentialsAttributes(CRED_HANDLE* phCredential, uint32 ulAttribute, void* pBuffer)
|
||||
{
|
||||
return SEC_E_OK;
|
||||
char* Name;
|
||||
SECURITY_STATUS status;
|
||||
SECURITY_FUNCTION_TABLE* table;
|
||||
|
||||
Name = (char*) sspi_SecureHandleGetUpperPointer(phCredential);
|
||||
|
||||
if (!Name)
|
||||
return SEC_E_SECPKG_NOT_FOUND;
|
||||
|
||||
table = sspi_GetSecurityFunctionTableByName(Name);
|
||||
|
||||
if (!table)
|
||||
return SEC_E_SECPKG_NOT_FOUND;
|
||||
|
||||
status = table->QueryCredentialsAttributes(phCredential, ulAttribute, pBuffer);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Context Management */
|
||||
@ -283,7 +406,25 @@ SECURITY_STATUS InitializeSecurityContext(CRED_HANDLE* phCredential, CTXT_HANDLE
|
||||
SEC_BUFFER_DESC* pInput, uint32 Reserved2, CTXT_HANDLE* phNewContext,
|
||||
SEC_BUFFER_DESC* pOutput, uint32* pfContextAttr, SEC_TIMESTAMP* ptsExpiry)
|
||||
{
|
||||
return SEC_E_OK;
|
||||
char* Name;
|
||||
SECURITY_STATUS status;
|
||||
SECURITY_FUNCTION_TABLE* table;
|
||||
|
||||
Name = (char*) sspi_SecureHandleGetUpperPointer(phCredential);
|
||||
|
||||
if (!Name)
|
||||
return SEC_E_SECPKG_NOT_FOUND;
|
||||
|
||||
table = sspi_GetSecurityFunctionTableByName(Name);
|
||||
|
||||
if (!table)
|
||||
return SEC_E_SECPKG_NOT_FOUND;
|
||||
|
||||
status = table->InitializeSecurityContext(phCredential, phContext,
|
||||
pszTargetName, fContextReq, Reserved1, TargetDataRep,
|
||||
pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SECURITY_STATUS QueryContextAttributes(CTXT_HANDLE* phContext, uint32 ulAttribute, void* pBuffer)
|
||||
|
44
libfreerdp-auth/sspi.h
Normal file
44
libfreerdp-auth/sspi.h
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Security Support Provider Interface (SSPI)
|
||||
*
|
||||
* Copyright 2012 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_AUTH_SSPI_PRIVATE_H
|
||||
#define FREERDP_AUTH_SSPI_PRIVATE_H
|
||||
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/auth/sspi.h>
|
||||
|
||||
struct _CREDENTIALS
|
||||
{
|
||||
SEC_AUTH_IDENTITY identity;
|
||||
};
|
||||
typedef struct _CREDENTIALS CREDENTIALS;
|
||||
|
||||
CREDENTIALS* sspi_CredentialsNew();
|
||||
void sspi_CredentialsFree(CREDENTIALS* credentials);
|
||||
|
||||
SEC_HANDLE* sspi_SecureHandleAlloc();
|
||||
void sspi_SecureHandleInit(SEC_HANDLE* handle);
|
||||
void sspi_SecureHandleInvalidate(SEC_HANDLE* handle);
|
||||
void* sspi_SecureHandleGetLowerPointer(SEC_HANDLE* handle);
|
||||
void sspi_SecureHandleSetLowerPointer(SEC_HANDLE* handle, void* pointer);
|
||||
void* sspi_SecureHandleGetUpperPointer(SEC_HANDLE* handle);
|
||||
void sspi_SecureHandleSetUpperPointer(SEC_HANDLE* handle, void* pointer);
|
||||
void sspi_SecureHandleFree(SEC_HANDLE* handle);
|
||||
|
||||
#endif /* FREERDP_AUTH_SSPI_PRIVATE_H */
|
@ -282,7 +282,9 @@ uint32 freerdp_keyboard_get_rdp_scancode_from_x11_keycode(uint32 keycode, boolea
|
||||
DEBUG_KBD("x11 keycode: %02X -> rdp code: %02X%s", keycode,
|
||||
X11_KEYCODE_TO_RDP_SCANCODE[keycode].code,
|
||||
X11_KEYCODE_TO_RDP_SCANCODE[keycode].extended ? " extended" : "");
|
||||
|
||||
*extended = X11_KEYCODE_TO_RDP_SCANCODE[keycode].extended;
|
||||
|
||||
return X11_KEYCODE_TO_RDP_SCANCODE[keycode].code;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
extern uint32 RDP_SCANCODE_TO_X11_KEYCODE[256][2];
|
||||
extern RDP_SCANCODE X11_KEYCODE_TO_RDP_SCANCODE[256];
|
||||
extern const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256];
|
||||
extern const uint32 VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[256];
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
@ -34,269 +35,268 @@ extern const uint32 VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[256];
|
||||
|
||||
#include <freerdp/utils/memory.h>
|
||||
|
||||
VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[] =
|
||||
VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[256] =
|
||||
{
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_LBUTTON */
|
||||
{ 0, "", "" }, /* VK_RBUTTON */
|
||||
{ 0, "", "" }, /* VK_CANCEL */
|
||||
{ 0, "", "" }, /* VK_MBUTTON */
|
||||
{ 0, "", "" }, /* VK_XBUTTON1 */
|
||||
{ 0, "", "" }, /* VK_XBUTTON2 */
|
||||
{ 0, "", "" },
|
||||
{ VK_BACK, "BKSP" }, /* VK_BACK */
|
||||
{ VK_TAB, "TAB" }, /* VK_TAB */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_CLEAR */
|
||||
{ VK_RETURN, "RTRN", "KPEN" }, /* VK_RETURN */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_SHIFT, "LFSH" }, /* VK_SHIFT */
|
||||
{ VK_CONTROL, "" }, /* VK_CONTROL */
|
||||
{ VK_MENU, "LALT" }, /* VK_MENU */
|
||||
{ 0, "", "PAUS" }, /* VK_PAUSE */
|
||||
{ VK_CAPITAL, "CAPS" }, /* VK_CAPITAL */
|
||||
{ 0, "", "" }, /* VK_KANA / VK_HANGUL */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_JUNJA */
|
||||
{ 0, "", "" }, /* VK_FINAL */
|
||||
{ 0, "", "" }, /* VK_HANJA / VK_KANJI */
|
||||
{ 0, "", "" },
|
||||
{ VK_ESCAPE, "ESC" }, /* VK_ESCAPE */
|
||||
{ 0, "", "" }, /* VK_CONVERT */
|
||||
{ 0, "", "" }, /* VK_NONCONVERT */
|
||||
{ 0, "", "" }, /* VK_ACCEPT */
|
||||
{ 0, "", "" }, /* VK_MODECHANGE */
|
||||
{ VK_SPACE, "SPCE" }, /* VK_SPACE */
|
||||
{ 0, "", "PGUP" }, /* VK_PRIOR */
|
||||
{ 0, "", "PGDN" }, /* VK_NEXT */
|
||||
{ 0, "", "END" }, /* VK_END */
|
||||
{ 0, "", "HOME" }, /* VK_HOME */
|
||||
{ 0, "", "LEFT" }, /* VK_LEFT */
|
||||
{ 0, "", "UP" }, /* VK_UP */
|
||||
{ 0, "", "RGHT" }, /* VK_RIGHT */
|
||||
{ 0, "", "DOWN" }, /* VK_DOWN */
|
||||
{ 0, "", "" }, /* VK_SELECT */
|
||||
{ 0, "", "PRSC" }, /* VK_PRINT */
|
||||
{ 0, "", "" }, /* VK_EXECUTE */
|
||||
{ 0, "", "" }, /* VK_SNAPSHOT */
|
||||
{ 0, "", "INS" }, /* VK_INSERT */
|
||||
{ 0, "", "DELE" }, /* VK_DELETE */
|
||||
{ 0, "", "" }, /* VK_HELP */
|
||||
{ VK_KEY_0, "AE10" }, /* VK_KEY_0 */
|
||||
{ VK_KEY_1, "AE01" }, /* VK_KEY_1 */
|
||||
{ VK_KEY_2, "AE02" }, /* VK_KEY_2 */
|
||||
{ VK_KEY_3, "AE03" }, /* VK_KEY_3 */
|
||||
{ VK_KEY_4, "AE04" }, /* VK_KEY_4 */
|
||||
{ VK_KEY_5, "AE05" }, /* VK_KEY_5 */
|
||||
{ VK_KEY_6, "AE06" }, /* VK_KEY_6 */
|
||||
{ VK_KEY_7, "AE07" }, /* VK_KEY_7 */
|
||||
{ VK_KEY_8, "AE08" }, /* VK_KEY_8 */
|
||||
{ VK_KEY_9, "AE09" }, /* VK_KEY_9 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_KEY_A, "AC01" }, /* VK_KEY_A */
|
||||
{ VK_KEY_B, "AB05" }, /* VK_KEY_B */
|
||||
{ VK_KEY_C, "AB03" }, /* VK_KEY_C */
|
||||
{ VK_KEY_D, "AC03" }, /* VK_KEY_D */
|
||||
{ VK_KEY_E, "AD03" }, /* VK_KEY_E */
|
||||
{ VK_KEY_F, "AC04" }, /* VK_KEY_F */
|
||||
{ VK_KEY_G, "AC05" }, /* VK_KEY_G */
|
||||
{ VK_KEY_H, "AC06" }, /* VK_KEY_H */
|
||||
{ VK_KEY_I, "AD08" }, /* VK_KEY_I */
|
||||
{ VK_KEY_J, "AC07" }, /* VK_KEY_J */
|
||||
{ VK_KEY_K, "AC08" }, /* VK_KEY_K */
|
||||
{ VK_KEY_L, "AC09" }, /* VK_KEY_L */
|
||||
{ VK_KEY_M, "AB07" }, /* VK_KEY_M */
|
||||
{ VK_KEY_N, "AB06" }, /* VK_KEY_N */
|
||||
{ VK_KEY_O, "AD09" }, /* VK_KEY_O */
|
||||
{ VK_KEY_P, "AD10" }, /* VK_KEY_P */
|
||||
{ VK_KEY_Q, "AD01" }, /* VK_KEY_Q */
|
||||
{ VK_KEY_R, "AD04" }, /* VK_KEY_R */
|
||||
{ VK_KEY_S, "AC02" }, /* VK_KEY_S */
|
||||
{ VK_KEY_T, "AD05" }, /* VK_KEY_T */
|
||||
{ VK_KEY_U, "AD07" }, /* VK_KEY_U */
|
||||
{ VK_KEY_V, "AB04" }, /* VK_KEY_V */
|
||||
{ VK_KEY_W, "AD02" }, /* VK_KEY_W */
|
||||
{ VK_KEY_X, "AB02" }, /* VK_KEY_X */
|
||||
{ VK_KEY_Y, "AD06" }, /* VK_KEY_Y */
|
||||
{ VK_KEY_Z, "AB01" }, /* VK_KEY_Z */
|
||||
{ 0, "", "LWIN" }, /* VK_LWIN */
|
||||
{ 0, "", "RWIN" }, /* VK_RWIN */
|
||||
{ 0, "", "COMP" }, /* VK_APPS */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_SLEEP */
|
||||
{ VK_NUMPAD0, "KP0" }, /* VK_NUMPAD0 */
|
||||
{ VK_NUMPAD1, "KP1" }, /* VK_NUMPAD1 */
|
||||
{ VK_NUMPAD2, "KP2" }, /* VK_NUMPAD2 */
|
||||
{ VK_NUMPAD3, "KP3" }, /* VK_NUMPAD3 */
|
||||
{ VK_NUMPAD4, "KP4" }, /* VK_NUMPAD4 */
|
||||
{ VK_NUMPAD5, "KP5" }, /* VK_NUMPAD5 */
|
||||
{ VK_NUMPAD6, "KP6" }, /* VK_NUMPAD6 */
|
||||
{ VK_NUMPAD7, "KP7" }, /* VK_NUMPAD7 */
|
||||
{ VK_NUMPAD8, "KP8" }, /* VK_NUMPAD8 */
|
||||
{ VK_NUMPAD9, "KP9" }, /* VK_NUMPAD9 */
|
||||
{ VK_MULTIPLY, "KPMU" }, /* VK_MULTIPLY */
|
||||
{ VK_ADD, "KPAD" }, /* VK_ADD */
|
||||
{ 0, "", "" }, /* VK_SEPARATOR */
|
||||
{ VK_SUBTRACT, "KPSU" }, /* VK_SUBTRACT */
|
||||
{ VK_DECIMAL, "KPDL" }, /* VK_DECIMAL */
|
||||
{ VK_DIVIDE, "AB10", "KPDV" }, /* VK_DIVIDE */
|
||||
{ VK_F1, "FK01" }, /* VK_F1 */
|
||||
{ VK_F2, "FK02" }, /* VK_F2 */
|
||||
{ VK_F3, "FK03" }, /* VK_F3 */
|
||||
{ VK_F4, "FK04" }, /* VK_F4 */
|
||||
{ VK_F5, "FK05" }, /* VK_F5 */
|
||||
{ VK_F6, "FK06" }, /* VK_F6 */
|
||||
{ VK_F7, "FK07" }, /* VK_F7 */
|
||||
{ VK_F8, "FK08" }, /* VK_F8 */
|
||||
{ VK_F9, "FK09" }, /* VK_F9 */
|
||||
{ VK_F10, "FK10" }, /* VK_F10 */
|
||||
{ VK_F11, "FK11" }, /* VK_F11 */
|
||||
{ VK_F12, "FK12" }, /* VK_F12 */
|
||||
{ 0, "", "" }, /* VK_F13 */
|
||||
{ 0, "", "" }, /* VK_F14 */
|
||||
{ 0, "", "" }, /* VK_F15 */
|
||||
{ 0, "", "" }, /* VK_F16 */
|
||||
{ 0, "", "" }, /* VK_F17 */
|
||||
{ 0, "", "" }, /* VK_F18 */
|
||||
{ 0, "", "" }, /* VK_F19 */
|
||||
{ 0, "", "" }, /* VK_F20 */
|
||||
{ 0, "", "" }, /* VK_F21 */
|
||||
{ 0, "", "" }, /* VK_F22 */
|
||||
{ 0, "", "" }, /* VK_F23 */
|
||||
{ 0, "", "" }, /* VK_F24 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_NUMLOCK, "NMLK" }, /* VK_NUMLOCK */
|
||||
{ VK_SCROLL, "SCLK" }, /* VK_SCROLL */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_LSHIFT, "" }, /* VK_LSHIFT */
|
||||
{ VK_RSHIFT, "RTSH" }, /* VK_RSHIFT */
|
||||
{ VK_LCONTROL, "LCTL" }, /* VK_LCONTROL */
|
||||
{ 0, "", "RCTL" }, /* VK_RCONTROL */
|
||||
{ VK_LMENU, "" }, /* VK_LMENU */
|
||||
{ 0, "", "RALT" }, /* VK_RMENU */
|
||||
{ 0, "", "" }, /* VK_BROWSER_BACK */
|
||||
{ 0, "", "" }, /* VK_BROWSER_FORWARD */
|
||||
{ 0, "", "" }, /* VK_BROWSER_REFRESH */
|
||||
{ 0, "", "" }, /* VK_BROWSER_STOP */
|
||||
{ 0, "", "" }, /* VK_BROWSER_SEARCH */
|
||||
{ 0, "", "" }, /* VK_BROWSER_FAVORITES */
|
||||
{ 0, "", "" }, /* VK_BROWSER_HOME */
|
||||
{ 0, "", "" }, /* VK_VOLUME_MUTE */
|
||||
{ 0, "", "" }, /* VK_VOLUME_DOWN */
|
||||
{ 0, "", "" }, /* VK_VOLUME_UP */
|
||||
{ 0, "", "" }, /* VK_MEDIA_NEXT_TRACK */
|
||||
{ 0, "", "" }, /* VK_MEDIA_PREV_TRACK */
|
||||
{ 0, "", "" }, /* VK_MEDIA_STOP */
|
||||
{ 0, "", "" }, /* VK_MEDIA_PLAY_PAUSE */
|
||||
{ 0, "", "" }, /* VK_LAUNCH_MAIL */
|
||||
{ 0, "", "" }, /* VK_MEDIA_SELECT */
|
||||
{ 0, "", "" }, /* VK_LAUNCH_APP1 */
|
||||
{ 0, "", "" }, /* VK_LAUNCH_APP2 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_OEM_1, "AC10" }, /* VK_OEM_1 */
|
||||
{ VK_OEM_PLUS, "AE12" }, /* VK_OEM_PLUS */
|
||||
{ VK_OEM_COMMA, "AB08" }, /* VK_OEM_COMMA */
|
||||
{ VK_OEM_MINUS, "AE11" }, /* VK_OEM_MINUS */
|
||||
{ VK_OEM_PERIOD, "AB09" }, /* VK_OEM_PERIOD */
|
||||
{ VK_OEM_2, "AB10" }, /* VK_OEM_2 */
|
||||
{ VK_OEM_3, "TLDE" }, /* VK_OEM_3 */
|
||||
{ VK_ABNT_C1, "AB11" }, /* VK_ABNT_C1 */
|
||||
{ VK_ABNT_C2, "I129" }, /* VK_ABNT_C2 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_OEM_4, "AD11" }, /* VK_OEM_4 */
|
||||
{ VK_OEM_5, "BKSL" }, /* VK_OEM_5 */
|
||||
{ VK_OEM_6, "AD12" }, /* VK_OEM_6 */
|
||||
{ VK_OEM_7, "AC11" }, /* VK_OEM_7 */
|
||||
{ 0, "", "" }, /* VK_OEM_8 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_OEM_102, "LSGT" }, /* VK_OEM_102 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_PROCESSKEY */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_PACKET */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_ATTN */
|
||||
{ 0, "", "" }, /* VK_CRSEL */
|
||||
{ 0, "", "" }, /* VK_EXSEL */
|
||||
{ 0, "", "" }, /* VK_EREOF */
|
||||
{ 0, "", "" }, /* VK_PLAY */
|
||||
{ 0, "", "" }, /* VK_ZOOM */
|
||||
{ 0, "", "" }, /* VK_NONAME */
|
||||
{ 0, "", "" }, /* VK_PA1 */
|
||||
{ 0, "", "" }, /* VK_OEM_CLEAR */
|
||||
{ 0, "" }
|
||||
{ 0, "", "" },
|
||||
{ VK_LBUTTON, "", "" }, /* VK_LBUTTON */
|
||||
{ VK_RBUTTON, "", "" }, /* VK_RBUTTON */
|
||||
{ VK_CANCEL, "", "" }, /* VK_CANCEL */
|
||||
{ VK_MBUTTON, "", "" }, /* VK_MBUTTON */
|
||||
{ VK_XBUTTON1, "", "" }, /* VK_XBUTTON1 */
|
||||
{ VK_XBUTTON2, "", "" }, /* VK_XBUTTON2 */
|
||||
{ 0, "", "" },
|
||||
{ VK_BACK, "BKSP", "" }, /* VK_BACK */
|
||||
{ VK_TAB, "TAB", "" }, /* VK_TAB */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" }, /* VK_CLEAR */
|
||||
{ VK_RETURN, "RTRN", "KPEN" }, /* VK_RETURN */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_SHIFT, "LFSH", "" }, /* VK_SHIFT */
|
||||
{ VK_CONTROL, "", "" }, /* VK_CONTROL */
|
||||
{ VK_MENU, "LALT", "" }, /* VK_MENU */
|
||||
{ VK_PAUSE, "", "PAUS" }, /* VK_PAUSE */
|
||||
{ VK_CAPITAL, "CAPS", "" }, /* VK_CAPITAL */
|
||||
{ VK_KANA, "", "" }, /* VK_KANA / VK_HANGUL */
|
||||
{ 0, "", "" },
|
||||
{ VK_JUNJA, "", "" }, /* VK_JUNJA */
|
||||
{ VK_FINAL, "", "" }, /* VK_FINAL */
|
||||
{ VK_KANJI, "", "" }, /* VK_HANJA / VK_KANJI */
|
||||
{ 0, "", "" },
|
||||
{ VK_ESCAPE, "ESC", "" }, /* VK_ESCAPE */
|
||||
{ VK_CONVERT, "", "" }, /* VK_CONVERT */
|
||||
{ VK_NONCONVERT, "", "" }, /* VK_NONCONVERT */
|
||||
{ VK_ACCEPT, "", "" }, /* VK_ACCEPT */
|
||||
{ VK_MODECHANGE, "", "" }, /* VK_MODECHANGE */
|
||||
{ VK_SPACE, "SPCE", "" }, /* VK_SPACE */
|
||||
{ VK_PRIOR, "", "PGUP" }, /* VK_PRIOR */
|
||||
{ VK_NEXT, "", "PGDN" }, /* VK_NEXT */
|
||||
{ VK_END, "", "END" }, /* VK_END */
|
||||
{ VK_HOME, "", "HOME" }, /* VK_HOME */
|
||||
{ VK_LEFT, "", "LEFT" }, /* VK_LEFT */
|
||||
{ VK_UP, "", "UP" }, /* VK_UP */
|
||||
{ VK_RIGHT, "", "RGHT" }, /* VK_RIGHT */
|
||||
{ VK_DOWN, "", "DOWN" }, /* VK_DOWN */
|
||||
{ VK_SELECT, "", "" }, /* VK_SELECT */
|
||||
{ VK_PRINT, "", "PRSC" }, /* VK_PRINT */
|
||||
{ VK_EXECUTE, "", "" }, /* VK_EXECUTE */
|
||||
{ VK_SNAPSHOT, "", "" }, /* VK_SNAPSHOT */
|
||||
{ VK_INSERT, "", "INS" }, /* VK_INSERT */
|
||||
{ VK_DELETE, "", "DELE" }, /* VK_DELETE */
|
||||
{ VK_HELP, "", "" }, /* VK_HELP */
|
||||
{ VK_KEY_0, "AE10", "" }, /* VK_KEY_0 */
|
||||
{ VK_KEY_1, "AE01", "" }, /* VK_KEY_1 */
|
||||
{ VK_KEY_2, "AE02", "" }, /* VK_KEY_2 */
|
||||
{ VK_KEY_3, "AE03", "" }, /* VK_KEY_3 */
|
||||
{ VK_KEY_4, "AE04", "" }, /* VK_KEY_4 */
|
||||
{ VK_KEY_5, "AE05", "" }, /* VK_KEY_5 */
|
||||
{ VK_KEY_6, "AE06", "" }, /* VK_KEY_6 */
|
||||
{ VK_KEY_7, "AE07", "" }, /* VK_KEY_7 */
|
||||
{ VK_KEY_8, "AE08", "" }, /* VK_KEY_8 */
|
||||
{ VK_KEY_9, "AE09", "" }, /* VK_KEY_9 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_KEY_A, "AC01", "" }, /* VK_KEY_A */
|
||||
{ VK_KEY_B, "AB05", "" }, /* VK_KEY_B */
|
||||
{ VK_KEY_C, "AB03", "" }, /* VK_KEY_C */
|
||||
{ VK_KEY_D, "AC03", "" }, /* VK_KEY_D */
|
||||
{ VK_KEY_E, "AD03", "" }, /* VK_KEY_E */
|
||||
{ VK_KEY_F, "AC04", "" }, /* VK_KEY_F */
|
||||
{ VK_KEY_G, "AC05", "" }, /* VK_KEY_G */
|
||||
{ VK_KEY_H, "AC06", "" }, /* VK_KEY_H */
|
||||
{ VK_KEY_I, "AD08", "" }, /* VK_KEY_I */
|
||||
{ VK_KEY_J, "AC07", "" }, /* VK_KEY_J */
|
||||
{ VK_KEY_K, "AC08", "" }, /* VK_KEY_K */
|
||||
{ VK_KEY_L, "AC09", "" }, /* VK_KEY_L */
|
||||
{ VK_KEY_M, "AB07", "" }, /* VK_KEY_M */
|
||||
{ VK_KEY_N, "AB06", "" }, /* VK_KEY_N */
|
||||
{ VK_KEY_O, "AD09", "" }, /* VK_KEY_O */
|
||||
{ VK_KEY_P, "AD10", "" }, /* VK_KEY_P */
|
||||
{ VK_KEY_Q, "AD01", "" }, /* VK_KEY_Q */
|
||||
{ VK_KEY_R, "AD04", "" }, /* VK_KEY_R */
|
||||
{ VK_KEY_S, "AC02", "" }, /* VK_KEY_S */
|
||||
{ VK_KEY_T, "AD05", "" }, /* VK_KEY_T */
|
||||
{ VK_KEY_U, "AD07", "" }, /* VK_KEY_U */
|
||||
{ VK_KEY_V, "AB04", "" }, /* VK_KEY_V */
|
||||
{ VK_KEY_W, "AD02", "" }, /* VK_KEY_W */
|
||||
{ VK_KEY_X, "AB02", "" }, /* VK_KEY_X */
|
||||
{ VK_KEY_Y, "AD06", "" }, /* VK_KEY_Y */
|
||||
{ VK_KEY_Z, "AB01", "" }, /* VK_KEY_Z */
|
||||
{ VK_LWIN, "", "LWIN" }, /* VK_LWIN */
|
||||
{ VK_RWIN, "", "RWIN" }, /* VK_RWIN */
|
||||
{ VK_APPS, "", "COMP" }, /* VK_APPS */
|
||||
{ 0, "", "" },
|
||||
{ VK_SLEEP, "", "" }, /* VK_SLEEP */
|
||||
{ VK_NUMPAD0, "KP0", "" }, /* VK_NUMPAD0 */
|
||||
{ VK_NUMPAD1, "KP1", "" }, /* VK_NUMPAD1 */
|
||||
{ VK_NUMPAD2, "KP2", "" }, /* VK_NUMPAD2 */
|
||||
{ VK_NUMPAD3, "KP3", "" }, /* VK_NUMPAD3 */
|
||||
{ VK_NUMPAD4, "KP4", "" }, /* VK_NUMPAD4 */
|
||||
{ VK_NUMPAD5, "KP5", "" }, /* VK_NUMPAD5 */
|
||||
{ VK_NUMPAD6, "KP6", "" }, /* VK_NUMPAD6 */
|
||||
{ VK_NUMPAD7, "KP7", "" }, /* VK_NUMPAD7 */
|
||||
{ VK_NUMPAD8, "KP8", "" }, /* VK_NUMPAD8 */
|
||||
{ VK_NUMPAD9, "KP9", "" }, /* VK_NUMPAD9 */
|
||||
{ VK_MULTIPLY, "KPMU", "" }, /* VK_MULTIPLY */
|
||||
{ VK_ADD, "KPAD", "" }, /* VK_ADD */
|
||||
{ VK_SEPARATOR, "", "" }, /* VK_SEPARATOR */
|
||||
{ VK_SUBTRACT, "KPSU", "" }, /* VK_SUBTRACT */
|
||||
{ VK_DECIMAL, "KPDL", "" }, /* VK_DECIMAL */
|
||||
{ VK_DIVIDE, "AB10", "KPDV" }, /* VK_DIVIDE */
|
||||
{ VK_F1, "FK01", "" }, /* VK_F1 */
|
||||
{ VK_F2, "FK02", "" }, /* VK_F2 */
|
||||
{ VK_F3, "FK03", "" }, /* VK_F3 */
|
||||
{ VK_F4, "FK04", "" }, /* VK_F4 */
|
||||
{ VK_F5, "FK05", "" }, /* VK_F5 */
|
||||
{ VK_F6, "FK06", "" }, /* VK_F6 */
|
||||
{ VK_F7, "FK07", "" }, /* VK_F7 */
|
||||
{ VK_F8, "FK08", "" }, /* VK_F8 */
|
||||
{ VK_F9, "FK09", "" }, /* VK_F9 */
|
||||
{ VK_F10, "FK10", "" }, /* VK_F10 */
|
||||
{ VK_F11, "FK11", "" }, /* VK_F11 */
|
||||
{ VK_F12, "FK12", "" }, /* VK_F12 */
|
||||
{ VK_F13, "", "" }, /* VK_F13 */
|
||||
{ VK_F14, "", "" }, /* VK_F14 */
|
||||
{ VK_F15, "", "" }, /* VK_F15 */
|
||||
{ VK_F16, "", "" }, /* VK_F16 */
|
||||
{ VK_F17, "", "" }, /* VK_F17 */
|
||||
{ VK_F18, "", "" }, /* VK_F18 */
|
||||
{ VK_F19, "", "" }, /* VK_F19 */
|
||||
{ VK_F20, "", "" }, /* VK_F20 */
|
||||
{ VK_F21, "", "" }, /* VK_F21 */
|
||||
{ VK_F22, "", "" }, /* VK_F22 */
|
||||
{ VK_F23, "", "" }, /* VK_F23 */
|
||||
{ VK_F24, "", "" }, /* VK_F24 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_NUMLOCK, "NMLK", "" }, /* VK_NUMLOCK */
|
||||
{ VK_SCROLL, "SCLK", "" }, /* VK_SCROLL */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_LSHIFT, "", "" }, /* VK_LSHIFT */
|
||||
{ VK_RSHIFT, "RTSH", "" }, /* VK_RSHIFT */
|
||||
{ VK_LCONTROL, "LCTL", "" }, /* VK_LCONTROL */
|
||||
{ VK_RCONTROL, "", "RCTL" }, /* VK_RCONTROL */
|
||||
{ VK_LMENU, "", "" }, /* VK_LMENU */
|
||||
{ VK_RMENU, "", "RALT" }, /* VK_RMENU */
|
||||
{ VK_BROWSER_BACK, "", "" }, /* VK_BROWSER_BACK */
|
||||
{ VK_BROWSER_FORWARD, "", "" }, /* VK_BROWSER_FORWARD */
|
||||
{ VK_BROWSER_REFRESH, "", "" }, /* VK_BROWSER_REFRESH */
|
||||
{ VK_BROWSER_STOP, "", "" }, /* VK_BROWSER_STOP */
|
||||
{ VK_BROWSER_SEARCH, "", "" }, /* VK_BROWSER_SEARCH */
|
||||
{ VK_BROWSER_FAVORITES, "", "" }, /* VK_BROWSER_FAVORITES */
|
||||
{ VK_BROWSER_HOME, "", "" }, /* VK_BROWSER_HOME */
|
||||
{ VK_VOLUME_MUTE, "", "" }, /* VK_VOLUME_MUTE */
|
||||
{ VK_VOLUME_DOWN, "", "" }, /* VK_VOLUME_DOWN */
|
||||
{ VK_VOLUME_UP, "", "" }, /* VK_VOLUME_UP */
|
||||
{ VK_MEDIA_NEXT_TRACK, "", "" }, /* VK_MEDIA_NEXT_TRACK */
|
||||
{ VK_MEDIA_PREV_TRACK, "", "" }, /* VK_MEDIA_PREV_TRACK */
|
||||
{ VK_MEDIA_STOP, "", "" }, /* VK_MEDIA_STOP */
|
||||
{ VK_MEDIA_PLAY_PAUSE, "", "" }, /* VK_MEDIA_PLAY_PAUSE */
|
||||
{ VK_LAUNCH_MAIL, "", "" }, /* VK_LAUNCH_MAIL */
|
||||
{ VK_MEDIA_SELECT, "", "" }, /* VK_MEDIA_SELECT */
|
||||
{ VK_LAUNCH_APP1, "", "" }, /* VK_LAUNCH_APP1 */
|
||||
{ VK_LAUNCH_APP2, "", "" }, /* VK_LAUNCH_APP2 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_OEM_1, "AC10", "" }, /* VK_OEM_1 */
|
||||
{ VK_OEM_PLUS, "AE12", "" }, /* VK_OEM_PLUS */
|
||||
{ VK_OEM_COMMA, "AB08", "" }, /* VK_OEM_COMMA */
|
||||
{ VK_OEM_MINUS, "AE11", "" }, /* VK_OEM_MINUS */
|
||||
{ VK_OEM_PERIOD, "AB09", "" }, /* VK_OEM_PERIOD */
|
||||
{ VK_OEM_2, "AB10", "" }, /* VK_OEM_2 */
|
||||
{ VK_OEM_3, "TLDE", "" }, /* VK_OEM_3 */
|
||||
{ VK_ABNT_C1, "AB11", "" }, /* VK_ABNT_C1 */
|
||||
{ VK_ABNT_C2, "I129", "" }, /* VK_ABNT_C2 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_OEM_4, "AD11", "" }, /* VK_OEM_4 */
|
||||
{ VK_OEM_5, "BKSL", "" }, /* VK_OEM_5 */
|
||||
{ VK_OEM_6, "AD12", "" }, /* VK_OEM_6 */
|
||||
{ VK_OEM_7, "AC11", "" }, /* VK_OEM_7 */
|
||||
{ VK_OEM_8, "", "" }, /* VK_OEM_8 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_OEM_102, "LSGT", "" }, /* VK_OEM_102 */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_PROCESSKEY, "", "" }, /* VK_PROCESSKEY */
|
||||
{ 0, "", "" },
|
||||
{ VK_PACKET, "", "" }, /* VK_PACKET */
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ 0, "", "" },
|
||||
{ VK_ATTN, "", "" }, /* VK_ATTN */
|
||||
{ VK_CRSEL, "", "" }, /* VK_CRSEL */
|
||||
{ VK_EXSEL, "", "" }, /* VK_EXSEL */
|
||||
{ VK_EREOF, "", "" }, /* VK_EREOF */
|
||||
{ VK_PLAY, "", "" }, /* VK_PLAY */
|
||||
{ VK_ZOOM, "", "" }, /* VK_ZOOM */
|
||||
{ VK_NONAME, "", "" }, /* VK_NONAME */
|
||||
{ VK_PA1, "", "" }, /* VK_PA1 */
|
||||
{ VK_OEM_CLEAR, "", "" }, /* VK_OEM_CLEAR */
|
||||
{ 0, "", "" }
|
||||
};
|
||||
|
||||
/*
|
||||
{ 0x54, 0, "" , "LVL3" },
|
||||
{ 0x1C, 1, "" , "KPEN" }
|
||||
*/
|
||||
|
||||
void* freerdp_keyboard_xkb_init()
|
||||
@ -407,8 +407,10 @@ uint32 detect_keyboard_layout_from_xkb(void* display)
|
||||
int freerdp_keyboard_load_map_from_xkb(void* display)
|
||||
{
|
||||
int i, j;
|
||||
uint32 vkcode;
|
||||
boolean found;
|
||||
XkbDescPtr xkb;
|
||||
uint32 scancode;
|
||||
boolean extended;
|
||||
boolean status = false;
|
||||
|
||||
@ -426,10 +428,14 @@ int freerdp_keyboard_load_map_from_xkb(void* display)
|
||||
|
||||
for (j = 0; j < 256; j++)
|
||||
{
|
||||
if (strlen(xkb_keyname) < 1)
|
||||
continue;
|
||||
|
||||
if (VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].xkb_keyname)
|
||||
{
|
||||
if (!strcmp(xkb_keyname, VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].xkb_keyname))
|
||||
{
|
||||
vkcode = j;
|
||||
extended = false;
|
||||
found = true;
|
||||
break;
|
||||
@ -440,6 +446,14 @@ int freerdp_keyboard_load_map_from_xkb(void* display)
|
||||
{
|
||||
if (!strcmp(xkb_keyname, VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].xkb_keyname_extended))
|
||||
{
|
||||
vkcode = j;
|
||||
|
||||
if (VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].vkcode != vkcode)
|
||||
{
|
||||
printf("error at vkcode %d vs vkcode %d", vkcode,
|
||||
VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].vkcode);
|
||||
}
|
||||
|
||||
extended = true;
|
||||
found = true;
|
||||
break;
|
||||
@ -449,8 +463,7 @@ int freerdp_keyboard_load_map_from_xkb(void* display)
|
||||
|
||||
if (found)
|
||||
{
|
||||
uint32 vkcode = VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].vkcode;
|
||||
uint32 scancode = VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode];
|
||||
scancode = VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode];
|
||||
|
||||
DEBUG_KBD("%4s: keycode: 0x%02X -> vkcode: 0x%02X -> rdp scancode: 0x%02X %s",
|
||||
xkb_keyname, i, vkcode, scancode, extended ? " extended" : "");
|
||||
|
Loading…
Reference in New Issue
Block a user