|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "rijndael.h" |
|
20 #include "rijndaeltables.h" |
|
21 #include "../common/inlines.h" |
|
22 #include <cryptostrength.h> |
|
23 |
|
24 const TUint KAESKeyBytes128 = 16; |
|
25 const TUint KAESKeyBytes192 = 24; |
|
26 const TUint KAESKeyBytes256 = 32; |
|
27 const TUint KAESBlockBytes = 16; |
|
28 |
|
29 /* CRijndael */ |
|
30 EXPORT_C CRijndael::CRijndael(void) |
|
31 { |
|
32 } |
|
33 |
|
34 void CRijndael::Reset() |
|
35 { |
|
36 SetKey(*iKey); |
|
37 } |
|
38 |
|
39 TInt CRijndael::KeySize() const |
|
40 { |
|
41 return (4*(iRounds+1)); |
|
42 } |
|
43 |
|
44 CRijndael::~CRijndael() |
|
45 { |
|
46 delete iKey; |
|
47 } |
|
48 |
|
49 void CRijndael::ConstructL(const TDesC8& aKey) |
|
50 { |
|
51 TUint keySize = aKey.Size(); |
|
52 assert((keySize==KAESKeyBytes128)||(keySize==KAESKeyBytes192)||(keySize==KAESKeyBytes256)); |
|
53 iKey = aKey.AllocL(); |
|
54 iRounds = keySize/4 + 6; |
|
55 SetKey(aKey); |
|
56 } |
|
57 |
|
58 void CRijndael::SetKey(const TDesC8& aKey) |
|
59 { |
|
60 TUint keySize = aKey.Size(); |
|
61 TUint32 temp; |
|
62 TUint32* rk = &iK[0]; |
|
63 |
|
64 TUint i = 0; |
|
65 |
|
66 GetUserKeyBigEndian(rk, keySize/4, &aKey[0], keySize); |
|
67 |
|
68 switch(keySize) |
|
69 { |
|
70 case (KAESKeyBytes128): |
|
71 { |
|
72 FOREVER |
|
73 { |
|
74 temp = rk[3]; |
|
75 rk[4] = rk[0] ^ |
|
76 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 2)] & 0xff000000) ^ |
|
77 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^ |
|
78 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^ |
|
79 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 3)] & 0x000000ff) ^ |
|
80 RIJNDAEL_TABLE::rcon[i]; |
|
81 rk[5] = rk[1] ^ rk[4]; |
|
82 rk[6] = rk[2] ^ rk[5]; |
|
83 rk[7] = rk[3] ^ rk[6]; |
|
84 if (++i == 10) |
|
85 break; |
|
86 rk += 4; |
|
87 } |
|
88 } |
|
89 break; |
|
90 |
|
91 case (KAESKeyBytes192): |
|
92 { |
|
93 FOREVER |
|
94 { |
|
95 temp = rk[ 5]; |
|
96 rk[ 6] = rk[ 0] ^ |
|
97 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 2)] & 0xff000000) ^ |
|
98 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^ |
|
99 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^ |
|
100 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 3)] & 0x000000ff) ^ |
|
101 RIJNDAEL_TABLE::rcon[i]; |
|
102 rk[ 7] = rk[ 1] ^ rk[ 6]; |
|
103 rk[ 8] = rk[ 2] ^ rk[ 7]; |
|
104 rk[ 9] = rk[ 3] ^ rk[ 8]; |
|
105 if (++i == 8) |
|
106 break; |
|
107 rk[10] = rk[ 4] ^ rk[ 9]; |
|
108 rk[11] = rk[ 5] ^ rk[10]; |
|
109 rk += 6; |
|
110 } |
|
111 } |
|
112 break; |
|
113 |
|
114 case (KAESKeyBytes256): |
|
115 { |
|
116 FOREVER |
|
117 { |
|
118 temp = rk[ 7]; |
|
119 rk[ 8] = rk[ 0] ^ |
|
120 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 2)] & 0xff000000) ^ |
|
121 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^ |
|
122 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^ |
|
123 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 3)] & 0x000000ff) ^ |
|
124 RIJNDAEL_TABLE::rcon[i]; |
|
125 rk[ 9] = rk[ 1] ^ rk[ 8]; |
|
126 rk[10] = rk[ 2] ^ rk[ 9]; |
|
127 rk[11] = rk[ 3] ^ rk[10]; |
|
128 if (++i == 7) |
|
129 break; |
|
130 temp = rk[11]; |
|
131 rk[12] = rk[ 4] ^ |
|
132 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 3)] & 0xff000000) ^ |
|
133 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 2)] & 0x00ff0000) ^ |
|
134 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 1)] & 0x0000ff00) ^ |
|
135 (RIJNDAEL_TABLE::Te4[GETBYTE(temp, 0)] & 0x000000ff); |
|
136 rk[13] = rk[ 5] ^ rk[12]; |
|
137 rk[14] = rk[ 6] ^ rk[13]; |
|
138 rk[15] = rk[ 7] ^ rk[14]; |
|
139 |
|
140 rk += 8; |
|
141 } |
|
142 } |
|
143 break; |
|
144 |
|
145 default: |
|
146 assert(0); // Shouldn't get here, keeps compiler happy |
|
147 } |
|
148 } |
|
149 |
|
150 |
|
151 /* CAESEncryptor */ |
|
152 EXPORT_C CAESEncryptor* CAESEncryptor::NewL(const TDesC8& aKey) |
|
153 { |
|
154 CAESEncryptor* me = CAESEncryptor::NewLC(aKey); |
|
155 CleanupStack::Pop(me); |
|
156 return (me); |
|
157 } |
|
158 |
|
159 EXPORT_C CAESEncryptor* CAESEncryptor::NewLC(const TDesC8& aKey) |
|
160 { |
|
161 CAESEncryptor* me = new (ELeave) CAESEncryptor(); |
|
162 CleanupStack::PushL(me); |
|
163 me->ConstructL(aKey); |
|
164 TCrypto::IsSymmetricWeakEnoughL(BytesToBits(aKey.Size())); |
|
165 return (me); |
|
166 } |
|
167 |
|
168 TInt CAESEncryptor::BlockSize() const |
|
169 { |
|
170 return KAESBlockBytes; |
|
171 } |
|
172 |
|
173 void CAESEncryptor::Transform(TDes8& aBlock) |
|
174 { |
|
175 assert((TUint)aBlock.Size()==KAESBlockBytes); |
|
176 |
|
177 TUint32 s0, s1, s2, s3, t0, t1, t2, t3; |
|
178 const TUint32* rk = &iK[0]; |
|
179 |
|
180 /* |
|
181 * map byte array block to cipher state |
|
182 * and add initial round key: |
|
183 */ |
|
184 GetBlockBigEndian((TUint8*)&aBlock[0], s0, s1, s2, s3); |
|
185 s0 ^= rk[0]; |
|
186 s1 ^= rk[1]; |
|
187 s2 ^= rk[2]; |
|
188 s3 ^= rk[3]; |
|
189 /* |
|
190 * Nr - 1 full rounds: |
|
191 */ |
|
192 TUint r = iRounds >> 1; |
|
193 FOREVER |
|
194 { |
|
195 t0 = |
|
196 RIJNDAEL_TABLE::Te0[GETBYTE(s0, 3)] ^ |
|
197 RIJNDAEL_TABLE::Te1[GETBYTE(s1, 2)] ^ |
|
198 RIJNDAEL_TABLE::Te2[GETBYTE(s2, 1)] ^ |
|
199 RIJNDAEL_TABLE::Te3[GETBYTE(s3, 0)] ^ |
|
200 rk[4]; |
|
201 t1 = |
|
202 RIJNDAEL_TABLE::Te0[GETBYTE(s1, 3)] ^ |
|
203 RIJNDAEL_TABLE::Te1[GETBYTE(s2, 2)] ^ |
|
204 RIJNDAEL_TABLE::Te2[GETBYTE(s3, 1)] ^ |
|
205 RIJNDAEL_TABLE::Te3[GETBYTE(s0, 0)] ^ |
|
206 rk[5]; |
|
207 t2 = |
|
208 RIJNDAEL_TABLE::Te0[GETBYTE(s2, 3)] ^ |
|
209 RIJNDAEL_TABLE::Te1[GETBYTE(s3, 2)] ^ |
|
210 RIJNDAEL_TABLE::Te2[GETBYTE(s0, 1)] ^ |
|
211 RIJNDAEL_TABLE::Te3[GETBYTE(s1, 0)] ^ |
|
212 rk[6]; |
|
213 t3 = |
|
214 RIJNDAEL_TABLE::Te0[GETBYTE(s3, 3)] ^ |
|
215 RIJNDAEL_TABLE::Te1[GETBYTE(s0, 2)] ^ |
|
216 RIJNDAEL_TABLE::Te2[GETBYTE(s1, 1)] ^ |
|
217 RIJNDAEL_TABLE::Te3[GETBYTE(s2, 0)] ^ |
|
218 rk[7]; |
|
219 |
|
220 rk += 8; |
|
221 if (--r == 0) |
|
222 break; |
|
223 |
|
224 s0 = |
|
225 RIJNDAEL_TABLE::Te0[GETBYTE(t0, 3)] ^ |
|
226 RIJNDAEL_TABLE::Te1[GETBYTE(t1, 2)] ^ |
|
227 RIJNDAEL_TABLE::Te2[GETBYTE(t2, 1)] ^ |
|
228 RIJNDAEL_TABLE::Te3[GETBYTE(t3, 0)] ^ |
|
229 rk[0]; |
|
230 s1 = |
|
231 RIJNDAEL_TABLE::Te0[GETBYTE(t1, 3)] ^ |
|
232 RIJNDAEL_TABLE::Te1[GETBYTE(t2, 2)] ^ |
|
233 RIJNDAEL_TABLE::Te2[GETBYTE(t3, 1)] ^ |
|
234 RIJNDAEL_TABLE::Te3[GETBYTE(t0, 0)] ^ |
|
235 rk[1]; |
|
236 s2 = |
|
237 RIJNDAEL_TABLE::Te0[GETBYTE(t2, 3)] ^ |
|
238 RIJNDAEL_TABLE::Te1[GETBYTE(t3, 2)] ^ |
|
239 RIJNDAEL_TABLE::Te2[GETBYTE(t0, 1)] ^ |
|
240 RIJNDAEL_TABLE::Te3[GETBYTE(t1, 0)] ^ |
|
241 rk[2]; |
|
242 s3 = |
|
243 RIJNDAEL_TABLE::Te0[GETBYTE(t3, 3)] ^ |
|
244 RIJNDAEL_TABLE::Te1[GETBYTE(t0, 2)] ^ |
|
245 RIJNDAEL_TABLE::Te2[GETBYTE(t1, 1)] ^ |
|
246 RIJNDAEL_TABLE::Te3[GETBYTE(t2, 0)] ^ |
|
247 rk[3]; |
|
248 } |
|
249 /* |
|
250 * apply last round and |
|
251 * map cipher state to byte array block: |
|
252 */ |
|
253 |
|
254 s0 = |
|
255 (RIJNDAEL_TABLE::Te4[GETBYTE(t0, 3)] & 0xff000000) ^ |
|
256 (RIJNDAEL_TABLE::Te4[GETBYTE(t1, 2)] & 0x00ff0000) ^ |
|
257 (RIJNDAEL_TABLE::Te4[GETBYTE(t2, 1)] & 0x0000ff00) ^ |
|
258 (RIJNDAEL_TABLE::Te4[GETBYTE(t3, 0)] & 0x000000ff) ^ |
|
259 rk[0]; |
|
260 s1 = |
|
261 (RIJNDAEL_TABLE::Te4[GETBYTE(t1, 3)] & 0xff000000) ^ |
|
262 (RIJNDAEL_TABLE::Te4[GETBYTE(t2, 2)] & 0x00ff0000) ^ |
|
263 (RIJNDAEL_TABLE::Te4[GETBYTE(t3, 1)] & 0x0000ff00) ^ |
|
264 (RIJNDAEL_TABLE::Te4[GETBYTE(t0, 0)] & 0x000000ff) ^ |
|
265 rk[1]; |
|
266 s2 = |
|
267 (RIJNDAEL_TABLE::Te4[GETBYTE(t2, 3)] & 0xff000000) ^ |
|
268 (RIJNDAEL_TABLE::Te4[GETBYTE(t3, 2)] & 0x00ff0000) ^ |
|
269 (RIJNDAEL_TABLE::Te4[GETBYTE(t0, 1)] & 0x0000ff00) ^ |
|
270 (RIJNDAEL_TABLE::Te4[GETBYTE(t1, 0)] & 0x000000ff) ^ |
|
271 rk[2]; |
|
272 s3 = |
|
273 (RIJNDAEL_TABLE::Te4[GETBYTE(t3, 3)] & 0xff000000) ^ |
|
274 (RIJNDAEL_TABLE::Te4[GETBYTE(t0, 2)] & 0x00ff0000) ^ |
|
275 (RIJNDAEL_TABLE::Te4[GETBYTE(t1, 1)] & 0x0000ff00) ^ |
|
276 (RIJNDAEL_TABLE::Te4[GETBYTE(t2, 0)] & 0x000000ff) ^ |
|
277 rk[3]; |
|
278 |
|
279 PutBlockBigEndian((TUint8*)&aBlock[0], s0, s1, s2, s3); |
|
280 } |
|
281 |
|
282 CAESEncryptor::CAESEncryptor(void) |
|
283 { |
|
284 } |
|
285 |
|
286 /* CAESDecryptor */ |
|
287 EXPORT_C CAESDecryptor* CAESDecryptor::NewL(const TDesC8& aKey) |
|
288 { |
|
289 CAESDecryptor* me = CAESDecryptor::NewLC(aKey); |
|
290 CleanupStack::Pop(me); |
|
291 return (me); |
|
292 } |
|
293 |
|
294 |
|
295 EXPORT_C CAESDecryptor* CAESDecryptor::NewLC(const TDesC8& aKey) |
|
296 { |
|
297 CAESDecryptor* me = new (ELeave) CAESDecryptor(); |
|
298 CleanupStack::PushL(me); |
|
299 me->ConstructL(aKey); |
|
300 TCrypto::IsSymmetricWeakEnoughL(BytesToBits(aKey.Size())); |
|
301 return (me); |
|
302 } |
|
303 |
|
304 TInt CAESDecryptor::BlockSize() const |
|
305 { |
|
306 return KAESBlockBytes; |
|
307 } |
|
308 |
|
309 void CAESDecryptor::Transform(TDes8& aBlock) |
|
310 { |
|
311 TUint32 s0, s1, s2, s3, t0, t1, t2, t3; |
|
312 const TUint32* rk = &iK[0]; |
|
313 |
|
314 /* |
|
315 * map byte array block to cipher state |
|
316 * and add initial round key: |
|
317 */ |
|
318 GetBlockBigEndian((TUint8*)&aBlock[0], s0, s1, s2, s3); |
|
319 |
|
320 s0 ^= rk[0]; |
|
321 s1 ^= rk[1]; |
|
322 s2 ^= rk[2]; |
|
323 s3 ^= rk[3]; |
|
324 /* |
|
325 * Nr - 1 full rounds: |
|
326 */ |
|
327 TUint r = iRounds >> 1; |
|
328 FOREVER |
|
329 { |
|
330 t0 = |
|
331 RIJNDAEL_TABLE::Td0[GETBYTE(s0, 3)] ^ |
|
332 RIJNDAEL_TABLE::Td1[GETBYTE(s3, 2)] ^ |
|
333 RIJNDAEL_TABLE::Td2[GETBYTE(s2, 1)] ^ |
|
334 RIJNDAEL_TABLE::Td3[GETBYTE(s1, 0)] ^ |
|
335 rk[4]; |
|
336 t1 = |
|
337 RIJNDAEL_TABLE::Td0[GETBYTE(s1, 3)] ^ |
|
338 RIJNDAEL_TABLE::Td1[GETBYTE(s0, 2)] ^ |
|
339 RIJNDAEL_TABLE::Td2[GETBYTE(s3, 1)] ^ |
|
340 RIJNDAEL_TABLE::Td3[GETBYTE(s2, 0)] ^ |
|
341 rk[5]; |
|
342 t2 = |
|
343 RIJNDAEL_TABLE::Td0[GETBYTE(s2, 3)] ^ |
|
344 RIJNDAEL_TABLE::Td1[GETBYTE(s1, 2)] ^ |
|
345 RIJNDAEL_TABLE::Td2[GETBYTE(s0, 1)] ^ |
|
346 RIJNDAEL_TABLE::Td3[GETBYTE(s3, 0)] ^ |
|
347 rk[6]; |
|
348 t3 = |
|
349 RIJNDAEL_TABLE::Td0[GETBYTE(s3, 3)] ^ |
|
350 RIJNDAEL_TABLE::Td1[GETBYTE(s2, 2)] ^ |
|
351 RIJNDAEL_TABLE::Td2[GETBYTE(s1, 1)] ^ |
|
352 RIJNDAEL_TABLE::Td3[GETBYTE(s0, 0)] ^ |
|
353 rk[7]; |
|
354 |
|
355 rk += 8; |
|
356 if (--r == 0) |
|
357 break; |
|
358 |
|
359 s0 = |
|
360 RIJNDAEL_TABLE::Td0[GETBYTE(t0, 3)] ^ |
|
361 RIJNDAEL_TABLE::Td1[GETBYTE(t3, 2)] ^ |
|
362 RIJNDAEL_TABLE::Td2[GETBYTE(t2, 1)] ^ |
|
363 RIJNDAEL_TABLE::Td3[GETBYTE(t1, 0)] ^ |
|
364 rk[0]; |
|
365 s1 = |
|
366 RIJNDAEL_TABLE::Td0[GETBYTE(t1, 3)] ^ |
|
367 RIJNDAEL_TABLE::Td1[GETBYTE(t0, 2)] ^ |
|
368 RIJNDAEL_TABLE::Td2[GETBYTE(t3, 1)] ^ |
|
369 RIJNDAEL_TABLE::Td3[GETBYTE(t2, 0)] ^ |
|
370 rk[1]; |
|
371 s2 = |
|
372 RIJNDAEL_TABLE::Td0[GETBYTE(t2, 3)] ^ |
|
373 RIJNDAEL_TABLE::Td1[GETBYTE(t1, 2)] ^ |
|
374 RIJNDAEL_TABLE::Td2[GETBYTE(t0, 1)] ^ |
|
375 RIJNDAEL_TABLE::Td3[GETBYTE(t3, 0)] ^ |
|
376 rk[2]; |
|
377 s3 = |
|
378 RIJNDAEL_TABLE::Td0[GETBYTE(t3, 3)] ^ |
|
379 RIJNDAEL_TABLE::Td1[GETBYTE(t2, 2)] ^ |
|
380 RIJNDAEL_TABLE::Td2[GETBYTE(t1, 1)] ^ |
|
381 RIJNDAEL_TABLE::Td3[GETBYTE(t0, 0)] ^ |
|
382 rk[3]; |
|
383 } |
|
384 /* |
|
385 * apply last round and |
|
386 * map cipher state to byte array block: |
|
387 */ |
|
388 s0 = |
|
389 (RIJNDAEL_TABLE::Td4[GETBYTE(t0, 3)] & 0xff000000) ^ |
|
390 (RIJNDAEL_TABLE::Td4[GETBYTE(t3, 2)] & 0x00ff0000) ^ |
|
391 (RIJNDAEL_TABLE::Td4[GETBYTE(t2, 1)] & 0x0000ff00) ^ |
|
392 (RIJNDAEL_TABLE::Td4[GETBYTE(t1, 0)] & 0x000000ff) ^ |
|
393 rk[0]; |
|
394 s1 = |
|
395 (RIJNDAEL_TABLE::Td4[GETBYTE(t1, 3)] & 0xff000000) ^ |
|
396 (RIJNDAEL_TABLE::Td4[GETBYTE(t0, 2)] & 0x00ff0000) ^ |
|
397 (RIJNDAEL_TABLE::Td4[GETBYTE(t3, 1)] & 0x0000ff00) ^ |
|
398 (RIJNDAEL_TABLE::Td4[GETBYTE(t2, 0)] & 0x000000ff) ^ |
|
399 rk[1]; |
|
400 s2 = |
|
401 (RIJNDAEL_TABLE::Td4[GETBYTE(t2, 3)] & 0xff000000) ^ |
|
402 (RIJNDAEL_TABLE::Td4[GETBYTE(t1, 2)] & 0x00ff0000) ^ |
|
403 (RIJNDAEL_TABLE::Td4[GETBYTE(t0, 1)] & 0x0000ff00) ^ |
|
404 (RIJNDAEL_TABLE::Td4[GETBYTE(t3, 0)] & 0x000000ff) ^ |
|
405 rk[2]; |
|
406 s3 = |
|
407 (RIJNDAEL_TABLE::Td4[GETBYTE(t3, 3)] & 0xff000000) ^ |
|
408 (RIJNDAEL_TABLE::Td4[GETBYTE(t2, 2)] & 0x00ff0000) ^ |
|
409 (RIJNDAEL_TABLE::Td4[GETBYTE(t1, 1)] & 0x0000ff00) ^ |
|
410 (RIJNDAEL_TABLE::Td4[GETBYTE(t0, 0)] & 0x000000ff) ^ |
|
411 rk[3]; |
|
412 |
|
413 |
|
414 PutBlockBigEndian((TUint8*)&aBlock[0], s0, s1, s2, s3); |
|
415 } |
|
416 |
|
417 |
|
418 void CAESDecryptor::SetKey(const TDesC8& aKey) |
|
419 { |
|
420 CRijndael::SetKey(aKey); |
|
421 |
|
422 TUint i, j; |
|
423 TUint32* rk = &iK[0]; |
|
424 TUint32 temp; |
|
425 |
|
426 // invert the order of the round keys |
|
427 for (i = 0, j = 4*iRounds; i < j; i += 4, j -= 4) |
|
428 { |
|
429 temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; |
|
430 temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; |
|
431 temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; |
|
432 temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; |
|
433 } |
|
434 |
|
435 // apply the inverse MixColumn transform to all round keys but the first and the last |
|
436 for (i = 1; i < iRounds; i++) |
|
437 { |
|
438 rk += 4; |
|
439 rk[0] = |
|
440 RIJNDAEL_TABLE::Td0[RIJNDAEL_TABLE::Te4[GETBYTE(rk[0], 3)] & 0xff] ^ |
|
441 RIJNDAEL_TABLE::Td1[RIJNDAEL_TABLE::Te4[GETBYTE(rk[0], 2)] & 0xff] ^ |
|
442 RIJNDAEL_TABLE::Td2[RIJNDAEL_TABLE::Te4[GETBYTE(rk[0], 1)] & 0xff] ^ |
|
443 RIJNDAEL_TABLE::Td3[RIJNDAEL_TABLE::Te4[GETBYTE(rk[0], 0)] & 0xff]; |
|
444 rk[1] = |
|
445 RIJNDAEL_TABLE::Td0[RIJNDAEL_TABLE::Te4[GETBYTE(rk[1], 3)] & 0xff] ^ |
|
446 RIJNDAEL_TABLE::Td1[RIJNDAEL_TABLE::Te4[GETBYTE(rk[1], 2)] & 0xff] ^ |
|
447 RIJNDAEL_TABLE::Td2[RIJNDAEL_TABLE::Te4[GETBYTE(rk[1], 1)] & 0xff] ^ |
|
448 RIJNDAEL_TABLE::Td3[RIJNDAEL_TABLE::Te4[GETBYTE(rk[1], 0)] & 0xff]; |
|
449 rk[2] = |
|
450 RIJNDAEL_TABLE::Td0[RIJNDAEL_TABLE::Te4[GETBYTE(rk[2], 3)] & 0xff] ^ |
|
451 RIJNDAEL_TABLE::Td1[RIJNDAEL_TABLE::Te4[GETBYTE(rk[2], 2)] & 0xff] ^ |
|
452 RIJNDAEL_TABLE::Td2[RIJNDAEL_TABLE::Te4[GETBYTE(rk[2], 1)] & 0xff] ^ |
|
453 RIJNDAEL_TABLE::Td3[RIJNDAEL_TABLE::Te4[GETBYTE(rk[2], 0)] & 0xff]; |
|
454 rk[3] = |
|
455 RIJNDAEL_TABLE::Td0[RIJNDAEL_TABLE::Te4[GETBYTE(rk[3], 3)] & 0xff] ^ |
|
456 RIJNDAEL_TABLE::Td1[RIJNDAEL_TABLE::Te4[GETBYTE(rk[3], 2)] & 0xff] ^ |
|
457 RIJNDAEL_TABLE::Td2[RIJNDAEL_TABLE::Te4[GETBYTE(rk[3], 1)] & 0xff] ^ |
|
458 RIJNDAEL_TABLE::Td3[RIJNDAEL_TABLE::Te4[GETBYTE(rk[3], 0)] & 0xff]; |
|
459 } |
|
460 } |
|
461 |
|
462 CAESDecryptor::CAESDecryptor() |
|
463 { |
|
464 } |