~ubuntu-branches/ubuntu/precise/freerdp/precise

« back to all changes in this revision

Viewing changes to libfreerdp/licence.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2010-10-25 14:29:02 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20101025142902-tw406witod94zw6z
Tags: 0.8.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
        uint8 hwid[LICENCE_HWID_SIZE];
154
154
        uint8 *licence_data;
155
155
        int licence_size;
156
 
        CRYPTO_RC4 crypt_key;
 
156
        CryptoRc4 crypt_key;
157
157
 
158
158
        /* Retrieve the server random from the incoming packet */
159
159
        in_uint8p(s, server_random, SEC_RANDOM_SIZE);   /* ServerRandom */
172
172
                sec_sign(signature, 16, licence->licence_sign_key, 16, hwid, sizeof(hwid));
173
173
 
174
174
                /* Now encrypt the HWID */
175
 
                crypto_rc4_set_key(&crypt_key, licence->licence_key, 16);
176
 
                crypto_rc4(&crypt_key, sizeof(hwid), hwid, hwid);
 
175
                crypt_key = crypto_rc4_init(licence->licence_key, 16);
 
176
                crypto_rc4(crypt_key, sizeof(hwid), hwid, hwid);
 
177
                crypto_rc4_free(crypt_key);
177
178
 
178
179
                licence_present(licence, null_data, null_data, licence_data, licence_size, hwid, signature);
179
180
                xfree(licence_data);
248
249
        uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];
249
250
        uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];
250
251
        uint8 out_sig[LICENCE_SIGNATURE_SIZE];
251
 
        CRYPTO_RC4 crypt_key;
 
252
        CryptoRc4 crypt_key;
252
253
 
253
254
        /* Parse incoming packet and save the encrypted token */
254
255
        licence_parse_authreq(licence, s, &in_token, &in_sig);
255
256
        memcpy(out_token, in_token, LICENCE_TOKEN_SIZE);
256
257
 
257
258
        /* Decrypt the token. It should read TEST in Unicode. */
258
 
        crypto_rc4_set_key(&crypt_key, licence->licence_key, 16);
259
 
        crypto_rc4(&crypt_key, LICENCE_TOKEN_SIZE, in_token, decrypt_token);
 
259
        crypt_key = crypto_rc4_init(licence->licence_key, 16);
 
260
        crypto_rc4(crypt_key, LICENCE_TOKEN_SIZE, in_token, decrypt_token);
 
261
        crypto_rc4_free(crypt_key);
260
262
 
261
263
        /* Generate a signature for a buffer of token and HWID */
262
264
        licence_generate_hwid(licence, hwid);
265
267
        sec_sign(out_sig, 16, licence->licence_sign_key, 16, sealed_buffer, sizeof(sealed_buffer));
266
268
 
267
269
        /* Now encrypt the HWID */
268
 
        crypto_rc4_set_key(&crypt_key, licence->licence_key, 16);
269
 
        crypto_rc4(&crypt_key, LICENCE_HWID_SIZE, hwid, crypt_hwid);
 
270
        crypt_key = crypto_rc4_init(licence->licence_key, 16);
 
271
        crypto_rc4(crypt_key, LICENCE_HWID_SIZE, hwid, crypt_hwid);
 
272
        crypto_rc4_free(crypt_key);
270
273
 
271
274
        licence_send_authresp(licence, out_token, crypt_hwid, out_sig);
272
275
}
279
282
        uint32 length;
280
283
        uint32 os_major;
281
284
        uint32 os_minor;
282
 
        CRYPTO_RC4 crypt_key;
283
 
        
 
285
        CryptoRc4 crypt_key;
 
286
 
284
287
        /* Licensing Binary BLOB with EncryptedLicenseInfo: */
285
288
        in_uint8s(s, 2);        /* wBlobType should be 0x0009 (BB_ENCRYPTED_DATA_BLOB) */
286
289
        in_uint16_le(s, length);        /* wBlobLen */
287
 
        
 
290
 
288
291
        /* RC4-encrypted New License Information */
289
292
        if (!s_check_rem(s, length))
290
293
                return;
291
 
        
292
 
        crypto_rc4_set_key(&crypt_key, licence->licence_key, 16);
293
 
        crypto_rc4(&crypt_key, length, s->p, s->p);     /* decrypt in place */
 
294
 
 
295
        crypt_key = crypto_rc4_init(licence->licence_key, 16);
 
296
        crypto_rc4(crypt_key, length, s->p, s->p);      /* decrypt in place */
 
297
        crypto_rc4_free(crypt_key);
294
298
 
295
299
        /* dwVersion */
296
300
        in_uint16_le(s, os_major);      /* OS major version */
297
301
        in_uint16_le(s, os_minor);      /* OS minor version */
298
 
                
 
302
 
299
303
        /* Skip Scope, CompanyName and ProductId */
300
304
        for (i = 0; i < 3; i++)
301
305
        {