コード例 #1
0
ファイル: license.c プロジェクト: FreeRDP/FreeRDP
BOOL license_send_platform_challenge_response_packet(rdpLicense* license)
{
    wStream* s;
    int length;
    BYTE* buffer;
    WINPR_RC4_CTX* rc4;
    BYTE mac_data[16];
    BOOL status;

    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;

    buffer = (BYTE*) malloc(length);
    if (!buffer)
        return FALSE;

    CopyMemory(buffer, license->PlatformChallenge->data, license->PlatformChallenge->length);
    CopyMemory(&buffer[license->PlatformChallenge->length], license->HardwareId, HWID_LENGTH);
    status = security_mac_data(license->MacSaltKey, buffer, length, mac_data);
    free(buffer);

    if (!status)
        return FALSE;

    rc4 = winpr_RC4_New(license->LicensingEncryptionKey,
                        LICENSING_ENCRYPTION_KEY_LENGTH);
    if (!rc4)
        return FALSE;

    buffer = (BYTE*) malloc(HWID_LENGTH);
    if (!buffer)
        return FALSE;

    status = winpr_RC4_Update(rc4, HWID_LENGTH, license->HardwareId, buffer);
    winpr_RC4_Free(rc4);
    if (!status)
    {
        free(buffer);
        return FALSE;
    }

    license->EncryptedHardwareId->type = BB_DATA_BLOB;
    license->EncryptedHardwareId->data = buffer;
    license->EncryptedHardwareId->length = HWID_LENGTH;
#ifdef WITH_DEBUG_LICENSE
    WLog_DBG(TAG, "LicensingEncryptionKey:");
    winpr_HexDump(TAG, WLOG_DEBUG, license->LicensingEncryptionKey, 16);
    WLog_DBG(TAG, "HardwareId:");
    winpr_HexDump(TAG, WLOG_DEBUG, license->HardwareId, HWID_LENGTH);
    WLog_DBG(TAG, "EncryptedHardwareId:");
    winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedHardwareId->data, HWID_LENGTH);
#endif
    return license_write_platform_challenge_response_packet(license, s, mac_data) &&
           license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
}
コード例 #2
0
ファイル: license.c プロジェクト: CTCAdmin/FreeRDP
void license_send_platform_challenge_response_packet(rdpLicense* license)
{
	wStream* s;
	int length;
	BYTE* buffer;
	CryptoRc4 rc4;
	BYTE mac_data[16];

	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;

	buffer = (BYTE*) malloc(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);

	buffer = (BYTE*) malloc(HWID_LENGTH);
	rc4 = crypto_rc4_init(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
	if (!rc4)
	{
		fprintf(stderr, "%s: unable to allocate a rc4\n", __FUNCTION__);
		return;
	}
	crypto_rc4(rc4, HWID_LENGTH, license->HardwareId, buffer);
	crypto_rc4_free(rc4);

	license->EncryptedHardwareId->type = BB_DATA_BLOB;
	license->EncryptedHardwareId->data = buffer;
	license->EncryptedHardwareId->length = HWID_LENGTH;

#ifdef WITH_DEBUG_LICENSE
	fprintf(stderr, "LicensingEncryptionKey:\n");
	winpr_HexDump(license->LicensingEncryptionKey, 16);
	fprintf(stderr, "\n");

	fprintf(stderr, "HardwareId:\n");
	winpr_HexDump(license->HardwareId, HWID_LENGTH);
	fprintf(stderr, "\n");

	fprintf(stderr, "EncryptedHardwareId:\n");
	winpr_HexDump(license->EncryptedHardwareId->data, HWID_LENGTH);
	fprintf(stderr, "\n");
#endif

	license_write_platform_challenge_response_packet(license, s, mac_data);

	license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
}
コード例 #3
0
ファイル: license.c プロジェクト: Cyclic/FreeRDP
void license_send_platform_challenge_response_packet(rdpLicense* license)
{
	STREAM* s;
	int length;
	uint8* buffer;
	CryptoRc4 rc4;
	uint8 mac_data[16];

	s = license_send_stream_init(license);
	DEBUG_LICENSE("Sending Platform Challenge Response Packet");

	license->encrypted_platform_challenge->type = BB_DATA_BLOB;
	length = license->platform_challenge->length + HWID_LENGTH;
	buffer = (uint8*) xmalloc(length);
	memcpy(buffer, license->platform_challenge->data, license->platform_challenge->length);
	memcpy(&buffer[license->platform_challenge->length], license->hwid, HWID_LENGTH);
	security_mac_data(license->mac_salt_key, buffer, length, mac_data);
	xfree(buffer);

	buffer = (uint8*) xmalloc(HWID_LENGTH);
	rc4 = crypto_rc4_init(license->licensing_encryption_key, LICENSING_ENCRYPTION_KEY_LENGTH);
	crypto_rc4(rc4, HWID_LENGTH, license->hwid, buffer);
	crypto_rc4_free(rc4);

#ifdef WITH_DEBUG_LICENSE
	printf("Licensing Encryption Key:\n");
	freerdp_hexdump(license->licensing_encryption_key, 16);

	printf("HardwareID:\n");
	freerdp_hexdump(license->hwid, 20);

	printf("Encrypted HardwareID:\n");
	freerdp_hexdump(buffer, 20);
#endif

	license->encrypted_hwid->type = BB_DATA_BLOB;
	license->encrypted_hwid->data = buffer;
	license->encrypted_hwid->length = HWID_LENGTH;

	license_write_platform_challenge_response_packet(license, s, mac_data);

	license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
}