-/* -*- c-basic-offset: 8 -*-\r
- rdesktop: A Remote Desktop Protocol client.\r
- RDP licensing negotiation\r
- Copyright (C) Matthew Chapman 1999-2005\r
-\r
- This program is free software; you can redistribute it and/or modify\r
- it under the terms of the GNU General Public License as published by\r
- the Free Software Foundation; either version 2 of the License, or\r
- (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
-*/\r
-\r
-#include "rdesktop.h"\r
-#include <openssl/rc4.h> // TODO: remove dependency on OpenSSL\r
-\r
-/* Generate a session key and RC4 keys, given client and server randoms */\r
-static void\r
-licence_generate_keys(RDPCLIENT * This, uint8 * client_random, uint8 * server_random, uint8 * pre_master_secret)\r
-{\r
- uint8 master_secret[48];\r
- uint8 key_block[48];\r
-\r
- /* Generate master secret and then key material */\r
- sec_hash_48(master_secret, pre_master_secret, client_random, server_random, 'A');\r
- sec_hash_48(key_block, master_secret, server_random, client_random, 'A');\r
-\r
- /* Store first 16 bytes of session key as MAC secret */\r
- memcpy(This->licence.sign_key, key_block, 16);\r
-\r
- /* Generate RC4 key from next 16 bytes */\r
- sec_hash_16(This->licence.key, &key_block[16], client_random, server_random);\r
-}\r
-\r
-static void\r
-licence_generate_hwid(RDPCLIENT * This, uint8 * hwid)\r
-{\r
- buf_out_uint32(hwid, 2);\r
- strncpy((char *) (hwid + 4), This->licence_hostname, LICENCE_HWID_SIZE - 4);\r
-}\r
-\r
-/* Present an existing licence to the server */\r
-static BOOL\r
-licence_present(RDPCLIENT * This, uint8 * client_random, uint8 * rsa_data,\r
- uint8 * licence_data, int licence_size, uint8 * hwid, uint8 * signature)\r
-{\r
- uint32 sec_flags = SEC_LICENCE_NEG;\r
- uint16 length =\r
- 16 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE +\r
- licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE;\r
- STREAM s;\r
-\r
- s = sec_init(This, sec_flags, length + 4);\r
-\r
- if(s == NULL)\r
- return False;\r
-\r
- out_uint8(s, LICENCE_TAG_PRESENT);\r
- out_uint8(s, 2); /* version */\r
- out_uint16_le(s, length);\r
-\r
- out_uint32_le(s, 1);\r
- out_uint16(s, 0);\r
- out_uint16_le(s, 0x0201);\r
-\r
- out_uint8p(s, client_random, SEC_RANDOM_SIZE);\r
- out_uint16(s, 0);\r
- out_uint16_le(s, (SEC_MODULUS_SIZE + SEC_PADDING_SIZE));\r
- out_uint8p(s, rsa_data, SEC_MODULUS_SIZE);\r
- out_uint8s(s, SEC_PADDING_SIZE);\r
-\r
- out_uint16_le(s, 1);\r
- out_uint16_le(s, licence_size);\r
- out_uint8p(s, licence_data, licence_size);\r
-\r
- out_uint16_le(s, 1);\r
- out_uint16_le(s, LICENCE_HWID_SIZE);\r
- out_uint8p(s, hwid, LICENCE_HWID_SIZE);\r
-\r
- out_uint8p(s, signature, LICENCE_SIGNATURE_SIZE);\r
-\r
- s_mark_end(s);\r
- return sec_send(This, s, sec_flags);\r
-}\r
-\r
-/* Send a licence request packet */\r
-static BOOL\r
-licence_send_request(RDPCLIENT * This, uint8 * client_random, uint8 * rsa_data, char *user, char *host)\r
-{\r
- uint32 sec_flags = SEC_LICENCE_NEG;\r
- uint16 userlen = (uint16)strlen(user) + 1;\r
- uint16 hostlen = (uint16)strlen(host) + 1;\r
- uint16 length = 128 + userlen + hostlen;\r
- STREAM s;\r
-\r
- s = sec_init(This, sec_flags, length + 2);\r
-\r
- if(s == NULL)\r
- return False;\r
-\r
- out_uint8(s, LICENCE_TAG_REQUEST);\r
- out_uint8(s, 2); /* version */\r
- out_uint16_le(s, length);\r
-\r
- out_uint32_le(s, 1);\r
- out_uint16(s, 0);\r
- out_uint16_le(s, 0xff01);\r
-\r
- out_uint8p(s, client_random, SEC_RANDOM_SIZE);\r
- out_uint16(s, 0);\r
- out_uint16_le(s, (SEC_MODULUS_SIZE + SEC_PADDING_SIZE));\r
- out_uint8p(s, rsa_data, SEC_MODULUS_SIZE);\r
- out_uint8s(s, SEC_PADDING_SIZE);\r
-\r
- out_uint16_le(s, LICENCE_TAG_USER);\r
- out_uint16_le(s, userlen);\r
- out_uint8p(s, user, userlen);\r
-\r
- out_uint16_le(s, LICENCE_TAG_HOST);\r
- out_uint16_le(s, hostlen);\r
- out_uint8p(s, host, hostlen);\r
-\r
- s_mark_end(s);\r
- return sec_send(This, s, sec_flags);\r
-}\r
-\r
-/* Process a licence demand packet */\r
-static BOOL\r
-licence_process_demand(RDPCLIENT * This, STREAM s)\r
-{\r
- uint8 null_data[SEC_MODULUS_SIZE];\r
- uint8 *server_random;\r
- uint8 signature[LICENCE_SIGNATURE_SIZE];\r
- uint8 hwid[LICENCE_HWID_SIZE];\r
- uint8 *licence_data;\r
- int licence_size;\r
- RC4_KEY crypt_key;\r
-\r
- /* Retrieve the server random from the incoming packet */\r
- in_uint8p(s, server_random, SEC_RANDOM_SIZE);\r
-\r
- /* We currently use null client keys. This is a bit naughty but, hey,\r
- the security of licence negotiation isn't exactly paramount. */\r
- memset(null_data, 0, sizeof(null_data));\r
- licence_generate_keys(This, null_data, server_random, null_data);\r
-\r
- licence_size = load_licence(This, &licence_data);\r
- if (licence_size > 0)\r
- {\r
- /* Generate a signature for the HWID buffer */\r
- licence_generate_hwid(This, hwid);\r
- sec_sign(signature, 16, This->licence.sign_key, 16, hwid, sizeof(hwid));\r
-\r
- /* Now encrypt the HWID */\r
- RC4_set_key(&crypt_key, 16, This->licence.key);\r
- RC4(&crypt_key, sizeof(hwid), hwid, hwid);\r
-\r
- if(!licence_present(This, null_data, null_data, licence_data, licence_size, hwid, signature))\r
- return False;\r
-\r
- free(licence_data);\r
- return True;\r
- }\r
-\r
- return licence_send_request(This, null_data, null_data, This->licence_username, This->licence_hostname);\r
-}\r
-\r
-/* Send an authentication response packet */\r
-static BOOL\r
-licence_send_authresp(RDPCLIENT * This, uint8 * token, uint8 * crypt_hwid, uint8 * signature)\r
-{\r
- uint32 sec_flags = SEC_LICENCE_NEG;\r
- uint16 length = 58;\r
- STREAM s;\r
-\r
- s = sec_init(This, sec_flags, length + 2);\r
-\r
- if(s == NULL)\r
- return False;\r
-\r
- out_uint8(s, LICENCE_TAG_AUTHRESP);\r
- out_uint8(s, 2); /* version */\r
- out_uint16_le(s, length);\r
-\r
- out_uint16_le(s, 1);\r
- out_uint16_le(s, LICENCE_TOKEN_SIZE);\r
- out_uint8p(s, token, LICENCE_TOKEN_SIZE);\r
-\r
- out_uint16_le(s, 1);\r
- out_uint16_le(s, LICENCE_HWID_SIZE);\r
- out_uint8p(s, crypt_hwid, LICENCE_HWID_SIZE);\r
-\r
- out_uint8p(s, signature, LICENCE_SIGNATURE_SIZE);\r
-\r
- s_mark_end(s);\r
- return sec_send(This, s, sec_flags);\r
-}\r
-\r
-/* Parse an authentication request packet */\r
-static BOOL\r
-licence_parse_authreq(STREAM s, uint8 ** token, uint8 ** signature)\r
-{\r
- uint16 tokenlen;\r
-\r
- in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */\r
-\r
- in_uint16_le(s, tokenlen);\r
- if (tokenlen != LICENCE_TOKEN_SIZE)\r
- {\r
- error("token len %d\n", tokenlen);\r
- return False;\r
- }\r
-\r
- in_uint8p(s, *token, tokenlen);\r
- in_uint8p(s, *signature, LICENCE_SIGNATURE_SIZE);\r
-\r
- return s_check_end(s);\r
-}\r
-\r
-/* Process an authentication request packet */\r
-static void\r
-licence_process_authreq(RDPCLIENT * This, STREAM s)\r
-{\r
- uint8 *in_token, *in_sig;\r
- uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE];\r
- uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];\r
- uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];\r
- uint8 out_sig[LICENCE_SIGNATURE_SIZE];\r
- RC4_KEY crypt_key;\r
-\r
- /* Parse incoming packet and save the encrypted token */\r
- licence_parse_authreq(s, &in_token, &in_sig);\r
- memcpy(out_token, in_token, LICENCE_TOKEN_SIZE);\r
-\r
- /* Decrypt the token. It should read TEST in Unicode. */\r
- RC4_set_key(&crypt_key, 16, This->licence.key);\r
- RC4(&crypt_key, LICENCE_TOKEN_SIZE, in_token, decrypt_token);\r
-\r
- /* Generate a signature for a buffer of token and HWID */\r
- licence_generate_hwid(This, hwid);\r
- memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE);\r
- memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE);\r
- sec_sign(out_sig, 16, This->licence.sign_key, 16, sealed_buffer, sizeof(sealed_buffer));\r
-\r
- /* Now encrypt the HWID */\r
- RC4_set_key(&crypt_key, 16, This->licence.key);\r
- RC4(&crypt_key, LICENCE_HWID_SIZE, hwid, crypt_hwid);\r
-\r
- licence_send_authresp(This, out_token, crypt_hwid, out_sig);\r
-}\r
-\r
-/* Process an licence issue packet */\r
-static void\r
-licence_process_issue(RDPCLIENT * This, STREAM s)\r
-{\r
- RC4_KEY crypt_key;\r
- uint32 length;\r
- uint16 check;\r
- int i;\r
-\r
- in_uint8s(s, 2); /* 3d 45 - unknown */\r
- in_uint16_le(s, length);\r
- if (!s_check_rem(s, length))\r
- return;\r
-\r
- RC4_set_key(&crypt_key, 16, This->licence.key);\r
- RC4(&crypt_key, length, s->p, s->p);\r
-\r
- in_uint16(s, check);\r
- if (check != 0)\r
- return;\r
-\r
- This->licence_issued = True;\r
-\r
- in_uint8s(s, 2); /* pad */\r
-\r
- /* advance to fourth string */\r
- length = 0;\r
- for (i = 0; i < 4; i++)\r
- {\r
- in_uint8s(s, length);\r
- in_uint32_le(s, length);\r
- if (!s_check_rem(s, length))\r
- return;\r
- }\r
-\r
- This->licence_issued = True;\r
- save_licence(This, s->p, length);\r
-}\r
-\r
-/* Process a licence packet */\r
-void\r
-licence_process(RDPCLIENT * This, STREAM s)\r
-{\r
- uint8 tag;\r
-\r
- in_uint8(s, tag);\r
- in_uint8s(s, 3); /* version, length */\r
-\r
- switch (tag)\r
- {\r
- case LICENCE_TAG_DEMAND:\r
- licence_process_demand(This, s);\r
- break;\r
-\r
- case LICENCE_TAG_AUTHREQ:\r
- licence_process_authreq(This, s);\r
- break;\r
-\r
- case LICENCE_TAG_ISSUE:\r
- licence_process_issue(This, s);\r
- break;\r
-\r
- case LICENCE_TAG_REISSUE:\r
- case LICENCE_TAG_RESULT:\r
- break;\r
-\r
- default:\r
- unimpl("licence tag 0x%x\n", tag);\r
- }\r
-}\r
+/* -*- c-basic-offset: 8 -*-
+ rdesktop: A Remote Desktop Protocol client.
+ RDP licensing negotiation
+ Copyright (C) Matthew Chapman 1999-2005
+
+ This program is free software; you can redistribute it and/or modify
+ 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.
+*/
+
+#include "rdesktop.h"
+#include <openssl/rc4.h> // TODO: remove dependency on OpenSSL
+
+/* Generate a session key and RC4 keys, given client and server randoms */
+static void
+licence_generate_keys(RDPCLIENT * This, uint8 * client_random, uint8 * server_random, uint8 * pre_master_secret)
+{
+ uint8 master_secret[48];
+ uint8 key_block[48];
+
+ /* Generate master secret and then key material */
+ sec_hash_48(master_secret, pre_master_secret, client_random, server_random, 'A');
+ sec_hash_48(key_block, master_secret, server_random, client_random, 'A');
+
+ /* Store first 16 bytes of session key as MAC secret */
+ memcpy(This->licence.sign_key, key_block, 16);
+
+ /* Generate RC4 key from next 16 bytes */
+ sec_hash_16(This->licence.key, &key_block[16], client_random, server_random);
+}
+
+static void
+licence_generate_hwid(RDPCLIENT * This, uint8 * hwid)
+{
+ buf_out_uint32(hwid, 2);
+ strncpy((char *) (hwid + 4), This->licence_hostname, LICENCE_HWID_SIZE - 4);
+}
+
+/* Present an existing licence to the server */
+static BOOL
+licence_present(RDPCLIENT * This, uint8 * client_random, uint8 * rsa_data,
+ uint8 * licence_data, int licence_size, uint8 * hwid, uint8 * signature)
+{
+ uint32 sec_flags = SEC_LICENCE_NEG;
+ uint16 length =
+ 16 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE +
+ licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE;
+ STREAM s;
+
+ s = sec_init(This, sec_flags, length + 4);
+
+ if(s == NULL)
+ return False;
+
+ out_uint8(s, LICENCE_TAG_PRESENT);
+ out_uint8(s, 2); /* version */
+ out_uint16_le(s, length);
+
+ out_uint32_le(s, 1);
+ out_uint16(s, 0);
+ out_uint16_le(s, 0x0201);
+
+ out_uint8p(s, client_random, SEC_RANDOM_SIZE);
+ out_uint16(s, 0);
+ out_uint16_le(s, (SEC_MODULUS_SIZE + SEC_PADDING_SIZE));
+ out_uint8p(s, rsa_data, SEC_MODULUS_SIZE);
+ out_uint8s(s, SEC_PADDING_SIZE);
+
+ out_uint16_le(s, 1);
+ out_uint16_le(s, licence_size);
+ out_uint8p(s, licence_data, licence_size);
+
+ out_uint16_le(s, 1);
+ out_uint16_le(s, LICENCE_HWID_SIZE);
+ out_uint8p(s, hwid, LICENCE_HWID_SIZE);
+
+ out_uint8p(s, signature, LICENCE_SIGNATURE_SIZE);
+
+ s_mark_end(s);
+ return sec_send(This, s, sec_flags);
+}
+
+/* Send a licence request packet */
+static BOOL
+licence_send_request(RDPCLIENT * This, uint8 * client_random, uint8 * rsa_data, char *user, char *host)
+{
+ uint32 sec_flags = SEC_LICENCE_NEG;
+ uint16 userlen = (uint16)strlen(user) + 1;
+ uint16 hostlen = (uint16)strlen(host) + 1;
+ uint16 length = 128 + userlen + hostlen;
+ STREAM s;
+
+ s = sec_init(This, sec_flags, length + 2);
+
+ if(s == NULL)
+ return False;
+
+ out_uint8(s, LICENCE_TAG_REQUEST);
+ out_uint8(s, 2); /* version */
+ out_uint16_le(s, length);
+
+ out_uint32_le(s, 1);
+ out_uint16(s, 0);
+ out_uint16_le(s, 0xff01);
+
+ out_uint8p(s, client_random, SEC_RANDOM_SIZE);
+ out_uint16(s, 0);
+ out_uint16_le(s, (SEC_MODULUS_SIZE + SEC_PADDING_SIZE));
+ out_uint8p(s, rsa_data, SEC_MODULUS_SIZE);
+ out_uint8s(s, SEC_PADDING_SIZE);
+
+ out_uint16_le(s, LICENCE_TAG_USER);
+ out_uint16_le(s, userlen);
+ out_uint8p(s, user, userlen);
+
+ out_uint16_le(s, LICENCE_TAG_HOST);
+ out_uint16_le(s, hostlen);
+ out_uint8p(s, host, hostlen);
+
+ s_mark_end(s);
+ return sec_send(This, s, sec_flags);
+}
+
+/* Process a licence demand packet */
+static BOOL
+licence_process_demand(RDPCLIENT * This, STREAM s)
+{
+ uint8 null_data[SEC_MODULUS_SIZE];
+ uint8 *server_random;
+ uint8 signature[LICENCE_SIGNATURE_SIZE];
+ uint8 hwid[LICENCE_HWID_SIZE];
+ uint8 *licence_data;
+ int licence_size;
+ RC4_KEY crypt_key;
+
+ /* Retrieve the server random from the incoming packet */
+ in_uint8p(s, server_random, SEC_RANDOM_SIZE);
+
+ /* We currently use null client keys. This is a bit naughty but, hey,
+ the security of licence negotiation isn't exactly paramount. */
+ memset(null_data, 0, sizeof(null_data));
+ licence_generate_keys(This, null_data, server_random, null_data);
+
+ licence_size = load_licence(This, &licence_data);
+ if (licence_size > 0)
+ {
+ /* Generate a signature for the HWID buffer */
+ licence_generate_hwid(This, hwid);
+ sec_sign(signature, 16, This->licence.sign_key, 16, hwid, sizeof(hwid));
+
+ /* Now encrypt the HWID */
+ RC4_set_key(&crypt_key, 16, This->licence.key);
+ RC4(&crypt_key, sizeof(hwid), hwid, hwid);
+
+ if(!licence_present(This, null_data, null_data, licence_data, licence_size, hwid, signature))
+ return False;
+
+ free(licence_data);
+ return True;
+ }
+
+ return licence_send_request(This, null_data, null_data, This->licence_username, This->licence_hostname);
+}
+
+/* Send an authentication response packet */
+static BOOL
+licence_send_authresp(RDPCLIENT * This, uint8 * token, uint8 * crypt_hwid, uint8 * signature)
+{
+ uint32 sec_flags = SEC_LICENCE_NEG;
+ uint16 length = 58;
+ STREAM s;
+
+ s = sec_init(This, sec_flags, length + 2);
+
+ if(s == NULL)
+ return False;
+
+ out_uint8(s, LICENCE_TAG_AUTHRESP);
+ out_uint8(s, 2); /* version */
+ out_uint16_le(s, length);
+
+ out_uint16_le(s, 1);
+ out_uint16_le(s, LICENCE_TOKEN_SIZE);
+ out_uint8p(s, token, LICENCE_TOKEN_SIZE);
+
+ out_uint16_le(s, 1);
+ out_uint16_le(s, LICENCE_HWID_SIZE);
+ out_uint8p(s, crypt_hwid, LICENCE_HWID_SIZE);
+
+ out_uint8p(s, signature, LICENCE_SIGNATURE_SIZE);
+
+ s_mark_end(s);
+ return sec_send(This, s, sec_flags);
+}
+
+/* Parse an authentication request packet */
+static BOOL
+licence_parse_authreq(STREAM s, uint8 ** token, uint8 ** signature)
+{
+ uint16 tokenlen;
+
+ in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */
+
+ in_uint16_le(s, tokenlen);
+ if (tokenlen != LICENCE_TOKEN_SIZE)
+ {
+ error("token len %d\n", tokenlen);
+ return False;
+ }
+
+ in_uint8p(s, *token, tokenlen);
+ in_uint8p(s, *signature, LICENCE_SIGNATURE_SIZE);
+
+ return s_check_end(s);
+}
+
+/* Process an authentication request packet */
+static void
+licence_process_authreq(RDPCLIENT * This, STREAM s)
+{
+ uint8 *in_token, *in_sig;
+ uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE];
+ uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];
+ uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];
+ uint8 out_sig[LICENCE_SIGNATURE_SIZE];
+ RC4_KEY crypt_key;
+
+ /* Parse incoming packet and save the encrypted token */
+ licence_parse_authreq(s, &in_token, &in_sig);
+ memcpy(out_token, in_token, LICENCE_TOKEN_SIZE);
+
+ /* Decrypt the token. It should read TEST in Unicode. */
+ RC4_set_key(&crypt_key, 16, This->licence.key);
+ RC4(&crypt_key, LICENCE_TOKEN_SIZE, in_token, decrypt_token);
+
+ /* Generate a signature for a buffer of token and HWID */
+ licence_generate_hwid(This, hwid);
+ memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE);
+ memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE);
+ sec_sign(out_sig, 16, This->licence.sign_key, 16, sealed_buffer, sizeof(sealed_buffer));
+
+ /* Now encrypt the HWID */
+ RC4_set_key(&crypt_key, 16, This->licence.key);
+ RC4(&crypt_key, LICENCE_HWID_SIZE, hwid, crypt_hwid);
+
+ licence_send_authresp(This, out_token, crypt_hwid, out_sig);
+}
+
+/* Process an licence issue packet */
+static void
+licence_process_issue(RDPCLIENT * This, STREAM s)
+{
+ RC4_KEY crypt_key;
+ uint32 length;
+ uint16 check;
+ int i;
+
+ in_uint8s(s, 2); /* 3d 45 - unknown */
+ in_uint16_le(s, length);
+ if (!s_check_rem(s, length))
+ return;
+
+ RC4_set_key(&crypt_key, 16, This->licence.key);
+ RC4(&crypt_key, length, s->p, s->p);
+
+ in_uint16(s, check);
+ if (check != 0)
+ return;
+
+ This->licence_issued = True;
+
+ in_uint8s(s, 2); /* pad */
+
+ /* advance to fourth string */
+ length = 0;
+ for (i = 0; i < 4; i++)
+ {
+ in_uint8s(s, length);
+ in_uint32_le(s, length);
+ if (!s_check_rem(s, length))
+ return;
+ }
+
+ This->licence_issued = True;
+ save_licence(This, s->p, length);
+}
+
+/* Process a licence packet */
+void
+licence_process(RDPCLIENT * This, STREAM s)
+{
+ uint8 tag;
+
+ in_uint8(s, tag);
+ in_uint8s(s, 3); /* version, length */
+
+ switch (tag)
+ {
+ case LICENCE_TAG_DEMAND:
+ licence_process_demand(This, s);
+ break;
+
+ case LICENCE_TAG_AUTHREQ:
+ licence_process_authreq(This, s);
+ break;
+
+ case LICENCE_TAG_ISSUE:
+ licence_process_issue(This, s);
+ break;
+
+ case LICENCE_TAG_REISSUE:
+ case LICENCE_TAG_RESULT:
+ break;
+
+ default:
+ unimpl("licence tag 0x%x\n", tag);
+ }
+}