33 |
#include "crypto/bn.h" |
#include "crypto/bn.h" |
34 |
#endif |
#endif |
35 |
|
|
36 |
extern char hostname[16]; |
extern char g_hostname[16]; |
37 |
extern int g_width; |
extern int g_width; |
38 |
extern int g_height; |
extern int g_height; |
39 |
extern int keylayout; |
extern int g_keylayout; |
40 |
extern BOOL g_encryption; |
extern BOOL g_encryption; |
41 |
extern BOOL g_licence_issued; |
extern BOOL g_licence_issued; |
42 |
extern BOOL g_use_rdp5; |
extern BOOL g_use_rdp5; |
134 |
uint8 key_block[48]; |
uint8 key_block[48]; |
135 |
|
|
136 |
/* Construct pre-master secret */ |
/* Construct pre-master secret */ |
137 |
memcpy(pre_master_secret, client_random, 24); |
memcpy(pre_master_secret, client_random, 24); |
138 |
memcpy(pre_master_secret + 24, server_random, 24); |
memcpy(pre_master_secret + 24, server_random, 24); |
139 |
|
|
140 |
/* Generate master secret and then key material */ |
/* Generate master secret and then key material */ |
141 |
sec_hash_48(master_secret, pre_master_secret, client_random, server_random, 'A'); |
sec_hash_48(master_secret, pre_master_secret, client_random, server_random, 'A'); |
142 |
sec_hash_48(key_block, master_secret, client_random, server_random, 'X'); |
sec_hash_48(key_block, master_secret, client_random, server_random, 'X'); |
143 |
|
|
144 |
/* First 16 bytes of key material is MAC secret */ |
/* First 16 bytes of key material is MAC secret */ |
145 |
memcpy(sec_sign_key, key_block, 16); |
memcpy(sec_sign_key, key_block, 16); |
410 |
static void |
static void |
411 |
sec_out_mcs_data(STREAM s) |
sec_out_mcs_data(STREAM s) |
412 |
{ |
{ |
413 |
int hostlen = 2 * strlen(hostname); |
int hostlen = 2 * strlen(g_hostname); |
414 |
int length = 158 + 76 + 12 + 4; |
int length = 158 + 76 + 12 + 4; |
415 |
unsigned int i; |
unsigned int i; |
416 |
|
|
446 |
out_uint16_le(s, g_height); |
out_uint16_le(s, g_height); |
447 |
out_uint16_le(s, 0xca01); |
out_uint16_le(s, 0xca01); |
448 |
out_uint16_le(s, 0xaa03); |
out_uint16_le(s, 0xaa03); |
449 |
out_uint32_le(s, keylayout); |
out_uint32_le(s, g_keylayout); |
450 |
out_uint32_le(s, 2600); /* Client build. We are now 2600 compatible :-) */ |
out_uint32_le(s, 2600); /* Client build. We are now 2600 compatible :-) */ |
451 |
|
|
452 |
/* Unicode name of client, padded to 32 bytes */ |
/* Unicode name of client, padded to 32 bytes */ |
453 |
rdp_out_unistr(s, hostname, hostlen); |
rdp_out_unistr(s, g_hostname, hostlen); |
454 |
out_uint8s(s, 30 - hostlen); |
out_uint8s(s, 30 - hostlen); |
455 |
|
|
456 |
out_uint32_le(s, 4); |
out_uint32_le(s, 4); |
820 |
|
|
821 |
/* Receive secure transport packet */ |
/* Receive secure transport packet */ |
822 |
STREAM |
STREAM |
823 |
sec_recv(void) |
sec_recv(uint8 * rdpver) |
824 |
{ |
{ |
825 |
uint32 sec_flags; |
uint32 sec_flags; |
826 |
uint16 channel; |
uint16 channel; |
827 |
STREAM s; |
STREAM s; |
828 |
|
|
829 |
while ((s = mcs_recv(&channel)) != NULL) |
while ((s = mcs_recv(&channel, rdpver)) != NULL) |
830 |
{ |
{ |
831 |
|
if (rdpver != NULL) |
832 |
|
{ |
833 |
|
if (*rdpver != 3) |
834 |
|
{ |
835 |
|
if (*rdpver & 0x80) |
836 |
|
{ |
837 |
|
in_uint8s(s, 8); /* signature */ |
838 |
|
sec_decrypt(s->p, s->end - s->p); |
839 |
|
} |
840 |
|
return s; |
841 |
|
} |
842 |
|
} |
843 |
if (g_encryption || !g_licence_issued) |
if (g_encryption || !g_licence_issued) |
844 |
{ |
{ |
845 |
in_uint32_le(s, sec_flags); |
in_uint32_le(s, sec_flags); |