36 |
uint8 temp_hash[48]; |
uint8 temp_hash[48]; |
37 |
|
|
38 |
/* Generate session key - two rounds of sec_hash_48 */ |
/* Generate session key - two rounds of sec_hash_48 */ |
39 |
sec_hash_48(temp_hash, client_rsa, client_key, server_key, 65); |
sec_hash_48(temp_hash, client_rsa, client_key, server_key, 65); |
40 |
sec_hash_48(session_key, temp_hash, server_key, client_key, 65); |
sec_hash_48(session_key, temp_hash, server_key, client_key, 65); |
41 |
|
|
42 |
/* Store first 16 bytes of session key, for generating signatures */ |
/* Store first 16 bytes of session key, for generating signatures */ |
43 |
memcpy(licence_sign_key, session_key, 16); |
memcpy(licence_sign_key, session_key, 16); |
44 |
|
|
45 |
/* Generate RC4 key */ |
/* Generate RC4 key */ |
46 |
sec_hash_16(licence_key, &session_key[16], client_key, server_key); |
sec_hash_16(licence_key, &session_key[16], client_key, server_key); |
48 |
|
|
49 |
/* Send a licence request packet */ |
/* Send a licence request packet */ |
50 |
static void licence_send_request(uint8 *client_random, uint8 *rsa_data, |
static void licence_send_request(uint8 *client_random, uint8 *rsa_data, |
51 |
char *user, char *host) |
char *user, char *host) |
52 |
{ |
{ |
53 |
uint32 sec_flags = SEC_LICENCE_NEG; |
uint32 sec_flags = SEC_LICENCE_NEG; |
54 |
uint16 userlen = strlen(user) + 1; |
uint16 userlen = strlen(user) + 1; |
102 |
|
|
103 |
/* Send an authentication response packet */ |
/* Send an authentication response packet */ |
104 |
static void licence_send_authresp(uint8 *token, uint8 *crypt_hwid, |
static void licence_send_authresp(uint8 *token, uint8 *crypt_hwid, |
105 |
uint8 *signature) |
uint8 *signature) |
106 |
{ |
{ |
107 |
uint32 sec_flags = SEC_LICENCE_NEG; |
uint32 sec_flags = SEC_LICENCE_NEG; |
108 |
uint16 length = 58; |
uint16 length = 58; |
132 |
{ |
{ |
133 |
uint16 tokenlen; |
uint16 tokenlen; |
134 |
|
|
135 |
in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */ |
in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */ |
136 |
|
|
137 |
in_uint16_le(s, tokenlen); |
in_uint16_le(s, tokenlen); |
138 |
if (tokenlen != LICENCE_TOKEN_SIZE) |
if (tokenlen != LICENCE_TOKEN_SIZE) |
151 |
static void licence_process_authreq(STREAM s) |
static void licence_process_authreq(STREAM s) |
152 |
{ |
{ |
153 |
uint8 *in_token, *in_sig; |
uint8 *in_token, *in_sig; |
154 |
uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE]; |
uint8 out_token[LICENCE_TOKEN_SIZE], |
155 |
|
decrypt_token[LICENCE_TOKEN_SIZE]; |
156 |
uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE]; |
uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE]; |
157 |
uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE]; |
uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE]; |
158 |
uint8 out_sig[LICENCE_SIGNATURE_SIZE]; |
uint8 out_sig[LICENCE_SIGNATURE_SIZE]; |
174 |
memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE); |
memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE); |
175 |
memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE); |
memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE); |
176 |
sec_sign(out_sig, licence_sign_key, 16, |
sec_sign(out_sig, licence_sign_key, 16, |
177 |
sealed_buffer, sizeof(sealed_buffer)); |
sealed_buffer, sizeof(sealed_buffer)); |
178 |
|
|
179 |
/* Deliberately break signature if licencing disabled */ |
/* Deliberately break signature if licencing disabled */ |
180 |
if (!licence) |
if (!licence) |
194 |
uint32 length; |
uint32 length; |
195 |
uint16 check; |
uint16 check; |
196 |
|
|
197 |
in_uint8s(s, 2); /* 3d 45 - unknown */ |
in_uint8s(s, 2); /* 3d 45 - unknown */ |
198 |
in_uint16_le(s, length); |
in_uint16_le(s, length); |
199 |
if (!s_check_rem(s, length)) |
if (!s_check_rem(s, length)) |
200 |
return; |
return; |
216 |
uint16 tag; |
uint16 tag; |
217 |
|
|
218 |
in_uint16_le(s, tag); |
in_uint16_le(s, tag); |
219 |
in_uint8s(s, 2); /* length */ |
in_uint8s(s, 2); /* length */ |
220 |
|
|
221 |
switch (tag) |
switch (tag) |
222 |
{ |
{ |