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

Side by Side Diff: openssl/crypto/idea/i_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/idea/Makefile ('k') | openssl/crypto/idea/idea.h » ('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/idea/i_skey.c */ 1 /* crypto/idea/i_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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
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/idea.h> 59 #include <openssl/idea.h>
60 #include <openssl/crypto.h>
61 #ifdef OPENSSL_FIPS
62 #include <openssl/fips.h>
63 #endif
64
65 #include "idea_lcl.h" 60 #include "idea_lcl.h"
66 61
67 static IDEA_INT inverse(unsigned int xin); 62 static IDEA_INT inverse(unsigned int xin);
68
69 #ifdef OPENSSL_FIPS
70 void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks) 63 void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks)
71 { 64 {
72 if (FIPS_mode())
73 FIPS_BAD_ABORT(IDEA)
74 private_idea_set_encrypt_key(key, ks);
75 }
76 void private_idea_set_encrypt_key(const unsigned char *key,
77 IDEA_KEY_SCHEDULE *ks)
78 #else
79 void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks)
80 #endif
81 {
82 int i; 65 int i;
83 register IDEA_INT *kt,*kf,r0,r1,r2; 66 register IDEA_INT *kt,*kf,r0,r1,r2;
84 67
85 kt= &(ks->data[0][0]); 68 kt= &(ks->data[0][0]);
86 n2s(key,kt[0]); n2s(key,kt[1]); n2s(key,kt[2]); n2s(key,kt[3]); 69 n2s(key,kt[0]); n2s(key,kt[1]); n2s(key,kt[2]); n2s(key,kt[3]);
87 n2s(key,kt[4]); n2s(key,kt[5]); n2s(key,kt[6]); n2s(key,kt[7]); 70 n2s(key,kt[4]); n2s(key,kt[5]); n2s(key,kt[6]); n2s(key,kt[7]);
88 71
89 kf=kt; 72 kf=kt;
90 kt+=8; 73 kt+=8;
91 for (i=0; i<6; i++) 74 for (i=0; i<6; i++)
(...skipping 12 matching lines...) Expand all
104 r0= kf[7]; 87 r0= kf[7];
105 *(kt++)= ((r1<<9) | (r0>>7))&0xffff; 88 *(kt++)= ((r1<<9) | (r0>>7))&0xffff;
106 r1= kf[0]; 89 r1= kf[0];
107 if (i >= 5) break; 90 if (i >= 5) break;
108 *(kt++)= ((r0<<9) | (r1>>7))&0xffff; 91 *(kt++)= ((r0<<9) | (r1>>7))&0xffff;
109 *(kt++)= ((r1<<9) | (r2>>7))&0xffff; 92 *(kt++)= ((r1<<9) | (r2>>7))&0xffff;
110 kf+=8; 93 kf+=8;
111 } 94 }
112 } 95 }
113 96
114 void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk) 97 void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk)
115 { 98 {
116 int r; 99 int r;
117 » register IDEA_INT *tp,t; 100 » register IDEA_INT *fp,*tp,t;
118 » const IDEA_INT *fp;
119 101
120 tp= &(dk->data[0][0]); 102 tp= &(dk->data[0][0]);
121 fp= &(ek->data[8][0]); 103 fp= &(ek->data[8][0]);
122 for (r=0; r<9; r++) 104 for (r=0; r<9; r++)
123 { 105 {
124 *(tp++)=inverse(fp[0]); 106 *(tp++)=inverse(fp[0]);
125 *(tp++)=((int)(0x10000L-fp[2])&0xffff); 107 *(tp++)=((int)(0x10000L-fp[2])&0xffff);
126 *(tp++)=((int)(0x10000L-fp[1])&0xffff); 108 *(tp++)=((int)(0x10000L-fp[1])&0xffff);
127 *(tp++)=inverse(fp[3]); 109 *(tp++)=inverse(fp[3]);
128 if (r == 8) break; 110 if (r == 8) break;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 n1=n2; 147 n1=n2;
166 n2=r; 148 n2=r;
167 t=b2; 149 t=b2;
168 b2=b1-q*b2; 150 b2=b1-q*b2;
169 b1=t; 151 b1=t;
170 } 152 }
171 } while (r != 0); 153 } while (r != 0);
172 } 154 }
173 return((IDEA_INT)b2); 155 return((IDEA_INT)b2);
174 } 156 }
OLDNEW
« no previous file with comments | « openssl/crypto/idea/Makefile ('k') | openssl/crypto/idea/idea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698