licence.c revision 6e9aa255e3376b2da5824c09c4c62bc233463bfe
/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
RDP licensing negotiation
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
Copyright (C) Thomas Uhle <thomas.uhle@mailbox.tu-dresden.de> 2011
Copyright (C) Henrik Andersson <henrik.andersson@cendio.com> 2014
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the General Public License version 2 (GPLv2) at this time for any software where
* a choice of GPL license versions is made available with the language indicating
* that GPLv2 or any later version may be used, or where a choice of which version
* of the GPL is applied is otherwise unspecified.
*/
#include "rdesktop.h"
#include "ssl.h"
extern char *g_username;
extern char g_hostname[16];
extern RDP_VERSION g_rdp_version;
/* Generate a session key and RC4 keys, given client and server randoms */
static void
{
/* Generate master secret and then key material */
/* Store first 16 bytes of session key as MAC secret */
/* Generate RC4 key from next 16 bytes */
}
static void
{
}
/* Send a lincece info packet to server */
static void
{
STREAM s;
out_uint16_le(s, length);
out_uint32_le(s, 1);
out_uint16(s, 0);
out_uint16_le(s, 0x0201);
out_uint16_le(s, 2);
out_uint16_le(s, 1);
out_uint16_le(s, 1);
s_mark_end(s);
}
/* Send a new licence request packet */
static void
{
STREAM s;
out_uint16_le(s, length);
out_uint16(s, 0);
out_uint16_le(s, 0xff01);
out_uint16_le(s, 2);
/* Username LICENSE_BINARY_BLOB */
out_uint16_le(s, userlen);
/* Machinename LICENSE_BINARY_BLOB */
out_uint16_le(s, hostlen);
s_mark_end(s);
}
/* Process a licence request packet */
static void
{
int licence_size;
/* Retrieve the server random from the incoming packet */
/* We currently use null client keys. This is a bit naughty but, hey,
the security of licence negotiation isn't exactly paramount. */
if (licence_size > 0)
{
/* Generate a signature for the HWID buffer */
/* Now encrypt the HWID */
#if WITH_DEBUG
#endif
return;
}
#if WITH_DEBUG
#endif
}
/* Send a platform challange response packet */
static void
{
STREAM s;
out_uint16_le(s, length);
out_uint16_le(s, 1);
out_uint16_le(s, 1);
s_mark_end(s);
}
/* Parse an platform challange request packet */
static RD_BOOL
{
in_uint16_le(s, tokenlen);
if (tokenlen != LICENCE_TOKEN_SIZE)
{
return False;
}
return s_check_end(s);
}
/* Process a platform challange packet */
static void
{
/* Parse incoming packet and save the encrypted token */
/* Decrypt the token. It should read TEST in Unicode. */
/* Generate a signature for a buffer of token and HWID */
/* Now encrypt the HWID */
}
/* Process a new licence packet */
static void
{
int i;
in_uint16_le(s, length);
if (!s_check_rem(s, length))
return;
/* Parse NEW_LICENSE_INFO block */
/* Skip strings, Scope, CompanyName and ProductId to get
to the LicenseInfo which we store in license blob. */
length = 0;
for (i = 0; i < 4; i++)
{
in_uint32_le(s, length);
if (!s_check_rem(s, length))
return;
}
save_licence(s->p, length);
}
/* process a licence error alert packet */
void
{
in_uint32(s, error_code);
in_uint32(s, error_info);
/* There is a special case in the error alert handling, when licensing is all good
and the server is not sending a license to client, a "Server License Error PDU -
Valid Client" packet is sent which means, every thing is ok.
Therefor we should flag that everything is ok with license here.
*/
if (error_code == 0x07)
{
return;
}
/* handle error codes, for now, jsut report them */
switch (error_code)
{
case 0x6: // ERR_NO_LICENSE_SERVER
warning("License error alert from server: No license server\n");
break;
case 0x8: // ERR_INVALID_CLIENT
warning("License error alert from server: Invalid client\n");
break;
case 0x4: // ERR_INVALID_SCOPE
case 0xb: // ERR_INVALID_PRODUCTID
case 0xc: // ERR_INVALID_MESSAGE_LENGTH
default:
warning("License error alert from server: code %u, state transition %u\n",
break;
}
}
/* Process a licence packet */
void
{
#if WITH_DEBUG
#endif
switch (tag)
{
case LICENCE_TAG_REQUEST:
break;
break;
case LICENCE_TAG_NEW_LICENCE:
/* we can handle new and upgrades of licences the same way. */
break;
case LICENCE_TAG_ERROR_ALERT:
break;
default:
}
}