]> git.sesse.net Git - rdpsrv/commitdiff
Decrypt the client random (although not without Valgrind hits from OpenSSL...)
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 5 Feb 2005 20:46:53 +0000 (20:46 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 5 Feb 2005 20:46:53 +0000 (20:46 +0000)
mcs.c
secure.c

diff --git a/mcs.c b/mcs.c
index 6e13770f5f74adc9145bedca2445519258a26527..e771a074a7dd65ce2bd1de0f15e0e228673fe0db 100644 (file)
--- a/mcs.c
+++ b/mcs.c
@@ -395,10 +395,12 @@ mcs_send_connect_response()
        // this is a good time to load our private key :-)
        {
                unsigned char *buf = (unsigned char *)malloc(1024);
        // this is a good time to load our private key :-)
        {
                unsigned char *buf = (unsigned char *)malloc(1024);
-               unsigned char *ptr = buf;
+               const unsigned char *ptr = buf;
                memcpy(buf, private_key, sizeof(private_key));
                privkey = d2i_RSAPrivateKey(NULL, &ptr, sizeof(private_key));
                free(buf);
                memcpy(buf, private_key, sizeof(private_key));
                privkey = d2i_RSAPrivateKey(NULL, &ptr, sizeof(private_key));
                free(buf);
+
+               printf("Loaded private key (%u bytes)\n", sizeof(private_key));
        }
 }
 
        }
 }
 
index 10fc91692fdb72684f7526c242bfa009d9c9edcd..7c90ee262538055b270f697b0c4d33008b473a64 100644 (file)
--- a/secure.c
+++ b/secure.c
@@ -752,6 +752,8 @@ sec_recv(void)
 
                        if (sec_flags & SEC_CLIENT_RANDOM) {
                                uint32 length;
 
                        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);
                                
                                printf("Receiving the client random!\n");
                                in_uint32_le(s, length);
@@ -763,6 +765,18 @@ sec_recv(void)
                                if (!s_check_end(s)) {
                                        error("Junk after client random\n");
                                }
                                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");
                        }
                }
 
                        }
                }