]> git.sesse.net Git - rdpsrv/blobdiff - secure.c
Decrypt the client random (although not without Valgrind hits from OpenSSL...)
[rdpsrv] / secure.c
index ba13a77c114a32745db06f55a261a7fc0611bcbb..7c90ee262538055b270f697b0c4d33008b473a64 100644 (file)
--- a/secure.c
+++ b/secure.c
@@ -51,6 +51,8 @@ static uint8 sec_decrypt_update_key[16];
 static uint8 sec_encrypt_update_key[16];
 static uint8 sec_crypted_random[SEC_MODULUS_SIZE];
 
+RSA *privkey;
+
 uint16 g_server_rdp_version = 0;
 
 /*
@@ -747,6 +749,35 @@ sec_recv(void)
                                printf("Received logon packet!\n");
                                rdp_get_logon_info(s);
                        }
+
+                       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");
+                       }
                }
 
                printf("Received MCS data on ch %u\n", channel);