]> git.sesse.net Git - rdpsrv/blobdiff - secure.c
Separated the RDP5 sending into its own protocol layer.
[rdpsrv] / secure.c
index 62e59a526a8749e5354b6a6e4e64d66231b2ef27..1f7797b023e73fc05601a09ad89dfe9fbc8d0ebf 100644 (file)
--- a/secure.c
+++ b/secure.c
@@ -39,12 +39,12 @@ extern uint16 mcs_userid;
 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];
@@ -254,7 +254,7 @@ sec_update(uint8 * key, uint8 * update_key)
 }
 
 /* Encrypt data using RC4 */
-static void
+void
 sec_encrypt(uint8 * data, int length)
 {
        static int use_count;
@@ -375,7 +375,7 @@ sec_send_to_channel(STREAM s, uint32 flags, uint16 channel)
                flags &= ~SEC_ENCRYPT;
                datalen = s->end - s->p - 8;
 
-#if WITH_DEBUG
+#if WITH_DEBUG && 0
                DEBUG(("Sending encrypted packet:\n"));
                hexdump(s->p + 8, datalen);
 #endif
@@ -842,7 +842,7 @@ sec_recv(void)
        uint16 channel;
        STREAM s;
 
-       while ((s = mcs_recv(&channel)) != NULL)
+       if ((s = mcs_recv(&channel)) != NULL)
        {
                if (/*g_encryption || !g_licence_issued*/ 1)
                {
@@ -883,7 +883,7 @@ sec_recv(void)
                                        }
                                }
                                
-                               continue;
+                               return NULL;
                        }
 
                        if (sec_flags & SEC_LOGON_INFO) 
@@ -901,7 +901,7 @@ sec_recv(void)
                                        sec_send(s, SEC_LICENCE_NEG);
                                }
                                
-                               continue;
+                               return NULL;
                        }
 
                        if (sec_flags & SEC_CLIENT_RANDOM) {
@@ -934,7 +934,7 @@ sec_recv(void)
 
                                // now we can generate the keys
                                sec_generate_keys(inr + SEC_RANDOM_SIZE, cacert, 1);
-                               continue;
+                               return NULL;
                        }
                }
 
@@ -942,7 +942,7 @@ sec_recv(void)
                if (channel != MCS_GLOBAL_CHANNEL)
                {
                        channel_process(s, channel);
-                       continue;
+                       return NULL;
                }
 
                return s;