--- sourceforge.net/trunk/rdesktop/secure.c 2002/07/30 07:18:48 82 +++ sourceforge.net/trunk/rdesktop/secure.c 2002/09/26 14:26:46 207 @@ -1,7 +1,7 @@ /* rdesktop: A Remote Desktop Protocol client. Protocol services - RDP encryption and licensing - Copyright (C) Matthew Chapman 1999-2001 + Copyright (C) Matthew Chapman 1999-2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -363,7 +363,7 @@ /* Transfer the client random to the server */ static void -sec_establish_key() +sec_establish_key(void) { uint32 length = SEC_MODULUS_SIZE + SEC_PADDING_SIZE; uint32 flags = SEC_CLIENT_RANDOM; @@ -385,6 +385,9 @@ { int hostlen = 2 * strlen(hostname); + if (hostlen > 30) + hostlen = 30; + out_uint16_be(s, 5); /* unknown */ out_uint16_be(s, 0x14); out_uint8(s, 0x7c); @@ -422,12 +425,12 @@ out_uint32_le(s, 12); out_uint8s(s, 64); /* reserved? 4 + 12 doublewords */ - out_uint16(s, 0xca01); + out_uint16_le(s, 0xca01); out_uint16(s, 0); /* Client encryption settings */ out_uint16_le(s, SEC_TAG_CLI_CRYPT); - out_uint16(s, 8); /* length */ + out_uint16_le(s, 8); /* length */ out_uint32_le(s, encryption ? 0x3 : 0); /* encryption supported, 128-bit supported */ s_mark_end(s); } @@ -471,6 +474,8 @@ in_uint32_le(s, *rc4_key_size); /* 1 = 40-bit, 2 = 128-bit */ in_uint32_le(s, crypt_level); /* 1 = low, 2 = medium, 3 = high */ + if (crypt_level == 0) /* no encryptation */ + return False; in_uint32_le(s, random_len); in_uint32_le(s, rsa_info_len); @@ -542,8 +547,12 @@ { uint16 tag, length; uint8 *next_tag; + uint8 len; - in_uint8s(s, 23); /* header */ + in_uint8s(s, 21); /* header */ + in_uint8(s, len); + if (len & 0x80) + in_uint8(s, len); while (s->p < s->end) { @@ -575,7 +584,7 @@ /* Receive secure transport packet */ STREAM -sec_recv() +sec_recv(void) { uint32 sec_flags; STREAM s; @@ -627,7 +636,7 @@ /* Disconnect a connection */ void -sec_disconnect() +sec_disconnect(void) { mcs_disconnect(); }