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

Side by Side Diff: openssl/crypto/rc4/rc4_skey.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/rc4/rc4_fblk.c ('k') | openssl/crypto/rc4/rc4test.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/rc4/rc4_skey.c */ 1 /* crypto/rc4/rc4_skey.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 * 52 *
53 * The licence and distribution terms for any publically available version or 53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59 #include <openssl/rc4.h> 59 #include <openssl/rc4.h>
60 #include "rc4_locl.h" 60 #include "rc4_locl.h"
61 #include <openssl/opensslv.h> 61 #include <openssl/opensslv.h>
62 #include <openssl/crypto.h>
63 #ifdef OPENSSL_FIPS
64 #include <openssl/fips.h>
65 #endif
66
67 62
68 const char RC4_version[]="RC4" OPENSSL_VERSION_PTEXT; 63 const char RC4_version[]="RC4" OPENSSL_VERSION_PTEXT;
69 64
70 const char *RC4_options(void) 65 const char *RC4_options(void)
71 { 66 {
72 #ifdef RC4_INDEX 67 #ifdef RC4_INDEX
73 if (sizeof(RC4_INT) == 1) 68 if (sizeof(RC4_INT) == 1)
74 return("rc4(idx,char)"); 69 return("rc4(idx,char)");
75 else 70 else
76 return("rc4(idx,int)"); 71 return("rc4(idx,int)");
77 #else 72 #else
78 if (sizeof(RC4_INT) == 1) 73 if (sizeof(RC4_INT) == 1)
79 return("rc4(ptr,char)"); 74 return("rc4(ptr,char)");
80 else 75 else
81 return("rc4(ptr,int)"); 76 return("rc4(ptr,int)");
82 #endif 77 #endif
83 } 78 }
84 79
85 /* RC4 as implemented from a posting from 80 /* RC4 as implemented from a posting from
86 * Newsgroups: sci.crypt 81 * Newsgroups: sci.crypt
87 * From: sterndark@netcom.com (David Sterndark) 82 * From: sterndark@netcom.com (David Sterndark)
88 * Subject: RC4 Algorithm revealed. 83 * Subject: RC4 Algorithm revealed.
89 * Message-ID: <sternCvKL4B.Hyy@netcom.com> 84 * Message-ID: <sternCvKL4B.Hyy@netcom.com>
90 * Date: Wed, 14 Sep 1994 06:35:31 GMT 85 * Date: Wed, 14 Sep 1994 06:35:31 GMT
91 */ 86 */
92 87
93 #ifdef OPENSSL_FIPS
94 void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
95 #else
96 void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) 88 void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
97 #endif
98 { 89 {
99 register RC4_INT tmp; 90 register RC4_INT tmp;
100 register int id1,id2; 91 register int id1,id2;
101 register RC4_INT *d; 92 register RC4_INT *d;
102 unsigned int i; 93 unsigned int i;
103 94
104 d= &(key->data[0]); 95 d= &(key->data[0]);
105 key->x = 0; 96 key->x = 0;
106 key->y = 0; 97 key->y = 0;
107 id1=id2=0; 98 id1=id2=0;
(...skipping 13 matching lines...) Expand all
121 /* 112 /*
122 * Unlike all other x86 [and x86_64] implementations, 113 * Unlike all other x86 [and x86_64] implementations,
123 * Intel P4 core [including EM64T] was found to perform 114 * Intel P4 core [including EM64T] was found to perform
124 * poorly with wider RC4_INT. Performance improvement 115 * poorly with wider RC4_INT. Performance improvement
125 * for IA-32 hand-coded assembler turned out to be 2.8x 116 * for IA-32 hand-coded assembler turned out to be 2.8x
126 * if re-coded for RC4_CHAR! It's however inappropriate 117 * if re-coded for RC4_CHAR! It's however inappropriate
127 * to just switch to RC4_CHAR for x86[_64], as non-P4 118 * to just switch to RC4_CHAR for x86[_64], as non-P4
128 * implementations suffer from significant performance 119 * implementations suffer from significant performance
129 * losses then, e.g. PIII exhibits >2x deterioration, 120 * losses then, e.g. PIII exhibits >2x deterioration,
130 * and so does Opteron. In order to assure optimal 121 * and so does Opteron. In order to assure optimal
131 » » * all-round performance, we detect P4 at run-time by 122 » » * all-round performance, let us [try to] detect P4 at
132 » » * checking upon reserved bit 20 in CPU capability 123 » » * run-time by checking upon HTT bit in CPU capability
133 * vector and set up compressed key schedule, which is 124 * vector and set up compressed key schedule, which is
134 * recognized by correspondingly updated assembler 125 * recognized by correspondingly updated assembler
135 » » * module... Bit 20 is set up by OPENSSL_ia32_cpuid. 126 » » * module...
136 » » *
137 * <appro@fy.chalmers.se> 127 * <appro@fy.chalmers.se>
138 */ 128 */
139 #ifdef OPENSSL_FIPS
140 unsigned long *ia32cap_ptr = OPENSSL_ia32cap_loc();
141 if (ia32cap_ptr && (*ia32cap_ptr & (1<<28))) {
142 #else
143 if (OPENSSL_ia32cap_P & (1<<28)) { 129 if (OPENSSL_ia32cap_P & (1<<28)) {
144 #endif
145 unsigned char *cp=(unsigned char *)d; 130 unsigned char *cp=(unsigned char *)d;
146 131
147 for (i=0;i<256;i++) cp[i]=i; 132 for (i=0;i<256;i++) cp[i]=i;
148 for (i=0;i<256;i++) SK_LOOP(cp,i); 133 for (i=0;i<256;i++) SK_LOOP(cp,i);
149 /* mark schedule as compressed! */ 134 /* mark schedule as compressed! */
150 d[256/sizeof(RC4_INT)]=-1; 135 d[256/sizeof(RC4_INT)]=-1;
151 return; 136 return;
152 } 137 }
153 } 138 }
154 # endif 139 # endif
155 #endif 140 #endif
156 for (i=0; i < 256; i++) d[i]=i; 141 for (i=0; i < 256; i++) d[i]=i;
157 for (i=0; i < 256; i+=4) 142 for (i=0; i < 256; i+=4)
158 { 143 {
159 SK_LOOP(d,i+0); 144 SK_LOOP(d,i+0);
160 SK_LOOP(d,i+1); 145 SK_LOOP(d,i+1);
161 SK_LOOP(d,i+2); 146 SK_LOOP(d,i+2);
162 SK_LOOP(d,i+3); 147 SK_LOOP(d,i+3);
163 } 148 }
164 } 149 }
165 150
OLDNEW
« no previous file with comments | « openssl/crypto/rc4/rc4_fblk.c ('k') | openssl/crypto/rc4/rc4test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698