licence.c revision d65680efa46fa49e8bf14e67b29b782510ff934c
/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
RDP licensing negotiation
Copyright (C) Matthew Chapman 1999-2007
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Sun GPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun 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[64];
extern char g_hostname[16];
/* 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
{
}
/* Present an existing licence to the 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(s, 0);
out_uint16_le(s, 1);
out_uint16_le(s, 1);
s_mark_end(s);
}
/* Send a licence request packet */
static void
{
STREAM s;
out_uint16_le(s, length);
out_uint32_le(s, 1);
out_uint16(s, 0);
out_uint16_le(s, 0xff01);
out_uint16(s, 0);
out_uint16_le(s, userlen);
out_uint16_le(s, hostlen);
s_mark_end(s);
}
/* Process a licence demand 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 */
return;
}
}
/* Send an authentication 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 authentication request packet */
static RD_BOOL
{
in_uint16_le(s, tokenlen);
if (tokenlen != LICENCE_TOKEN_SIZE)
{
return False;
}
return s_check_end(s);
}
/* Process an authentication request 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 an licence issue packet */
static void
{
int i;
in_uint16_le(s, length);
if (!s_check_rem(s, length))
return;
if (check != 0)
return;
/* advance to fourth string */
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 packet */
void
{
switch (tag)
{
case LICENCE_TAG_DEMAND:
break;
case LICENCE_TAG_AUTHREQ:
break;
case LICENCE_TAG_ISSUE:
break;
case LICENCE_TAG_REISSUE:
case LICENCE_TAG_RESULT:
break;
default:
}
}