libfreerdp-core: added more licensing debug output
This commit is contained in:
parent
1b97663de8
commit
04c329cc53
@ -96,6 +96,20 @@ void license_print_product_info(PRODUCT_INFO* productInfo)
|
||||
free(ProductId);
|
||||
}
|
||||
|
||||
void license_print_scope_list(SCOPE_LIST* scopeList)
|
||||
{
|
||||
int index;
|
||||
LICENSE_BLOB* scope;
|
||||
|
||||
printf("ScopeList (%d):\n", scopeList->count);
|
||||
|
||||
for (index = 0; index < scopeList->count; index++)
|
||||
{
|
||||
scope = &scopeList->array[index];
|
||||
printf("\t%s\n", (char*) scope->data);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -435,16 +449,6 @@ void license_decrypt_platform_challenge(rdpLicense* license)
|
||||
license->EncryptedPlatformChallenge->data,
|
||||
license->PlatformChallenge->data);
|
||||
|
||||
#ifdef WITH_DEBUG_LICENSE
|
||||
printf("EncryptedPlatformChallenge:\n");
|
||||
winpr_HexDump(license->EncryptedPlatformChallenge->data, license->EncryptedPlatformChallenge->length);
|
||||
printf("\n");
|
||||
|
||||
printf("PlatformChallenge:\n");
|
||||
winpr_HexDump(license->PlatformChallenge->data, license->PlatformChallenge->length);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
crypto_rc4_free(rc4);
|
||||
}
|
||||
|
||||
@ -746,6 +750,9 @@ BOOL license_read_license_request_packet(rdpLicense* license, STREAM* s)
|
||||
|
||||
license_print_product_info(license->ProductInfo);
|
||||
printf("\n");
|
||||
|
||||
license_print_scope_list(license->ScopeList);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
@ -760,24 +767,45 @@ BOOL license_read_license_request_packet(rdpLicense* license, STREAM* s)
|
||||
|
||||
BOOL license_read_platform_challenge_packet(rdpLicense* license, STREAM* s)
|
||||
{
|
||||
BYTE MacData[16];
|
||||
UINT32 ConnectFlags = 0;
|
||||
|
||||
DEBUG_LICENSE("Receiving Platform Challenge Packet");
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, 4); /* ConnectFlags, Reserved (4 bytes) */
|
||||
stream_read_UINT32(s, ConnectFlags); /* ConnectFlags, Reserved (4 bytes) */
|
||||
|
||||
/* EncryptedPlatformChallenge */
|
||||
license->EncryptedPlatformChallenge->type = BB_ANY_BLOB;
|
||||
license_read_binary_blob(s, license->EncryptedPlatformChallenge);
|
||||
license->EncryptedPlatformChallenge->type = BB_ENCRYPTED_DATA_BLOB;
|
||||
|
||||
/* MACData (16 bytes) */
|
||||
if (!stream_skip(s, 16))
|
||||
if (stream_get_left(s) < 16)
|
||||
return FALSE;
|
||||
|
||||
stream_read(s, MacData, 16); /* MACData (16 bytes) */
|
||||
|
||||
license_decrypt_platform_challenge(license);
|
||||
|
||||
#ifdef WITH_DEBUG_LICENSE
|
||||
printf("ConnectFlags: 0x%08X\n", ConnectFlags);
|
||||
printf("\n");
|
||||
|
||||
printf("EncryptedPlatformChallenge:\n");
|
||||
winpr_HexDump(license->EncryptedPlatformChallenge->data, license->EncryptedPlatformChallenge->length);
|
||||
printf("\n");
|
||||
|
||||
printf("PlatformChallenge:\n");
|
||||
winpr_HexDump(license->PlatformChallenge->data, license->PlatformChallenge->length);
|
||||
printf("\n");
|
||||
|
||||
printf("MacData:\n");
|
||||
winpr_HexDump(MacData, 16);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -963,9 +991,10 @@ void license_send_platform_challenge_response_packet(rdpLicense* license)
|
||||
|
||||
license->EncryptedPlatformChallenge->type = BB_DATA_BLOB;
|
||||
length = license->PlatformChallenge->length + HWID_LENGTH;
|
||||
|
||||
buffer = (BYTE*) malloc(length);
|
||||
memcpy(buffer, license->PlatformChallenge->data, license->PlatformChallenge->length);
|
||||
memcpy(&buffer[license->PlatformChallenge->length], license->HardwareId, HWID_LENGTH);
|
||||
CopyMemory(buffer, license->PlatformChallenge->data, license->PlatformChallenge->length);
|
||||
CopyMemory(&buffer[license->PlatformChallenge->length], license->HardwareId, HWID_LENGTH);
|
||||
security_mac_data(license->MacSaltKey, buffer, length, mac_data);
|
||||
free(buffer);
|
||||
|
||||
@ -974,24 +1003,24 @@ void license_send_platform_challenge_response_packet(rdpLicense* license)
|
||||
crypto_rc4(rc4, HWID_LENGTH, license->HardwareId, buffer);
|
||||
crypto_rc4_free(rc4);
|
||||
|
||||
#ifdef WITH_DEBUG_LICENSE
|
||||
printf("Licensing Encryption Key:\n");
|
||||
winpr_HexDump(license->LicensingEncryptionKey, 16);
|
||||
printf("\n");
|
||||
|
||||
printf("HardwareID:\n");
|
||||
winpr_HexDump(license->HardwareId, 20);
|
||||
printf("\n");
|
||||
|
||||
printf("Encrypted HardwareID:\n");
|
||||
winpr_HexDump(buffer, 20);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
license->EncryptedHardwareId->type = BB_DATA_BLOB;
|
||||
license->EncryptedHardwareId->data = buffer;
|
||||
license->EncryptedHardwareId->length = HWID_LENGTH;
|
||||
|
||||
#ifdef WITH_DEBUG_LICENSE
|
||||
printf("LicensingEncryptionKey:\n");
|
||||
winpr_HexDump(license->LicensingEncryptionKey, 16);
|
||||
printf("\n");
|
||||
|
||||
printf("HardwareId:\n");
|
||||
winpr_HexDump(license->HardwareId, 20);
|
||||
printf("\n");
|
||||
|
||||
printf("EncryptedHardwareId:\n");
|
||||
winpr_HexDump(license->EncryptedHardwareId->data, 20);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
license_write_platform_challenge_response_packet(license, s, mac_data);
|
||||
|
||||
license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
|
||||
@ -1060,7 +1089,7 @@ rdpLicense* license_new(rdpRdp* rdp)
|
||||
|
||||
void license_free(rdpLicense* license)
|
||||
{
|
||||
if (license != NULL)
|
||||
if (license)
|
||||
{
|
||||
certificate_free(license->certificate);
|
||||
license_free_product_info(license->ProductInfo);
|
||||
|
@ -31,6 +31,7 @@ typedef struct rdp_license rdpLicense;
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
/* Licensing Packet Types */
|
||||
|
||||
#define LICENSE_REQUEST 0x01
|
||||
#define PLATFORM_CHALLENGE 0x02
|
||||
#define NEW_LICENSE 0x03
|
||||
@ -40,14 +41,15 @@ typedef struct rdp_license rdpLicense;
|
||||
#define PLATFORM_CHALLENGE_RESPONSE 0x15
|
||||
#define ERROR_ALERT 0xFF
|
||||
|
||||
#define LICENSE_PKT_CS_MASK (LICENSE_INFO | NEW_LICENSE_REQUEST | PLATFORM_CHALLENGE_RESPONSE | ERROR_ALERT)
|
||||
#define LICENSE_PKT_SC_MASK (LICENSE_REQUEST | PLATFORM_CHALLENGE | NEW_LICENSE | UPGRADE_LICENSE | ERROR_ALERT)
|
||||
#define LICENSE_PKT_MASK (LICENSE_PKT_CS_MASK | LICENSE_PKT_SC_MASK)
|
||||
#define LICENSE_PKT_CS_MASK (LICENSE_INFO | NEW_LICENSE_REQUEST | PLATFORM_CHALLENGE_RESPONSE | ERROR_ALERT)
|
||||
#define LICENSE_PKT_SC_MASK (LICENSE_REQUEST | PLATFORM_CHALLENGE | NEW_LICENSE | UPGRADE_LICENSE | ERROR_ALERT)
|
||||
#define LICENSE_PKT_MASK (LICENSE_PKT_CS_MASK | LICENSE_PKT_SC_MASK)
|
||||
|
||||
#define LICENSE_PREAMBLE_LENGTH 4
|
||||
#define LICENSE_PACKET_HEADER_MAX_LENGTH (RDP_PACKET_HEADER_MAX_LENGTH + RDP_SECURITY_HEADER_LENGTH + LICENSE_PREAMBLE_LENGTH)
|
||||
|
||||
/* Cryptographic Lengths */
|
||||
|
||||
#define CLIENT_RANDOM_LENGTH 32
|
||||
#define SERVER_RANDOM_LENGTH 32
|
||||
#define MASTER_SECRET_LENGTH 48
|
||||
@ -60,13 +62,15 @@ typedef struct rdp_license rdpLicense;
|
||||
#define HWID_LENGTH 20
|
||||
#define LICENSING_PADDING_SIZE 8
|
||||
|
||||
/* Licensing Preamble Flags */
|
||||
/* Preamble Flags */
|
||||
|
||||
#define PREAMBLE_VERSION_2_0 0x02
|
||||
#define PREAMBLE_VERSION_3_0 0x03
|
||||
#define LicenseProtocolVersionMask 0x0F
|
||||
#define EXTENDED_ERROR_MSG_SUPPORTED 0x80
|
||||
|
||||
/* Licensing Binary Blob Types */
|
||||
/* Binary Blob Types */
|
||||
|
||||
#define BB_ANY_BLOB 0x0000
|
||||
#define BB_DATA_BLOB 0x0001
|
||||
#define BB_RANDOM_BLOB 0x0002
|
||||
@ -78,10 +82,12 @@ typedef struct rdp_license rdpLicense;
|
||||
#define BB_CLIENT_USER_NAME_BLOB 0x000F
|
||||
#define BB_CLIENT_MACHINE_NAME_BLOB 0x0010
|
||||
|
||||
/* Key Exchange Algorithms */
|
||||
/* License Key Exchange Algorithms */
|
||||
|
||||
#define KEY_EXCHANGE_ALG_RSA 0x00000001
|
||||
|
||||
/* Licensing Error Codes */
|
||||
/* License Error Codes */
|
||||
|
||||
#define ERR_INVALID_SERVER_CERTIFICATE 0x00000001
|
||||
#define ERR_NO_LICENSE 0x00000002
|
||||
#define ERR_INVALID_MAC 0x00000003
|
||||
@ -92,12 +98,26 @@ typedef struct rdp_license rdpLicense;
|
||||
#define ERR_INVALID_PRODUCT_ID 0x0000000B
|
||||
#define ERR_INVALID_MESSAGE_LENGTH 0x0000000C
|
||||
|
||||
/* Licensing State Transition Codes */
|
||||
/* State Transition Codes */
|
||||
|
||||
#define ST_TOTAL_ABORT 0x00000001
|
||||
#define ST_NO_TRANSITION 0x00000002
|
||||
#define ST_RESET_PHASE_TO_START 0x00000003
|
||||
#define ST_RESEND_LAST_MESSAGE 0x00000004
|
||||
|
||||
/* Platform Challenge Types */
|
||||
|
||||
#define WIN32_PLATFORM_CHALLENGE_TYPE 0x0100
|
||||
#define WIN16_PLATFORM_CHALLENGE_TYPE 0x0200
|
||||
#define WINCE_PLATFORM_CHALLENGE_TYPE 0x0300
|
||||
#define OTHER_PLATFORM_CHALLENGE_TYPE 0xFF00
|
||||
|
||||
/* License Detail Levels */
|
||||
|
||||
#define LICENSE_DETAIL_SIMPLE 0x0001
|
||||
#define LICENSE_DETAIL_MODERATE 0x0002
|
||||
#define LICENSE_DETAIL_DETAIL 0x0003
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 dwVersion;
|
||||
|
Loading…
Reference in New Issue
Block a user