/[rdesktop]/sourceforge.net/trunk/rdesktop/licence.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/licence.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 10 by matty, Tue Aug 15 10:23:24 2000 UTC revision 25 by matty, Sat Jan 6 03:47:04 2001 UTC
# Line 29  static uint8 licence_key[16]; Line 29  static uint8 licence_key[16];
29  static uint8 licence_sign_key[16];  static uint8 licence_sign_key[16];
30    
31  /* Generate a session key and RC4 keys, given client and server randoms */  /* Generate a session key and RC4 keys, given client and server randoms */
32  void licence_generate_keys(uint8 *client_key, uint8 *server_key,  void
33                             uint8 *client_rsa)  licence_generate_keys(uint8 *client_key, uint8 *server_key, uint8 *client_rsa)
34  {  {
35          uint8 session_key[48];          uint8 session_key[48];
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);
47  }  }
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
51                                          char *user, char *host)  licence_send_request(uint8 *client_random, uint8 *rsa_data,
52                         char *user, char *host)
53  {  {
54          uint32 sec_flags = SEC_LICENCE_NEG;          uint32 sec_flags = SEC_LICENCE_NEG;
55          uint16 userlen = strlen(user) + 1;          uint16 userlen = strlen(user) + 1;
# Line 83  static void licence_send_request(uint8 * Line 84  static void licence_send_request(uint8 *
84  }  }
85    
86  /* Process a licence demand packet */  /* Process a licence demand packet */
87  static void licence_process_demand(STREAM s)  static void
88    licence_process_demand(STREAM s)
89  {  {
90          uint8 null_data[SEC_MODULUS_SIZE];          uint8 null_data[SEC_MODULUS_SIZE];
91          uint8 *server_random;          uint8 *server_random;
# Line 101  static void licence_process_demand(STREA Line 103  static void licence_process_demand(STREA
103  }  }
104    
105  /* Send an authentication response packet */  /* Send an authentication response packet */
106  static void licence_send_authresp(uint8 *token, uint8 *crypt_hwid,  static void
107                                          uint8 *signature)  licence_send_authresp(uint8 *token, uint8 *crypt_hwid, uint8 *signature)
108  {  {
109          uint32 sec_flags = SEC_LICENCE_NEG;          uint32 sec_flags = SEC_LICENCE_NEG;
110          uint16 length = 58;          uint16 length = 58;
# Line 128  static void licence_send_authresp(uint8 Line 130  static void licence_send_authresp(uint8
130  }  }
131    
132  /* Parse an authentication request packet */  /* Parse an authentication request packet */
133  static BOOL licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature)  static BOOL
134    licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature)
135  {  {
136          uint16 tokenlen;          uint16 tokenlen;
137    
138          in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */          in_uint8s(s, 6);        /* unknown: f8 3d 15 00 04 f6 */
139    
140          in_uint16_le(s, tokenlen);          in_uint16_le(s, tokenlen);
141          if (tokenlen != LICENCE_TOKEN_SIZE)          if (tokenlen != LICENCE_TOKEN_SIZE)
# Line 148  static BOOL licence_parse_authreq(STREAM Line 151  static BOOL licence_parse_authreq(STREAM
151  }  }
152    
153  /* Process an authentication request packet */  /* Process an authentication request packet */
154  static void licence_process_authreq(STREAM s)  static void
155    licence_process_authreq(STREAM s)
156  {  {
157          uint8 *in_token, *in_sig;          uint8 *in_token, *in_sig;
158          uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE];          uint8 out_token[LICENCE_TOKEN_SIZE],
159                    decrypt_token[LICENCE_TOKEN_SIZE];
160          uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];          uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];
161          uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];          uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];
162          uint8 out_sig[LICENCE_SIGNATURE_SIZE];          uint8 out_sig[LICENCE_SIGNATURE_SIZE];
# Line 173  static void licence_process_authreq(STRE Line 178  static void licence_process_authreq(STRE
178          memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE);          memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE);
179          memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE);          memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE);
180          sec_sign(out_sig, licence_sign_key, 16,          sec_sign(out_sig, licence_sign_key, 16,
181                          sealed_buffer, sizeof(sealed_buffer));                   sealed_buffer, sizeof(sealed_buffer));
182    
183          /* Deliberately break signature if licencing disabled */          /* Deliberately break signature if licencing disabled */
184          if (!licence)          if (!licence)
# Line 187  static void licence_process_authreq(STRE Line 192  static void licence_process_authreq(STRE
192  }  }
193    
194  /* Process an licence issue packet */  /* Process an licence issue packet */
195  static void licence_process_issue(STREAM s)  static void
196    licence_process_issue(STREAM s)
197  {  {
198          RC4_KEY crypt_key;          RC4_KEY crypt_key;
199          uint32 length;          uint32 length;
200          uint16 check;          uint16 check;
201    
202          in_uint8s(s, 2); /* 3d 45 - unknown */          in_uint8s(s, 2);        /* 3d 45 - unknown */
203          in_uint16_le(s, length);          in_uint16_le(s, length);
204          if (!s_check_rem(s, length))          if (!s_check_rem(s, length))
205                  return;                  return;
# Line 210  static void licence_process_issue(STREAM Line 216  static void licence_process_issue(STREAM
216  }  }
217    
218  /* Process a licence packet */  /* Process a licence packet */
219  void licence_process(STREAM s)  void
220    licence_process(STREAM s)
221  {  {
222          uint16 tag;          uint16 tag;
223    
224          in_uint16_le(s, tag);          in_uint16_le(s, tag);
225          in_uint8s(s, 2); /* length */          in_uint8s(s, 2);        /* length */
226    
227          switch (tag)          switch (tag)
228          {          {

Legend:
Removed from v.10  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26