+
+ // demand activity
+ {
+ STREAM s;
+
+ s = sec_init(g_encryption ? SEC_ENCRYPT : 0, 10);
+ out_uint16_le(s, 10);
+ out_uint16_le(s, (RDP_PDU_DEMAND_ACTIVE | 0x10));
+ out_uint16_le(s, 1001);
+
+ out_uint32_le(s, 0x103ea);
+ s_mark_end(s);
+ sec_send(s, g_encryption ? SEC_ENCRYPT : 0);
+ }
+
+ continue;
+ }
+
+ if (sec_flags & SEC_CLIENT_RANDOM) {
+ uint32 length;
+ uint8 inr[SEC_MODULUS_SIZE];
+ int i;
+
+ printf("Receiving the client random!\n");
+ in_uint32_le(s, length);
+ if (length != SEC_MODULUS_SIZE + SEC_PADDING_SIZE) {
+ error("Client random was wrong size, %u bytes\n", length);
+ }
+ in_uint8a(s, sec_crypted_random, SEC_MODULUS_SIZE);
+ in_uint8s(s, SEC_PADDING_SIZE);
+ if (!s_check_end(s)) {
+ error("Junk after client random\n");
+ }
+
+ reverse(sec_crypted_random, SEC_MODULUS_SIZE);
+
+ RSA_private_decrypt(SEC_MODULUS_SIZE, sec_crypted_random, inr, privkey, RSA_NO_PADDING);
+
+ reverse(inr + SEC_RANDOM_SIZE, SEC_RANDOM_SIZE);
+
+ printf("Unencrypted client random: ");
+ for (i = 0; i < SEC_RANDOM_SIZE; ++i) {
+ printf("0x%x ", inr[i + SEC_RANDOM_SIZE]);
+ }
+ printf("\n");
+
+ // now we can generate the keys
+ sec_generate_keys(inr + SEC_RANDOM_SIZE, cacert, 1);
+ continue;