X-Git-Url: https://git.sesse.net/?p=rdpsrv;a=blobdiff_plain;f=rdp5.c;h=e8fd59749ab8a86278be0b35c3bbc59792427d03;hp=0ac38076132bbcd5768c83df303537cbba25ccc7;hb=a089728102db1602cb96b01049aee0222f077444;hpb=99f2e8c32508ab193c1d42221c86cb7fca4be9ab diff --git a/rdp5.c b/rdp5.c index 0ac3807..e8fd597 100644 --- a/rdp5.c +++ b/rdp5.c @@ -24,6 +24,46 @@ extern uint8 *g_next_packet; extern int listen_on_vnc; +extern uint8 sec_sign_key[16]; +extern int rc4_key_len; + +/* Initialise secure transport packet */ +STREAM +rdp5_init(int maxlen, BOOL encryption) +{ + int hdrlen; + STREAM s; + + hdrlen = encryption ? 11 : 3; + s = tcp_init(maxlen + hdrlen); + s_push_layer(s, sec_hdr, hdrlen); + + return s; +} + +void +rdp5_send(STREAM s, BOOL encryption) +{ + int datalen; + + s_pop_layer(s, sec_hdr); + + datalen = s->end - s->p; + + out_uint8(s, encryption ? 0x80 : 0); // protocol + out_uint8(s, 0x80 | (datalen >> 8)); + out_uint8(s, datalen & 0xff); + + if (encryption) { + datalen -= 11; + + sec_sign(s->p, 8, sec_sign_key, rc4_key_len, s->p + 8, datalen); + sec_encrypt(s->p + 8, datalen); + } + + tcp_send(s); +} + void rdp5_process(STREAM s, BOOL encryption) { @@ -79,7 +119,7 @@ rdp5_process(STREAM s, BOOL encryption) break; } default: - printf("Unimplemented RDP5 opcode %d (len=%u)\n", type, length); + printf("Unimplemented RDP5 opcode %d\n", type); return; } }