From 0de89ab4c981c12fafb32c916b2914df02d372ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 5 Feb 2013 09:46:25 -0500 Subject: [PATCH] libfreerdp-core: enable non-null licensing client random --- include/freerdp/crypto/crypto.h | 1 - libfreerdp/core/license.c | 25 +++++++++++-------------- libfreerdp/core/license.h | 4 ++-- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/include/freerdp/crypto/crypto.h b/include/freerdp/crypto/crypto.h index a1fb28704..fdf20e715 100644 --- a/include/freerdp/crypto/crypto.h +++ b/include/freerdp/crypto/crypto.h @@ -40,7 +40,6 @@ #endif #define EXPONENT_MAX_SIZE 4 -#define MODULUS_MAX_SIZE 256 #include #include diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index a4d162d7e..5a2486822 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -28,7 +28,8 @@ #include "license.h" -#define LICENSE_NULL_RANDOM 1 +//#define LICENSE_NULL_CLIENT_RANDOM 1 +#define LICENSE_NULL_PREMASTER_SECRET 1 #ifdef WITH_DEBUG_LICENSE @@ -304,11 +305,14 @@ BOOL license_recv(rdpLicense* license, STREAM* s) void license_generate_randoms(rdpLicense* license) { -#ifdef LICENSE_NULL_RANDOM ZeroMemory(license->ClientRandom, CLIENT_RANDOM_LENGTH); /* ClientRandom */ ZeroMemory(license->PremasterSecret, PREMASTER_SECRET_LENGTH); /* PremasterSecret */ -#else + +#ifndef LICENSE_NULL_CLIENT_RANDOM crypto_nonce(license->ClientRandom, CLIENT_RANDOM_LENGTH); /* ClientRandom */ +#endif + +#ifndef LICENSE_NULL_PREMASTER_SECRET crypto_nonce(license->PremasterSecret, PREMASTER_SECRET_LENGTH); /* PremasterSecret */ #endif } @@ -421,24 +425,17 @@ void license_encrypt_premaster_secret(rdpLicense* license) printf("\n"); #endif -#ifdef LICENSE_NULL_RANDOM - EncryptedPremasterSecret = (BYTE*) malloc(MODULUS_MAX_SIZE); - ZeroMemory(EncryptedPremasterSecret, MODULUS_MAX_SIZE); - - license->EncryptedPremasterSecret->type = BB_RANDOM_BLOB; - license->EncryptedPremasterSecret->length = PREMASTER_SECRET_LENGTH; - license->EncryptedPremasterSecret->data = EncryptedPremasterSecret; -#else - EncryptedPremasterSecret = (BYTE*) malloc(MODULUS_MAX_SIZE); - ZeroMemory(EncryptedPremasterSecret, MODULUS_MAX_SIZE); + EncryptedPremasterSecret = (BYTE*) malloc(ModulusLength); + ZeroMemory(EncryptedPremasterSecret, ModulusLength); +#ifndef LICENSE_NULL_PREMASTER_SECRET crypto_rsa_public_encrypt(license->PremasterSecret, PREMASTER_SECRET_LENGTH, ModulusLength, Modulus, Exponent, EncryptedPremasterSecret); +#endif license->EncryptedPremasterSecret->type = BB_RANDOM_BLOB; license->EncryptedPremasterSecret->length = PREMASTER_SECRET_LENGTH; license->EncryptedPremasterSecret->data = EncryptedPremasterSecret; -#endif } void license_decrypt_platform_challenge(rdpLicense* license) diff --git a/libfreerdp/core/license.h b/libfreerdp/core/license.h index 0902da6e6..8943c5708 100644 --- a/libfreerdp/core/license.h +++ b/libfreerdp/core/license.h @@ -172,8 +172,8 @@ typedef enum struct rdp_license { LICENSE_STATE state; - struct rdp_rdp* rdp; - struct rdp_certificate* certificate; + rdpRdp* rdp; + rdpCertificate* certificate; BYTE* Modulus; UINT32 ModulusLength; BYTE Exponent[4];