Bump version to 24.04.3.4
[LibreOffice.git] / sal / qa / rtl / cipher / rtl_cipher.cxx
blob3844c5613bd3e3284741f368da8ace5bf7507e74
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <cstring>
22 #include <sal/types.h>
23 #include <cppunit/TestFixture.h>
24 #include <cppunit/extensions/HelperMacros.h>
26 #include <rtl/cipher.h>
27 #include <rtl/string.hxx>
29 namespace rtl_cipher
32 class create : public CppUnit::TestFixture
34 public:
36 void create_001()
38 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
39 #if defined LIBO_CIPHER_OPENSSL_BACKEND
40 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
41 #else
42 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
43 rtl_cipher_destroy(aCipher);
44 #endif
46 void create_002()
48 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeECB);
49 CPPUNIT_ASSERT_EQUAL_MESSAGE("create provide wrong object.", static_cast<rtlCipher>(nullptr), aCipher);
51 void create_003()
53 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC);
54 #if defined LIBO_CIPHER_OPENSSL_BACKEND
55 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
56 #else
57 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
58 rtl_cipher_destroy(aCipher);
59 #endif
61 void create_004()
63 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeCBC);
64 CPPUNIT_ASSERT_EQUAL_MESSAGE("create provide wrong object.", static_cast<rtlCipher>(nullptr), aCipher);
66 void create_005()
68 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
69 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
70 rtl_cipher_destroy(aCipher);
72 void create_006()
74 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeStream);
75 CPPUNIT_ASSERT_EQUAL_MESSAGE("create provide wrong object.", static_cast<rtlCipher>(nullptr), aCipher);
77 void create_007()
79 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeInvalid);
80 CPPUNIT_ASSERT_EQUAL_MESSAGE("create provide wrong object.", static_cast<rtlCipher>(nullptr), aCipher);
82 void create_008()
84 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeInvalid);
85 CPPUNIT_ASSERT_EQUAL_MESSAGE("create provide wrong object.", static_cast<rtlCipher>(nullptr), aCipher);
88 // Change the following lines only, if you add, remove or rename
89 // member functions of the current class,
90 // because these macros are need by auto register mechanism.
92 CPPUNIT_TEST_SUITE(create);
93 CPPUNIT_TEST(create_001);
94 CPPUNIT_TEST(create_002);
95 CPPUNIT_TEST(create_003);
96 CPPUNIT_TEST(create_004);
97 CPPUNIT_TEST(create_005);
98 CPPUNIT_TEST(create_006);
99 CPPUNIT_TEST(create_007);
100 CPPUNIT_TEST(create_008);
101 CPPUNIT_TEST_SUITE_END();
102 }; // class create
104 class createBF : public CppUnit::TestFixture
106 public:
108 void createBF_001()
110 rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeECB);
111 #if defined LIBO_CIPHER_OPENSSL_BACKEND
112 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
113 #else
114 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
115 rtl_cipher_destroy(aCipher);
116 #endif
118 void createBF_002()
120 rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeCBC);
121 #if defined LIBO_CIPHER_OPENSSL_BACKEND
122 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
123 #else
124 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
125 rtl_cipher_destroy(aCipher);
126 #endif
128 void createBF_003()
130 rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeStream);
131 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
132 rtl_cipher_destroy(aCipher);
134 void createBF_004()
136 rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeInvalid);
137 CPPUNIT_ASSERT_EQUAL_MESSAGE("create provide wrong object.", static_cast<rtlCipher>(nullptr), aCipher);
138 // rtl_cipher_destroy(aCipher);
140 // Change the following lines only, if you add, remove or rename
141 // member functions of the current class,
142 // because these macros are need by auto register mechanism.
144 CPPUNIT_TEST_SUITE(createBF);
145 CPPUNIT_TEST(createBF_001);
146 CPPUNIT_TEST(createBF_002);
147 CPPUNIT_TEST(createBF_003);
148 CPPUNIT_TEST(createBF_004);
149 CPPUNIT_TEST_SUITE_END();
150 }; // class createBF
152 class decode : public CppUnit::TestFixture
154 public:
156 void test_encode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, OString const& _sPlainTextStr)
158 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
159 #if defined LIBO_CIPHER_OPENSSL_BACKEND
160 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
161 (void) _nKeyValue;
162 (void) _nArgValue;
163 (void) _sPlainTextStr;
164 #else
165 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
167 sal_uInt32 nKeyLen = 16;
168 sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
169 memset(pKeyBuffer, 0, nKeyLen);
170 pKeyBuffer[0] = _nKeyValue;
172 sal_uInt32 nArgLen = 16;
173 sal_uInt8 *pArgBuffer = new sal_uInt8[ nArgLen ];
174 memset(pArgBuffer, 0, nArgLen);
175 pArgBuffer[0] = _nArgValue;
177 rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
178 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong init", rtl_Cipher_E_None, aError);
180 sal_uInt32 nPlainTextLen = 16;
181 sal_uInt8 *pPlainTextBuffer = new sal_uInt8[ nPlainTextLen ];
182 memset(pPlainTextBuffer, 0, nPlainTextLen);
183 strncpy(reinterpret_cast<char*>(pPlainTextBuffer), _sPlainTextStr.getStr(), 16);
185 sal_uInt32 nCipherLen = 16;
186 sal_uInt8 *pCipherBuffer = new sal_uInt8[ nCipherLen ];
187 memset(pCipherBuffer, 0, nCipherLen);
189 /* rtlCipherError */ aError = rtl_cipher_encode(aCipher, pPlainTextBuffer, nPlainTextLen, pCipherBuffer, nCipherLen);
190 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong encode", rtl_Cipher_E_None, aError);
192 sal_uInt32 nPlainText2Len = 16;
193 sal_uInt8 *pPlainText2Buffer = new sal_uInt8[ nPlainText2Len ];
194 memset(pPlainText2Buffer, 0, nPlainText2Len);
196 /* rtlCipherError */ aError = rtl_cipher_decode(aCipher, pCipherBuffer, nCipherLen, pPlainText2Buffer, nPlainText2Len);
197 CPPUNIT_ASSERT_MESSAGE("decode should not work", aError != rtl_Cipher_E_None);
199 delete [] pPlainText2Buffer;
201 delete [] pCipherBuffer;
202 delete [] pPlainTextBuffer;
204 delete [] pArgBuffer;
205 delete [] pKeyBuffer;
207 rtl_cipher_destroy(aCipher);
208 #endif
211 void test_encode_and_decode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, OString const& _sPlainTextStr)
213 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
214 #if defined LIBO_CIPHER_OPENSSL_BACKEND
215 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
216 (void) _nKeyValue;
217 (void) _nArgValue;
218 (void) _sPlainTextStr;
219 #else
220 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
222 sal_uInt32 nKeyLen = 16;
223 sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
224 memset(pKeyBuffer, 0, nKeyLen);
225 pKeyBuffer[0] = _nKeyValue;
227 sal_uInt32 nArgLen = 16;
228 sal_uInt8 *pArgBuffer = new sal_uInt8[ nArgLen ];
229 memset(pArgBuffer, 0, nArgLen);
230 pArgBuffer[0] = _nArgValue;
232 rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionBoth, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
233 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong init", rtl_Cipher_E_None, aError);
235 sal_uInt32 nPlainTextLen = 16;
236 sal_uInt8 *pPlainTextBuffer = new sal_uInt8[ nPlainTextLen ];
237 memset(pPlainTextBuffer, 0, nPlainTextLen);
238 strncpy(reinterpret_cast<char*>(pPlainTextBuffer), _sPlainTextStr.getStr(), 16);
240 sal_uInt32 nCipherLen = 16;
241 sal_uInt8 *pCipherBuffer = new sal_uInt8[ nCipherLen ];
242 memset(pCipherBuffer, 0, nCipherLen);
244 /* rtlCipherError */ aError = rtl_cipher_encode(aCipher, pPlainTextBuffer, nPlainTextLen, pCipherBuffer, nCipherLen);
245 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong encode", rtl_Cipher_E_None, aError);
247 sal_uInt32 nPlainText2Len = 16;
248 sal_uInt8 *pPlainText2Buffer = new sal_uInt8[ nPlainText2Len ];
249 memset(pPlainText2Buffer, 0, nPlainText2Len);
251 /* rtlCipherError */ aError = rtl_cipher_decode(aCipher, pCipherBuffer, nCipherLen, pPlainText2Buffer, nPlainText2Len);
252 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong decode", rtl_Cipher_E_None, aError);
254 sal_Int32 nCompare = memcmp(pPlainTextBuffer, pPlainText2Buffer, 16);
256 CPPUNIT_ASSERT_EQUAL_MESSAGE("compare between plain and decoded plain failed", static_cast<sal_Int32>(0), nCompare);
258 delete [] pPlainText2Buffer;
260 delete [] pCipherBuffer;
261 delete [] pPlainTextBuffer;
263 delete [] pArgBuffer;
264 delete [] pKeyBuffer;
266 rtl_cipher_destroy(aCipher);
267 #endif
270 void decode_001()
272 test_encode_and_decode(0,0,""_ostr);
273 test_encode_and_decode(0,0,"hallo"_ostr);
274 test_encode_and_decode(1,0,"B2Aahg5B"_ostr);
275 test_encode_and_decode(1,2,"Longer text string"_ostr);
278 void decode_002()
280 test_encode(0,0,""_ostr);
281 test_encode(0,0,"hallo"_ostr);
282 test_encode(1,0,"B2Aahg5B"_ostr);
283 test_encode(1,2,"Longer text string"_ostr);
285 // Change the following lines only, if you add, remove or rename
286 // member functions of the current class,
287 // because these macros are need by auto register mechanism.
289 CPPUNIT_TEST_SUITE(decode);
290 CPPUNIT_TEST(decode_001);
291 CPPUNIT_TEST(decode_002);
292 CPPUNIT_TEST_SUITE_END();
293 }; // class decode
295 class decodeBF : public CppUnit::TestFixture
297 public:
299 void decodeBF_001()
302 // Change the following lines only, if you add, remove or rename
303 // member functions of the current class,
304 // because these macros are need by auto register mechanism.
306 CPPUNIT_TEST_SUITE(decodeBF);
307 CPPUNIT_TEST(decodeBF_001);
308 CPPUNIT_TEST_SUITE_END();
309 }; // class decodeBF
311 class destroy : public CppUnit::TestFixture
313 public:
315 void destroy_001()
317 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC);
318 #if defined LIBO_CIPHER_OPENSSL_BACKEND
319 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
320 #else
321 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
322 rtl_cipher_destroy(aCipher);
323 #endif
325 // Change the following lines only, if you add, remove or rename
326 // member functions of the current class,
327 // because these macros are need by auto register mechanism.
329 CPPUNIT_TEST_SUITE(destroy);
330 CPPUNIT_TEST(destroy_001);
331 CPPUNIT_TEST_SUITE_END();
332 }; // class destroy
334 class destroyBF : public CppUnit::TestFixture
336 public:
338 void destroyBF_001()
340 rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeECB);
341 #if defined LIBO_CIPHER_OPENSSL_BACKEND
342 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
343 #else
344 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
345 rtl_cipher_destroyBF(aCipher);
346 // more proforma
347 // should not GPF
348 #endif
350 // Change the following lines only, if you add, remove or rename
351 // member functions of the current class,
352 // because these macros are need by auto register mechanism.
354 CPPUNIT_TEST_SUITE(destroyBF);
355 CPPUNIT_TEST(destroyBF_001);
356 CPPUNIT_TEST_SUITE_END();
357 }; // class destroyBF
359 class encode : public CppUnit::TestFixture
361 public:
363 void test_encode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, sal_uInt8 _nDataValue)
365 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
366 #if defined LIBO_CIPHER_OPENSSL_BACKEND
367 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
368 (void) _nKeyValue;
369 (void) _nArgValue;
370 (void) _nDataValue;
371 #else
372 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
374 sal_uInt32 nKeyLen = 16;
375 sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
376 memset(pKeyBuffer, 0, nKeyLen);
377 pKeyBuffer[0] = _nKeyValue;
379 sal_uInt32 nArgLen = 16;
380 sal_uInt8 *pArgBuffer = new sal_uInt8[ nArgLen ];
381 memset(pArgBuffer, 0, nArgLen);
382 pArgBuffer[0] = _nArgValue;
384 rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
385 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong init", rtl_Cipher_E_None, aError);
387 sal_uInt32 nDataLen = 16;
388 sal_uInt8 *pDataBuffer = new sal_uInt8[ nDataLen ];
389 memset(pDataBuffer, 0, nDataLen);
390 pDataBuffer[0] = _nDataValue;
392 sal_uInt32 nLen = 16;
393 sal_uInt8 *pBuffer = new sal_uInt8[ nLen ];
394 memset(pBuffer, 0, nLen);
396 /* rtlCipherError */ aError = rtl_cipher_encode(aCipher, pDataBuffer, nDataLen, pBuffer, nLen);
397 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong encode", rtl_Cipher_E_None, aError);
399 delete [] pBuffer;
400 delete [] pDataBuffer;
402 delete [] pArgBuffer;
403 delete [] pKeyBuffer;
405 rtl_cipher_destroy(aCipher);
406 #endif
409 void encode_001()
411 test_encode(0,0,0);
412 test_encode(1,0,0);
413 test_encode(0,1,0);
414 test_encode(1,1,0);
416 test_encode(0,0,1);
417 test_encode(1,0,1);
418 test_encode(0,1,1);
419 test_encode(1,1,1);
422 // Change the following lines only, if you add, remove or rename
423 // member functions of the current class,
424 // because these macros are need by auto register mechanism.
426 CPPUNIT_TEST_SUITE(encode);
427 CPPUNIT_TEST(encode_001);
428 CPPUNIT_TEST_SUITE_END();
429 }; // class encode
431 class encodeBF : public CppUnit::TestFixture
433 public:
435 void encodeBF_001()
438 // Change the following lines only, if you add, remove or rename
439 // member functions of the current class,
440 // because these macros are need by auto register mechanism.
442 CPPUNIT_TEST_SUITE(encodeBF);
443 CPPUNIT_TEST(encodeBF_001);
444 CPPUNIT_TEST_SUITE_END();
445 }; // class encodeBF
447 class init : public CppUnit::TestFixture
449 public:
451 void init_001()
453 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
454 #if defined LIBO_CIPHER_OPENSSL_BACKEND
455 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
456 #else
457 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
459 sal_uInt32 nKeyLen = 16;
460 sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
461 memset(pKeyBuffer, 0, nKeyLen);
463 sal_uInt32 nArgLen = 16;
464 sal_uInt8 *pArgBuffer = new sal_uInt8[ nArgLen ];
465 memset(pArgBuffer, 0, nArgLen);
467 rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
468 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong init", rtl_Cipher_E_None, aError);
470 delete [] pArgBuffer;
471 delete [] pKeyBuffer;
473 rtl_cipher_destroy(aCipher);
474 #endif
477 void init_002()
479 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
480 #if defined LIBO_CIPHER_OPENSSL_BACKEND
481 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
482 #else
483 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
485 sal_uInt32 nKeyLen = 16;
486 sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
487 memset(pKeyBuffer, 0, nKeyLen);
488 pKeyBuffer[0] = 1;
490 sal_uInt32 nArgLen = 16;
491 sal_uInt8 *pArgBuffer = new sal_uInt8[ nArgLen ];
492 memset(pArgBuffer, 0, nArgLen);
494 rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
495 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong init", rtl_Cipher_E_None, aError);
497 delete [] pArgBuffer;
498 delete [] pKeyBuffer;
500 rtl_cipher_destroy(aCipher);
501 #endif
503 void init_003()
505 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
506 #if defined LIBO_CIPHER_OPENSSL_BACKEND
507 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
508 #else
509 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
511 sal_uInt32 nKeyLen = 16;
512 sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
513 memset(pKeyBuffer, 0, nKeyLen);
515 sal_uInt32 nArgLen = 16;
516 sal_uInt8 *pArgBuffer = new sal_uInt8[ nArgLen ];
517 memset(pArgBuffer, 0, nArgLen);
518 pArgBuffer[0] = 1;
520 rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
521 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong init", rtl_Cipher_E_None, aError);
523 delete [] pArgBuffer;
524 delete [] pKeyBuffer;
526 rtl_cipher_destroy(aCipher);
527 #endif
529 void init_004()
531 rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
532 #if defined LIBO_CIPHER_OPENSSL_BACKEND
533 CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher);
534 #else
535 CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr);
537 sal_uInt32 nKeyLen = 16;
538 sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
539 memset(pKeyBuffer, 0, nKeyLen);
540 pKeyBuffer[0] = 1;
542 sal_uInt32 nArgLen = 16;
543 sal_uInt8 *pArgBuffer = new sal_uInt8[ nArgLen ];
544 memset(pArgBuffer, 0, nArgLen);
545 pArgBuffer[0] = 1;
547 rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
548 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong init", rtl_Cipher_E_None, aError);
550 delete [] pArgBuffer;
551 delete [] pKeyBuffer;
553 rtl_cipher_destroy(aCipher);
554 #endif
556 // Change the following lines only, if you add, remove or rename
557 // member functions of the current class,
558 // because these macros are need by auto register mechanism.
560 CPPUNIT_TEST_SUITE(init);
561 CPPUNIT_TEST(init_001);
562 CPPUNIT_TEST(init_002);
563 CPPUNIT_TEST(init_003);
564 CPPUNIT_TEST(init_004);
565 CPPUNIT_TEST_SUITE_END();
566 }; // class init
568 class initBF : public CppUnit::TestFixture
570 public:
572 void initBF_001()
574 // seems to be the same as init, so empty
577 // Change the following lines only, if you add, remove or rename
578 // member functions of the current class,
579 // because these macros are need by auto register mechanism.
581 CPPUNIT_TEST_SUITE(initBF);
582 CPPUNIT_TEST(initBF_001);
583 CPPUNIT_TEST_SUITE_END();
584 }; // class initBF
586 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::create);
587 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::createBF);
588 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::decode);
589 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::decodeBF);
590 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::destroy);
591 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::destroyBF);
592 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::encode);
593 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::encodeBF);
594 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::init);
595 CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::initBF);
597 } // namespace rtl_cipher
599 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */