LCOV - code coverage report
Current view: top level - libreoffice/sal/qa/rtl/cipher - rtl_cipher.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 359 359 100.0 %
Date: 2012-12-27 Functions: 110 111 99.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <cstring>
      21             : 
      22             : #include <sal/types.h>
      23             : #include <cppunit/TestFixture.h>
      24             : #include <cppunit/extensions/HelperMacros.h>
      25             : #include <cppunit/plugin/TestPlugIn.h>
      26             : 
      27             : #include <rtl/strbuf.hxx>
      28             : #include <rtl/cipher.h>
      29             : 
      30             : // -----------------------------------------------------------------------------
      31             : namespace rtl_cipher
      32             : {
      33             : 
      34          24 : class create : public CppUnit::TestFixture
      35             : {
      36             : public:
      37             :     // initialise your test code values here.
      38           8 :     void setUp()
      39             :     {
      40           8 :     }
      41             : 
      42           8 :     void tearDown()
      43             :     {
      44           8 :     }
      45             : 
      46           1 :     void create_001()
      47             :         {
      48           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
      49           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
      50           1 :             rtl_cipher_destroy(aCipher);
      51           1 :         }
      52           1 :     void create_002()
      53             :         {
      54           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeECB);
      55           1 :             CPPUNIT_ASSERT_MESSAGE("create provide wrong object.", aCipher == NULL);
      56           1 :         }
      57           1 :     void create_003()
      58             :         {
      59           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC);
      60           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
      61           1 :             rtl_cipher_destroy(aCipher);
      62           1 :         }
      63           1 :     void create_004()
      64             :         {
      65           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeCBC);
      66           1 :             CPPUNIT_ASSERT_MESSAGE("create provide wrong object.", aCipher == NULL);
      67           1 :         }
      68           1 :     void create_005()
      69             :         {
      70           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
      71           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
      72           1 :             rtl_cipher_destroy(aCipher);
      73           1 :         }
      74           1 :     void create_006()
      75             :         {
      76           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeStream);
      77           1 :             CPPUNIT_ASSERT_MESSAGE("create provide wrong object.", aCipher == NULL);
      78           1 :         }
      79           1 :     void create_007()
      80             :         {
      81           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeInvalid);
      82           1 :             CPPUNIT_ASSERT_MESSAGE("create provide wrong object.", aCipher == NULL);
      83           1 :         }
      84           1 :     void create_008()
      85             :         {
      86           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmInvalid, rtl_Cipher_ModeInvalid);
      87           1 :             CPPUNIT_ASSERT_MESSAGE("create provide wrong object.", aCipher == NULL);
      88           1 :         }
      89             : 
      90             :     // Change the following lines only, if you add, remove or rename
      91             :     // member functions of the current class,
      92             :     // because these macros are need by auto register mechanism.
      93             : 
      94           2 :     CPPUNIT_TEST_SUITE(create);
      95           1 :     CPPUNIT_TEST(create_001);
      96           1 :     CPPUNIT_TEST(create_002);
      97           1 :     CPPUNIT_TEST(create_003);
      98           1 :     CPPUNIT_TEST(create_004);
      99           1 :     CPPUNIT_TEST(create_005);
     100           1 :     CPPUNIT_TEST(create_006);
     101           1 :     CPPUNIT_TEST(create_007);
     102           1 :     CPPUNIT_TEST(create_008);
     103           2 :     CPPUNIT_TEST_SUITE_END();
     104             : }; // class create
     105             : 
     106             : // -----------------------------------------------------------------------------
     107          12 : class createBF : public CppUnit::TestFixture
     108             : {
     109             : public:
     110             :     // initialise your test code values here.
     111           4 :     void setUp()
     112             :     {
     113           4 :     }
     114             : 
     115           4 :     void tearDown()
     116             :     {
     117           4 :     }
     118             : 
     119           1 :     void createBF_001()
     120             :         {
     121           1 :             rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeECB);
     122           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     123           1 :             rtl_cipher_destroy(aCipher);
     124           1 :         }
     125           1 :     void createBF_002()
     126             :         {
     127           1 :             rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeCBC);
     128           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     129           1 :             rtl_cipher_destroy(aCipher);
     130           1 :         }
     131           1 :     void createBF_003()
     132             :         {
     133           1 :             rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeStream);
     134           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     135           1 :             rtl_cipher_destroy(aCipher);
     136           1 :         }
     137           1 :     void createBF_004()
     138             :         {
     139           1 :             rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeInvalid);
     140           1 :             CPPUNIT_ASSERT_MESSAGE("create provide wrong object.", aCipher == NULL);
     141             :             // rtl_cipher_destroy(aCipher);
     142           1 :         }
     143             :     // Change the following lines only, if you add, remove or rename
     144             :     // member functions of the current class,
     145             :     // because these macros are need by auto register mechanism.
     146             : 
     147           2 :     CPPUNIT_TEST_SUITE(createBF);
     148           1 :     CPPUNIT_TEST(createBF_001);
     149           1 :     CPPUNIT_TEST(createBF_002);
     150           1 :     CPPUNIT_TEST(createBF_003);
     151           1 :     CPPUNIT_TEST(createBF_004);
     152           2 :     CPPUNIT_TEST_SUITE_END();
     153             : }; // class createBF
     154             : // -----------------------------------------------------------------------------
     155           6 : class decode : public CppUnit::TestFixture
     156             : {
     157             : public:
     158             :     // initialise your test code values here.
     159           2 :     void setUp()
     160             :     {
     161           2 :     }
     162             : 
     163           2 :     void tearDown()
     164             :     {
     165           2 :     }
     166             : 
     167           4 :     void test_encode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, rtl::OString const& _sPlainTextStr)
     168             :         {
     169           4 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
     170           4 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     171             : 
     172           4 :             sal_uInt32     nKeyLen = 16;
     173           4 :             sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
     174           4 :             memset(pKeyBuffer, 0, nKeyLen);
     175           4 :             pKeyBuffer[0] = _nKeyValue;
     176             : 
     177           4 :             sal_uInt32     nArgLen = 16;
     178           4 :             sal_uInt8     *pArgBuffer = new sal_uInt8[ nArgLen ];
     179           4 :             memset(pArgBuffer, 0, nArgLen);
     180           4 :             pArgBuffer[0] = _nArgValue;
     181             : 
     182           4 :             rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
     183           4 :             CPPUNIT_ASSERT_MESSAGE("wrong init", aError == rtl_Cipher_E_None);
     184             : 
     185           4 :             sal_uInt32     nPlainTextLen = 16;
     186           4 :             sal_uInt8     *pPlainTextBuffer = new sal_uInt8[ nPlainTextLen ];
     187           4 :             memset(pPlainTextBuffer, 0, nPlainTextLen);
     188           4 :             strncpy((char*)pPlainTextBuffer, _sPlainTextStr.getStr(), 16);
     189             : 
     190           4 :             sal_uInt32     nCipherLen = 16;
     191           4 :             sal_uInt8     *pCipherBuffer = new sal_uInt8[ nCipherLen ];
     192           4 :             memset(pCipherBuffer, 0, nCipherLen);
     193             : 
     194           4 :             /* rtlCipherError */ aError = rtl_cipher_encode(aCipher, pPlainTextBuffer, nPlainTextLen, pCipherBuffer, nCipherLen);
     195           4 :             CPPUNIT_ASSERT_MESSAGE("wrong encode", aError == rtl_Cipher_E_None);
     196             : 
     197           4 :             sal_uInt32     nPlainText2Len = 16;
     198           4 :             sal_uInt8     *pPlainText2Buffer = new sal_uInt8[ nPlainText2Len ];
     199           4 :             memset(pPlainText2Buffer, 0, nPlainText2Len);
     200             : 
     201           4 :             /* rtlCipherError */ aError = rtl_cipher_decode(aCipher, pCipherBuffer, nCipherLen, pPlainText2Buffer, nPlainText2Len);
     202           4 :             CPPUNIT_ASSERT_MESSAGE("decode should not work", aError != rtl_Cipher_E_None);
     203             : 
     204           4 :             delete [] pPlainText2Buffer;
     205             : 
     206           4 :             delete [] pCipherBuffer;
     207           4 :             delete [] pPlainTextBuffer;
     208             : 
     209           4 :             delete [] pArgBuffer;
     210           4 :             delete [] pKeyBuffer;
     211             : 
     212           4 :             rtl_cipher_destroy(aCipher);
     213           4 :         }
     214             : 
     215           4 :     void test_encode_and_decode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, rtl::OString const& _sPlainTextStr)
     216             :         {
     217           4 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
     218           4 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     219             : 
     220           4 :             sal_uInt32     nKeyLen = 16;
     221           4 :             sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
     222           4 :             memset(pKeyBuffer, 0, nKeyLen);
     223           4 :             pKeyBuffer[0] = _nKeyValue;
     224             : 
     225           4 :             sal_uInt32     nArgLen = 16;
     226           4 :             sal_uInt8     *pArgBuffer = new sal_uInt8[ nArgLen ];
     227           4 :             memset(pArgBuffer, 0, nArgLen);
     228           4 :             pArgBuffer[0] = _nArgValue;
     229             : 
     230           4 :             rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionBoth, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
     231           4 :             CPPUNIT_ASSERT_MESSAGE("wrong init", aError == rtl_Cipher_E_None);
     232             : 
     233           4 :             sal_uInt32     nPlainTextLen = 16;
     234           4 :             sal_uInt8     *pPlainTextBuffer = new sal_uInt8[ nPlainTextLen ];
     235           4 :             memset(pPlainTextBuffer, 0, nPlainTextLen);
     236           4 :             strncpy((char*)pPlainTextBuffer, _sPlainTextStr.getStr(), 16);
     237             : 
     238           4 :             sal_uInt32     nCipherLen = 16;
     239           4 :             sal_uInt8     *pCipherBuffer = new sal_uInt8[ nCipherLen ];
     240           4 :             memset(pCipherBuffer, 0, nCipherLen);
     241             : 
     242           4 :             /* rtlCipherError */ aError = rtl_cipher_encode(aCipher, pPlainTextBuffer, nPlainTextLen, pCipherBuffer, nCipherLen);
     243           4 :             CPPUNIT_ASSERT_MESSAGE("wrong encode", aError == rtl_Cipher_E_None);
     244             : 
     245           4 :             sal_uInt32     nPlainText2Len = 16;
     246           4 :             sal_uInt8     *pPlainText2Buffer = new sal_uInt8[ nPlainText2Len ];
     247           4 :             memset(pPlainText2Buffer, 0, nPlainText2Len);
     248             : 
     249           4 :             /* rtlCipherError */ aError = rtl_cipher_decode(aCipher, pCipherBuffer, nCipherLen, pPlainText2Buffer, nPlainText2Len);
     250           4 :             CPPUNIT_ASSERT_MESSAGE("wrong decode", aError == rtl_Cipher_E_None);
     251             : 
     252           4 :             sal_Int32 nCompare = memcmp(pPlainTextBuffer, pPlainText2Buffer, 16);
     253             : 
     254           4 :             CPPUNIT_ASSERT_MESSAGE("compare between plain and decoded plain failed", nCompare == 0);
     255             : 
     256           4 :             delete [] pPlainText2Buffer;
     257             : 
     258           4 :             delete [] pCipherBuffer;
     259           4 :             delete [] pPlainTextBuffer;
     260             : 
     261           4 :             delete [] pArgBuffer;
     262           4 :             delete [] pKeyBuffer;
     263             : 
     264           4 :             rtl_cipher_destroy(aCipher);
     265           4 :         }
     266             : 
     267           1 :     void decode_001()
     268             :         {
     269           1 :             test_encode_and_decode(0,0,"");
     270           1 :             test_encode_and_decode(0,0,"hallo");
     271           1 :             test_encode_and_decode(1,0,"B2Aahg5B");
     272           1 :             test_encode_and_decode(1,2,"Longer text string");
     273           1 :         }
     274             : 
     275           1 :     void decode_002()
     276             :         {
     277           1 :             test_encode(0,0,"");
     278           1 :             test_encode(0,0,"hallo");
     279           1 :             test_encode(1,0,"B2Aahg5B");
     280           1 :             test_encode(1,2,"Longer text string");
     281           1 :         }
     282             :     // Change the following lines only, if you add, remove or rename
     283             :     // member functions of the current class,
     284             :     // because these macros are need by auto register mechanism.
     285             : 
     286           2 :     CPPUNIT_TEST_SUITE(decode);
     287           1 :     CPPUNIT_TEST(decode_001);
     288           1 :     CPPUNIT_TEST(decode_002);
     289           2 :     CPPUNIT_TEST_SUITE_END();
     290             : }; // class decode
     291             : // -----------------------------------------------------------------------------
     292           3 : class decodeBF : public CppUnit::TestFixture
     293             : {
     294             : public:
     295             :     // initialise your test code values here.
     296           1 :     void setUp()
     297             :     {
     298           1 :     }
     299             : 
     300           1 :     void tearDown()
     301             :     {
     302           1 :     }
     303             : 
     304           1 :     void decodeBF_001()
     305             :         {
     306           1 :         }
     307             :     // Change the following lines only, if you add, remove or rename
     308             :     // member functions of the current class,
     309             :     // because these macros are need by auto register mechanism.
     310             : 
     311           2 :     CPPUNIT_TEST_SUITE(decodeBF);
     312           1 :     CPPUNIT_TEST(decodeBF_001);
     313           2 :     CPPUNIT_TEST_SUITE_END();
     314             : }; // class decodeBF
     315             : // -----------------------------------------------------------------------------
     316           3 : class destroy : public CppUnit::TestFixture
     317             : {
     318             : public:
     319             :     // initialise your test code values here.
     320           1 :     void setUp()
     321             :     {
     322           1 :     }
     323             : 
     324           1 :     void tearDown()
     325             :     {
     326           1 :     }
     327             : 
     328           1 :     void destroy_001()
     329             :         {
     330           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC);
     331           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     332           1 :             rtl_cipher_destroy(aCipher);
     333           1 :         }
     334             :     // Change the following lines only, if you add, remove or rename
     335             :     // member functions of the current class,
     336             :     // because these macros are need by auto register mechanism.
     337             : 
     338           2 :     CPPUNIT_TEST_SUITE(destroy);
     339           1 :     CPPUNIT_TEST(destroy_001);
     340           2 :     CPPUNIT_TEST_SUITE_END();
     341             : }; // class destroy
     342             : // -----------------------------------------------------------------------------
     343           3 : class destroyBF : public CppUnit::TestFixture
     344             : {
     345             : public:
     346             :     // initialise your test code values here.
     347           1 :     void setUp()
     348             :     {
     349           1 :     }
     350             : 
     351           1 :     void tearDown()
     352             :     {
     353           1 :     }
     354             : 
     355           1 :     void destroyBF_001()
     356             :         {
     357           1 :             rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeECB);
     358           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     359           1 :             rtl_cipher_destroyBF(aCipher);
     360             :             // more proforma
     361             :             // should not GPF
     362           1 :         }
     363             :     // Change the following lines only, if you add, remove or rename
     364             :     // member functions of the current class,
     365             :     // because these macros are need by auto register mechanism.
     366             : 
     367           2 :     CPPUNIT_TEST_SUITE(destroyBF);
     368           1 :     CPPUNIT_TEST(destroyBF_001);
     369           2 :     CPPUNIT_TEST_SUITE_END();
     370             : }; // class destroyBF
     371             : // -----------------------------------------------------------------------------
     372           3 : class encode : public CppUnit::TestFixture
     373             : {
     374             : public:
     375             :     // initialise your test code values here.
     376           1 :     void setUp()
     377             :     {
     378           1 :     }
     379             : 
     380           1 :     void tearDown()
     381             :     {
     382           1 :     }
     383             : 
     384           8 :     void test_encode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, sal_uInt8 _nDataValue)
     385             :         {
     386           8 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
     387           8 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     388             : 
     389           8 :             sal_uInt32     nKeyLen = 16;
     390           8 :             sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
     391           8 :             memset(pKeyBuffer, 0, nKeyLen);
     392           8 :             pKeyBuffer[0] = _nKeyValue;
     393             : 
     394           8 :             sal_uInt32     nArgLen = 16;
     395           8 :             sal_uInt8     *pArgBuffer = new sal_uInt8[ nArgLen ];
     396           8 :             memset(pArgBuffer, 0, nArgLen);
     397           8 :             pArgBuffer[0] = _nArgValue;
     398             : 
     399           8 :             rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
     400           8 :             CPPUNIT_ASSERT_MESSAGE("wrong init", aError == rtl_Cipher_E_None);
     401             : 
     402           8 :             sal_uInt32     nDataLen = 16;
     403           8 :             sal_uInt8     *pDataBuffer = new sal_uInt8[ nDataLen ];
     404           8 :             memset(pDataBuffer, 0, nDataLen);
     405           8 :             pDataBuffer[0] = _nDataValue;
     406             : 
     407           8 :             sal_uInt32     nLen = 16;
     408           8 :             sal_uInt8     *pBuffer = new sal_uInt8[ nLen ];
     409           8 :             memset(pBuffer, 0, nLen);
     410             : 
     411           8 :             /* rtlCipherError */ aError = rtl_cipher_encode(aCipher, pDataBuffer, nDataLen, pBuffer, nLen);
     412           8 :             CPPUNIT_ASSERT_MESSAGE("wrong encode", aError == rtl_Cipher_E_None);
     413             : 
     414           8 :             delete [] pBuffer;
     415           8 :             delete [] pDataBuffer;
     416             : 
     417           8 :             delete [] pArgBuffer;
     418           8 :             delete [] pKeyBuffer;
     419             : 
     420           8 :             rtl_cipher_destroy(aCipher);
     421           8 :         }
     422             : 
     423           1 :     void encode_001()
     424             :         {
     425           1 :             test_encode(0,0,0);
     426           1 :             test_encode(1,0,0);
     427           1 :             test_encode(0,1,0);
     428           1 :             test_encode(1,1,0);
     429             : 
     430           1 :             test_encode(0,0,1);
     431           1 :             test_encode(1,0,1);
     432           1 :             test_encode(0,1,1);
     433           1 :             test_encode(1,1,1);
     434           1 :         }
     435             : 
     436             :     // Change the following lines only, if you add, remove or rename
     437             :     // member functions of the current class,
     438             :     // because these macros are need by auto register mechanism.
     439             : 
     440           2 :     CPPUNIT_TEST_SUITE(encode);
     441           1 :     CPPUNIT_TEST(encode_001);
     442           2 :     CPPUNIT_TEST_SUITE_END();
     443             : }; // class encode
     444             : // -----------------------------------------------------------------------------
     445           3 : class encodeBF : public CppUnit::TestFixture
     446             : {
     447             : public:
     448             :     // initialise your test code values here.
     449           1 :     void setUp()
     450             :     {
     451           1 :     }
     452             : 
     453           1 :     void tearDown()
     454             :     {
     455           1 :     }
     456             : 
     457           1 :     void encodeBF_001()
     458             :         {
     459           1 :         }
     460             :     // Change the following lines only, if you add, remove or rename
     461             :     // member functions of the current class,
     462             :     // because these macros are need by auto register mechanism.
     463             : 
     464           2 :     CPPUNIT_TEST_SUITE(encodeBF);
     465           1 :     CPPUNIT_TEST(encodeBF_001);
     466           2 :     CPPUNIT_TEST_SUITE_END();
     467             : }; // class encodeBF
     468             : // -----------------------------------------------------------------------------
     469          12 : class init : public CppUnit::TestFixture
     470             : {
     471             : public:
     472             :     // initialise your test code values here.
     473           4 :     void setUp()
     474             :     {
     475           4 :     }
     476             : 
     477           4 :     void tearDown()
     478             :     {
     479           4 :     }
     480             : 
     481           1 :     void init_001()
     482             :         {
     483           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
     484           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     485             : 
     486           1 :             sal_uInt32     nKeyLen = 16;
     487           1 :             sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
     488           1 :             memset(pKeyBuffer, 0, nKeyLen);
     489             : 
     490           1 :             sal_uInt32     nArgLen = 16;
     491           1 :             sal_uInt8     *pArgBuffer = new sal_uInt8[ nArgLen ];
     492           1 :             memset(pArgBuffer, 0, nArgLen);
     493             : 
     494           1 :             rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
     495           1 :             CPPUNIT_ASSERT_MESSAGE("wrong init", aError == rtl_Cipher_E_None);
     496             : 
     497           1 :             delete [] pArgBuffer;
     498           1 :             delete [] pKeyBuffer;
     499             : 
     500           1 :             rtl_cipher_destroy(aCipher);
     501           1 :         }
     502             : 
     503           1 :     void init_002()
     504             :         {
     505           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
     506           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     507             : 
     508           1 :             sal_uInt32     nKeyLen = 16;
     509           1 :             sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
     510           1 :             memset(pKeyBuffer, 0, nKeyLen);
     511           1 :             pKeyBuffer[0] = 1;
     512             : 
     513           1 :             sal_uInt32     nArgLen = 16;
     514           1 :             sal_uInt8     *pArgBuffer = new sal_uInt8[ nArgLen ];
     515           1 :             memset(pArgBuffer, 0, nArgLen);
     516             : 
     517           1 :             rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
     518           1 :             CPPUNIT_ASSERT_MESSAGE("wrong init", aError == rtl_Cipher_E_None);
     519             : 
     520           1 :             delete [] pArgBuffer;
     521           1 :             delete [] pKeyBuffer;
     522             : 
     523           1 :             rtl_cipher_destroy(aCipher);
     524           1 :         }
     525           1 :     void init_003()
     526             :         {
     527           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
     528           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     529             : 
     530           1 :             sal_uInt32     nKeyLen = 16;
     531           1 :             sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
     532           1 :             memset(pKeyBuffer, 0, nKeyLen);
     533             : 
     534           1 :             sal_uInt32     nArgLen = 16;
     535           1 :             sal_uInt8     *pArgBuffer = new sal_uInt8[ nArgLen ];
     536           1 :             memset(pArgBuffer, 0, nArgLen);
     537           1 :             pArgBuffer[0] = 1;
     538             : 
     539           1 :             rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
     540           1 :             CPPUNIT_ASSERT_MESSAGE("wrong init", aError == rtl_Cipher_E_None);
     541             : 
     542           1 :             delete [] pArgBuffer;
     543           1 :             delete [] pKeyBuffer;
     544             : 
     545           1 :             rtl_cipher_destroy(aCipher);
     546           1 :         }
     547           1 :     void init_004()
     548             :         {
     549           1 :             rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
     550           1 :             CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != NULL);
     551             : 
     552           1 :             sal_uInt32     nKeyLen = 16;
     553           1 :             sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
     554           1 :             memset(pKeyBuffer, 0, nKeyLen);
     555           1 :             pKeyBuffer[0] = 1;
     556             : 
     557           1 :             sal_uInt32     nArgLen = 16;
     558           1 :             sal_uInt8     *pArgBuffer = new sal_uInt8[ nArgLen ];
     559           1 :             memset(pArgBuffer, 0, nArgLen);
     560           1 :             pArgBuffer[0] = 1;
     561             : 
     562           1 :             rtlCipherError aError = rtl_cipher_init(aCipher, rtl_Cipher_DirectionEncode, pKeyBuffer, nKeyLen, pArgBuffer, nArgLen);
     563           1 :             CPPUNIT_ASSERT_MESSAGE("wrong init", aError == rtl_Cipher_E_None);
     564             : 
     565           1 :             delete [] pArgBuffer;
     566           1 :             delete [] pKeyBuffer;
     567             : 
     568           1 :             rtl_cipher_destroy(aCipher);
     569           1 :         }
     570             :     // Change the following lines only, if you add, remove or rename
     571             :     // member functions of the current class,
     572             :     // because these macros are need by auto register mechanism.
     573             : 
     574           2 :     CPPUNIT_TEST_SUITE(init);
     575           1 :     CPPUNIT_TEST(init_001);
     576           1 :     CPPUNIT_TEST(init_002);
     577           1 :     CPPUNIT_TEST(init_003);
     578           1 :     CPPUNIT_TEST(init_004);
     579           2 :     CPPUNIT_TEST_SUITE_END();
     580             : }; // class init
     581             : // -----------------------------------------------------------------------------
     582           3 : class initBF : public CppUnit::TestFixture
     583             : {
     584             : public:
     585             :     // initialise your test code values here.
     586           1 :     void setUp()
     587             :     {
     588           1 :     }
     589             : 
     590           1 :     void tearDown()
     591             :     {
     592           1 :     }
     593             : 
     594           1 :     void initBF_001()
     595             :         {
     596             :             // seems to be the same as init, so empty
     597           1 :         }
     598             : 
     599             :     // Change the following lines only, if you add, remove or rename
     600             :     // member functions of the current class,
     601             :     // because these macros are need by auto register mechanism.
     602             : 
     603           2 :     CPPUNIT_TEST_SUITE(initBF);
     604           1 :     CPPUNIT_TEST(initBF_001);
     605           2 :     CPPUNIT_TEST_SUITE_END();
     606             : }; // class initBF
     607             : 
     608             : // -----------------------------------------------------------------------------
     609             : 
     610           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::create);
     611           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::createBF);
     612           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::decode);
     613           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::decodeBF);
     614           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::destroy);
     615           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::destroyBF);
     616           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::encode);
     617           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::encodeBF);
     618           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::init);
     619           1 : CPPUNIT_TEST_SUITE_REGISTRATION(rtl_cipher::initBF);
     620             : 
     621             : } // namespace rtl_cipher
     622             : 
     623             : 
     624             : // -----------------------------------------------------------------------------
     625             : 
     626             : // this macro creates an empty function, which will called by the RegisterAllFunctions()
     627             : // to let the user the possibility to also register some functions by hand.
     628           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     629             : 
     630             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10