int load_licence(unsigned char **data);
void save_licence(unsigned char *data, int length);
/* rdp5.c */
+STREAM rdp5_init(int maxlen, BOOL encryption);
+void rdp5_send(STREAM s, BOOL encryption);
void rdp5_process(STREAM s, BOOL encryption);
/* rdp.c */
STREAM rdp_recv(uint8 * type);
void wave_out_write(STREAM s, uint16 tick, uint8 index);
void wave_out_play(void);
/* secure.c */
+void sec_encrypt(uint8 * data, int length);
void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt);
void sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2);
void buf_out_uint32(uint8 * buffer, uint32 value);
{
STREAM s;
- int length = 10*2 + width*height*3 + 8;
+ int length = 10*2 + width*height*3 + 5;
- printf("RDP5 chunk length: %u\n", 10*2 + width*height*3 + 2);
-
- s = tcp_init(length);
- out_uint8(s, 0); // version (RDP5)
- out_uint8(s, 0x80 | (length >> 8));
- out_uint8(s, length & 0xff);
+ s = rdp5_init(length, 0);
out_uint8(s, 1); // process bitmap update
out_uint16_le(s, 10*2 + width*height*3 + 2); // RDP5 chunk length
out_uint8p(s, data, width*height*3);
s_mark_end(s);
- tcp_send(s);
+ rdp5_send(s, 0);
}
#define EXPECT16(value) { in_uint16_le(s, unknown); if (unknown != (value)) printf("Unknown value on code line %u; expected 0x%x, got 0x%x\n", __LINE__, (value), unknown); }
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 -= 8;
+
+ 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)
{
extern VCHANNEL g_channels[];
extern unsigned int g_num_channels;
-static int rc4_key_len;
+int rc4_key_len;
static RC4_KEY rc4_decrypt_key;
static RC4_KEY rc4_encrypt_key;
static RSA *server_public_key;
-static uint8 sec_sign_key[16];
+uint8 sec_sign_key[16];
static uint8 sec_decrypt_key[16];
static uint8 sec_encrypt_key[16];
static uint8 sec_decrypt_update_key[16];
}
/* Encrypt data using RC4 */
-static void
+void
sec_encrypt(uint8 * data, int length)
{
static int use_count;