Author: phater
Date: Tue May 16 16:37:29 2017
New Revision: 74556
URL:
http://svn.reactos.org/svn/reactos?rev=74556&view=rev
Log:
[MSTSC] Bring MSTSC closer to latest rdesktop (1.83) CORE-13258
Modified:
trunk/reactos/base/applications/mstsc/constants.h
trunk/reactos/base/applications/mstsc/licence.c
trunk/reactos/base/applications/mstsc/precomp.h
trunk/reactos/base/applications/mstsc/proto.h
trunk/reactos/base/applications/mstsc/rdp.c
trunk/reactos/base/applications/mstsc/secure.c
trunk/reactos/base/applications/mstsc/ssl_calls.c
trunk/reactos/base/applications/mstsc/uimain.c
Modified: trunk/reactos/base/applications/mstsc/constants.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/co…
==============================================================================
--- trunk/reactos/base/applications/mstsc/constants.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/constants.h [iso-8859-1] Tue May 16 16:37:29
2017
@@ -94,11 +94,23 @@
#define SEC_PADDING_SIZE 8
#define SEC_EXPONENT_SIZE 4
-#define SEC_CLIENT_RANDOM 0x0001
+/* TS_SECURITY_HEADER.flags */
+#define SEC_EXCHANGE_PKT 0x0001
+#define SEC_TRANSPORT_REQ 0x0002
+#define RDP_SEC_TRANSPORT_RSP 0x0004
#define SEC_ENCRYPT 0x0008
-#define SEC_LOGON_INFO 0x0040
-#define SEC_LICENCE_NEG 0x0080
-#define SEC_REDIRECT_ENCRYPT 0x0C00
+#define SEC_RESET_SEQNO 0x0010
+#define SEC_IGNORE_SEQNO 0x0020
+#define SEC_INFO_PKT 0x0040
+#define SEC_LICENSE_PKT 0x0080
+#define SEC_LICENSE_ENCRYPT_CS 0x0200
+#define SEC_LICENSE_ENCRYPT_SC 0x0200
+#define SEC_REDIRECTION_PKT 0x0400
+#define SEC_SECURE_CHECKSUM 0x0800
+#define SEC_AUTODETECT_REQ 0x1000
+#define SEC_AUTODETECT_RSP 0x2000
+#define SEC_HEARTBEAT 0x4000
+#define SEC_FLAGSHI_VALID 0x8000
#define SEC_TAG_SRV_INFO 0x0c01
#define SEC_TAG_SRV_CRYPT 0x0c02
@@ -131,12 +143,12 @@
#define LICENCE_SIGNATURE_SIZE 16
#define LICENCE_TAG_REQUEST 0x01
-#define LICENCE_TAG_PLATFORM_CHALLENGE 0x02
+#define LICENCE_TAG_PLATFORM_CHALLANGE 0x02
#define LICENCE_TAG_NEW_LICENCE 0x03
#define LICENCE_TAG_UPGRADE_LICENCE 0x04
#define LICENCE_TAG_LICENCE_INFO 0x12
#define LICENCE_TAG_NEW_LICENCE_REQUEST 0x13
-#define LICENCE_TAG_PLATFORM_CHALLENGE_RESPONSE 0x15
+#define LICENCE_TAG_PLATFORM_CHALLANGE_RESPONSE 0x15
#define LICENCE_TAG_ERROR_ALERT 0xff
#define BB_CLIENT_USER_NAME_BLOB 0x000f
@@ -323,19 +335,20 @@
#define RDP_INFO_AUTOLOGON 0x00000008
#define RDP_INFO_UNICODE 0x00000010
#define RDP_INFO_MAXIMIZESHELL 0x00000020
-#define RDP_INFO_COMPRESSION 0x00000080 /* mppc compression with 8kB history buffer
*/
+#define RDP_INFO_COMPRESSION 0x00000080 /* mppc compression with 8kB histroy buffer
*/
#define RDP_INFO_ENABLEWINDOWSKEY 0x00000100
#define RDP_INFO_COMPRESSION2 0x00000200 /* rdp5 mppc compression with 64kB history
buffer */
#define RDP_INFO_REMOTE_CONSOLE_AUDIO 0x00002000
#define RDP_INFO_PASSWORD_IS_SC_PIN 0x00040000
-#define RDP5_DISABLE_NOTHING 0x00
-#define RDP5_NO_WALLPAPER 0x01
-#define RDP5_NO_FULLWINDOWDRAG 0x02
-#define RDP5_NO_MENUANIMATIONS 0x04
-#define RDP5_NO_THEMING 0x08
-#define RDP5_NO_CURSOR_SHADOW 0x20
-#define RDP5_NO_CURSORSETTINGS 0x40 /* disables cursor blinking */
+/* TS_EXTENDED_INFO_PACKET.performanceFlags */
+#define PERF_DISABLE_WALLPAPER 0x01
+#define PERF_DISABLE_FULLWINDOWDRAG 0x02
+#define PERF_DISABLE_MENUANIMATIONS 0x04
+#define PERF_DISABLE_THEMING 0x08
+#define PERF_DISABLE_CURSOR_SHADOW 0x20
+#define PERF_DISABLE_CURSORSETTINGS 0x40 /* disables cursor blinking */
+#define PERF_ENABLE_FONT_SMOOTHING 0x80
/* compression types */
#define RDP_MPPC_BIG 0x01
@@ -481,6 +494,48 @@
#define FILE_DELETE_ON_CLOSE 0x00001000
#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
+#define CAP_GENERAL_TYPE 0x0001
+#define CAP_PRINTER_TYPE 0x0002
+#define CAP_PORT_TYPE 0x0003
+#define CAP_DRIVE_TYPE 0x0004
+#define CAP_SMARTCARD_TYPE 0x0005
+
+#define GENERAL_CAPABILITY_VERSION_01 0x00000001
+#define GENERAL_CAPABILITY_VERSION_02 0x00000002
+#define PRINT_CAPABILITY_VERSION_01 0x00000001
+#define PORT_CAPABILITY_VERSION_01 0x00000001
+#define DRIVE_CAPABILITY_VERSION_01 0x00000001
+#define DRIVE_CAPABILITY_VERSION_02 0x00000002
+#define SMARTCARD_CAPABILITY_VERSION_01 0x00000001
+
+#define RDPDR_IRP_MJ_CREATE 0x00000001
+#define RDPDR_IRP_MJ_CLEANUP 0x00000002
+#define RDPDR_IRP_MJ_CLOSE 0x00000004
+#define RDPDR_IRP_MJ_READ 0x00000008
+#define RDPDR_IRP_MJ_WRITE 0x00000010
+#define RDPDR_IRP_MJ_FLUSH_BUFFERS 0x00000020
+#define RDPDR_IRP_MJ_SHUTDOWN 0x00000040
+#define RDPDR_IRP_MJ_DEVICE_CONTROL 0x00000080
+#define RDPDR_IRP_MJ_QUERY_VOLUME_INFORMATION 0x00000100
+#define RDPDR_IRP_MJ_SET_VOLUME_INFORMATION 0x00000200
+#define RDPDR_IRP_MJ_QUERY_INFORMATION 0x00000400
+#define RDPDR_IRP_MJ_SET_INFORMATION 0x00000800
+#define RDPDR_IRP_MJ_DIRECTORY_CONTROL 0x00001000
+#define RDPDR_IRP_MJ_LOCK_CONTROL 0x00002000
+#define RDPDR_IRP_MJ_QUERY_SECURITY 0x00004000
+#define RDPDR_IRP_MJ_SET_SECURITY 0x00008000
+#define ALL_RDPDR_IRP_MJ 0x0000FFFF
+
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_ASCII 0x00000001
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER 0x00000002
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_NETWORKPRINTER 0x00000004
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_TSPRINTER 0x00000008
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_XPSFORMAT 0x00000010
+
+#define RDPDR_DEVICE_REMOVE_PDUS 0x00000001
+#define RDPDR_CLIENT_DISPLAY_NAME_PDU 0x00000002
+#define RDPDR_USER_LOGGEDON_PDU 0x00000004
+
/* RDP5 disconnect PDU */
#define exDiscReasonNoInfo 0x0000
#define exDiscReasonAPIInitiatedDisconnect 0x0001
@@ -531,15 +586,20 @@
/* redirect flags, from [MS-RDPBCGR] 2.2.13.1 */
enum RDP_PDU_REDIRECT_FLAGS
{
- PDU_REDIRECT_HAS_IP = 0x1,
- PDU_REDIRECT_HAS_LOAD_BALANCE_INFO = 0x2,
- PDU_REDIRECT_HAS_USERNAME = 0x4,
- PDU_REDIRECT_HAS_DOMAIN = 0x8,
- PDU_REDIRECT_HAS_PASSWORD = 0x10,
- PDU_REDIRECT_DONT_STORE_USERNAME = 0x20,
- PDU_REDIRECT_USE_SMARTCARD = 0x40,
- PDU_REDIRECT_INFORMATIONAL = 0x80,
- PDU_REDIRECT_HAS_TARGET_FQDN = 0x100,
- PDU_REDIRECT_HAS_TARGET_NETBIOS = 0x200,
- PDU_REDIRECT_HAS_TARGET_IP_ARRAY = 0x800
-};
+ LB_TARGET_NET_ADDRESS = 0x1,
+ LB_LOAD_BALANCE_INFO = 0x2,
+ LB_USERNAME = 0x4,
+ LB_DOMAIN = 0x8,
+ LB_PASSWORD = 0x10,
+ LB_DONTSTOREUSERNAME = 0x20,
+ LB_SMARTCARD_LOGON = 0x40,
+ LB_NOREDIRECT = 0x80,
+ LB_TARGET_FQDN = 0x100,
+ LB_TARGET_NETBIOS = 0x200,
+ LB_TARGET_NET_ADDRESSES = 0x800,
+ LB_CLIENT_TSV_URL = 0x1000,
+ LB_SERVER_TSV_CAPABLE = 0x2000,
+ LB_PASSWORD_IS_PK_ENCRYPTED = 0x4000,
+ LB_REDIRECTION_GUID = 0x8000,
+ LB_TARGET_CERTIFICATE = 0x10000
+};
Modified: trunk/reactos/base/applications/mstsc/licence.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/li…
==============================================================================
--- trunk/reactos/base/applications/mstsc/licence.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/licence.c [iso-8859-1] Tue May 16 16:37:29 2017
@@ -23,16 +23,16 @@
#include "precomp.h"
void *
-ssl_rc4_info_create(void);
+rdssl_rc4_info_create(void);
void
-ssl_rc4_info_delete(void * rc4_info);
+rdssl_rc4_info_delete(void * rc4_info);
void
-ssl_rc4_set_key(void * rc4_info, char * key, int len);
+rdssl_rc4_set_key(void * rc4_info, char * key, int len);
void
-ssl_rc4_crypt(void * rc4_info, char * in_data, char * out_data, int len);
+rdssl_rc4_crypt(void * rc4_info, char * in_data, char * out_data, int len);
int
-ssl_mod_exp(char* out, int out_len, char* in, int in_len,
- char* mod, int mod_len, char* exp, int exp_len);
+rdssl_mod_exp(char* out, int out_len, char* in, int in_len,
+ char* mod, int mod_len, char* exp, int exp_len);
extern char g_username[256];
extern char g_hostname[256];
@@ -74,7 +74,7 @@
licence_info(uint8 * client_random, uint8 * rsa_data,
uint8 * licence_data, int licence_size, uint8 * hwid, uint8 * signature)
{
- uint32 sec_flags = SEC_LICENCE_NEG;
+ uint32 sec_flags = SEC_LICENSE_PKT;
uint16 length =
24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE +
licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE;
@@ -114,7 +114,7 @@
static void
licence_send_new_licence_request(uint8 * client_random, uint8 * rsa_data, char *user,
char *host)
{
- uint32 sec_flags = SEC_LICENCE_NEG;
+ uint32 sec_flags = SEC_LICENSE_PKT;
uint16 userlen = strlen(user) + 1;
uint16 hostlen = strlen(host) + 1;
uint16 length =
@@ -179,10 +179,10 @@
sec_sign(signature, 16, g_licence_sign_key, 16, hwid, sizeof(hwid));
/* Now encrypt the HWID */
- crypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
- ssl_rc4_crypt(crypt_key, (char *)hwid, (char *)hwid, sizeof(hwid));
- ssl_rc4_info_delete(crypt_key);
+ crypt_key = rdssl_rc4_info_create();
+ rdssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
+ rdssl_rc4_crypt(crypt_key, (char *)hwid, (char *)hwid, sizeof(hwid));
+ rdssl_rc4_info_delete(crypt_key);
#if WITH_DEBUG
DEBUG(("Sending licensing PDU (message type 0x%02x)\n",
LICENCE_TAG_LICENCE_INFO));
@@ -203,13 +203,13 @@
static void
licence_send_platform_challenge_response(uint8 * token, uint8 * crypt_hwid, uint8 *
signature)
{
- uint32 sec_flags = SEC_LICENCE_NEG;
+ uint32 sec_flags = SEC_LICENSE_PKT;
uint16 length = 58;
STREAM s;
s = sec_init(sec_flags, length + 2);
- out_uint8(s, LICENCE_TAG_PLATFORM_CHALLENGE_RESPONSE);
+ out_uint8(s, LICENCE_TAG_PLATFORM_CHALLANGE_RESPONSE);
out_uint8(s, ((g_rdp_version >= RDP_V5) ? 3 : 2)); /* version */
out_uint16_le(s, length);
@@ -264,10 +264,10 @@
memcpy(out_token, in_token, LICENCE_TOKEN_SIZE);
/* Decrypt the token. It should read TEST in Unicode. */
- crypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
- ssl_rc4_crypt(crypt_key, (char *)in_token, (char *)decrypt_token, LICENCE_TOKEN_SIZE);
- ssl_rc4_info_delete(crypt_key);
+ crypt_key = rdssl_rc4_info_create();
+ rdssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
+ rdssl_rc4_crypt(crypt_key, (char *)in_token, (char *)decrypt_token,
LICENCE_TOKEN_SIZE);
+ rdssl_rc4_info_delete(crypt_key);
/* Generate a signature for a buffer of token and HWID */
licence_generate_hwid(hwid);
@@ -276,10 +276,9 @@
sec_sign(out_sig, 16, g_licence_sign_key, 16, sealed_buffer, sizeof(sealed_buffer));
/* Now encrypt the HWID */
- crypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
- ssl_rc4_crypt(crypt_key, (char *)hwid, (char *)crypt_hwid, LICENCE_HWID_SIZE);
- ssl_rc4_info_delete(crypt_key);
+ crypt_key = rdssl_rc4_info_create();
+ rdssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
+ rdssl_rc4_crypt(crypt_key, (char *)hwid, (char *)crypt_hwid, LICENCE_HWID_SIZE);
licence_send_platform_challenge_response(out_token, crypt_hwid, out_sig);
}
@@ -297,10 +296,10 @@
if (!s_check_rem(s, length))
return;
- crypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
- ssl_rc4_crypt(crypt_key, (char *)s->p, (char *)s->p, length);
- ssl_rc4_info_delete(crypt_key);
+ crypt_key = rdssl_rc4_info_create();
+ rdssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
+ rdssl_rc4_crypt(crypt_key, (char *)s->p, (char *)s->p, length);
+ rdssl_rc4_info_delete(crypt_key);
/* Parse NEW_LICENSE_INFO block */
in_uint8s(s, 4); // skip dwVersion
@@ -393,7 +392,7 @@
licence_process_request(s);
break;
- case LICENCE_TAG_PLATFORM_CHALLENGE:
+ case LICENCE_TAG_PLATFORM_CHALLANGE:
licence_process_platform_challenge(s);
break;
Modified: trunk/reactos/base/applications/mstsc/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/pr…
==============================================================================
--- trunk/reactos/base/applications/mstsc/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/precomp.h [iso-8859-1] Tue May 16 16:37:29 2017
@@ -13,26 +13,13 @@
#include <wincon.h>
#include <shlobj.h>
#include <stdio.h>
+#include <wincrypt.h>
#include "rdesktop.h"
#include "resource.h"
#ifndef __TODO_MSTSC_H
#define __TODO_MSTSC_H
-
-#define RDP_INFO_MOUSE 0x00000001
-#define RDP_INFO_DISABLECTRLALTDEL 0x00000002
-#define RDP_INFO_AUTOLOGON 0x00000008
-#define RDP_INFO_UNICODE 0x00000010
-#define RDP_INFO_MAXIMIZESHELL 0x00000020
-#define RDP_INFO_COMPRESSION 0x00000080 /* mppc compression with 8kB history
buffer */
-#define RDP_INFO_ENABLEWINDOWSKEY 0x00000100
-#define RDP_INFO_COMPRESSION2 0x00000200 /* rdp5 mppc compression with 64kB
history buffer */
-#define RDP_INFO_REMOTE_CONSOLE_AUDIO 0x00002000
-#define RDP_INFO_PASSWORD_IS_SC_PIN 0x00040000
-
-#define RDP5_DISABLE_NOTHING 0x00
-#define RDP5_NO_WALLPAPER 0x01
#define RDP_LOGON_NORMAL (RDP_INFO_MOUSE | RDP_INFO_DISABLECTRLALTDEL | RDP_INFO_UNICODE
| RDP_INFO_MAXIMIZESHELL)
Modified: trunk/reactos/base/applications/mstsc/proto.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/pr…
==============================================================================
--- trunk/reactos/base/applications/mstsc/proto.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/proto.h [iso-8859-1] Tue May 16 16:37:29 2017
@@ -24,12 +24,6 @@
extern "C" {
#endif
/* *INDENT-ON* */
-/* utils.c */
-char *utils_string_escape(const char *str);
-char *utils_string_unescape(const char *str);
-int utils_locale_to_utf8(const char *src, size_t is, char *dest, size_t os);
-int utils_mkdir_safe(const char *path, int mask);
-int utils_mkdir_p(const char *path, int mask);
/* bitmap.c */
RD_BOOL bitmap_decompress(uint8 * output, int width, int height, uint8 * input, int size,
int Bpp);
/* cache.c */
Modified: trunk/reactos/base/applications/mstsc/rdp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/rd…
==============================================================================
--- trunk/reactos/base/applications/mstsc/rdp.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/rdp.c [iso-8859-1] Tue May 16 16:37:29 2017
@@ -70,7 +70,7 @@
extern RD_BOOL g_has_reconnect_random;
extern uint8 g_client_random[SEC_RANDOM_SIZE];
-void ssl_hmac_md5(char* key, int keylen, char* data, int len, char* output);
+void rdssl_hmac_md5(char* key, int keylen, char* data, int len, char* output);
#if WITH_DEBUG
static uint32 g_packetno;
@@ -139,7 +139,7 @@
static STREAM
rdp_init_data(int maxlen)
{
- STREAM s = NULL;
+ STREAM s;
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, maxlen + 18);
s_push_layer(s, rdp_hdr, 18);
@@ -169,6 +169,18 @@
out_uint16(s, 0); /* compress_len */
sec_send(s, g_encryption ? SEC_ENCRYPT : 0);
+}
+
+/* Output a string in Unicode with mandatory null termination. If
+ string is NULL or len is 0, write an unicode null termination to
+ stream. */
+void
+rdp_out_unistr_mandatory_null(STREAM s, char *string, int len)
+{
+ if (string && len > 0)
+ rdp_out_unistr(s, string, len);
+ else
+ out_uint16_le(s, 0);
}
/* Output a string in Unicode */
@@ -344,8 +356,8 @@
int len_dll = 2 * strlen("C:\\") + 2;
int packetlen = 0;
- uint32 sec_flags = g_encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO;
- STREAM s = NULL;
+ uint32 sec_flags = g_encryption ? (SEC_INFO_PKT | SEC_ENCRYPT) : SEC_INFO_PKT;
+ STREAM s;
time_t t = time(NULL);
time_t tzone;
uint8 security_verifier[16];
@@ -364,11 +376,12 @@
out_uint16_le(s, len_password);
out_uint16_le(s, len_program);
out_uint16_le(s, len_directory);
- rdp_out_unistr(s, domain, len_domain);
- rdp_out_unistr(s, user, len_user);
- rdp_out_unistr(s, password, len_password);
- rdp_out_unistr(s, program, len_program);
- rdp_out_unistr(s, directory, len_directory);
+
+ rdp_out_unistr_mandatory_null(s, domain, len_domain);
+ rdp_out_unistr_mandatory_null(s, user, len_user);
+ rdp_out_unistr_mandatory_null(s, password, len_password);
+ rdp_out_unistr_mandatory_null(s, program, len_program);
+ rdp_out_unistr_mandatory_null(s, directory, len_directory);
}
else
{
@@ -376,6 +389,7 @@
if (g_redirect == True && g_redirect_cookie_len > 0)
{
+ flags |= RDP_INFO_AUTOLOGON;
len_password = g_redirect_cookie_len;
len_password -= 2; /* substract 2 bytes which is added below */
}
@@ -427,44 +441,26 @@
out_uint16_le(s, len_program);
out_uint16_le(s, len_directory);
- if (0 < len_domain)
- rdp_out_unistr(s, domain, len_domain);
+ rdp_out_unistr_mandatory_null(s, domain, len_domain);
+ rdp_out_unistr_mandatory_null(s, user, len_user);
+
+ if (g_redirect == True && 0 < g_redirect_cookie_len)
+ {
+ out_uint8p(s, g_redirect_cookie, g_redirect_cookie_len);
+ }
else
- out_uint16_le(s, 0); /* mandatory 2 bytes null terminator */
-
- if (0 < len_user)
- rdp_out_unistr(s, user, len_user);
- else
- out_uint16_le(s, 0); /* mandatory 2 bytes null terminator */
-
- if (0 < len_password)
- {
- if (g_redirect == True && 0 < g_redirect_cookie_len)
- {
- out_uint8p(s, g_redirect_cookie, g_redirect_cookie_len);
- }
- else
- {
- rdp_out_unistr(s, password, len_password);
- }
- }
- else
- out_uint16_le(s, 0); /* mandatory 2 bytes null terminator */
-
- if (0 < len_program)
- rdp_out_unistr(s, program, len_program);
- else
- out_uint16_le(s, 0); /* mandatory 2 bytes null terminator */
-
- if (0 < len_directory)
- rdp_out_unistr(s, directory, len_directory);
- else
- out_uint16_le(s, 0); /* mandatory 2 bytes null terminator */
+ {
+ rdp_out_unistr_mandatory_null(s, password, len_password);
+ }
+
+
+ rdp_out_unistr_mandatory_null(s, program, len_program);
+ rdp_out_unistr_mandatory_null(s, directory, len_directory);
/* TS_EXTENDED_INFO_PACKET */
out_uint16_le(s, 2); /* clientAddressFamily = AF_INET */
- out_uint16_le(s, len_ip); /* cbClientAddress, Length of client ip */
- rdp_out_unistr(s, ipaddr, len_ip - 2); /* clientAddress */
+ out_uint16_le(s, len_ip); /* cbClientAddress */
+ rdp_out_unistr_mandatory_null(s, ipaddr, len_ip - 2); /* clientAddress */
out_uint16_le(s, len_dll); /* cbClientDir */
rdp_out_unistr(s, "C:\\", len_dll - 2); /* clientDir */
@@ -498,8 +494,8 @@
out_uint32_le(s, 28); /* cbLen */
out_uint32_le(s, 1); /* Version */
out_uint32_le(s, g_reconnect_logonid); /* LogonId */
- ssl_hmac_md5(g_reconnect_random, sizeof(g_reconnect_random),
- (char *)g_client_random, SEC_RANDOM_SIZE, (char *)security_verifier);
+ rdssl_hmac_md5(g_reconnect_random, sizeof(g_reconnect_random),
+ g_client_random, SEC_RANDOM_SIZE, security_verifier);
out_uint8a(s, security_verifier, sizeof(security_verifier));
}
else
@@ -1547,7 +1543,7 @@
/* read connection flags */
in_uint32_le(s, g_redirect_flags);
- if (g_redirect_flags & PDU_REDIRECT_HAS_IP)
+ if (g_redirect_flags & LB_TARGET_NET_ADDRESS)
{
/* read length of ip string */
in_uint32_le(s, len);
@@ -1556,7 +1552,7 @@
rdp_in_unistr(s, len, &g_redirect_server, &g_redirect_server_len);
}
- if (g_redirect_flags & PDU_REDIRECT_HAS_LOAD_BALANCE_INFO)
+ if (g_redirect_flags & LB_LOAD_BALANCE_INFO)
{
/* read length of load balance info blob */
in_uint32_le(s, g_redirect_lb_info_len);
@@ -1571,7 +1567,7 @@
in_uint8p(s, g_redirect_lb_info, g_redirect_lb_info_len);
}
- if (g_redirect_flags & PDU_REDIRECT_HAS_USERNAME)
+ if (g_redirect_flags & LB_USERNAME)
{
/* read length of username string */
in_uint32_le(s, len);
@@ -1580,7 +1576,7 @@
rdp_in_unistr(s, len, &g_redirect_username, &g_redirect_username_len);
}
- if (g_redirect_flags & PDU_REDIRECT_HAS_DOMAIN)
+ if (g_redirect_flags & LB_DOMAIN)
{
/* read length of domain string */
in_uint32_le(s, len);
@@ -1589,7 +1585,7 @@
rdp_in_unistr(s, len, &g_redirect_domain, &g_redirect_domain_len);
}
- if (g_redirect_flags & PDU_REDIRECT_HAS_PASSWORD)
+ if (g_redirect_flags & LB_PASSWORD)
{
/* the information in this blob is either a password or a cookie that
should be passed though as blob and not parsed as a unicode string */
@@ -1607,24 +1603,24 @@
in_uint8p(s, g_redirect_cookie, g_redirect_cookie_len);
}
- if (g_redirect_flags & PDU_REDIRECT_DONT_STORE_USERNAME)
- {
- warning("PDU_REDIRECT_DONT_STORE_USERNAME set\n");
- }
-
- if (g_redirect_flags & PDU_REDIRECT_USE_SMARTCARD)
- {
- warning("PDU_REDIRECT_USE_SMARTCARD set\n");
- }
-
- if (g_redirect_flags & PDU_REDIRECT_INFORMATIONAL)
+ if (g_redirect_flags & LB_DONTSTOREUSERNAME)
+ {
+ warning("LB_DONTSTOREUSERNAME set\n");
+ }
+
+ if (g_redirect_flags & LB_SMARTCARD_LOGON)
+ {
+ warning("LB_SMARTCARD_LOGON set\n");
+ }
+
+ if (g_redirect_flags & LB_NOREDIRECT)
{
/* By spec this is only for information and doesn't mean that an actual
redirect should be performed. How it should be used is not mentioned. */
g_redirect = False;
}
- if (g_redirect_flags & PDU_REDIRECT_HAS_TARGET_FQDN)
+ if (g_redirect_flags & LB_TARGET_FQDN)
{
in_uint32_le(s, len);
@@ -1639,14 +1635,39 @@
rdp_in_unistr(s, len, &g_redirect_server, &g_redirect_server_len);
}
- if (g_redirect_flags & PDU_REDIRECT_HAS_TARGET_NETBIOS)
- {
- warning("PDU_REDIRECT_HAS_TARGET_NETBIOS set\n");
- }
-
- if (g_redirect_flags & PDU_REDIRECT_HAS_TARGET_IP_ARRAY)
- {
- warning("PDU_REDIRECT_HAS_TARGET_IP_ARRAY set\n");
+ if (g_redirect_flags & LB_TARGET_NETBIOS)
+ {
+ warning("LB_TARGET_NETBIOS set\n");
+ }
+
+ if (g_redirect_flags & LB_TARGET_NET_ADDRESSES)
+ {
+ warning("LB_TARGET_NET_ADDRESSES set\n");
+ }
+
+ if (g_redirect_flags & LB_CLIENT_TSV_URL)
+ {
+ warning("LB_CLIENT_TSV_URL set\n");
+ }
+
+ if (g_redirect_flags & LB_SERVER_TSV_CAPABLE)
+ {
+ warning("LB_SERVER_TSV_CAPABLE set\n");
+ }
+
+ if (g_redirect_flags & LB_PASSWORD_IS_PK_ENCRYPTED)
+ {
+ warning("LB_PASSWORD_IS_PK_ENCRYPTED set\n");
+ }
+
+ if (g_redirect_flags & LB_REDIRECTION_GUID)
+ {
+ warning("LB_REDIRECTION_GUID set\n");
+ }
+
+ if (g_redirect_flags & LB_TARGET_CERTIFICATE)
+ {
+ warning("LB_TARGET_CERTIFICATE set\n");
}
return True;
Modified: trunk/reactos/base/applications/mstsc/secure.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/se…
==============================================================================
--- trunk/reactos/base/applications/mstsc/secure.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/secure.c [iso-8859-1] Tue May 16 16:37:29 2017
@@ -21,43 +21,43 @@
#include "precomp.h"
void *
-ssl_sha1_info_create(void);
-void
-ssl_sha1_info_delete(void * sha1_info);
-void
-ssl_sha1_clear(void * sha1_info);
-void
-ssl_sha1_transform(void * sha1_info, char * data, int len);
-void
-ssl_sha1_complete(void * sha1_info, char * data);
+rdssl_sha1_info_create(void);
+void
+rdssl_sha1_info_delete(void * sha1_info);
+void
+rdssl_sha1_clear(void * sha1_info);
+void
+rdssl_sha1_transform(void * sha1_info, char * data, int len);
+void
+rdssl_sha1_complete(void * sha1_info, char * data);
void *
-ssl_md5_info_create(void);
-void
-ssl_md5_info_delete(void * md5_info);
+rdssl_md5_info_create(void);
+void
+rdssl_md5_info_delete(void * md5_info);
void *
-ssl_md5_info_create(void);
-void
-ssl_md5_info_delete(void * md5_info);
-void
-ssl_md5_clear(void * md5_info);
-void
-ssl_md5_transform(void * md5_info, char * data, int len);
-void
-ssl_md5_complete(void * md5_info, char * data);
+rdssl_md5_info_create(void);
+void
+rdssl_md5_info_delete(void * md5_info);
+void
+rdssl_md5_clear(void * md5_info);
+void
+rdssl_md5_transform(void * md5_info, char * data, int len);
+void
+rdssl_md5_complete(void * md5_info, char * data);
void *
-ssl_rc4_info_create(void);
-void
-ssl_rc4_info_delete(void * rc4_info);
-void
-ssl_rc4_set_key(void * rc4_info, char * key, int len);
-void
-ssl_rc4_crypt(void * rc4_info, char * in_data, char * out_data, int len);
+rdssl_rc4_info_create(void);
+void
+rdssl_rc4_info_delete(void * rc4_info);
+void
+rdssl_rc4_set_key(void * rc4_info, char * key, int len);
+void
+rdssl_rc4_crypt(void * rc4_info, char * in_data, char * out_data, int len);
int
-ssl_mod_exp(char* out, int out_len, char* in, int in_len,
+rdssl_mod_exp(char* out, int out_len, char* in, int in_len,
char* mod, int mod_len, char* exp, int exp_len);
-//int
-//ssl_sig_ok(char * exp, int exp_size, char * mod, int mod_len,
-// char * sig, int sig_len);
+int
+rdssl_sign_ok(char* e_data, int e_len, char* n_data, int n_len,
+ char* sign_data, int sign_len, char* sign_data2, int sign_len2, char* testkey);
extern char g_hostname[16];
extern int g_width;
@@ -96,37 +96,6 @@
static int g_sec_decrypt_use_count = 0;
#define SEC_MODULUS_SIZE 64
-
-static uint8 g_ppk_n[72] =
-{
- 0x3D, 0x3A, 0x5E, 0xBD, 0x72, 0x43, 0x3E, 0xC9,
- 0x4D, 0xBB, 0xC1, 0x1E, 0x4A, 0xBA, 0x5F, 0xCB,
- 0x3E, 0x88, 0x20, 0x87, 0xEF, 0xF5, 0xC1, 0xE2,
- 0xD7, 0xB7, 0x6B, 0x9A, 0xF2, 0x52, 0x45, 0x95,
- 0xCE, 0x63, 0x65, 0x6B, 0x58, 0x3A, 0xFE, 0xEF,
- 0x7C, 0xE7, 0xBF, 0xFE, 0x3D, 0xF6, 0x5C, 0x7D,
- 0x6C, 0x5E, 0x06, 0x09, 0x1A, 0xF5, 0x61, 0xBB,
- 0x20, 0x93, 0x09, 0x5F, 0x05, 0x6D, 0xEA, 0x87,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static uint8 g_ppk_d[108] =
-{
- 0x87, 0xA7, 0x19, 0x32, 0xDA, 0x11, 0x87, 0x55,
- 0x58, 0x00, 0x16, 0x16, 0x25, 0x65, 0x68, 0xF8,
- 0x24, 0x3E, 0xE6, 0xFA, 0xE9, 0x67, 0x49, 0x94,
- 0xCF, 0x92, 0xCC, 0x33, 0x99, 0xE8, 0x08, 0x60,
- 0x17, 0x9A, 0x12, 0x9F, 0x24, 0xDD, 0xB1, 0x24,
- 0x99, 0xC7, 0x3A, 0xB8, 0x0A, 0x7B, 0x0D, 0xDD,
- 0x35, 0x07, 0x79, 0x17, 0x0B, 0x51, 0x9B, 0xB3,
- 0xC7, 0x10, 0x01, 0x13, 0xE7, 0x3F, 0xF3, 0x5F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
-};
static uint8 g_testkey[176] =
{
@@ -181,20 +150,20 @@
for (i = 0; i < 3; i++)
{
memset(pad, salt + i, i + 1);
- sha = ssl_sha1_info_create();
- ssl_sha1_clear(sha);
- ssl_sha1_transform(sha, (char *)pad, i + 1);
- ssl_sha1_transform(sha, (char *)in, 48);
- ssl_sha1_transform(sha, (char *)salt1, 32);
- ssl_sha1_transform(sha, (char *)salt2, 32);
- ssl_sha1_complete(sha, (char *)shasig);
- ssl_sha1_info_delete(sha);
- md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
- ssl_md5_transform(md5, (char *)in, 48);
- ssl_md5_transform(md5, (char *)shasig, 20);
- ssl_md5_complete(md5, (char *)out + i * 16);
- ssl_md5_info_delete(md5);
+ sha = rdssl_sha1_info_create();
+ rdssl_sha1_clear(sha);
+ rdssl_sha1_transform(sha, (char *)pad, i + 1);
+ rdssl_sha1_transform(sha, (char *)in, 48);
+ rdssl_sha1_transform(sha, (char *)salt1, 32);
+ rdssl_sha1_transform(sha, (char *)salt2, 32);
+ rdssl_sha1_complete(sha, (char *)shasig);
+ rdssl_sha1_info_delete(sha);
+ md5 = rdssl_md5_info_create();
+ rdssl_md5_clear(md5);
+ rdssl_md5_transform(md5, (char *)in, 48);
+ rdssl_md5_transform(md5, (char *)shasig, 20);
+ rdssl_md5_complete(md5, (char *)out + i * 16);
+ rdssl_md5_info_delete(md5);
}
}
@@ -206,13 +175,13 @@
{
void * md5;
- md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
- ssl_md5_transform(md5, (char *)in, 16);
- ssl_md5_transform(md5, (char *)salt1, 32);
- ssl_md5_transform(md5, (char *)salt2, 32);
- ssl_md5_complete(md5, (char *)out);
- ssl_md5_info_delete(md5);
+ md5 = rdssl_md5_info_create();
+ rdssl_md5_clear(md5);
+ rdssl_md5_transform(md5, (char *)in, 16);
+ rdssl_md5_transform(md5, (char *)salt1, 32);
+ rdssl_md5_transform(md5, (char *)salt2, 32);
+ rdssl_md5_complete(md5, (char *)out);
+ rdssl_md5_info_delete(md5);
}
/*
@@ -222,12 +191,12 @@
sec_hash_sha1_16(uint8 * out, uint8 * in, uint8 * salt1)
{
void * sha;
- sha = ssl_sha1_info_create();
- ssl_sha1_clear(sha);
- ssl_sha1_transform(&sha, (char *)in, 16);
- ssl_sha1_transform(&sha, (char *)salt1, 16);
- ssl_sha1_complete(&sha, (char *)out);
- ssl_sha1_info_delete(sha);
+ sha = rdssl_sha1_info_create();
+ rdssl_sha1_clear(sha);
+ rdssl_sha1_transform(&sha, (char *)in, 16);
+ rdssl_sha1_transform(&sha, (char *)salt1, 16);
+ rdssl_sha1_complete(&sha, (char *)out);
+ rdssl_sha1_info_delete(sha);
}
/* create string from hash */
@@ -294,13 +263,13 @@
/* Initialise RC4 state arrays */
- ssl_rc4_info_delete(g_rc4_decrypt_key);
- g_rc4_decrypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(g_rc4_decrypt_key, (char *)g_sec_decrypt_key, g_rc4_key_len);
-
- ssl_rc4_info_delete(g_rc4_encrypt_key);
- g_rc4_encrypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(g_rc4_encrypt_key, (char *)g_sec_encrypt_key, g_rc4_key_len);
+ rdssl_rc4_info_delete(g_rc4_decrypt_key);
+ g_rc4_decrypt_key = rdssl_rc4_info_create();
+ rdssl_rc4_set_key(g_rc4_decrypt_key, (char *)g_sec_decrypt_key, g_rc4_key_len);
+
+ rdssl_rc4_info_delete(g_rc4_encrypt_key);
+ g_rc4_encrypt_key = rdssl_rc4_info_create();
+ rdssl_rc4_set_key(g_rc4_encrypt_key, (char *)g_sec_encrypt_key, g_rc4_key_len);
}
static uint8 pad_54[40] = {
@@ -339,22 +308,22 @@
buf_out_uint32(lenhdr, datalen);
- sha = ssl_sha1_info_create();
- ssl_sha1_clear(sha);
- ssl_sha1_transform(sha, (char *)session_key, keylen);
- ssl_sha1_transform(sha, (char *)pad_54, 40);
- ssl_sha1_transform(sha, (char *)lenhdr, 4);
- ssl_sha1_transform(sha, (char *)data, datalen);
- ssl_sha1_complete(sha, (char *)shasig);
- ssl_sha1_info_delete(sha);
-
- md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
- ssl_md5_transform(md5, (char *)session_key, keylen);
- ssl_md5_transform(md5, (char *)pad_92, 48);
- ssl_md5_transform(md5, (char *)shasig, 20);
- ssl_md5_complete(md5, (char *)md5sig);
- ssl_md5_info_delete(md5);
+ sha = rdssl_sha1_info_create();
+ rdssl_sha1_clear(sha);
+ rdssl_sha1_transform(sha, (char *)session_key, keylen);
+ rdssl_sha1_transform(sha, (char *)pad_54, 40);
+ rdssl_sha1_transform(sha, (char *)lenhdr, 4);
+ rdssl_sha1_transform(sha, (char *)data, datalen);
+ rdssl_sha1_complete(sha, (char *)shasig);
+ rdssl_sha1_info_delete(sha);
+
+ md5 = rdssl_md5_info_create();
+ rdssl_md5_clear(md5);
+ rdssl_md5_transform(md5, (char *)session_key, keylen);
+ rdssl_md5_transform(md5, (char *)pad_92, 48);
+ rdssl_md5_transform(md5, (char *)shasig, 20);
+ rdssl_md5_complete(md5, (char *)md5sig);
+ rdssl_md5_info_delete(md5);
memcpy(signature, md5sig, siglen);
}
@@ -368,27 +337,27 @@
void * md5;
void * update;
- sha = ssl_sha1_info_create();
- ssl_sha1_clear(sha);
- ssl_sha1_transform(sha, (char *)update_key, g_rc4_key_len);
- ssl_sha1_transform(sha, (char *)pad_54, 40);
- ssl_sha1_transform(sha, (char *)key, g_rc4_key_len);
- ssl_sha1_complete(sha, (char *)shasig);
- ssl_sha1_info_delete(sha);
-
- md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
- ssl_md5_transform(md5, (char *)update_key, g_rc4_key_len);
- ssl_md5_transform(md5, (char *)pad_92, 48);
- ssl_md5_transform(md5, (char *)shasig, 20);
- ssl_md5_complete(md5, (char *)key);
- ssl_md5_info_delete(md5);
-
-
- update = ssl_rc4_info_create();
- ssl_rc4_set_key(update, (char *)key, g_rc4_key_len);
- ssl_rc4_crypt(update, (char *)key, (char *)key, g_rc4_key_len);
- ssl_rc4_info_delete(update);
+ sha = rdssl_sha1_info_create();
+ rdssl_sha1_clear(sha);
+ rdssl_sha1_transform(sha, (char *)update_key, g_rc4_key_len);
+ rdssl_sha1_transform(sha, (char *)pad_54, 40);
+ rdssl_sha1_transform(sha, (char *)key, g_rc4_key_len);
+ rdssl_sha1_complete(sha, (char *)shasig);
+ rdssl_sha1_info_delete(sha);
+
+ md5 = rdssl_md5_info_create();
+ rdssl_md5_clear(md5);
+ rdssl_md5_transform(md5, (char *)update_key, g_rc4_key_len);
+ rdssl_md5_transform(md5, (char *)pad_92, 48);
+ rdssl_md5_transform(md5, (char *)shasig, 20);
+ rdssl_md5_complete(md5, (char *)key);
+ rdssl_md5_info_delete(md5);
+
+
+ update = rdssl_rc4_info_create();
+ rdssl_rc4_set_key(update, (char *)key, g_rc4_key_len);
+ rdssl_rc4_crypt(update, (char *)key, (char *)key, g_rc4_key_len);
+ rdssl_rc4_info_delete(update);
if (g_rc4_key_len == 8)
sec_make_40bit(key);
@@ -401,11 +370,11 @@
if (g_sec_encrypt_use_count == 4096)
{
sec_update(g_sec_encrypt_key, g_sec_encrypt_update_key);
- ssl_rc4_set_key(g_rc4_encrypt_key, (char *)g_sec_encrypt_key, g_rc4_key_len);
+ rdssl_rc4_set_key(g_rc4_encrypt_key, (char *)g_sec_encrypt_key, g_rc4_key_len);
g_sec_encrypt_use_count = 0;
}
- ssl_rc4_crypt(g_rc4_encrypt_key, (char *)data, (char *)data, length);
+ rdssl_rc4_crypt(g_rc4_encrypt_key, (char *)data, (char *)data, length);
g_sec_encrypt_use_count++;
}
@@ -416,11 +385,11 @@
if (g_sec_decrypt_use_count == 4096)
{
sec_update(g_sec_decrypt_key, g_sec_decrypt_update_key);
- ssl_rc4_set_key(g_rc4_decrypt_key, (char *)g_sec_decrypt_key, g_rc4_key_len);
+ rdssl_rc4_set_key(g_rc4_decrypt_key, (char *)g_sec_decrypt_key, g_rc4_key_len);
g_sec_decrypt_use_count = 0;
}
- ssl_rc4_crypt(g_rc4_decrypt_key,(char *)data, (char *)data, length);
+ rdssl_rc4_crypt(g_rc4_decrypt_key,(char *)data, (char *)data, length);
g_sec_decrypt_use_count++;
}
@@ -429,48 +398,7 @@
sec_rsa_encrypt(uint8 * out, uint8 * in, int len, uint32 modulus_size, uint8 * modulus,
uint8 * exponent)
{
- ssl_mod_exp((char *)out, 64, (char *)in, 32, (char *)modulus, 64, (char *)exponent, 4);
-}
-
-static int
-sec_sign_ok(char* e_data, int e_len, char* n_data, int n_len,
- char* sign_data, int sign_len, char* sign_data2, int sign_len2, char* testkey)
-{
- char* key;
- char* md5_final;
- void* md5;
-
- if ((e_len != 4) || (n_len != 64) || (sign_len != 64) || (sign_len2 != 64))
- {
- return 1;
- }
- key = (char*)xmalloc(176);
- md5_final = (char*)xmalloc(64);
- md5 = ssl_md5_info_create();
- // copy the test key
- memcpy(key, testkey, 176);
- // replace e and n
- memcpy(key + 32, e_data, 4);
- memcpy(key + 36, n_data, 64);
- ssl_md5_clear(md5);
- // the first 108 bytes
- ssl_md5_transform(md5, key, 108);
- // set the whole thing with 0xff
- memset(md5_final, 0xff, 64);
- // digest 16 bytes
- ssl_md5_complete(md5, md5_final);
- // set non 0xff array items
- md5_final[16] = 0;
- md5_final[62] = 1;
- md5_final[63] = 0;
- // encrypt
- ssl_mod_exp(sign_data, 64, md5_final, 64, (char*)g_ppk_n, 64,
- (char*)g_ppk_d, 64);
- // cleanup
- ssl_md5_info_delete(md5);
- xfree(key);
- xfree(md5_final);
- return memcmp(sign_data, sign_data2, sign_len2);
+ rdssl_mod_exp((char *)out, 64, (char *)in, 32, (char *)modulus, 64, (char *)exponent,
4);
}
/* Initialise secure transport packet */
@@ -539,7 +467,7 @@
sec_establish_key(void)
{
uint32 length = g_server_public_key_len + SEC_PADDING_SIZE;
- uint32 flags = SEC_CLIENT_RANDOM;
+ uint32 flags = SEC_EXCHANGE_PKT;
STREAM s;
s = sec_init(flags, length + 4);
@@ -698,8 +626,8 @@
memset(signature, 0, sizeof(signature));
sig_len = len - 8;
in_uint8a(s, signature, sig_len);
- if(sec_sign_ok((char *)exponent, SEC_EXPONENT_SIZE, (char *)modulus,
g_server_public_key_len,
- (char *)signature_, SEC_MODULUS_SIZE, (char *)signature, sig_len, (char
*)g_testkey))
+ if(rdssl_sign_ok((char *)exponent, SEC_EXPONENT_SIZE, (char *)modulus,
g_server_public_key_len,
+ (char *)signature_, SEC_MODULUS_SIZE, (char *)signature, sig_len,
(char *)g_testkey))
{
DEBUG_RDP5(("key signature doesn't match test key\n"));
}
@@ -963,7 +891,8 @@
STREAM
sec_recv(uint8 * rdpver)
{
- uint32 sec_flags;
+ uint16 sec_flags;
+ uint16 sec_flags_hi;
uint16 channel;
STREAM s;
@@ -983,7 +912,9 @@
}
if (g_encryption || (!g_licence_issued && !g_licence_error_result))
{
- in_uint32_le(s, sec_flags);
+ /* TS_SECURITY_HEADER */
+ in_uint16_le(s, sec_flags);
+ in_uint16_le(s, sec_flags_hi);
if (g_encryption)
{
@@ -993,13 +924,13 @@
sec_decrypt(s->p, s->end - s->p);
}
- if (sec_flags & SEC_LICENCE_NEG)
+ if (sec_flags & SEC_LICENSE_PKT)
{
licence_process(s);
continue;
}
- if (sec_flags & 0x0400) /* SEC_REDIRECT_ENCRYPT */
+ if (sec_flags & SEC_REDIRECTION_PKT) /* SEC_REDIRECT_ENCRYPT */
{
uint8 swapbyte;
@@ -1035,8 +966,8 @@
}
else
{
- if ((sec_flags & 0xffff) == SEC_LICENCE_NEG)
- {
+ if (sec_flags & SEC_LICENSE_PKT)
+ {
licence_process(s);
continue;
}
Modified: trunk/reactos/base/applications/mstsc/ssl_calls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/ss…
==============================================================================
--- trunk/reactos/base/applications/mstsc/ssl_calls.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/ssl_calls.c [iso-8859-1] Tue May 16 16:37:29
2017
@@ -59,21 +59,21 @@
/*****************************************************************************/
void* APP_CC
-ssl_rc4_info_create(void)
+rdssl_rc4_info_create(void)
{
return g_malloc(sizeof(struct rc4_state), 1);
}
/*****************************************************************************/
void APP_CC
-ssl_rc4_info_delete(void* rc4_info)
+rdssl_rc4_info_delete(void* rc4_info)
{
g_free(rc4_info);
}
/*****************************************************************************/
void APP_CC
-ssl_rc4_set_key(void* rc4_info, char* key, int len)
+rdssl_rc4_set_key(void* rc4_info, char* key, int len)
{
int i;
int j;
@@ -108,7 +108,7 @@
/*****************************************************************************/
void APP_CC
-ssl_rc4_crypt(void* rc4_info, char* in_data, char* out_data, int len)
+rdssl_rc4_crypt(void* rc4_info, char* in_data, char* out_data, int len)
{
int i;
int x;
@@ -152,21 +152,21 @@
/*****************************************************************************/
void* APP_CC
-ssl_sha1_info_create(void)
+rdssl_sha1_info_create(void)
{
return g_malloc(sizeof(struct sha1_context), 1);
}
/*****************************************************************************/
void APP_CC
-ssl_sha1_info_delete(void* sha1_info)
+rdssl_sha1_info_delete(void* sha1_info)
{
g_free(sha1_info);
}
/*****************************************************************************/
void APP_CC
-ssl_sha1_clear(void* sha1_info)
+rdssl_sha1_clear(void* sha1_info)
{
struct sha1_context* ctx;
@@ -370,7 +370,7 @@
/*****************************************************************************/
void APP_CC
-ssl_sha1_transform(void* sha1_info, char* data, int len)
+rdssl_sha1_transform(void* sha1_info, char* data, int len)
{
int left;
int fill;
@@ -419,7 +419,7 @@
/*****************************************************************************/
void APP_CC
-ssl_sha1_complete(void* sha1_info, char* data)
+rdssl_sha1_complete(void* sha1_info, char* data)
{
int last;
int padn;
@@ -435,8 +435,8 @@
PUT_UINT32(low, msglen, 4);
last = ctx->total[0] & 0x3F;
padn = (last < 56) ? (56 - last) : (120 - last);
- ssl_sha1_transform(ctx, (char *)sha1_padding, padn);
- ssl_sha1_transform(ctx, msglen, 8);
+ rdssl_sha1_transform(ctx, (char *)sha1_padding, padn);
+ rdssl_sha1_transform(ctx, msglen, 8);
PUT_UINT32(ctx->state[0], data, 0);
PUT_UINT32(ctx->state[1], data, 4);
PUT_UINT32(ctx->state[2], data, 8);
@@ -461,21 +461,21 @@
/*****************************************************************************/
void* APP_CC
-ssl_md5_info_create(void)
+rdssl_md5_info_create(void)
{
return g_malloc(sizeof(struct md5_context), 1);
}
/*****************************************************************************/
void APP_CC
-ssl_md5_info_delete(void* md5_info)
+rdssl_md5_info_delete(void* md5_info)
{
g_free(md5_info);
}
/*****************************************************************************/
void APP_CC
-ssl_md5_clear(void* md5_info)
+rdssl_md5_clear(void* md5_info)
{
struct md5_context* ctx;
@@ -640,7 +640,7 @@
/*****************************************************************************/
void APP_CC
-ssl_md5_transform(void* md5_info, char* data, int len)
+rdssl_md5_transform(void* md5_info, char* data, int len)
{
int left;
int fill;
@@ -689,7 +689,7 @@
/*****************************************************************************/
void APP_CC
-ssl_md5_complete(void* md5_info, char* data)
+rdssl_md5_complete(void* md5_info, char* data)
{
int last;
int padn;
@@ -705,15 +705,16 @@
PUT_UINT32(high, msglen, 4);
last = ctx->total[0] & 0x3F;
padn = (last < 56) ? (56 - last) : (120 - last);
- ssl_md5_transform(ctx, (char *)md5_padding, padn);
- ssl_md5_transform(ctx, msglen, 8);
+ rdssl_md5_transform(ctx, (char *)md5_padding, padn);
+ rdssl_md5_transform(ctx, msglen, 8);
PUT_UINT32(ctx->state[0], data, 0);
PUT_UINT32(ctx->state[1], data, 4);
PUT_UINT32(ctx->state[2], data, 8);
PUT_UINT32(ctx->state[3], data, 12);
}
-void APP_CC ssl_hmac_md5(char* key, int keylen, char* data, int len, char* output)
+void APP_CC
+rdssl_hmac_md5(char* key, int keylen, char* data, int len, char* output)
{
int i;
char ipad[64];
@@ -723,10 +724,10 @@
if( keylen > 64 )
{
- ctx = ssl_md5_info_create();
- ssl_md5_transform(ctx, key, keylen);
- ssl_md5_complete(ctx, sum);
- ssl_md5_info_delete(ctx);
+ ctx = rdssl_md5_info_create();
+ rdssl_md5_transform(ctx, key, keylen);
+ rdssl_md5_complete(ctx, sum);
+ rdssl_md5_info_delete(ctx);
keylen = 16;
key = sum;
}
@@ -739,15 +740,15 @@
ipad[i] = ipad[i] ^ key[i];
opad[i] = opad[i] ^ key[i];
}
- ctx = ssl_md5_info_create();
- ssl_md5_transform(ctx, ipad, sizeof(ipad));
- ssl_md5_transform(ctx, data, len);
- ssl_md5_complete(ctx, sum);
- ssl_md5_info_delete(ctx);
- ctx = ssl_md5_info_create();
- ssl_md5_transform(ctx, opad, sizeof(opad));
- ssl_md5_complete(ctx, output);
- ssl_md5_info_delete(ctx);
+ ctx = rdssl_md5_info_create();
+ rdssl_md5_transform(ctx, ipad, sizeof(ipad));
+ rdssl_md5_transform(ctx, data, len);
+ rdssl_md5_complete(ctx, sum);
+ rdssl_md5_info_delete(ctx);
+ ctx = rdssl_md5_info_create();
+ rdssl_md5_transform(ctx, opad, sizeof(opad));
+ rdssl_md5_complete(ctx, output);
+ rdssl_md5_info_delete(ctx);
}
/*****************************************************************************/
@@ -1602,8 +1603,8 @@
/*****************************************************************************/
int APP_CC
-ssl_mod_exp(char* out, int out_len, char* in, int in_len,
- char* mod, int mod_len, char* exp, int exp_len)
+rdssl_mod_exp(char* out, int out_len, char* in, int in_len,
+ char* mod, int mod_len, char* exp, int exp_len)
{
/* Computes y = x ^ e mod m */
/* Binary left-to-right method */
@@ -1679,3 +1680,75 @@
return out_len;
}
+static uint8 g_ppk_n[72] =
+{
+ 0x3D, 0x3A, 0x5E, 0xBD, 0x72, 0x43, 0x3E, 0xC9,
+ 0x4D, 0xBB, 0xC1, 0x1E, 0x4A, 0xBA, 0x5F, 0xCB,
+ 0x3E, 0x88, 0x20, 0x87, 0xEF, 0xF5, 0xC1, 0xE2,
+ 0xD7, 0xB7, 0x6B, 0x9A, 0xF2, 0x52, 0x45, 0x95,
+ 0xCE, 0x63, 0x65, 0x6B, 0x58, 0x3A, 0xFE, 0xEF,
+ 0x7C, 0xE7, 0xBF, 0xFE, 0x3D, 0xF6, 0x5C, 0x7D,
+ 0x6C, 0x5E, 0x06, 0x09, 0x1A, 0xF5, 0x61, 0xBB,
+ 0x20, 0x93, 0x09, 0x5F, 0x05, 0x6D, 0xEA, 0x87,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static uint8 g_ppk_d[108] =
+{
+ 0x87, 0xA7, 0x19, 0x32, 0xDA, 0x11, 0x87, 0x55,
+ 0x58, 0x00, 0x16, 0x16, 0x25, 0x65, 0x68, 0xF8,
+ 0x24, 0x3E, 0xE6, 0xFA, 0xE9, 0x67, 0x49, 0x94,
+ 0xCF, 0x92, 0xCC, 0x33, 0x99, 0xE8, 0x08, 0x60,
+ 0x17, 0x9A, 0x12, 0x9F, 0x24, 0xDD, 0xB1, 0x24,
+ 0x99, 0xC7, 0x3A, 0xB8, 0x0A, 0x7B, 0x0D, 0xDD,
+ 0x35, 0x07, 0x79, 0x17, 0x0B, 0x51, 0x9B, 0xB3,
+ 0xC7, 0x10, 0x01, 0x13, 0xE7, 0x3F, 0xF3, 0x5F,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+int
+rdssl_sign_ok(char* e_data, int e_len, char* n_data, int n_len,
+ char* sign_data, int sign_len, char* sign_data2, int sign_len2, char* testkey)
+{
+ char* key;
+ char* md5_final;
+ void* md5;
+
+ if ((e_len != 4) || (n_len != 64) || (sign_len != 64) || (sign_len2 != 64))
+ {
+ return 1;
+ }
+ key = (char*)xmalloc(176);
+ md5_final = (char*)xmalloc(64);
+ md5 = rdssl_md5_info_create();
+ // copy the test key
+ memcpy(key, testkey, 176);
+ // replace e and n
+ memcpy(key + 32, e_data, 4);
+ memcpy(key + 36, n_data, 64);
+ rdssl_md5_clear(md5);
+ // the first 108 bytes
+ rdssl_md5_transform(md5, key, 108);
+ // set the whole thing with 0xff
+ memset(md5_final, 0xff, 64);
+ // digest 16 bytes
+ rdssl_md5_complete(md5, md5_final);
+ // set non 0xff array items
+ md5_final[16] = 0;
+ md5_final[62] = 1;
+ md5_final[63] = 0;
+ // encrypt
+ rdssl_mod_exp(sign_data, 64, md5_final, 64, (char*)g_ppk_n, 64,
+ (char*)g_ppk_d, 64);
+ // cleanup
+ rdssl_md5_info_delete(md5);
+ xfree(key);
+ xfree(md5_final);
+ return memcmp(sign_data, sign_data2, sign_len2);
+}
+
Modified: trunk/reactos/base/applications/mstsc/uimain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/ui…
==============================================================================
--- trunk/reactos/base/applications/mstsc/uimain.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/uimain.c [iso-8859-1] Tue May 16 16:37:29 2017
@@ -33,7 +33,7 @@
RD_BOOL g_polygon_ellipse_orders = False; /* polygon / ellipse orders */
RD_BOOL g_bitmap_compression = True;
uint32 g_rdp5_performanceflags =
- RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS |
RDP5_NO_CURSOR_SHADOW;
+ PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS |
PERF_DISABLE_CURSOR_SHADOW;
RD_BOOL g_bitmap_cache_persist_enable = False;
RD_BOOL g_bitmap_cache_precache = True;
RD_BOOL g_bitmap_cache = True;