From 0b87100632f98d02e4f58b42f56c332f136bcdf0 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Tue, 15 Nov 2011 07:27:17 +0000 Subject: [PATCH] Applied patch from Thomas Uhle which includes fixes the license handling, this patch fixes bug 2817779. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1642 423420c4-83ab-492f-b58f-81f9feb106b5 --- licence.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/licence.c b/licence.c index 1244fe1..57e2dec 100644 --- a/licence.c +++ b/licence.c @@ -2,6 +2,7 @@ rdesktop: A Remote Desktop Protocol client. RDP licensing negotiation Copyright (C) Matthew Chapman 1999-2008 + Copyright (C) Thomas Uhle 2011 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 @@ -22,6 +23,7 @@ extern char *g_username; extern char g_hostname[16]; +extern RD_BOOL g_use_rdp5; static uint8 g_licence_key[16]; static uint8 g_licence_sign_key[16]; @@ -60,14 +62,14 @@ licence_present(uint8 * client_random, uint8 * rsa_data, { uint32 sec_flags = SEC_LICENCE_NEG; uint16 length = - 16 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE + + 24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE + licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE; STREAM s; - s = sec_init(sec_flags, length + 4); + s = sec_init(sec_flags, length + 2); out_uint8(s, LICENCE_TAG_PRESENT); - out_uint8(s, 2); /* version */ + out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */ out_uint16_le(s, length); out_uint32_le(s, 1); @@ -75,7 +77,7 @@ licence_present(uint8 * client_random, uint8 * rsa_data, out_uint16_le(s, 0x0201); out_uint8p(s, client_random, SEC_RANDOM_SIZE); - out_uint16(s, 0); + out_uint16_le(s, 2); out_uint16_le(s, (SEC_MODULUS_SIZE + SEC_PADDING_SIZE)); out_uint8p(s, rsa_data, SEC_MODULUS_SIZE); out_uint8s(s, SEC_PADDING_SIZE); @@ -107,7 +109,7 @@ licence_send_request(uint8 * client_random, uint8 * rsa_data, char *user, char * s = sec_init(sec_flags, length + 2); out_uint8(s, LICENCE_TAG_REQUEST); - out_uint8(s, 2); /* version */ + out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */ out_uint16_le(s, length); out_uint32_le(s, 1); @@ -115,7 +117,7 @@ licence_send_request(uint8 * client_random, uint8 * rsa_data, char *user, char * out_uint16_le(s, 0xff01); out_uint8p(s, client_random, SEC_RANDOM_SIZE); - out_uint16(s, 0); + out_uint16_le(s, 2); out_uint16_le(s, (SEC_MODULUS_SIZE + SEC_PADDING_SIZE)); out_uint8p(s, rsa_data, SEC_MODULUS_SIZE); out_uint8s(s, SEC_PADDING_SIZE); @@ -163,11 +165,18 @@ licence_process_demand(STREAM s) ssl_rc4_set_key(&crypt_key, g_licence_key, 16); ssl_rc4_crypt(&crypt_key, hwid, hwid, sizeof(hwid)); +#if WITH_DEBUG + DEBUG(("Sending licensing PDU (message type 0x%02x)\n", LICENCE_TAG_PRESENT)); +#endif licence_present(null_data, null_data, licence_data, licence_size, hwid, signature); + xfree(licence_data); return; } +#if WITH_DEBUG + DEBUG(("Sending licensing PDU (message type 0x%02x)\n", LICENCE_TAG_REQUEST)); +#endif licence_send_request(null_data, null_data, g_username, g_hostname); } @@ -182,7 +191,7 @@ licence_send_authresp(uint8 * token, uint8 * crypt_hwid, uint8 * signature) s = sec_init(sec_flags, length + 2); out_uint8(s, LICENCE_TAG_AUTHRESP); - out_uint8(s, 2); /* version */ + out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */ out_uint16_le(s, length); out_uint16_le(s, 1); @@ -249,6 +258,9 @@ licence_process_authreq(STREAM s) ssl_rc4_set_key(&crypt_key, g_licence_key, 16); ssl_rc4_crypt(&crypt_key, hwid, crypt_hwid, LICENCE_HWID_SIZE); +#if WITH_DEBUG + DEBUG(("Sending licensing PDU (message type 0x%02x)\n", LICENCE_TAG_AUTHRESP)); +#endif licence_send_authresp(out_token, crypt_hwid, out_sig); } @@ -300,6 +312,10 @@ licence_process(STREAM s) in_uint8(s, tag); in_uint8s(s, 3); /* version, length */ +#if WITH_DEBUG + DEBUG(("Received licensing PDU (message type 0x%02x)\n", tag)); +#endif + switch (tag) { case LICENCE_TAG_DEMAND: @@ -311,14 +327,14 @@ licence_process(STREAM s) break; case LICENCE_TAG_ISSUE: + case LICENCE_TAG_REISSUE: licence_process_issue(s); break; - case LICENCE_TAG_REISSUE: case LICENCE_TAG_RESULT: break; default: - unimpl("licence tag 0x%x\n", tag); + unimpl("licence tag 0x%02x\n", tag); } }