--- sourceforge.net/trunk/rdesktop/licence.c 2000/08/15 10:23:24 10 +++ sourceforge.net/trunk/rdesktop/licence.c 2001/01/06 03:47:04 25 @@ -29,26 +29,27 @@ static uint8 licence_sign_key[16]; /* Generate a session key and RC4 keys, given client and server randoms */ -void licence_generate_keys(uint8 *client_key, uint8 *server_key, - uint8 *client_rsa) +void +licence_generate_keys(uint8 *client_key, uint8 *server_key, uint8 *client_rsa) { uint8 session_key[48]; uint8 temp_hash[48]; /* Generate session key - two rounds of sec_hash_48 */ - sec_hash_48(temp_hash, client_rsa, client_key, server_key, 65); - sec_hash_48(session_key, temp_hash, server_key, client_key, 65); + sec_hash_48(temp_hash, client_rsa, client_key, server_key, 65); + sec_hash_48(session_key, temp_hash, server_key, client_key, 65); /* Store first 16 bytes of session key, for generating signatures */ - memcpy(licence_sign_key, session_key, 16); + memcpy(licence_sign_key, session_key, 16); /* Generate RC4 key */ sec_hash_16(licence_key, &session_key[16], client_key, server_key); } /* Send a licence request packet */ -static void licence_send_request(uint8 *client_random, uint8 *rsa_data, - char *user, char *host) +static void +licence_send_request(uint8 *client_random, uint8 *rsa_data, + char *user, char *host) { uint32 sec_flags = SEC_LICENCE_NEG; uint16 userlen = strlen(user) + 1; @@ -83,7 +84,8 @@ } /* Process a licence demand packet */ -static void licence_process_demand(STREAM s) +static void +licence_process_demand(STREAM s) { uint8 null_data[SEC_MODULUS_SIZE]; uint8 *server_random; @@ -101,8 +103,8 @@ } /* Send an authentication response packet */ -static void licence_send_authresp(uint8 *token, uint8 *crypt_hwid, - uint8 *signature) +static void +licence_send_authresp(uint8 *token, uint8 *crypt_hwid, uint8 *signature) { uint32 sec_flags = SEC_LICENCE_NEG; uint16 length = 58; @@ -128,11 +130,12 @@ } /* Parse an authentication request packet */ -static BOOL licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature) +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_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */ in_uint16_le(s, tokenlen); if (tokenlen != LICENCE_TOKEN_SIZE) @@ -148,10 +151,12 @@ } /* Process an authentication request packet */ -static void licence_process_authreq(STREAM s) +static void +licence_process_authreq(STREAM s) { uint8 *in_token, *in_sig; - uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE]; + 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]; @@ -173,7 +178,7 @@ memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE); memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE); sec_sign(out_sig, licence_sign_key, 16, - sealed_buffer, sizeof(sealed_buffer)); + sealed_buffer, sizeof(sealed_buffer)); /* Deliberately break signature if licencing disabled */ if (!licence) @@ -187,13 +192,14 @@ } /* Process an licence issue packet */ -static void licence_process_issue(STREAM s) +static void +licence_process_issue(STREAM s) { RC4_KEY crypt_key; uint32 length; uint16 check; - in_uint8s(s, 2); /* 3d 45 - unknown */ + in_uint8s(s, 2); /* 3d 45 - unknown */ in_uint16_le(s, length); if (!s_check_rem(s, length)) return; @@ -210,12 +216,13 @@ } /* Process a licence packet */ -void licence_process(STREAM s) +void +licence_process(STREAM s) { uint16 tag; in_uint16_le(s, tag); - in_uint8s(s, 2); /* length */ + in_uint8s(s, 2); /* length */ switch (tag) {