Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: openssl/crypto/des/set_key.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/crypto/des/fcrypt_b.c ('k') | openssl/crypto/des/xcbc_enc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* crypto/des/set_key.c */ 1 /* crypto/des/set_key.c */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 */ 57 */
58 58
59 /* set_key.c v 1.4 eay 24/9/91 59 /* set_key.c v 1.4 eay 24/9/91
60 * 1.4 Speed up by 400% :-) 60 * 1.4 Speed up by 400% :-)
61 * 1.3 added register declarations. 61 * 1.3 added register declarations.
62 * 1.2 unrolled make_key_sched a bit more 62 * 1.2 unrolled make_key_sched a bit more
63 * 1.1 added norm_expand_bits 63 * 1.1 added norm_expand_bits
64 * 1.0 First working version 64 * 1.0 First working version
65 */ 65 */
66 #include "des_locl.h" 66 #include "des_locl.h"
67 #ifdef OPENSSL_FIPS
68 #include <openssl/fips.h>
69 #endif
70 67
71 68 OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key,0)» /* defaults to false */
72 OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key);» /* defaults to false */
73 69
74 static const unsigned char odd_parity[256]={ 70 static const unsigned char odd_parity[256]={
75 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, 71 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
76 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, 72 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
77 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, 73 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
78 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, 74 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
79 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, 75 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
80 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, 76 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
81 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, 77 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
82 112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, 78 112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (!DES_check_key_parity(key)) 329 if (!DES_check_key_parity(key))
334 return(-1); 330 return(-1);
335 if (DES_is_weak_key(key)) 331 if (DES_is_weak_key(key))
336 return(-2); 332 return(-2);
337 DES_set_key_unchecked(key, schedule); 333 DES_set_key_unchecked(key, schedule);
338 return 0; 334 return 0;
339 } 335 }
340 336
341 void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) 337 void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
342 { 338 {
343 » static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 339 » static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
344 register DES_LONG c,d,t,s,t2; 340 register DES_LONG c,d,t,s,t2;
345 register const unsigned char *in; 341 register const unsigned char *in;
346 register DES_LONG *k; 342 register DES_LONG *k;
347 register int i; 343 register int i;
348 344
349 #ifdef OPENBSD_DEV_CRYPTO 345 #ifdef OPENBSD_DEV_CRYPTO
350 memcpy(schedule->key,key,sizeof schedule->key); 346 memcpy(schedule->key,key,sizeof schedule->key);
351 schedule->session=NULL; 347 schedule->session=NULL;
352 #endif 348 #endif
353 k = &schedule->ks->deslong[0]; 349 k = &schedule->ks->deslong[0];
354 in = &(*key)[0]; 350 in = &(*key)[0];
355 351
356 #ifdef OPENSSL_FIPS
357 FIPS_selftest_check();
358 #endif
359
360 c2l(in,c); 352 c2l(in,c);
361 c2l(in,d); 353 c2l(in,d);
362 354
363 /* do PC1 in 47 simple operations :-) 355 /* do PC1 in 47 simple operations :-)
364 * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) 356 * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov)
365 * for the inspiration. :-) */ 357 * for the inspiration. :-) */
366 PERM_OP (d,c,t,4,0x0f0f0f0fL); 358 PERM_OP (d,c,t,4,0x0f0f0f0fL);
367 HPERM_OP(c,t,-2,0xcccc0000L); 359 HPERM_OP(c,t,-2,0xcccc0000L);
368 HPERM_OP(d,t,-2,0xcccc0000L); 360 HPERM_OP(d,t,-2,0xcccc0000L);
369 PERM_OP (d,c,t,1,0x55555555L); 361 PERM_OP (d,c,t,1,0x55555555L);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 { 398 {
407 return(DES_set_key(key,schedule)); 399 return(DES_set_key(key,schedule));
408 } 400 }
409 /* 401 /*
410 #undef des_fixup_key_parity 402 #undef des_fixup_key_parity
411 void des_fixup_key_parity(des_cblock *key) 403 void des_fixup_key_parity(des_cblock *key)
412 { 404 {
413 des_set_odd_parity(key); 405 des_set_odd_parity(key);
414 } 406 }
415 */ 407 */
416
OLDNEW
« no previous file with comments | « openssl/crypto/des/fcrypt_b.c ('k') | openssl/crypto/des/xcbc_enc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698