--- sourceforge.net/trunk/rdesktop/licence.c 2002/07/30 07:18:48 82 +++ sourceforge.net/trunk/rdesktop/licence.c 2003/02/11 11:31:04 325 @@ -1,7 +1,7 @@ /* rdesktop: A Remote Desktop Protocol client. RDP licensing negotiation - 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 @@ -19,11 +19,15 @@ */ #include "rdesktop.h" + +#ifdef WITH_OPENSSL +#include +#else #include "crypto/rc4.h" +#endif extern char username[16]; extern char hostname[16]; -extern BOOL licence; static uint8 licence_key[16]; static uint8 licence_sign_key[16]; @@ -137,9 +141,9 @@ licence_process_demand(STREAM s) { uint8 null_data[SEC_MODULUS_SIZE]; - uint8 hwid[LICENCE_HWID_SIZE]; - uint8 signature[LICENCE_SIGNATURE_SIZE]; uint8 *server_random; + uint8 signature[LICENCE_SIGNATURE_SIZE]; + uint8 hwid[LICENCE_HWID_SIZE]; uint8 *licence_data; int licence_size; RC4_KEY crypt_key; @@ -153,22 +157,22 @@ licence_generate_keys(null_data, server_random, null_data); licence_size = load_licence(&licence_data); - if (licence_size == -1) + if (licence_size != -1) { - licence_send_request(null_data, null_data, username, hostname); + /* Generate a signature for the HWID buffer */ + licence_generate_hwid(hwid); + sec_sign(signature, 16, licence_sign_key, 16, hwid, sizeof(hwid)); + + /* Now encrypt the HWID */ + RC4_set_key(&crypt_key, 16, licence_key); + RC4(&crypt_key, sizeof(hwid), hwid, hwid); + + licence_present(null_data, null_data, licence_data, licence_size, hwid, signature); + xfree(licence_data); return; } - /* Generate a signature for the HWID buffer */ - licence_generate_hwid(hwid); - sec_sign(signature, 16, licence_sign_key, 16, hwid, sizeof(hwid)); - - /* Now encrypt the HWID */ - RC4_set_key(&crypt_key, 16, licence_key); - RC4(&crypt_key, sizeof(hwid), hwid, hwid); - - licence_present(null_data, null_data, licence_data, licence_size, hwid, signature); - xfree(licence_data); + licence_send_request(null_data, null_data, username, hostname); } /* Send an authentication response packet */ @@ -244,10 +248,6 @@ memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE); sec_sign(out_sig, 16, licence_sign_key, 16, sealed_buffer, sizeof(sealed_buffer)); - /* Deliberately break signature if licencing disabled */ - if (!licence) - memset(out_sig, 0, sizeof(out_sig)); - /* Now encrypt the HWID */ RC4_set_key(&crypt_key, 16, licence_key); RC4(&crypt_key, LICENCE_HWID_SIZE, hwid, crypt_hwid);