libfreerdp-core: added more licensing debug output
This commit is contained in:
parent
04c329cc53
commit
4cd720416a
@ -2,7 +2,7 @@
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* RDP Licensing
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2011-2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -383,15 +383,15 @@ void license_generate_hwid(rdpLicense* license)
|
||||
|
||||
void license_encrypt_premaster_secret(rdpLicense* license)
|
||||
{
|
||||
BYTE* encrypted_premaster_secret;
|
||||
BYTE* EncryptedPremasterSecret;
|
||||
|
||||
#ifdef LICENSE_NULL_RANDOM
|
||||
encrypted_premaster_secret = (BYTE*) malloc(MODULUS_MAX_SIZE);
|
||||
ZeroMemory(encrypted_premaster_secret, MODULUS_MAX_SIZE);
|
||||
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 = encrypted_premaster_secret;
|
||||
license->EncryptedPremasterSecret->data = EncryptedPremasterSecret;
|
||||
#else
|
||||
BYTE* modulus;
|
||||
BYTE* exponent;
|
||||
@ -548,13 +548,13 @@ BOOL license_read_binary_blob(STREAM* s, LICENSE_BLOB* blob)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Server can choose to not send data by setting len to 0.
|
||||
* Server can choose to not send data by setting length to 0.
|
||||
* If so, it may not bother to set the type, so shortcut the warning
|
||||
*/
|
||||
if (blob->type != BB_ANY_BLOB && blob->length == 0)
|
||||
if ((blob->type != BB_ANY_BLOB) && (blob->length == 0))
|
||||
return TRUE;
|
||||
|
||||
if (blob->type != wBlobType && blob->type != BB_ANY_BLOB)
|
||||
if ((blob->type != wBlobType) && (blob->type != BB_ANY_BLOB))
|
||||
{
|
||||
printf("license binary blob type (%x) does not match expected type (%x).\n", wBlobType, blob->type);
|
||||
}
|
||||
@ -891,20 +891,6 @@ BOOL license_read_error_alert_packet(rdpLicense* license, STREAM* s)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Platform ID.\n
|
||||
* @msdn{cc241918}
|
||||
* @param license license module
|
||||
* @param s stream
|
||||
*/
|
||||
|
||||
void license_write_platform_id(rdpLicense* license, STREAM* s)
|
||||
{
|
||||
stream_write_BYTE(s, 0); /* Client Operating System Version */
|
||||
stream_write_BYTE(s, 0); /* Independent Software Vendor (ISV) */
|
||||
stream_write_UINT16(s, 0); /* Client Software Build */
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a NEW_LICENSE_REQUEST packet.\n
|
||||
* @msdn{cc241918}
|
||||
@ -914,12 +900,36 @@ void license_write_platform_id(rdpLicense* license, STREAM* s)
|
||||
|
||||
void license_write_new_license_request_packet(rdpLicense* license, STREAM* s)
|
||||
{
|
||||
stream_write_UINT32(s, KEY_EXCHANGE_ALG_RSA); /* PreferredKeyExchangeAlg (4 bytes) */
|
||||
license_write_platform_id(license, s); /* PlatformId (4 bytes) */
|
||||
UINT32 PlatformId;
|
||||
UINT32 PreferredKeyExchangeAlg = KEY_EXCHANGE_ALG_RSA;
|
||||
|
||||
PlatformId = CLIENT_OS_ID_WINNT_POST_52 | CLIENT_IMAGE_ID_MICROSOFT;
|
||||
|
||||
stream_write_UINT32(s, PreferredKeyExchangeAlg); /* PreferredKeyExchangeAlg (4 bytes) */
|
||||
stream_write_UINT32(s, PlatformId); /* PlatformId (4 bytes) */
|
||||
stream_write(s, license->ClientRandom, 32); /* ClientRandom (32 bytes) */
|
||||
license_write_padded_binary_blob(s, license->EncryptedPremasterSecret); /* EncryptedPremasterSecret */
|
||||
license_write_binary_blob(s, license->ClientUserName); /* ClientUserName */
|
||||
license_write_binary_blob(s, license->ClientMachineName); /* ClientMachineName */
|
||||
|
||||
#ifdef WITH_DEBUG_LICENSE
|
||||
printf("PreferredKeyExchangeAlg: 0x%08X\n", PreferredKeyExchangeAlg);
|
||||
printf("\n");
|
||||
|
||||
printf("ClientRandom:\n");
|
||||
winpr_HexDump(license->ClientRandom, 32);
|
||||
printf("\n");
|
||||
|
||||
printf("EncryptedPremasterSecret\n");
|
||||
winpr_HexDump(license->EncryptedPremasterSecret->data, license->EncryptedPremasterSecret->length);
|
||||
printf("\n");
|
||||
|
||||
printf("ClientUserName (%d): %s\n", license->ClientUserName->length, (char*) license->ClientUserName->data);
|
||||
printf("\n");
|
||||
|
||||
printf("ClientMachineName (%d): %s\n", license->ClientMachineName->length, (char*) license->ClientMachineName->data);
|
||||
printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -933,6 +943,8 @@ void license_send_new_license_request_packet(rdpLicense* license)
|
||||
STREAM* s;
|
||||
char* username;
|
||||
|
||||
DEBUG_LICENSE("Sending New License Packet");
|
||||
|
||||
s = license_send_stream_init(license);
|
||||
|
||||
if (license->rdp->settings->Username != NULL)
|
||||
@ -965,11 +977,11 @@ void license_send_new_license_request_packet(rdpLicense* license)
|
||||
* @param mac_data signature
|
||||
*/
|
||||
|
||||
void license_write_platform_challenge_response_packet(rdpLicense* license, STREAM* s, BYTE* mac_data)
|
||||
void license_write_platform_challenge_response_packet(rdpLicense* license, STREAM* s, BYTE* macData)
|
||||
{
|
||||
license_write_binary_blob(s, license->EncryptedPlatformChallenge); /* EncryptedPlatformChallengeResponse */
|
||||
license_write_binary_blob(s, license->EncryptedHardwareId); /* EncryptedHWID */
|
||||
stream_write(s, mac_data, 16); /* MACData */
|
||||
stream_write(s, macData, 16); /* MACData */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -986,9 +998,10 @@ void license_send_platform_challenge_response_packet(rdpLicense* license)
|
||||
CryptoRc4 rc4;
|
||||
BYTE mac_data[16];
|
||||
|
||||
s = license_send_stream_init(license);
|
||||
DEBUG_LICENSE("Sending Platform Challenge Response Packet");
|
||||
|
||||
s = license_send_stream_init(license);
|
||||
|
||||
license->EncryptedPlatformChallenge->type = BB_DATA_BLOB;
|
||||
length = license->PlatformChallenge->length + HWID_LENGTH;
|
||||
|
||||
@ -1038,6 +1051,8 @@ BOOL license_send_valid_client_error_packet(rdpLicense* license)
|
||||
|
||||
s = license_send_stream_init(license);
|
||||
|
||||
DEBUG_LICENSE("Sending Error Alert Packet");
|
||||
|
||||
stream_write_UINT32(s, STATUS_VALID_CLIENT); /* dwErrorCode */
|
||||
stream_write_UINT32(s, ST_NO_TRANSITION); /* dwStateTransition */
|
||||
|
||||
|
@ -118,6 +118,27 @@ typedef struct rdp_license rdpLicense;
|
||||
#define LICENSE_DETAIL_MODERATE 0x0002
|
||||
#define LICENSE_DETAIL_DETAIL 0x0003
|
||||
|
||||
/*
|
||||
* PlatformId:
|
||||
*
|
||||
* The most significant byte of the PlatformId field contains the operating system version of the client.
|
||||
* The second most significant byte of the PlatformId field identifies the ISV that provided the client image.
|
||||
* The remaining two bytes in the PlatformId field are used by the ISV to identify the build number of the operating system.
|
||||
*
|
||||
* 0x04010000:
|
||||
*
|
||||
* CLIENT_OS_ID_WINNT_POST_52 (0x04000000)
|
||||
* CLIENT_IMAGE_ID_MICROSOFT (0x00010000)
|
||||
*/
|
||||
|
||||
#define CLIENT_OS_ID_WINNT_351 0x01000000
|
||||
#define CLIENT_OS_ID_WINNT_40 0x02000000
|
||||
#define CLIENT_OS_ID_WINNT_50 0x03000000
|
||||
#define CLIENT_OS_ID_WINNT_POST_52 0x04000000
|
||||
|
||||
#define CLIENT_IMAGE_ID_MICROSOFT 0x00010000
|
||||
#define CLIENT_IMAGE_ID_CITRIX 0x00020000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 dwVersion;
|
||||
|
@ -28,15 +28,10 @@
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#define CopyMemory RtlCopyMemory
|
||||
#define MoveMemory RtlMoveMemory
|
||||
#define FillMemory RtlFillMemory
|
||||
#define ZeroMemory RtlZeroMemory
|
||||
|
||||
#define RtlCopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length))
|
||||
#define RtlMoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length))
|
||||
#define RtlFillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length))
|
||||
#define RtlZeroMemory(Destination, Length) memset((Destination), 0, (Length))
|
||||
#define CopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length))
|
||||
#define MoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length))
|
||||
#define FillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length))
|
||||
#define ZeroMemory(Destination, Length) memset((Destination), 0, (Length))
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user