FreeRDP
license.c File Reference
#include <winpr/crt.h>
#include <winpr/crypto.h>
#include <winpr/shell.h>
#include <winpr/path.h>
#include <freerdp/log.h>
#include "redirection.h"
#include "certificate.h"
#include "license.h"

Macros

#define TAG   FREERDP_TAG("core.license")
 
#define PLATFORMID   (CLIENT_OS_ID_WINNT_POST_52 | CLIENT_IMAGE_ID_MICROSOFT)
 

Functions

static wStream * license_send_stream_init (rdpLicense *license)
 
static void license_generate_randoms (rdpLicense *license)
 
static BOOL license_generate_keys (rdpLicense *license)
 
static BOOL license_generate_hwid (rdpLicense *license)
 
static BOOL license_encrypt_premaster_secret (rdpLicense *license)
 
static LICENSE_PRODUCT_INFOlicense_new_product_info (void)
 
static void license_free_product_info (LICENSE_PRODUCT_INFO *productInfo)
 
static BOOL license_read_product_info (wStream *s, LICENSE_PRODUCT_INFO *productInfo)
 
static LICENSE_BLOBlicense_new_binary_blob (UINT16 type)
 
static void license_free_binary_blob (LICENSE_BLOB *blob)
 
static BOOL license_read_binary_blob (wStream *s, LICENSE_BLOB *blob)
 
static BOOL license_write_binary_blob (wStream *s, const LICENSE_BLOB *blob)
 
static SCOPE_LISTlicense_new_scope_list (void)
 
static void license_free_scope_list (SCOPE_LIST *scopeList)
 
static BOOL license_read_scope_list (wStream *s, SCOPE_LIST *scopeList)
 
static BOOL license_read_license_request_packet (rdpLicense *license, wStream *s)
 
static BOOL license_read_platform_challenge_packet (rdpLicense *license, wStream *s)
 
static BOOL license_read_new_or_upgrade_license_packet (rdpLicense *license, wStream *s)
 
static BOOL license_read_error_alert_packet (rdpLicense *license, wStream *s)
 
static BOOL license_write_new_license_request_packet (rdpLicense *license, wStream *s)
 
static BOOL license_answer_license_request (rdpLicense *license)
 
static BOOL license_write_platform_challenge_response_packet (rdpLicense *license, wStream *s, const BYTE *mac_data)
 
static BOOL license_send_platform_challenge_response_packet (rdpLicense *license)
 
static BOOL license_send_client_info (rdpLicense *license, const LICENSE_BLOB *calBlob, BYTE *signature)
 
static BOOL computeCalHash (const char *hostname, char *hashStr)
 
static BOOL saveCal (rdpSettings *settings, const BYTE *data, int length, char *hostname)
 
static BYTEloadCalFile (rdpSettings *settings, const char *hostname, int *dataLen)
 
BOOL license_read_preamble (wStream *s, BYTE *bMsgType, BYTE *flags, UINT16 *wMsgSize)
 
static BOOL license_write_preamble (wStream *s, BYTE bMsgType, BYTE flags, UINT16 wMsgSize)
 
static BOOL license_send (rdpLicense *license, wStream *s, BYTE type)
 
int license_recv (rdpLicense *license, wStream *s)
 
BOOL license_get_server_rsa_public_key (rdpLicense *license)
 
static BOOL license_rc4_with_licenseKey (const rdpLicense *license, const BYTE *input, size_t len, LICENSE_BLOB *target)
 
static BOOL license_encrypt_and_MAC (rdpLicense *license, const BYTE *input, size_t len, LICENSE_BLOB *target, BYTE *mac)
 
static BOOL license_decrypt_and_check_MAC (rdpLicense *license, const BYTE *input, size_t len, LICENSE_BLOB *target, const BYTE *packetMac)
 
BOOL license_write_encrypted_premaster_secret_blob (wStream *s, const LICENSE_BLOB *blob, UINT32 ModulusLength)
 
static BOOL license_read_encrypted_blob (const rdpLicense *license, wStream *s, LICENSE_BLOB *target)
 
BOOL license_send_valid_client_error_packet (rdpLicense *license)
 
rdpLicense * license_new (rdpRdp *rdp)
 
void license_free (rdpLicense *license)
 

Variables

static const char licenseStore [] = "licenses"
 

Macro Definition Documentation

#define TAG   FREERDP_TAG("core.license")

FreeRDP: A Remote Desktop Protocol Implementation RDP Licensing

Copyright 2011-2013 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2014 Norbert Federa norbe.nosp@m.rt.f.nosp@m.edera.nosp@m.@thi.nosp@m.ncast.nosp@m..com Copyright 2018 David Fort conta.nosp@m.ct@h.nosp@m.arden.nosp@m.ing-.nosp@m.consu.nosp@m.ltin.nosp@m.g.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

static BOOL computeCalHash ( const char *  hostname,
char *  hashStr 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_answer_license_request ( rdpLicense *  license)
static

Send a NEW_LICENSE_REQUEST packet.
http://msdn.microsoft.com/en-us/library/cc241918/

Parameters
licenselicense module

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL license_decrypt_and_check_MAC ( rdpLicense *  license,
const BYTE input,
size_t  len,
LICENSE_BLOB target,
const BYTE packetMac 
)
static

Decrypt the input using the license key and check the MAC

Parameters
licenserdpLicense to get keys and salt from
inputthe input data to decrypt and MAC
lensize of input
targeta target LICENSE_BLOB where the decrypted input will be stored
macthe signature buffer (16 bytes)
Returns
if the operation completed successfully

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL license_encrypt_and_MAC ( rdpLicense *  license,
const BYTE input,
size_t  len,
LICENSE_BLOB target,
BYTE mac 
)
static

Encrypt the input using the license key and MAC the input for a signature

Parameters
licenserdpLicense to get keys and salt from
inputthe input data to encrypt and MAC
lensize of input
targeta target LICENSE_BLOB where the encrypted input will be stored
macthe signature buffer (16 bytes)
Returns
if the operation completed successfully

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_encrypt_premaster_secret ( rdpLicense *  license)
static

Here is the call graph for this function:

Here is the caller graph for this function:

void license_free ( rdpLicense *  license)

Free license module.

Parameters
licenselicense module to be freed

Here is the call graph for this function:

Here is the caller graph for this function:

void license_free_binary_blob ( LICENSE_BLOB blob)
static

Free License Binary Blob (LICENSE_BINARY_BLOB).
http://msdn.microsoft.com/en-us/library/cc240481/

Parameters
bloblicense binary blob

Here is the caller graph for this function:

void license_free_product_info ( LICENSE_PRODUCT_INFO productInfo)
static

Free Product Information (LICENSE_PRODUCT_INFO).
http://msdn.microsoft.com/en-us/library/cc241915/

Parameters
productInfoproduct information

Here is the caller graph for this function:

void license_free_scope_list ( SCOPE_LIST scopeList)
static

Free License Scope List (SCOPE_LIST).
http://msdn.microsoft.com/en-us/library/cc241916/

Parameters
scopeListscope list

Here is the caller graph for this function:

BOOL license_generate_hwid ( rdpLicense *  license)
static

Generate Unique Hardware Identifier (CLIENT_HARDWARE_ID).

Parameters
licenselicense module

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL license_generate_keys ( rdpLicense *  license)
static

Generate License Cryptographic Keys.

Parameters
licenselicense module

Here is the call graph for this function:

Here is the caller graph for this function:

void license_generate_randoms ( rdpLicense *  license)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_get_server_rsa_public_key ( rdpLicense *  license)

Here is the call graph for this function:

Here is the caller graph for this function:

rdpLicense* license_new ( rdpRdp *  rdp)

Instantiate new license module.

Parameters
rdpRDP module
Returns
new license module

Here is the call graph for this function:

Here is the caller graph for this function:

LICENSE_BLOB * license_new_binary_blob ( UINT16  type)
static

Allocate New License Binary Blob (LICENSE_BINARY_BLOB).
http://msdn.microsoft.com/en-us/library/cc240481/

Returns
new license binary blob

Here is the caller graph for this function:

LICENSE_PRODUCT_INFO * license_new_product_info ( )
static

Allocate New Product Information (LICENSE_PRODUCT_INFO).
http://msdn.microsoft.com/en-us/library/cc241915/

Returns
new product information

Here is the caller graph for this function:

SCOPE_LIST * license_new_scope_list ( )
static

Allocate New License Scope List (SCOPE_LIST).
http://msdn.microsoft.com/en-us/library/cc241916/

Returns
new scope list

Here is the caller graph for this function:

static BOOL license_rc4_with_licenseKey ( const rdpLicense *  license,
const BYTE input,
size_t  len,
LICENSE_BLOB target 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_binary_blob ( wStream *  s,
LICENSE_BLOB blob 
)
static

Read License Binary Blob (LICENSE_BINARY_BLOB).
http://msdn.microsoft.com/en-us/library/cc240481/

Parameters
sstream
bloblicense binary blob

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL license_read_encrypted_blob ( const rdpLicense *  license,
wStream *  s,
LICENSE_BLOB target 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_error_alert_packet ( rdpLicense *  license,
wStream *  s 
)
static

Read an ERROR_ALERT packet.
http://msdn.microsoft.com/en-us/library/cc240482/

Parameters
licenselicense module
sstream

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_license_request_packet ( rdpLicense *  license,
wStream *  s 
)
static

Read a LICENSE_REQUEST packet.
http://msdn.microsoft.com/en-us/library/cc241914/

Parameters
licenselicense module
sstream

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_new_or_upgrade_license_packet ( rdpLicense *  license,
wStream *  s 
)
static

Read a NEW_LICENSE packet.
http://msdn.microsoft.com/en-us/library/cc241926/

Parameters
licenselicense module
sstream

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_platform_challenge_packet ( rdpLicense *  license,
wStream *  s 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_preamble ( wStream *  s,
BYTE bMsgType,
BYTE flags,
UINT16 wMsgSize 
)

Read a licensing preamble.
http://msdn.microsoft.com/en-us/library/cc240480/

Parameters
sstream
bMsgTypelicense message type
flagsmessage flags
wMsgSizemessage size
Returns
if the operation completed successfully

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_product_info ( wStream *  s,
LICENSE_PRODUCT_INFO productInfo 
)
static

Read Product Information (PRODUCT_INFO).
http://msdn.microsoft.com/en-us/library/cc241915/

Parameters
sstream
productInfoproduct information

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_read_scope_list ( wStream *  s,
SCOPE_LIST scopeList 
)
static

Read License Scope List (SCOPE_LIST).
http://msdn.microsoft.com/en-us/library/cc241916/

Parameters
sstream
scopeListscope list

Here is the call graph for this function:

Here is the caller graph for this function:

int license_recv ( rdpLicense *  license,
wStream *  s 
)

Receive an RDP licensing packet.
http://msdn.microsoft.com/en-us/library/cc240479/

Parameters
licenselicense module
sstream
Returns
if the operation completed successfully

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL license_send ( rdpLicense *  license,
wStream *  s,
BYTE  type 
)
static

Send an RDP licensing packet.
http://msdn.microsoft.com/en-us/library/cc240479/

Parameters
licenselicense module
sstream

Using EXTENDED_ERROR_MSG_SUPPORTED here would cause mstsc to crash when running in server mode! This flag seems to be incorrectly documented.

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_send_client_info ( rdpLicense *  license,
const LICENSE_BLOB calBlob,
BYTE signature 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_send_platform_challenge_response_packet ( rdpLicense *  license)
static

Send Client Challenge Response Packet.
http://msdn.microsoft.com/en-us/library/cc241922/

Parameters
licenselicense module

Here is the call graph for this function:

Here is the caller graph for this function:

wStream * license_send_stream_init ( rdpLicense *  license)
static

Initialize a license packet stream.

Parameters
licenselicense module
Returns
stream

Encryption of licensing packets is optional even if the rdp security layer is used. If the peer has not indicated that it is capable of processing encrypted licensing packets (rdp->do_crypt_license) we turn off encryption (via rdp->do_crypt) before initializing the rdp stream and reenable it afterwards.

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_send_valid_client_error_packet ( rdpLicense *  license)

Send Server License Error - Valid Client Packet.
http://msdn.microsoft.com/en-us/library/cc241922/

Parameters
licenselicense module

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_write_binary_blob ( wStream *  s,
const LICENSE_BLOB blob 
)
static

Write License Binary Blob (LICENSE_BINARY_BLOB).
http://msdn.microsoft.com/en-us/library/cc240481/

Parameters
sstream
bloblicense binary blob

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_write_encrypted_premaster_secret_blob ( wStream *  s,
const LICENSE_BLOB blob,
UINT32  ModulusLength 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_write_new_license_request_packet ( rdpLicense *  license,
wStream *  s 
)
static

Write a NEW_LICENSE_REQUEST packet.
http://msdn.microsoft.com/en-us/library/cc241918/

Parameters
licenselicense module
sstream

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL license_write_platform_challenge_response_packet ( rdpLicense *  license,
wStream *  s,
const BYTE macData 
)
static

Write Client Challenge Response Packet.
http://msdn.microsoft.com/en-us/library/cc241922/

Parameters
licenselicense module
sstream
mac_datasignature

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL license_write_preamble ( wStream *  s,
BYTE  bMsgType,
BYTE  flags,
UINT16  wMsgSize 
)
static

Write a licensing preamble.
http://msdn.microsoft.com/en-us/library/cc240480/

Parameters
sstream
bMsgTypelicense message type
flagsmessage flags
wMsgSizemessage size

Here is the call graph for this function:

Here is the caller graph for this function:

static BYTE* loadCalFile ( rdpSettings *  settings,
const char *  hostname,
int *  dataLen 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL saveCal ( rdpSettings *  settings,
const BYTE data,
int  length,
char *  hostname 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const char licenseStore[] = "licenses"
static