Debian Codegraph @

src/lib/crypto/test/DESTests.cpp

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 * Copyright (c) 2010 SURFnet bv
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 /*****************************************************************************
28 DESTests.cpp
29
30 Contains test cases to test the DES implementation
31 *****************************************************************************/
32
33 #include <stdlib.h>
34 #include <cppunit/extensions/HelperMacros.h>
35 #include "DESTests.h"
36 #include "CryptoFactory.h"
37 #include "DESKey.h"
38 #include <stdio.h>
39
40 CPPUNIT_TEST_SUITE_REGISTRATION(DESTests);
41
42 void DESTests::setUp()
43 {
44 des = NULL;
45
46 des = CryptoFactory::i()->getSymmetricAlgorithm(SymAlgo::DES);
47
48 // Check the return value
49 CPPUNIT_ASSERT(des != NULL);
50 }
51
52 void DESTests::tearDown()
53 {
54 if (des != NULL)
55 {
56 CryptoFactory::i()->recycleSymmetricAlgorithm(des);
57 }
58
59 fflush(stdout);
60 }
61
62 void DESTests::testBlockSize()
63 {
64 CPPUNIT_ASSERT(des->getBlockSize() == 8);
65 }
66
67 void DESTests::testCBC()
68 {
69 #ifndef WITH_FIPS
70 char testKeys56[][17] =
71 {
72 "0000000000000000",
73 "0102030405060708",
74 "4041424344454647",
75 "4698436794236871",
76 "0940278947239572"
77 };
78
79 char testKeys112[][33] =
80 {
81 "00000000000000000000000000000000",
82 "0102030405060708090A0B0C0D0E0F10",
83 "404142434445464748494A4B4C4D4E4F",
84 "64398647034486943598534703463870",
85 "87406984068406984607412103517413"
86 };
87 #endif
88
89 char testKeys168[][49] =
90 {
91 "000000000000000000000000000000000000000000000000",
92 "0102030405060708090A0B0C0D0E0F101112131415161718",
93 "404142434445464748494A4B4C4D4E4F5051525354555657",
94 "643906874509874309687459084769847562436043696747",
95 "430135460496813044639085714376487549490586439575"
96 };
97
98 char testData[][256] =
99 {
100 "4938673409687134684698438657403986439058740935874395813968496846",
101 "549813644389670948567490687546098245665626527788",
102 "64398769586792586795867965624526",
103 "468376458463264536"
104 };
105
106 char testResult[5][4][3][256] = {
107 {
108 {
109 "ACC8B1BE444EEA9E016A46EF600E9B3FB2C87DE8CE9BE5394917AABB0A04639A3BFF1E250FE971D7",
110 "ACC8B1BE444EEA9E016A46EF600E9B3FB2C87DE8CE9BE5394917AABB0A04639A3BFF1E250FE971D7",
111 "ACC8B1BE444EEA9E016A46EF600E9B3FB2C87DE8CE9BE5394917AABB0A04639A3BFF1E250FE971D7"
112 },
113 {
114 "F9A1913AA27A05379506BE00D5F7398F67722076A3439E759BA729A58E8FEE64",
115 "F9A1913AA27A05379506BE00D5F7398F67722076A3439E759BA729A58E8FEE64",
116 "F9A1913AA27A05379506BE00D5F7398F67722076A3439E759BA729A58E8FEE64"
117 },
118 {
119 "36FD5581BB31F3E27910895DC2F2599CD0F8B8F002220588",
120 "36FD5581BB31F3E27910895DC2F2599CD0F8B8F002220588",
121 "36FD5581BB31F3E27910895DC2F2599CD0F8B8F002220588"
122 },
123 {
124 "B81DA29972385E55CB453A17B6D88D22",
125 "B81DA29972385E55CB453A17B6D88D22",
126 "B81DA29972385E55CB453A17B6D88D22"
127 }
128 },
129 {
130 {
131 "EE16FFE3CC4D4589766FA0957FB728A75D44A00D9BEBE2D43C4D4F3A5AFDB49730CFD4DF46D3AEF6",
132 "A070EE9DED89EE198E0E9B3CEB4879BB0244AB7FCD3450ED044BB5EE0AC8F7797383FDB8AAEF77B8",
133 "E7C594590C9CA00B376B702CE3B92C3F699B3EEEB2CEA08FA551350C837BF031FCAF4E1E97450327"
134 },
135 {
136 "D4142C47C700069F3E71EA6B1EF301B9B97261543ED75B32242C05A253B077B8",
137 "102BBE7D93CD0EF66280D3FA1F2A3976FB9C4D1B155D19E4985ADB86015DDE8C",
138 "600C3A75AC6EB4C4609BA6B7ED273ED56E59CD49FC911C33DD8DFCA384BAA462"
139 },
140 {
141 "47452120CD84CC32FC72F3B8600E5C43EEE192A29BC6BCB7",
142 "ADCF4292A32E51A7843CC8590E6934083A2CC847082FF2B4",
143 "D0FA596AC00BDA870999FD3FA2494C3C8B40B261EB3066F6"
144 },
145 {
146 "6BD20CDBE6E6ECAD6ED829FB43E92751",
147 "AE4379E371E295F63423F861B59111F0",
148 "2757FC58EDEEB8499EA9B49AB2729BAD"
149 }
150 },
151 {
152 {
153 "298621D5237F6230067DE7871DDBA6991E85CA14AD661D21357240923604D23A6A4119277B75B331",
154 "2C9F4FC0ACE7C8A4847472A0D5DDD42F36D3B2C46144B5A0ECDBB59806472E6257952DFD4DB9EBE5",
155 "679A832C630207E76BC1FF8371C61CA2518E37FE97EDED1B171E3E11807250145736949368AC822B"
156 },
157 {
158 "80FFD37B545675BB8C7CD317A73AB48CC0A39D3D9C11474EC3FD1220A066C034",
159 "F9228036718792EE86A85626AB1BC05E17F9CE21FF5D1723D0442CE852F004C3",
160 "D5F5F1EA7D8C2038FEDCBEDF157A5D2469A941FEC696D74DB8359CA5AECDD4CE"
161 },
162 {
163 "1ABB1CC10F589D993030A978B1B7F44AD52FFFEBF23638CA",
164 "D2423F54FA4978C95E4B13EF4DD6AA82DFD772F0FDAF5AD1",
165 "8128EC49D71F5711E5304E7C4423C63AD0EFC45453B66583"
166 },
167 {
168 "B9EE976AB97396047510C1DEA5C86A4B",
169 "46BA1930042146B31BD8FAF3AE6F3414",
170 "46EF3BCCA73E33C03D81BFE0DFFA7ABD"
171 }
172 },
173 {
174 {
175 "30D1B2556D516F20C2FD117FE0355845FBB0B11ABE5922A7EAA19C3A48E30207218321B3F0F30A6D",
176 "CBFA560297901DD691CDFDF98675BD7FF3A64FDCC0EF02F29C81105D3ECAC4E2803E2279F4476B35",
177 "4A30EC10433BE3695DC2B064E6240419C7BF81F1EE7640D5E2FFFA106666A2CEBF18DB954A992B5E"
178 },
179 {
180 "61FFB2E5A73170603E48F9823E6DF7105C9A909CC2F5CEDBEA7E60C076355B37",
181 "8408BD722B12031D17A1645AA59B05E2A50F7002B19877D6EB1C9BB7107C523F",
182 "97EF5791017B10CF07FB8144C19633522CBBE55DC63EF608F8734EE6484C0B0E"
183 },
184 {
185 "7205DC463B3D5EC858C8E7A13844A1A8FF21C0D615CA56AF",
186 "D5D08C1DC728A47CD55A2ACBB811294962022E745F4BCDF4",
187 "7761189D73039A3F06BDDF00B308D7A43BE7BEA1CE9D042E"
188 },
189 {
190 "1702428661BA4CFE686CFDEDFFAA6A27",
191 "9218A89B0A7AEC7E6E2AF1CA493B2829",
192 "6EEB9F7DDF66CED3DB74F7E8DE0CB2CD"
193 }
194 },
195 {
196 {
197 "4FD3A4C759827F6E188E542B83A858026C17FD1DEF21477A964D122B62EE55FA9DB3CCF05A768C83",
198 "F2C8B52652970805EE60ECECC8369C98443463F1C3A5A6357DFDFEE6B7F1EF0CF05523B5469E4555",
199 "21FCBDC92C07F112D19742F5100F2A995E27CB282D73DF5CFEC802C629A279BD4E498C98D170003E"
200 },
201 {
202 "3FD4C32A44DC0A9605A5A793C57E94826E80FC9E8E9620BBC2E02FE41A62A2D3",
203 "4FC88F1E88C3B5A76CF6BE5FA8205BA6F7FA201F7C40E8F0F9CA156E140A4EC5",
204 "CCE31260C967F4B9BB3D2D31F82320715E434C1313D911C58CE7E42AA78DA831"
205 },
206 {
207 "714766BE5CB60DA99DC0BD4E7E655ADE7F26E45F372EF1BF",
208 "00064542E2B4821B4E9173DA6FD1ABAE45C5E5CF26DB506D",
209 "4D88D531C20E63A39372F275329BDBEBE15E7D2C32F2A98F"
210 },
211 {
212 "4933917C9B56124914D2B76DE221BA13",
213 "7F2D1CA9D942630FE1E954E4176E84A5",
214 "9A46902F3997F0EB121981DAEC6D89C4"
215 }
216 }
217 };
218
219 char testIV[][33] =
220 {
221 "0000000000000000",
222 "0102030405060708",
223 "4041424344454647",
224 "4693867334098764",
225 "6209876098547207"
226 };
227
228 for (int i = 0; i < 5; i++)
229 {
230 #ifndef WITH_FIPS
231 ByteString keyData56(testKeys56[i]);
232 CPPUNIT_ASSERT(keyData56.size() == 8);
233 ByteString keyData112(testKeys112[i]);
234 CPPUNIT_ASSERT(keyData112.size() == 16);
235 #endif
236 ByteString keyData168(testKeys168[i]);
237 CPPUNIT_ASSERT(keyData168.size() == 24);
238
239 #ifndef WITH_FIPS
240 DESKey desKey56(56);
241 CPPUNIT_ASSERT(desKey56.setKeyBits(keyData56));
242 DESKey desKey112(112);
243 CPPUNIT_ASSERT(desKey112.setKeyBits(keyData112));
244 #endif
245 DESKey desKey168(168);
246 CPPUNIT_ASSERT(desKey168.setKeyBits(keyData168));
247
248 ByteString IV(testIV[i]);
249
250 for (int j = 0; j < 4; j++)
251 {
252 ByteString plainText(testData[j]), shsmPlainText;
253 ByteString cipherText;
254 ByteString shsmCipherText, OB;
255
256 #ifndef WITH_FIPS
257 // Test 56-bit key
258 cipherText = ByteString(testResult[i][j][0]);
259
260 // Now, do the same thing using our DES implementation
261 shsmCipherText.wipe();
262 CPPUNIT_ASSERT(des->encryptInit(&desKey56, SymMode::CBC, IV));
263
264 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
265 shsmCipherText += OB;
266
267 CPPUNIT_ASSERT(des->encryptFinal(OB));
268 shsmCipherText += OB;
269
270 CPPUNIT_ASSERT(shsmCipherText == cipherText);
271
272 // Check that we can get the plain text
273 shsmPlainText.wipe();
274 CPPUNIT_ASSERT(des->decryptInit(&desKey56, SymMode::CBC, IV));
275
276 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
277 shsmPlainText += OB;
278
279 CPPUNIT_ASSERT(des->decryptFinal(OB));
280 shsmPlainText += OB;
281
282 CPPUNIT_ASSERT(shsmPlainText == plainText);
283
284 // Test 112-bit key
285 cipherText = ByteString(testResult[i][j][1]);
286
287 // Now, do the same thing using our DES implementation
288 shsmCipherText.wipe();
289 CPPUNIT_ASSERT(des->encryptInit(&desKey112, SymMode::CBC, IV));
290
291 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
292 shsmCipherText += OB;
293
294 CPPUNIT_ASSERT(des->encryptFinal(OB));
295 shsmCipherText += OB;
296
297 CPPUNIT_ASSERT(shsmCipherText == cipherText);
298
299 // Check that we can get the plain text
300 shsmPlainText.wipe();
301 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::CBC, IV));
302
303 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
304 shsmPlainText += OB;
305
306 CPPUNIT_ASSERT(des->decryptFinal(OB));
307 shsmPlainText += OB;
308
309 CPPUNIT_ASSERT(shsmPlainText == plainText);
310 #endif
311
312 // Test 168-bit key
313 cipherText = ByteString(testResult[i][j][2]);
314
315 // Now, do the same thing using our DES implementation
316 shsmCipherText.wipe();
317 CPPUNIT_ASSERT(des->encryptInit(&desKey168, SymMode::CBC, IV));
318
319 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
320 shsmCipherText += OB;
321
322 CPPUNIT_ASSERT(des->encryptFinal(OB));
323 shsmCipherText += OB;
324
325 CPPUNIT_ASSERT(shsmCipherText == cipherText);
326
327 // Check that we can get the plain text
328 shsmPlainText.wipe();
329 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::CBC, IV));
330
331 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
332 shsmPlainText += OB;
333
334 CPPUNIT_ASSERT(des->decryptFinal(OB));
335 shsmPlainText += OB;
336
337 CPPUNIT_ASSERT(shsmPlainText == plainText);
338 }
339 }
340 }
341
342 void DESTests::testECB()
343 {
344 #ifndef WITH_FIPS
345 char testKeys56[][17] =
346 {
347 "0000000000000000",
348 "0102030405060708",
349 "4041424344454647",
350 "4698436794236871",
351 "0940278947239572"
352 };
353
354 char testKeys112[][33] =
355 {
356 "00000000000000000000000000000000",
357 "0102030405060708090A0B0C0D0E0F10",
358 "404142434445464748494A4B4C4D4E4F",
359 "64398647034486943598534703463870",
360 "87406984068406984607412103517413"
361 };
362 #endif
363
364 char testKeys168[][49] =
365 {
366 "000000000000000000000000000000000000000000000000",
367 "0102030405060708090A0B0C0D0E0F101112131415161718",
368 "404142434445464748494A4B4C4D4E4F5051525354555657",
369 "643906874509874309687459084769847562436043696747",
370 "430135460496813044639085714376487549490586439575"
371 };
372
373 char testData[][256] =
374 {
375 "4938673409687134684698438657403986439058740935874395813968496846",
376 "549813644389670948567490687546098245665626527788",
377 "64398769586792586795867965624526",
378 "468376458463264536"
379 };
380
381 char testResult[5][4][3][256] = {
382 {
383 {
384 "ACC8B1BE444EEA9E44404B8595B7667982F1BDF99F419F083249964334F2B15F7E422822773666C0",
385 "ACC8B1BE444EEA9E44404B8595B7667982F1BDF99F419F083249964334F2B15F7E422822773666C0",
386 "ACC8B1BE444EEA9E44404B8595B7667982F1BDF99F419F083249964334F2B15F7E422822773666C0"
387 },
388 {
389 "F9A1913AA27A0537CA0BB1A6417C4037978BC92CEFCD10BB7E422822773666C0",
390 "F9A1913AA27A0537CA0BB1A6417C4037978BC92CEFCD10BB7E422822773666C0",
391 "F9A1913AA27A0537CA0BB1A6417C4037978BC92CEFCD10BB7E422822773666C0"
392 },
393 {
394 "36FD5581BB31F3E2ADA81678B64A0F3C7E422822773666C0",
395 "36FD5581BB31F3E2ADA81678B64A0F3C7E422822773666C0",
396 "36FD5581BB31F3E2ADA81678B64A0F3C7E422822773666C0"
397 },
398 {
399 "B81DA29972385E55EA1F3677CDC02D27",
400 "B81DA29972385E55EA1F3677CDC02D27",
401 "B81DA29972385E55EA1F3677CDC02D27"
402 }
403 },
404 {
405 {
406 "278B2CA6259C30E180CCB62E69F0841F235507E2FB3404FC2BC223E37E32B3A78207EA5D3E19A5FD",
407 "417579E3ABEF6F0D620B4FF88E2220457466420803140BFEFBA062A2A41D7C15061019377C6BFD8A",
408 "A676D0404F0F105B2073B9DD19C8C434428098BFC5AF1292FE12477340395F118F45B5BE23F16C4E"
409 },
410 {
411 "7D004390E5638E54077E2551B01BD52BFA1B98403ECE1AEF8207EA5D3E19A5FD",
412 "391B84593FEA836450318A6E943F1C3A4A6BD74E5001EB7A061019377C6BFD8A",
413 "DEAF58111ECCCB449F0C2564B52E360E4AACC8672ABBDF1A8F45B5BE23F16C4E"
414 },
415 {
416 "A6947F9EF4159BAE636A70B904059BC38207EA5D3E19A5FD",
417 "14ADFE212E27BF7F409395B45577F2C8061019377C6BFD8A",
418 "FF87BF761FC159F4442B3B4593233BC48F45B5BE23F16C4E"
419 },
420 {
421 "3A1777DAAAC85389EE0B499A90AE1739",
422 "376E61DF2EAFE5B523964A03885AD085",
423 "E4D81EE64FE8FB187EB7B5E80E075C73"
424 }
425 },
426 {
427 {
428 "F105809DF621715F4D3492E1EEC4A7DE0775A0632ECC13429DF0DC695A60882FA47F93E855A1445B",
429 "77C85215179312315997B4D0E997DB413176C80A8ED9F5EB9B726200224CE97C20A8A19F543BCCBD",
430 "AF1477E32B5BB1CA46D26B6020B3B48DB0A90A97B1BA60F032ADA648296EC92DEE924AA617423FD1"
431 },
432 {
433 "0FB3C3D9D93E0025F87909CD351D0116C0F684A204015E2CA47F93E855A1445B",
434 "67A66DB3209C406D2FE31AF6C36D24C7B32D0F8F1EAFA90020A8A19F543BCCBD",
435 "F85B1F07D788C59CD3DE6D562A175725DF596847ADEA8764EE924AA617423FD1"
436 },
437 {
438 "243A34CD70CE3819B9510980B6EFF3EAA47F93E855A1445B",
439 "997E145467B88D9D4C923797F539AC1620A8A19F543BCCBD",
440 "836788D7AD1F879B405438775FFD6D76EE924AA617423FD1"
441 },
442 {
443 "70856D6B67EE353F27EBB96462DACE63",
444 "D02F2A92C175A58001D89C4AEC476384",
445 "4ED379A40187826CAA90D2D6A05D5A9B"
446 }
447 },
448 {
449 {
450 "C79F67ABCE6F741CF6D5B7B4870397779AEB89F48805DD1A28305E804A4A2B91114E1CF0C7FA91DA",
451 "42956EA3B9415E8FE75B667A7C6B1ADF64D08E53C38DE733A776A97C7A8FC27E32945078552FA3E2",
452 "3685365AD0F07609E13CCDE69CEDC8CCA0C37262A87B734286B9119643AC3BABE435BDA25919BE86"
453 },
454 {
455 "09B882774309CC2B117586F5FA8BF7E4A5DA2A65E137665B114E1CF0C7FA91DA",
456 "0E52A9ABE753758D3C4F6326A8F689282D1DAB8AF6FC8CFF32945078552FA3E2",
457 "8DB6B9D50B5B8CE7DA56546CFF36C16BA3159E0EB7BD649AE435BDA25919BE86"
458 },
459 {
460 "025F9704F6ACD844BCFC6EBA809CD871114E1CF0C7FA91DA",
461 "1692C6A1DF9192C6D4125991EA9A9CBE32945078552FA3E2",
462 "6B848E67225EDDCCD7E8EC89ACDAA0AFE435BDA25919BE86"
463 },
464 {
465 "9D01CD89916AEE48AFE528A376E07AE9",
466 "6FA6A689405048060D65E1B1240B76B7",
467 "7EADEB7073D2EA995C5ED613C978817F"
468 }
469 },
470 {
471 {
472 "A98D0E8E72C589D80D240F192CF65C30FF3A1AB9D8CE54B09AA249C72E395AC3B40F19A649C1B237",
473 "33AC43C7A936665859431D18C089EE45F1356C34F5DF462D81BBFA42380A7E4F6732A473091A3673",
474 "FD4F2F77CCE20147CD0932B2E2D8D5978523F6A03D59E31E1F678A5DA4C350132E94F199555C371E"
475 },
476 {
477 "39453F3BF3C0CAE54279D96F4592359A5AEE6DD04D5F6162B40F19A649C1B237",
478 "E2AFCEEFF2317C520D890D7F2CB91ACD99D5DCAEC9C409016732A473091A3673",
479 "CB19BF88B2DEDDE981E048379A47BDF77ED5F815034CB07A2E94F199555C371E"
480 },
481 {
482 "9D466BACFA69266F7CC26D2C8B8CD203B40F19A649C1B237",
483 "265FDBCCF5F2325B3C8770ABEEECA4166732A473091A3673",
484 "C61E9B86A8A663AE1566CFFCF2046D6B2E94F199555C371E"
485 },
486 {
487 "380091B24160152B63EF067F6C189385",
488 "548EB237B455CBA0100A5C52A6F28C2B",
489 "066C3B0C5E6AF1E9BDD3DDAE5040F809"
490 }
491 }
492 };
493
494 char testIV[][33] =
495 {
496 "0000000000000000",
497 "0102030405060708",
498 "4041424344454647",
499 "4693867334098764",
500 "6209876098547207"
501 };
502
503 for (int i = 0; i < 5; i++)
504 {
505 #ifndef WITH_FIPS
506 ByteString keyData56(testKeys56[i]);
507 CPPUNIT_ASSERT(keyData56.size() == 8);
508 ByteString keyData112(testKeys112[i]);
509 CPPUNIT_ASSERT(keyData112.size() == 16);
510 #endif
511 ByteString keyData168(testKeys168[i]);
512 CPPUNIT_ASSERT(keyData168.size() == 24);
513
514 #ifndef WITH_FIPS
515 DESKey desKey56(56);
516 CPPUNIT_ASSERT(desKey56.setKeyBits(keyData56));
517 DESKey desKey112(112);
518 CPPUNIT_ASSERT(desKey112.setKeyBits(keyData112));
519 #endif
520 DESKey desKey168(168);
521 CPPUNIT_ASSERT(desKey168.setKeyBits(keyData168));
522
523 ByteString IV(testIV[i]);
524
525 for (int j = 0; j < 4; j++)
526 {
527 ByteString plainText(testData[j]), shsmPlainText;
528 ByteString cipherText;
529 ByteString shsmCipherText, OB;
530
531 #ifndef WITH_FIPS
532 // Test 56-bit key
533 cipherText = ByteString(testResult[i][j][0]);
534
535 // Now, do the same thing using our DES implementation
536 shsmCipherText.wipe();
537 CPPUNIT_ASSERT(des->encryptInit(&desKey56, SymMode::ECB, IV));
538
539 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
540 shsmCipherText += OB;
541
542 CPPUNIT_ASSERT(des->encryptFinal(OB));
543 shsmCipherText += OB;
544
545 CPPUNIT_ASSERT(shsmCipherText == cipherText);
546
547 // Check that we can get the plain text
548 shsmPlainText.wipe();
549 CPPUNIT_ASSERT(des->decryptInit(&desKey56, SymMode::ECB, IV));
550
551 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
552 shsmPlainText += OB;
553
554 CPPUNIT_ASSERT(des->decryptFinal(OB));
555 shsmPlainText += OB;
556
557 CPPUNIT_ASSERT(shsmPlainText == plainText);
558
559 // Test 112-bit key
560 cipherText = ByteString(testResult[i][j][1]);
561
562 // Now, do the same thing using our DES implementation
563 shsmCipherText.wipe();
564 CPPUNIT_ASSERT(des->encryptInit(&desKey112, SymMode::ECB, IV));
565
566 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
567 shsmCipherText += OB;
568
569 CPPUNIT_ASSERT(des->encryptFinal(OB));
570 shsmCipherText += OB;
571
572 CPPUNIT_ASSERT(shsmCipherText == cipherText);
573
574 // Check that we can get the plain text
575 shsmPlainText.wipe();
576 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::ECB, IV));
577
578 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
579 shsmPlainText += OB;
580
581 CPPUNIT_ASSERT(des->decryptFinal(OB));
582 shsmPlainText += OB;
583
584 CPPUNIT_ASSERT(shsmPlainText == plainText);
585 #endif
586
587 // Test 168-bit key
588 cipherText = ByteString(testResult[i][j][2]);
589
590 // Now, do the same thing using our DES implementation
591 shsmCipherText.wipe();
592 CPPUNIT_ASSERT(des->encryptInit(&desKey168, SymMode::ECB, IV));
593
594 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
595 shsmCipherText += OB;
596
597 CPPUNIT_ASSERT(des->encryptFinal(OB));
598 shsmCipherText += OB;
599
600 CPPUNIT_ASSERT(shsmCipherText == cipherText);
601
602 // Check that we can get the plain text
603 shsmPlainText.wipe();
604 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::ECB, IV));
605
606 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
607 shsmPlainText += OB;
608
609 CPPUNIT_ASSERT(des->decryptFinal(OB));
610 shsmPlainText += OB;
611
612 CPPUNIT_ASSERT(shsmPlainText == plainText);
613 }
614 }
615 }
616
617 void DESTests::testOFB()
618 {
619 #ifndef WITH_FIPS
620 char testKeys56[][17] =
621 {
622 "0000000000000000",
623 "0102030405060708",
624 "4041424344454647",
625 "4698436794236871",
626 "0940278947239572"
627 };
628
629 char testKeys112[][33] =
630 {
631 "00000000000000000000000000000000",
632 "0102030405060708090A0B0C0D0E0F10",
633 "404142434445464748494A4B4C4D4E4F",
634 "64398647034486943598534703463870",
635 "87406984068406984607412103517413"
636 };
637 #endif
638
639 char testKeys168[][49] =
640 {
641 "000000000000000000000000000000000000000000000000",
642 "0102030405060708090A0B0C0D0E0F101112131415161718",
643 "404142434445464748494A4B4C4D4E4F5051525354555657",
644 "643906874509874309687459084769847562436043696747",
645 "430135460496813044639085714376487549490586439575"
646 };
647
648 char testData[][256] =
649 {
650 "4938673409687134684698438657403986439058740935874395813968496846",
651 "549813644389670948567490687546098245665626527788",
652 "64398769586792586795867965624526",
653 "468376458463264536"
654 };
655
656 char testResult[5][4][3][256] = {
657 {
658 {
659 "C59E2ADDC8D9529368469843865740390AE5DDB1B5B816204395813968496846",
660 "C59E2ADDC8D9529368469843865740390AE5DDB1B5B816204395813968496846",
661 "C59E2ADDC8D9529368469843865740390AE5DDB1B5B816204395813968496846"
662 },
663 {
664 "D83E5E8D823844AE48567490687546090EE32BBFE7E3542F",
665 "D83E5E8D823844AE48567490687546090EE32BBFE7E3542F",
666 "D83E5E8D823844AE48567490687546090EE32BBFE7E3542F"
667 },
668 {
669 "E89FCA8099D6B1FF6795867965624526",
670 "E89FCA8099D6B1FF6795867965624526",
671 "E89FCA8099D6B1FF6795867965624526"
672 },
673 {
674 "CA253BAC45D205E236",
675 "CA253BAC45D205E236",
676 "CA253BAC45D205E236"
677 }
678 },
679 {
680 {
681 "3E9FB188FC11138D05109EA396CA48E1681DF27A857C3C4A9E92D3DC85A5F313",
682 "3440BEFCF35DC87716D8440F71BAF9ACD0441E10B9E5B525F0584499620086E2",
683 "DDB35281888DF064195C42D45E4E2571AD62113A228B5107D1AC849861C199C0"
684 },
685 {
686 "233FC5D8B6F005B02500727078E84ED16C1B0474D7277E45",
687 "29E0CAACB9BCDE4A36C8A8DC9F98FF9CD442E81EEBBEF72A",
688 "C01326D1C26CE659394CAE07B06C2341A964E73470D01308"
689 },
690 {
691 "139E51D5AD1EF0E10AC3809975FF4DFE",
692 "19415EA1A2522B1B190B5A35928FFCB3",
693 "F0B2B2DCD9821308168F5CEEBD7B206E"
694 },
695 {
696 "3124A0F9711A44FC5B",
697 "3BFBAF8D7E569F0648",
698 "D20843F00586A71547"
699 }
700 },
701 {
702 {
703 "E376288A10BD52CB7162ADA9A732D24B574B1E7CB4FF5C791FFEA2E481AD3049",
704 "FD82CFAE85B8581FFCF489F467D94B1B4FAAAEDDE4EC531ABD30D7EA235896AA",
705 "24D9411BA456571900244AEA3EA7159BAA96522B6F891606A8D9A559FE218A9B"
706 },
707 {
708 "FED65CDA5A5C44F65172417A4910D47B534DE872E6A41E76",
709 "E022BBFECF594E22DCE4652789FB4D2B4BAC58D3B6B71115",
710 "3979354BEEB741242034A639D08513ABAE90A4253DD25409"
711 },
712 {
713 "CE77C8D741B2B1A77EB1B3934407D754",
714 "D0832FF3D4B7BB73F32797CE84EC4E04",
715 "09D8A146F559B4750FF754D0DD921084"
716 },
717 {
718 "ECCD39FB9DB605BA2F",
719 "F239DEDF08B30F6EA2",
720 "2B62506A295D00685E"
721 }
722 },
723 {
724 {
725 "740A4786C73A7C6B52DAF270161895E13B4437C56B9837827C2FE237532F4C19",
726 "581B63C58404AEBECFDFD51D74A79836C11514685B47F3B02A2419AF0AA8C625",
727 "D5FCB196868673D136D480E0B6EFC33C589131D87A4AC004A6E0DE8ADC8DE611"
728 },
729 {
730 "69AA33D68DDB6A5672CA1EA3F83A93D13F42C1CB39C3758D",
731 "45BB1795CEE5B883EFCF39CE9A859E06C513E266091CB1BF",
732 "C85CC5C6CC6765EC16C46C3358CDC50C5C97C7D62811820B"
733 },
734 {
735 "590BA7DB96359F075D09EC4AF52D90FE",
736 "751A8398D50B4DD2C00CCB2797929D29",
737 "F8FD51CBD78990BD39079EDA55DAC623"
738 },
739 {
740 "7BB156F74A312B1A0C",
741 "57A072B4090FF9CF91",
742 "DA47A0E70B8D24A068"
743 }
744 },
745 {
746 {
747 "0855A84EAD2176C3F10B9DCFC8D1A379AF616FC5C5CD4E6D434353C52832F9F6",
748 "A8420E97462B0215AAC1DB0835D4064C6A8B123327FC396C9520BEA70B59B412",
749 "3461DEDF1B4893E16706900E1DDBE351E90C1300B9B01E8A518A01AD56E9AC8C"
750 },
751 {
752 "15F5DC1EE7C060FED11B711C26F3A549AB6799CB97960C62",
753 "B5E27AC70CCA14288AD137DBDBF6007C6E8DE43D75A77B63",
754 "29C1AA8F51A985DC47167CDDF3F9E561ED0AE50EEBEB5C85"
755 },
756 {
757 "25544813FC2E95AFFED883F52BE4A666",
758 "8543EECA1724E179A512C532D6E10353",
759 "19603E824A47708D68D58E34FEEEE64E"
760 },
761 {
762 "07EEB93F202A21B2AF",
763 "A7F91FE6CB205564F4",
764 "3BDACFAE9643C49039"
765 }
766 }
767 };
768
769 char testIV[][33] =
770 {
771 "0000000000000000",
772 "0102030405060708",
773 "4041424344454647",
774 "4693867334098764",
775 "6209876098547207"
776 };
777
778 for (int i = 0; i < 5; i++)
779 {
780 #ifndef WITH_FIPS
781 ByteString keyData56(testKeys56[i]);
782 CPPUNIT_ASSERT(keyData56.size() == 8);
783 ByteString keyData112(testKeys112[i]);
784 CPPUNIT_ASSERT(keyData112.size() == 16);
785 #endif
786 ByteString keyData168(testKeys168[i]);
787 CPPUNIT_ASSERT(keyData168.size() == 24);
788
789 #ifndef WITH_FIPS
790 DESKey desKey56(56);
791 CPPUNIT_ASSERT(desKey56.setKeyBits(keyData56));
792 DESKey desKey112(112);
793 CPPUNIT_ASSERT(desKey112.setKeyBits(keyData112));
794 #endif
795 DESKey desKey168(168);
796 CPPUNIT_ASSERT(desKey168.setKeyBits(keyData168));
797
798 ByteString IV(testIV[i]);
799
800 for (int j = 0; j < 4; j++)
801 {
802 ByteString plainText(testData[j]), shsmPlainText;
803 ByteString cipherText;
804 ByteString shsmCipherText, OB;
805
806 #ifndef WITH_FIPS
807 // Test 56-bit key
808 cipherText = ByteString(testResult[i][j][0]);
809
810 // Now, do the same thing using our DES implementation
811 shsmCipherText.wipe();
812 CPPUNIT_ASSERT(des->encryptInit(&desKey56, SymMode::OFB, IV));
813
814 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
815 shsmCipherText += OB;
816
817 CPPUNIT_ASSERT(des->encryptFinal(OB));
818 shsmCipherText += OB;
819
820 CPPUNIT_ASSERT(shsmCipherText == cipherText);
821
822 // Check that we can get the plain text
823 shsmPlainText.wipe();
824 CPPUNIT_ASSERT(des->decryptInit(&desKey56, SymMode::OFB, IV));
825
826 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
827 shsmPlainText += OB;
828
829 CPPUNIT_ASSERT(des->decryptFinal(OB));
830 shsmPlainText += OB;
831
832 CPPUNIT_ASSERT(shsmPlainText == plainText);
833
834 // Test 112-bit key
835 cipherText = ByteString(testResult[i][j][1]);
836
837 // Now, do the same thing using our DES implementation
838 shsmCipherText.wipe();
839 CPPUNIT_ASSERT(des->encryptInit(&desKey112, SymMode::OFB, IV));
840
841 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
842 shsmCipherText += OB;
843
844 CPPUNIT_ASSERT(des->encryptFinal(OB));
845 shsmCipherText += OB;
846
847 CPPUNIT_ASSERT(shsmCipherText == cipherText);
848
849 // Check that we can get the plain text
850 shsmPlainText.wipe();
851 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::OFB, IV));
852
853 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
854 shsmPlainText += OB;
855
856 CPPUNIT_ASSERT(des->decryptFinal(OB));
857 shsmPlainText += OB;
858
859 CPPUNIT_ASSERT(shsmPlainText == plainText);
860 #endif
861
862 // Test 168-bit key
863 cipherText = ByteString(testResult[i][j][2]);
864
865 // Now, do the same thing using our DES implementation
866 shsmCipherText.wipe();
867 CPPUNIT_ASSERT(des->encryptInit(&desKey168, SymMode::OFB, IV));
868
869 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
870 shsmCipherText += OB;
871
872 CPPUNIT_ASSERT(des->encryptFinal(OB));
873 shsmCipherText += OB;
874
875 CPPUNIT_ASSERT(shsmCipherText == cipherText);
876
877 // Check that we can get the plain text
878 shsmPlainText.wipe();
879 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::OFB, IV));
880
881 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
882 shsmPlainText += OB;
883
884 CPPUNIT_ASSERT(des->decryptFinal(OB));
885 shsmPlainText += OB;
886
887 CPPUNIT_ASSERT(shsmPlainText == plainText);
888 }
889 }
890 }
891
892 void DESTests::testCFB()
893 {
894 #ifndef WITH_FIPS
895 char testKeys56[][17] =
896 {
897 "0000000000000000",
898 "0102030405060708",
899 "4041424344454647",
900 "4698436794236871",
901 "0940278947239572"
902 };
903
904 char testKeys112[][33] =
905 {
906 "00000000000000000000000000000000",
907 "0102030405060708090A0B0C0D0E0F10",
908 "404142434445464748494A4B4C4D4E4F",
909 "64398647034486943598534703463870",
910 "87406984068406984607412103517413"
911 };
912 #endif
913
914 char testKeys168[][49] =
915 {
916 "000000000000000000000000000000000000000000000000",
917 "0102030405060708090A0B0C0D0E0F101112131415161718",
918 "404142434445464748494A4B4C4D4E4F5051525354555657",
919 "643906874509874309687459084769847562436043696747",
920 "430135460496813044639085714376487549490586439575"
921 };
922
923 char testData[][256] =
924 {
925 "4938673409687134684698438657403986439058740935874395813968496846",
926 "549813644389670948567490687546098245665626527788",
927 "64398769586792586795867965624526",
928 "468376458463264536"
929 };
930
931 char testResult[5][4][3][256] = {
932 {
933 {
934 "C59E2ADDC8D95293F8ED346ADAF018111F0B6726349664FF9B02C46C2EC5B96F",
935 "C59E2ADDC8D95293F8ED346ADAF018111F0B6726349664FF9B02C46C2EC5B96F",
936 "C59E2ADDC8D95293F8ED346ADAF018111F0B6726349664FF9B02C46C2EC5B96F"
937 },
938 {
939 "D83E5E8D823844AE748E369586FA76A2BFD1E668EC78D67B",
940 "D83E5E8D823844AE748E369586FA76A2BFD1E668EC78D67B",
941 "D83E5E8D823844AE748E369586FA76A2BFD1E668EC78D67B"
942 },
943 {
944 "E89FCA8099D6B1FFB3A24C435B847A73",
945 "E89FCA8099D6B1FFB3A24C435B847A73",
946 "E89FCA8099D6B1FFB3A24C435B847A73"
947 },
948 {
949 "CA253BAC45D205E270",
950 "CA253BAC45D205E270",
951 "CA253BAC45D205E270"
952 }
953 },
954 {
955 {
956 "3E9FB188FC11138D49C438ABB98A3846671A4DB257AA62C7929CD55A43E46D88",
957 "3440BEFCF35DC8773DD631A9C8CCF222009D45E301BBF6432A78E99416CE87D8",
958 "DDB35281888DF06446772085E3DE849298B4BE0089979260DDC59FACB17AD0BE"
959 },
960 {
961 "233FC5D8B6F005B0966FB313EA0DDFBECF19CBC937445A56",
962 "29E0CAACB9BCDE4AB219A19AA77E2C9A407C98A18BD56FDF",
963 "C01326D1C26CE6592FA4E9909D93A85BE005431046661C73"
964 },
965 {
966 "139E51D5AD1EF0E1E74DD9919AE65DB6",
967 "19415EA1A2522B1B5972F5DCBEEF4E01",
968 "F0B2B2DCD9821308815ADB01F0A16B76"
969 },
970 {
971 "3124A0F9711A44FC92",
972 "3BFBAF8D7E569F06CF",
973 "D20843F00586A715DB"
974 }
975 },
976 {
977 {
978 "E376288A10BD52CB06B42B4582A425907D2DF490EC14B478507BCDE58CE95B02",
979 "FD82CFAE85B8581F1409EB62D06A98E05C401607619DE1235822E2DEB74737E1",
980 "24D9411BA4565719BE9FF1A4D91F23B3BF8980A706747077583C8EB84AF63745"
981 },
982 {
983 "FED65CDA5A5C44F619325429C78F464D271807342B10F899",
984 "E022BBFECF594E22ABC22FA25024B6FD8F61337CBD1F023D",
985 "3979354BEEB741241F0D219B5521A488F870C849275FF8B9"
986 },
987 {
988 "CE77C8D741B2B1A7E488B94EB32C96FD",
989 "D0832FF3D4B7BB73AEC7646A3686ABCF",
990 "09D8A146F559B475A6258D03BC6F8BD3"
991 },
992 {
993 "ECCD39FB9DB605BAB2",
994 "F239DEDF08B30F6EE4",
995 "2B62506A295D00687E"
996 }
997 },
998 {
999 {
1000 "740A4786C73A7C6B435071A654DA8FCC75BA3299969E327A2ABC7024378CF3AA",
1001 "581B63C58404AEBE49FA5FA4032918813075279E836DFE9BAEDF37D9B21ABEE1",
1002 "D5FCB196868673D1FA9C8A67E6A2449354B292E1A76BA11C416A394116857B29"
1003 },
1004 {
1005 "69AA33D68DDB6A561FB6D6218FAC0E812514782FC6059E46",
1006 "45BB1795CEE5B883232EBCCB672FC9C4803C6B827825FE94",
1007 "C85CC5C6CC6765EC466B8F8AC8DFC91CB916F617873AF187"
1008 },
1009 {
1010 "590BA7DB96359F07DB2F2CE68748425C",
1011 "751A8398D50B4DD24E4681B6D0E880FC",
1012 "F8FD51CBD78990BD5D088ECA798DA0E6"
1013 },
1014 {
1015 "7BB156F74A312B1A8C",
1016 "57A072B4090FF9CF1B",
1017 "DA47A0E70B8D24A043"
1018 }
1019 },
1020 {
1021 {
1022 "0855A84EAD2176C3D2C3DE4FB868CA2C1B0DF550E187E29808C45594C070FBF4",
1023 "A8420E97462B02158D2CABD1574D072F8D83123CED9BA7CEDD7C2799E168F32D",
1024 "3461DEDF1B4893E182BE36017DEBC6669B15269DFA4435A31EB1A0CE6A845176"
1025 },
1026 {
1027 "15F5DC1EE7C060FEDC9B1B43A20588E7A073A300BEFC4CAD",
1028 "B5E27AC70CCA142857CB807226DC1EA9B31BE81C0FDCD3FB",
1029 "29C1AA8F51A985DC7E530E6EB7AEAC246F2ED097D09851CC"
1030 },
1031 {
1032 "25544813FC2E95AF817E0897D4E22ECD",
1033 "8543EECA1724E179543979F02103C150",
1034 "19603E824A47708D80E29D3A61BAE5EA"
1035 },
1036 {
1037 "07EEB93F202A21B250",
1038 "A7F91FE6CB205564F2",
1039 "3BDACFAE9643C49027"
1040 }
1041 }
1042 };
1043 char testIV[][33] =
1044 {
1045 "0000000000000000",
1046 "0102030405060708",
1047 "4041424344454647",
1048 "4693867334098764",
1049 "6209876098547207"
1050 };
1051
1052 for (int i = 0; i < 5; i++)
1053 {
1054 #ifndef WITH_FIPS
1055 ByteString keyData56(testKeys56[i]);
1056 CPPUNIT_ASSERT(keyData56.size() == 8);
1057 ByteString keyData112(testKeys112[i]);
1058 CPPUNIT_ASSERT(keyData112.size() == 16);
1059 #endif
1060 ByteString keyData168(testKeys168[i]);
1061 CPPUNIT_ASSERT(keyData168.size() == 24);
1062
1063 #ifndef WITH_FIPS
1064 DESKey desKey56(56);
1065 CPPUNIT_ASSERT(desKey56.setKeyBits(keyData56));
1066 DESKey desKey112(112);
1067 CPPUNIT_ASSERT(desKey112.setKeyBits(keyData112));
1068 #endif
1069 DESKey desKey168(168);
1070 CPPUNIT_ASSERT(desKey168.setKeyBits(keyData168));
1071
1072 ByteString IV(testIV[i]);
1073
1074 for (int j = 0; j < 4; j++)
1075 {
1076 ByteString plainText(testData[j]), shsmPlainText;
1077 ByteString cipherText;
1078 ByteString shsmCipherText, OB;
1079
1080 #ifndef WITH_FIPS
1081 // Test 56-bit key
1082 cipherText = ByteString(testResult[i][j][0]);
1083
1084 // Now, do the same thing using our DES implementation
1085 shsmCipherText.wipe();
1086 CPPUNIT_ASSERT(des->encryptInit(&desKey56, SymMode::CFB, IV));
1087
1088 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
1089 shsmCipherText += OB;
1090
1091 CPPUNIT_ASSERT(des->encryptFinal(OB));
1092 shsmCipherText += OB;
1093
1094 CPPUNIT_ASSERT(shsmCipherText == cipherText);
1095
1096 // Check that we can get the plain text
1097 shsmPlainText.wipe();
1098 CPPUNIT_ASSERT(des->decryptInit(&desKey56, SymMode::CFB, IV));
1099
1100 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
1101 shsmPlainText += OB;
1102
1103 CPPUNIT_ASSERT(des->decryptFinal(OB));
1104 shsmPlainText += OB;
1105
1106 CPPUNIT_ASSERT(shsmPlainText == plainText);
1107
1108 // Test 112-bit key
1109 cipherText = ByteString(testResult[i][j][1]);
1110
1111 // Now, do the same thing using our DES implementation
1112 shsmCipherText.wipe();
1113 CPPUNIT_ASSERT(des->encryptInit(&desKey112, SymMode::CFB, IV));
1114
1115 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
1116 shsmCipherText += OB;
1117
1118 CPPUNIT_ASSERT(des->encryptFinal(OB));
1119 shsmCipherText += OB;
1120
1121 CPPUNIT_ASSERT(shsmCipherText == cipherText);
1122
1123 // Check that we can get the plain text
1124 shsmPlainText.wipe();
1125 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::CFB, IV));
1126
1127 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
1128 shsmPlainText += OB;
1129
1130 CPPUNIT_ASSERT(des->decryptFinal(OB));
1131 shsmPlainText += OB;
1132
1133 CPPUNIT_ASSERT(shsmPlainText == plainText);
1134 #endif
1135
1136 // Test 168-bit key
1137 cipherText = ByteString(testResult[i][j][2]);
1138
1139 // Now, do the same thing using our DES implementation
1140 shsmCipherText.wipe();
1141 CPPUNIT_ASSERT(des->encryptInit(&desKey168, SymMode::CFB, IV));
1142
1143 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
1144 shsmCipherText += OB;
1145
1146 CPPUNIT_ASSERT(des->encryptFinal(OB));
1147 shsmCipherText += OB;
1148
1149 CPPUNIT_ASSERT(shsmCipherText == cipherText);
1150
1151 // Check that we can get the plain text
1152 shsmPlainText.wipe();
1153 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::CFB, IV));
1154
1155 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
1156 shsmPlainText += OB;
1157
1158 CPPUNIT_ASSERT(des->decryptFinal(OB));
1159 shsmPlainText += OB;
1160
1161 CPPUNIT_ASSERT(shsmPlainText == plainText);
1162 }
1163 }
1164 }