Debian Codegraph @

src/lib/crypto/test/DESTests.cpp

raw ◀ ▶
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 if (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 }
285
286 // Test 112-bit key
287 cipherText = ByteString(testResult[i][j][1]);
288
289 // Now, do the same thing using our DES implementation
290 shsmCipherText.wipe();
•291 if (des->encryptInit(&desKey112, SymMode::CBC, IV)) {
292
•293 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
294 shsmCipherText += OB;
295
•296 CPPUNIT_ASSERT(des->encryptFinal(OB));
297 shsmCipherText += OB;
298
•299 CPPUNIT_ASSERT(shsmCipherText == cipherText);
300
•301 // Check that we can get the plain text
302 shsmPlainText.wipe();
303 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::CBC, IV));
304
•305 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
306 shsmPlainText += OB;
307
•308 CPPUNIT_ASSERT(des->decryptFinal(OB));
309 shsmPlainText += OB;
310
311 CPPUNIT_ASSERT(shsmPlainText == plainText);
312 }
313
314 #endif
315
316 // Test 168-bit key
317 cipherText = ByteString(testResult[i][j][2]);
318
319 // Now, do the same thing using our DES implementation
320 shsmCipherText.wipe();
•321 if (des->encryptInit(&desKey168, SymMode::CBC, IV)) {
322
•323 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
324 shsmCipherText += OB;
325
•326 CPPUNIT_ASSERT(des->encryptFinal(OB));
327 shsmCipherText += OB;
328
•329 CPPUNIT_ASSERT(shsmCipherText == cipherText);
330
•331 // Check that we can get the plain text
332 shsmPlainText.wipe();
333 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::CBC, IV));
334
•335 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
336 shsmPlainText += OB;
337
•338 CPPUNIT_ASSERT(des->decryptFinal(OB));
339 shsmPlainText += OB;
340
•341 CPPUNIT_ASSERT(shsmPlainText == plainText);
342 }
343 }
344 }
345 }
346
347 void DESTests::testECB()
348 {
349 #ifndef WITH_FIPS
350 char testKeys56[][17] =
351 {
352 "0000000000000000",
353 "0102030405060708",
354 "4041424344454647",
355 "4698436794236871",
356 "0940278947239572"
357 };
358
359 char testKeys112[][33] =
360 {
361 "00000000000000000000000000000000",
362 "0102030405060708090A0B0C0D0E0F10",
363 "404142434445464748494A4B4C4D4E4F",
364 "64398647034486943598534703463870",
365 "87406984068406984607412103517413"
366 };
367 #endif
368
369 char testKeys168[][49] =
370 {
371 "000000000000000000000000000000000000000000000000",
372 "0102030405060708090A0B0C0D0E0F101112131415161718",
373 "404142434445464748494A4B4C4D4E4F5051525354555657",
374 "643906874509874309687459084769847562436043696747",
375 "430135460496813044639085714376487549490586439575"
376 };
377
378 char testData[][256] =
379 {
380 "4938673409687134684698438657403986439058740935874395813968496846",
381 "549813644389670948567490687546098245665626527788",
382 "64398769586792586795867965624526",
383 "468376458463264536"
384 };
385
386 char testResult[5][4][3][256] = {
387 {
388 {
389 "ACC8B1BE444EEA9E44404B8595B7667982F1BDF99F419F083249964334F2B15F7E422822773666C0",
390 "ACC8B1BE444EEA9E44404B8595B7667982F1BDF99F419F083249964334F2B15F7E422822773666C0",
391 "ACC8B1BE444EEA9E44404B8595B7667982F1BDF99F419F083249964334F2B15F7E422822773666C0"
392 },
393 {
394 "F9A1913AA27A0537CA0BB1A6417C4037978BC92CEFCD10BB7E422822773666C0",
395 "F9A1913AA27A0537CA0BB1A6417C4037978BC92CEFCD10BB7E422822773666C0",
396 "F9A1913AA27A0537CA0BB1A6417C4037978BC92CEFCD10BB7E422822773666C0"
397 },
398 {
399 "36FD5581BB31F3E2ADA81678B64A0F3C7E422822773666C0",
400 "36FD5581BB31F3E2ADA81678B64A0F3C7E422822773666C0",
401 "36FD5581BB31F3E2ADA81678B64A0F3C7E422822773666C0"
402 },
403 {
404 "B81DA29972385E55EA1F3677CDC02D27",
405 "B81DA29972385E55EA1F3677CDC02D27",
406 "B81DA29972385E55EA1F3677CDC02D27"
407 }
408 },
409 {
410 {
411 "278B2CA6259C30E180CCB62E69F0841F235507E2FB3404FC2BC223E37E32B3A78207EA5D3E19A5FD",
412 "417579E3ABEF6F0D620B4FF88E2220457466420803140BFEFBA062A2A41D7C15061019377C6BFD8A",
413 "A676D0404F0F105B2073B9DD19C8C434428098BFC5AF1292FE12477340395F118F45B5BE23F16C4E"
414 },
415 {
416 "7D004390E5638E54077E2551B01BD52BFA1B98403ECE1AEF8207EA5D3E19A5FD",
417 "391B84593FEA836450318A6E943F1C3A4A6BD74E5001EB7A061019377C6BFD8A",
418 "DEAF58111ECCCB449F0C2564B52E360E4AACC8672ABBDF1A8F45B5BE23F16C4E"
419 },
420 {
421 "A6947F9EF4159BAE636A70B904059BC38207EA5D3E19A5FD",
422 "14ADFE212E27BF7F409395B45577F2C8061019377C6BFD8A",
423 "FF87BF761FC159F4442B3B4593233BC48F45B5BE23F16C4E"
424 },
425 {
426 "3A1777DAAAC85389EE0B499A90AE1739",
427 "376E61DF2EAFE5B523964A03885AD085",
428 "E4D81EE64FE8FB187EB7B5E80E075C73"
429 }
430 },
431 {
432 {
433 "F105809DF621715F4D3492E1EEC4A7DE0775A0632ECC13429DF0DC695A60882FA47F93E855A1445B",
434 "77C85215179312315997B4D0E997DB413176C80A8ED9F5EB9B726200224CE97C20A8A19F543BCCBD",
435 "AF1477E32B5BB1CA46D26B6020B3B48DB0A90A97B1BA60F032ADA648296EC92DEE924AA617423FD1"
436 },
437 {
438 "0FB3C3D9D93E0025F87909CD351D0116C0F684A204015E2CA47F93E855A1445B",
439 "67A66DB3209C406D2FE31AF6C36D24C7B32D0F8F1EAFA90020A8A19F543BCCBD",
440 "F85B1F07D788C59CD3DE6D562A175725DF596847ADEA8764EE924AA617423FD1"
441 },
442 {
443 "243A34CD70CE3819B9510980B6EFF3EAA47F93E855A1445B",
444 "997E145467B88D9D4C923797F539AC1620A8A19F543BCCBD",
445 "836788D7AD1F879B405438775FFD6D76EE924AA617423FD1"
446 },
447 {
448 "70856D6B67EE353F27EBB96462DACE63",
449 "D02F2A92C175A58001D89C4AEC476384",
450 "4ED379A40187826CAA90D2D6A05D5A9B"
451 }
452 },
453 {
454 {
455 "C79F67ABCE6F741CF6D5B7B4870397779AEB89F48805DD1A28305E804A4A2B91114E1CF0C7FA91DA",
456 "42956EA3B9415E8FE75B667A7C6B1ADF64D08E53C38DE733A776A97C7A8FC27E32945078552FA3E2",
457 "3685365AD0F07609E13CCDE69CEDC8CCA0C37262A87B734286B9119643AC3BABE435BDA25919BE86"
458 },
459 {
460 "09B882774309CC2B117586F5FA8BF7E4A5DA2A65E137665B114E1CF0C7FA91DA",
461 "0E52A9ABE753758D3C4F6326A8F689282D1DAB8AF6FC8CFF32945078552FA3E2",
462 "8DB6B9D50B5B8CE7DA56546CFF36C16BA3159E0EB7BD649AE435BDA25919BE86"
463 },
464 {
465 "025F9704F6ACD844BCFC6EBA809CD871114E1CF0C7FA91DA",
466 "1692C6A1DF9192C6D4125991EA9A9CBE32945078552FA3E2",
467 "6B848E67225EDDCCD7E8EC89ACDAA0AFE435BDA25919BE86"
468 },
469 {
470 "9D01CD89916AEE48AFE528A376E07AE9",
471 "6FA6A689405048060D65E1B1240B76B7",
472 "7EADEB7073D2EA995C5ED613C978817F"
473 }
474 },
475 {
476 {
477 "A98D0E8E72C589D80D240F192CF65C30FF3A1AB9D8CE54B09AA249C72E395AC3B40F19A649C1B237",
478 "33AC43C7A936665859431D18C089EE45F1356C34F5DF462D81BBFA42380A7E4F6732A473091A3673",
479 "FD4F2F77CCE20147CD0932B2E2D8D5978523F6A03D59E31E1F678A5DA4C350132E94F199555C371E"
480 },
481 {
482 "39453F3BF3C0CAE54279D96F4592359A5AEE6DD04D5F6162B40F19A649C1B237",
483 "E2AFCEEFF2317C520D890D7F2CB91ACD99D5DCAEC9C409016732A473091A3673",
484 "CB19BF88B2DEDDE981E048379A47BDF77ED5F815034CB07A2E94F199555C371E"
485 },
486 {
487 "9D466BACFA69266F7CC26D2C8B8CD203B40F19A649C1B237",
488 "265FDBCCF5F2325B3C8770ABEEECA4166732A473091A3673",
489 "C61E9B86A8A663AE1566CFFCF2046D6B2E94F199555C371E"
490 },
491 {
492 "380091B24160152B63EF067F6C189385",
493 "548EB237B455CBA0100A5C52A6F28C2B",
494 "066C3B0C5E6AF1E9BDD3DDAE5040F809"
495 }
496 }
497 };
498
499 char testIV[][33] =
500 {
501 "0000000000000000",
502 "0102030405060708",
503 "4041424344454647",
504 "4693867334098764",
505 "6209876098547207"
506 };
507
508 for (int i = 0; i < 5; i++)
509 {
510 #ifndef WITH_FIPS
511 ByteString keyData56(testKeys56[i]);
512 CPPUNIT_ASSERT(keyData56.size() == 8);
513 ByteString keyData112(testKeys112[i]);
514 CPPUNIT_ASSERT(keyData112.size() == 16);
515 #endif
516 ByteString keyData168(testKeys168[i]);
517 CPPUNIT_ASSERT(keyData168.size() == 24);
518
519 #ifndef WITH_FIPS
520 DESKey desKey56(56);
521 CPPUNIT_ASSERT(desKey56.setKeyBits(keyData56));
522 DESKey desKey112(112);
523 CPPUNIT_ASSERT(desKey112.setKeyBits(keyData112));
524 #endif
525 DESKey desKey168(168);
526 CPPUNIT_ASSERT(desKey168.setKeyBits(keyData168));
527
528 ByteString IV(testIV[i]);
529
530 for (int j = 0; j < 4; j++)
531 {
532 ByteString plainText(testData[j]), shsmPlainText;
533 ByteString cipherText;
534 ByteString shsmCipherText, OB;
535
536 #ifndef WITH_FIPS
537 // Test 56-bit key
538 cipherText = ByteString(testResult[i][j][0]);
539
540 // Now, do the same thing using our DES implementation
541 shsmCipherText.wipe();
•542 if (des->encryptInit(&desKey56, SymMode::ECB, IV)) {
543
•544 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
545 shsmCipherText += OB;
546
•547 CPPUNIT_ASSERT(des->encryptFinal(OB));
548 shsmCipherText += OB;
549
•550 CPPUNIT_ASSERT(shsmCipherText == cipherText);
551
•552 // Check that we can get the plain text
553 shsmPlainText.wipe();
554 CPPUNIT_ASSERT(des->decryptInit(&desKey56, SymMode::ECB, IV));
555
•556 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
557 shsmPlainText += OB;
558
•559 CPPUNIT_ASSERT(des->decryptFinal(OB));
560 shsmPlainText += OB;
561
•562 CPPUNIT_ASSERT(shsmPlainText == plainText);
563 }
564
565 // Test 112-bit key
566 cipherText = ByteString(testResult[i][j][1]);
567
568 // Now, do the same thing using our DES implementation
569 shsmCipherText.wipe();
•570 if (des->encryptInit(&desKey112, SymMode::ECB, IV)) {
571
•572 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
573 shsmCipherText += OB;
574
•575 CPPUNIT_ASSERT(des->encryptFinal(OB));
576 shsmCipherText += OB;
577
•578 CPPUNIT_ASSERT(shsmCipherText == cipherText);
579
•580 // Check that we can get the plain text
581 shsmPlainText.wipe();
582 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::ECB, IV));
583
•584 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
585 shsmPlainText += OB;
586
•587 CPPUNIT_ASSERT(des->decryptFinal(OB));
588 shsmPlainText += OB;
589
•590 CPPUNIT_ASSERT(shsmPlainText == plainText);
591 }
592 #endif
593
594 // Test 168-bit key
595 cipherText = ByteString(testResult[i][j][2]);
596
597 // Now, do the same thing using our DES implementation
598 shsmCipherText.wipe();
•599 if (des->encryptInit(&desKey168, SymMode::ECB, IV)) {
600
•601 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
602 shsmCipherText += OB;
603
•604 CPPUNIT_ASSERT(des->encryptFinal(OB));
605 shsmCipherText += OB;
606
•607 CPPUNIT_ASSERT(shsmCipherText == cipherText);
608
•609 // Check that we can get the plain text
610 shsmPlainText.wipe();
611 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::ECB, IV));
612
•613 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
614 shsmPlainText += OB;
615
•616 CPPUNIT_ASSERT(des->decryptFinal(OB));
617 shsmPlainText += OB;
618
•619 CPPUNIT_ASSERT(shsmPlainText == plainText);
620 }
621 }
622 }
623 }
624
625 void DESTests::testOFB()
626 {
627 #ifndef WITH_FIPS
628 char testKeys56[][17] =
629 {
630 "0000000000000000",
631 "0102030405060708",
632 "4041424344454647",
633 "4698436794236871",
634 "0940278947239572"
635 };
636
637 char testKeys112[][33] =
638 {
639 "00000000000000000000000000000000",
640 "0102030405060708090A0B0C0D0E0F10",
641 "404142434445464748494A4B4C4D4E4F",
642 "64398647034486943598534703463870",
643 "87406984068406984607412103517413"
644 };
645 #endif
646
647 char testKeys168[][49] =
648 {
649 "000000000000000000000000000000000000000000000000",
650 "0102030405060708090A0B0C0D0E0F101112131415161718",
651 "404142434445464748494A4B4C4D4E4F5051525354555657",
652 "643906874509874309687459084769847562436043696747",
653 "430135460496813044639085714376487549490586439575"
654 };
655
656 char testData[][256] =
657 {
658 "4938673409687134684698438657403986439058740935874395813968496846",
659 "549813644389670948567490687546098245665626527788",
660 "64398769586792586795867965624526",
661 "468376458463264536"
662 };
663
664 char testResult[5][4][3][256] = {
665 {
666 {
667 "C59E2ADDC8D9529368469843865740390AE5DDB1B5B816204395813968496846",
668 "C59E2ADDC8D9529368469843865740390AE5DDB1B5B816204395813968496846",
669 "C59E2ADDC8D9529368469843865740390AE5DDB1B5B816204395813968496846"
670 },
671 {
672 "D83E5E8D823844AE48567490687546090EE32BBFE7E3542F",
673 "D83E5E8D823844AE48567490687546090EE32BBFE7E3542F",
674 "D83E5E8D823844AE48567490687546090EE32BBFE7E3542F"
675 },
676 {
677 "E89FCA8099D6B1FF6795867965624526",
678 "E89FCA8099D6B1FF6795867965624526",
679 "E89FCA8099D6B1FF6795867965624526"
680 },
681 {
682 "CA253BAC45D205E236",
683 "CA253BAC45D205E236",
684 "CA253BAC45D205E236"
685 }
686 },
687 {
688 {
689 "3E9FB188FC11138D05109EA396CA48E1681DF27A857C3C4A9E92D3DC85A5F313",
690 "3440BEFCF35DC87716D8440F71BAF9ACD0441E10B9E5B525F0584499620086E2",
691 "DDB35281888DF064195C42D45E4E2571AD62113A228B5107D1AC849861C199C0"
692 },
693 {
694 "233FC5D8B6F005B02500727078E84ED16C1B0474D7277E45",
695 "29E0CAACB9BCDE4A36C8A8DC9F98FF9CD442E81EEBBEF72A",
696 "C01326D1C26CE659394CAE07B06C2341A964E73470D01308"
697 },
698 {
699 "139E51D5AD1EF0E10AC3809975FF4DFE",
700 "19415EA1A2522B1B190B5A35928FFCB3",
701 "F0B2B2DCD9821308168F5CEEBD7B206E"
702 },
703 {
704 "3124A0F9711A44FC5B",
705 "3BFBAF8D7E569F0648",
706 "D20843F00586A71547"
707 }
708 },
709 {
710 {
711 "E376288A10BD52CB7162ADA9A732D24B574B1E7CB4FF5C791FFEA2E481AD3049",
712 "FD82CFAE85B8581FFCF489F467D94B1B4FAAAEDDE4EC531ABD30D7EA235896AA",
713 "24D9411BA456571900244AEA3EA7159BAA96522B6F891606A8D9A559FE218A9B"
714 },
715 {
716 "FED65CDA5A5C44F65172417A4910D47B534DE872E6A41E76",
717 "E022BBFECF594E22DCE4652789FB4D2B4BAC58D3B6B71115",
718 "3979354BEEB741242034A639D08513ABAE90A4253DD25409"
719 },
720 {
721 "CE77C8D741B2B1A77EB1B3934407D754",
722 "D0832FF3D4B7BB73F32797CE84EC4E04",
723 "09D8A146F559B4750FF754D0DD921084"
724 },
725 {
726 "ECCD39FB9DB605BA2F",
727 "F239DEDF08B30F6EA2",
728 "2B62506A295D00685E"
729 }
730 },
731 {
732 {
733 "740A4786C73A7C6B52DAF270161895E13B4437C56B9837827C2FE237532F4C19",
734 "581B63C58404AEBECFDFD51D74A79836C11514685B47F3B02A2419AF0AA8C625",
735 "D5FCB196868673D136D480E0B6EFC33C589131D87A4AC004A6E0DE8ADC8DE611"
736 },
737 {
738 "69AA33D68DDB6A5672CA1EA3F83A93D13F42C1CB39C3758D",
739 "45BB1795CEE5B883EFCF39CE9A859E06C513E266091CB1BF",
740 "C85CC5C6CC6765EC16C46C3358CDC50C5C97C7D62811820B"
741 },
742 {
743 "590BA7DB96359F075D09EC4AF52D90FE",
744 "751A8398D50B4DD2C00CCB2797929D29",
745 "F8FD51CBD78990BD39079EDA55DAC623"
746 },
747 {
748 "7BB156F74A312B1A0C",
749 "57A072B4090FF9CF91",
750 "DA47A0E70B8D24A068"
751 }
752 },
753 {
754 {
755 "0855A84EAD2176C3F10B9DCFC8D1A379AF616FC5C5CD4E6D434353C52832F9F6",
756 "A8420E97462B0215AAC1DB0835D4064C6A8B123327FC396C9520BEA70B59B412",
757 "3461DEDF1B4893E16706900E1DDBE351E90C1300B9B01E8A518A01AD56E9AC8C"
758 },
759 {
760 "15F5DC1EE7C060FED11B711C26F3A549AB6799CB97960C62",
761 "B5E27AC70CCA14288AD137DBDBF6007C6E8DE43D75A77B63",
762 "29C1AA8F51A985DC47167CDDF3F9E561ED0AE50EEBEB5C85"
763 },
764 {
765 "25544813FC2E95AFFED883F52BE4A666",
766 "8543EECA1724E179A512C532D6E10353",
767 "19603E824A47708D68D58E34FEEEE64E"
768 },
769 {
770 "07EEB93F202A21B2AF",
771 "A7F91FE6CB205564F4",
772 "3BDACFAE9643C49039"
773 }
774 }
775 };
776
777 char testIV[][33] =
778 {
779 "0000000000000000",
780 "0102030405060708",
781 "4041424344454647",
782 "4693867334098764",
783 "6209876098547207"
784 };
785
786 for (int i = 0; i < 5; i++)
787 {
788 #ifndef WITH_FIPS
789 ByteString keyData56(testKeys56[i]);
790 CPPUNIT_ASSERT(keyData56.size() == 8);
791 ByteString keyData112(testKeys112[i]);
792 CPPUNIT_ASSERT(keyData112.size() == 16);
793 #endif
794 ByteString keyData168(testKeys168[i]);
795 CPPUNIT_ASSERT(keyData168.size() == 24);
796
797 #ifndef WITH_FIPS
798 DESKey desKey56(56);
799 CPPUNIT_ASSERT(desKey56.setKeyBits(keyData56));
800 DESKey desKey112(112);
801 CPPUNIT_ASSERT(desKey112.setKeyBits(keyData112));
802 #endif
803 DESKey desKey168(168);
804 CPPUNIT_ASSERT(desKey168.setKeyBits(keyData168));
805
806 ByteString IV(testIV[i]);
807
808 for (int j = 0; j < 4; j++)
809 {
810 ByteString plainText(testData[j]), shsmPlainText;
811 ByteString cipherText;
812 ByteString shsmCipherText, OB;
813
814 #ifndef WITH_FIPS
815 // Test 56-bit key
816 cipherText = ByteString(testResult[i][j][0]);
817
818 // Now, do the same thing using our DES implementation
819 shsmCipherText.wipe();
•820 if (des->encryptInit(&desKey56, SymMode::OFB, IV)) {
821
•822 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
823 shsmCipherText += OB;
824
•825 CPPUNIT_ASSERT(des->encryptFinal(OB));
826 shsmCipherText += OB;
827
•828 CPPUNIT_ASSERT(shsmCipherText == cipherText);
829
•830 // Check that we can get the plain text
831 shsmPlainText.wipe();
832 CPPUNIT_ASSERT(des->decryptInit(&desKey56, SymMode::OFB, IV));
833
•834 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
835 shsmPlainText += OB;
836
•837 CPPUNIT_ASSERT(des->decryptFinal(OB));
838 shsmPlainText += OB;
839
•840 CPPUNIT_ASSERT(shsmPlainText == plainText);
841 }
842
843 // Test 112-bit key
844 cipherText = ByteString(testResult[i][j][1]);
845
846 // Now, do the same thing using our DES implementation
847 shsmCipherText.wipe();
•848 if (des->encryptInit(&desKey112, SymMode::OFB, IV)) {
849
•850 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
851 shsmCipherText += OB;
852
•853 CPPUNIT_ASSERT(des->encryptFinal(OB));
854 shsmCipherText += OB;
855
•856 CPPUNIT_ASSERT(shsmCipherText == cipherText);
857
•858 // Check that we can get the plain text
859 shsmPlainText.wipe();
860 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::OFB, IV));
861
•862 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
863 shsmPlainText += OB;
864
•865 CPPUNIT_ASSERT(des->decryptFinal(OB));
866 shsmPlainText += OB;
867
•868 CPPUNIT_ASSERT(shsmPlainText == plainText);
869 }
870 #endif
871
872 // Test 168-bit key
873 cipherText = ByteString(testResult[i][j][2]);
874
875 // Now, do the same thing using our DES implementation
876 shsmCipherText.wipe();
•877 if (des->encryptInit(&desKey168, SymMode::OFB, IV)) {
878
•879 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
880 shsmCipherText += OB;
881
•882 CPPUNIT_ASSERT(des->encryptFinal(OB));
883 shsmCipherText += OB;
884
•885 CPPUNIT_ASSERT(shsmCipherText == cipherText);
886
•887 // Check that we can get the plain text
888 shsmPlainText.wipe();
889 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::OFB, IV));
890
•891 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
892 shsmPlainText += OB;
893
•894 CPPUNIT_ASSERT(des->decryptFinal(OB));
895 shsmPlainText += OB;
896
•897 CPPUNIT_ASSERT(shsmPlainText == plainText);
898 }
899 }
900 }
901 }
902
903 void DESTests::testCFB()
904 {
905 #ifndef WITH_FIPS
906 char testKeys56[][17] =
907 {
908 "0000000000000000",
909 "0102030405060708",
910 "4041424344454647",
911 "4698436794236871",
912 "0940278947239572"
913 };
914
915 char testKeys112[][33] =
916 {
917 "00000000000000000000000000000000",
918 "0102030405060708090A0B0C0D0E0F10",
919 "404142434445464748494A4B4C4D4E4F",
920 "64398647034486943598534703463870",
921 "87406984068406984607412103517413"
922 };
923 #endif
924
925 char testKeys168[][49] =
926 {
927 "000000000000000000000000000000000000000000000000",
928 "0102030405060708090A0B0C0D0E0F101112131415161718",
929 "404142434445464748494A4B4C4D4E4F5051525354555657",
930 "643906874509874309687459084769847562436043696747",
931 "430135460496813044639085714376487549490586439575"
932 };
933
934 char testData[][256] =
935 {
936 "4938673409687134684698438657403986439058740935874395813968496846",
937 "549813644389670948567490687546098245665626527788",
938 "64398769586792586795867965624526",
939 "468376458463264536"
940 };
941
942 char testResult[5][4][3][256] = {
943 {
944 {
945 "C59E2ADDC8D95293F8ED346ADAF018111F0B6726349664FF9B02C46C2EC5B96F",
946 "C59E2ADDC8D95293F8ED346ADAF018111F0B6726349664FF9B02C46C2EC5B96F",
947 "C59E2ADDC8D95293F8ED346ADAF018111F0B6726349664FF9B02C46C2EC5B96F"
948 },
949 {
950 "D83E5E8D823844AE748E369586FA76A2BFD1E668EC78D67B",
951 "D83E5E8D823844AE748E369586FA76A2BFD1E668EC78D67B",
952 "D83E5E8D823844AE748E369586FA76A2BFD1E668EC78D67B"
953 },
954 {
955 "E89FCA8099D6B1FFB3A24C435B847A73",
956 "E89FCA8099D6B1FFB3A24C435B847A73",
957 "E89FCA8099D6B1FFB3A24C435B847A73"
958 },
959 {
960 "CA253BAC45D205E270",
961 "CA253BAC45D205E270",
962 "CA253BAC45D205E270"
963 }
964 },
965 {
966 {
967 "3E9FB188FC11138D49C438ABB98A3846671A4DB257AA62C7929CD55A43E46D88",
968 "3440BEFCF35DC8773DD631A9C8CCF222009D45E301BBF6432A78E99416CE87D8",
969 "DDB35281888DF06446772085E3DE849298B4BE0089979260DDC59FACB17AD0BE"
970 },
971 {
972 "233FC5D8B6F005B0966FB313EA0DDFBECF19CBC937445A56",
973 "29E0CAACB9BCDE4AB219A19AA77E2C9A407C98A18BD56FDF",
974 "C01326D1C26CE6592FA4E9909D93A85BE005431046661C73"
975 },
976 {
977 "139E51D5AD1EF0E1E74DD9919AE65DB6",
978 "19415EA1A2522B1B5972F5DCBEEF4E01",
979 "F0B2B2DCD9821308815ADB01F0A16B76"
980 },
981 {
982 "3124A0F9711A44FC92",
983 "3BFBAF8D7E569F06CF",
984 "D20843F00586A715DB"
985 }
986 },
987 {
988 {
989 "E376288A10BD52CB06B42B4582A425907D2DF490EC14B478507BCDE58CE95B02",
990 "FD82CFAE85B8581F1409EB62D06A98E05C401607619DE1235822E2DEB74737E1",
991 "24D9411BA4565719BE9FF1A4D91F23B3BF8980A706747077583C8EB84AF63745"
992 },
993 {
994 "FED65CDA5A5C44F619325429C78F464D271807342B10F899",
995 "E022BBFECF594E22ABC22FA25024B6FD8F61337CBD1F023D",
996 "3979354BEEB741241F0D219B5521A488F870C849275FF8B9"
997 },
998 {
999 "CE77C8D741B2B1A7E488B94EB32C96FD",
1000 "D0832FF3D4B7BB73AEC7646A3686ABCF",
1001 "09D8A146F559B475A6258D03BC6F8BD3"
1002 },
1003 {
1004 "ECCD39FB9DB605BAB2",
1005 "F239DEDF08B30F6EE4",
1006 "2B62506A295D00687E"
1007 }
1008 },
1009 {
1010 {
1011 "740A4786C73A7C6B435071A654DA8FCC75BA3299969E327A2ABC7024378CF3AA",
1012 "581B63C58404AEBE49FA5FA4032918813075279E836DFE9BAEDF37D9B21ABEE1",
1013 "D5FCB196868673D1FA9C8A67E6A2449354B292E1A76BA11C416A394116857B29"
1014 },
1015 {
1016 "69AA33D68DDB6A561FB6D6218FAC0E812514782FC6059E46",
1017 "45BB1795CEE5B883232EBCCB672FC9C4803C6B827825FE94",
1018 "C85CC5C6CC6765EC466B8F8AC8DFC91CB916F617873AF187"
1019 },
1020 {
1021 "590BA7DB96359F07DB2F2CE68748425C",
1022 "751A8398D50B4DD24E4681B6D0E880FC",
1023 "F8FD51CBD78990BD5D088ECA798DA0E6"
1024 },
1025 {
1026 "7BB156F74A312B1A8C",
1027 "57A072B4090FF9CF1B",
1028 "DA47A0E70B8D24A043"
1029 }
1030 },
1031 {
1032 {
1033 "0855A84EAD2176C3D2C3DE4FB868CA2C1B0DF550E187E29808C45594C070FBF4",
1034 "A8420E97462B02158D2CABD1574D072F8D83123CED9BA7CEDD7C2799E168F32D",
1035 "3461DEDF1B4893E182BE36017DEBC6669B15269DFA4435A31EB1A0CE6A845176"
1036 },
1037 {
1038 "15F5DC1EE7C060FEDC9B1B43A20588E7A073A300BEFC4CAD",
1039 "B5E27AC70CCA142857CB807226DC1EA9B31BE81C0FDCD3FB",
1040 "29C1AA8F51A985DC7E530E6EB7AEAC246F2ED097D09851CC"
1041 },
1042 {
1043 "25544813FC2E95AF817E0897D4E22ECD",
1044 "8543EECA1724E179543979F02103C150",
1045 "19603E824A47708D80E29D3A61BAE5EA"
1046 },
1047 {
1048 "07EEB93F202A21B250",
1049 "A7F91FE6CB205564F2",
1050 "3BDACFAE9643C49027"
1051 }
1052 }
1053 };
1054 char testIV[][33] =
1055 {
1056 "0000000000000000",
1057 "0102030405060708",
1058 "4041424344454647",
1059 "4693867334098764",
1060 "6209876098547207"
1061 };
1062
1063 for (int i = 0; i < 5; i++)
1064 {
1065 #ifndef WITH_FIPS
1066 ByteString keyData56(testKeys56[i]);
1067 CPPUNIT_ASSERT(keyData56.size() == 8);
1068 ByteString keyData112(testKeys112[i]);
1069 CPPUNIT_ASSERT(keyData112.size() == 16);
1070 #endif
1071 ByteString keyData168(testKeys168[i]);
1072 CPPUNIT_ASSERT(keyData168.size() == 24);
1073
1074 #ifndef WITH_FIPS
1075 DESKey desKey56(56);
1076 CPPUNIT_ASSERT(desKey56.setKeyBits(keyData56));
1077 DESKey desKey112(112);
1078 CPPUNIT_ASSERT(desKey112.setKeyBits(keyData112));
1079 #endif
1080 DESKey desKey168(168);
1081 CPPUNIT_ASSERT(desKey168.setKeyBits(keyData168));
1082
1083 ByteString IV(testIV[i]);
1084
1085 for (int j = 0; j < 4; j++)
1086 {
1087 ByteString plainText(testData[j]), shsmPlainText;
1088 ByteString cipherText;
1089 ByteString shsmCipherText, OB;
1090
1091 #ifndef WITH_FIPS
1092 // Test 56-bit key
1093 cipherText = ByteString(testResult[i][j][0]);
1094
1095 // Now, do the same thing using our DES implementation
1096 shsmCipherText.wipe();
•1097 if (des->encryptInit(&desKey56, SymMode::CFB, IV)) {
1098
•1099 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
1100 shsmCipherText += OB;
1101
•1102 CPPUNIT_ASSERT(des->encryptFinal(OB));
1103 shsmCipherText += OB;
1104
•1105 CPPUNIT_ASSERT(shsmCipherText == cipherText);
1106
•1107 // Check that we can get the plain text
1108 shsmPlainText.wipe();
1109 CPPUNIT_ASSERT(des->decryptInit(&desKey56, SymMode::CFB, IV));
1110
•1111 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
1112 shsmPlainText += OB;
1113
•1114 CPPUNIT_ASSERT(des->decryptFinal(OB));
1115 shsmPlainText += OB;
1116
•1117 CPPUNIT_ASSERT(shsmPlainText == plainText);
1118 }
1119
1120 // Test 112-bit key
1121 cipherText = ByteString(testResult[i][j][1]);
1122
1123 // Now, do the same thing using our DES implementation
1124 shsmCipherText.wipe();
•1125 if (des->encryptInit(&desKey112, SymMode::CFB, IV)) {
1126
•1127 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
1128 shsmCipherText += OB;
1129
•1130 CPPUNIT_ASSERT(des->encryptFinal(OB));
1131 shsmCipherText += OB;
1132
•1133 CPPUNIT_ASSERT(shsmCipherText == cipherText);
1134
•1135 // Check that we can get the plain text
1136 shsmPlainText.wipe();
1137 CPPUNIT_ASSERT(des->decryptInit(&desKey112, SymMode::CFB, IV));
1138
•1139 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
1140 shsmPlainText += OB;
1141
•1142 CPPUNIT_ASSERT(des->decryptFinal(OB));
1143 shsmPlainText += OB;
1144
•1145 CPPUNIT_ASSERT(shsmPlainText == plainText);
1146 }
1147 #endif
1148
1149 // Test 168-bit key
1150 cipherText = ByteString(testResult[i][j][2]);
1151
1152 // Now, do the same thing using our DES implementation
1153 shsmCipherText.wipe();
•1154 if (des->encryptInit(&desKey168, SymMode::CFB, IV)) {
1155
•1156 CPPUNIT_ASSERT(des->encryptUpdate(plainText, OB));
1157 shsmCipherText += OB;
1158
•1159 CPPUNIT_ASSERT(des->encryptFinal(OB));
1160 shsmCipherText += OB;
1161
•1162 CPPUNIT_ASSERT(shsmCipherText == cipherText);
1163
•1164 // Check that we can get the plain text
1165 shsmPlainText.wipe();
1166 CPPUNIT_ASSERT(des->decryptInit(&desKey168, SymMode::CFB, IV));
1167
•1168 CPPUNIT_ASSERT(des->decryptUpdate(shsmCipherText, OB));
1169 shsmPlainText += OB;
1170
•1171 CPPUNIT_ASSERT(des->decryptFinal(OB));
1172 shsmPlainText += OB;
1173
•1174 CPPUNIT_ASSERT(shsmPlainText == plainText);
1175 }
1176 }
1177 }
1178 }