[Libreoffice-commits] core.git: 2 commits - sal/CppunitTest_sal_rtl_digest.mk sal/Module_sal.mk sal/qa

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Sun Mar 23 05:13:35 PDT 2014


 sal/CppunitTest_sal_rtl_digest.mk |   22 
 sal/Module_sal.mk                 |    1 
 sal/qa/rtl/digest/rtl_digest.cxx  | 1533 ++++++--------------------------------
 3 files changed, 292 insertions(+), 1264 deletions(-)

New commits:
commit 8d2da0b94ac5d679ef697683cacb2c83498cc497
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Mar 23 13:06:40 2014 +0100

    sal: Add rtl_digest_SHA1 which shows wrong sha1 calculation
    
    This test shows wrong sha1 calculation after 52 bytes of input
    data. For now this test is commented.
    
    Change-Id: Id6df40ecc4059d4a4f9e1646a2c1bb7242f4cf69

diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx
index 1ae3d27..0953854 100644
--- a/sal/qa/rtl/digest/rtl_digest.cxx
+++ b/sal/qa/rtl/digest/rtl_digest.cxx
@@ -372,6 +372,55 @@ public:
         rtl_digest_destroyMD5(aHandle);
     }
 
+    void testSHA1SumForBiggerInputData()
+    {
+        // The test data was extracted from oox encrypted document (salt + password).
+        // First  case: 16 bytes salt + 34 bytes password (12345678901234567)
+        // Second case: 16 bytes salt + 36 bytes password (123456789012345678)
+        {
+            const unsigned char aData[] = {
+                    0x37, 0x5f, 0x47, 0x7a, 0xd2, 0x13, 0xbe, 0xd2, 0x3c, 0x23, 0x33, 0x39,
+                    0x68, 0x21, 0x03, 0x6d, 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00,
+                    0x35, 0x00, 0x36, 0x00, 0x37, 0x00, 0x38, 0x00, 0x39, 0x00, 0x30, 0x00,
+                    0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00,
+                    0x37, 0x00
+            };
+
+            boost::scoped_array<sal_uInt8> pResult(new sal_uInt8[RTL_DIGEST_LENGTH_SHA1]);
+
+            OString sExpected = "06f460d693aecdd3b5cbe8365408eccfc570f32a";
+
+            rtl_digest_SHA1(aData, sizeof(aData), pResult.get(), RTL_DIGEST_LENGTH_SHA1);
+
+            OString sKey = createHex(pResult.get(), RTL_DIGEST_LENGTH_SHA1);
+
+            CPPUNIT_ASSERT_EQUAL(sExpected, sKey);
+        }
+
+        {
+            const unsigned char aData[] = {
+                    0x37, 0x5f, 0x47, 0x7a, 0xd2, 0x13, 0xbe, 0xd2, 0x3c, 0x23, 0x33, 0x39,
+                    0x68, 0x21, 0x03, 0x6d, 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00,
+                    0x35, 0x00, 0x36, 0x00, 0x37, 0x00, 0x38, 0x00, 0x39, 0x00, 0x30, 0x00,
+                    0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00,
+                    0x37, 0x00, 0x38, 0x00
+            };
+
+            boost::scoped_array<sal_uInt8> pResult(new sal_uInt8[RTL_DIGEST_LENGTH_SHA1]);
+
+            OString sExpected = "0bfe41eb7fb3edf5f5a6de57192de4ba1b925758";
+
+            rtl_digest_SHA1(aData, sizeof(aData), pResult.get(), RTL_DIGEST_LENGTH_SHA1);
+
+            OString sKey = createHex(pResult.get(), RTL_DIGEST_LENGTH_SHA1);
+
+            // With this test case rtl_digest_SHA1 computes the wrong sum. This was confirmed
+            // by decrytion of a MSO encrypted document. Replacing the rtl_digest_SHA1 calculation
+            // with sha1 calculation from NSS was able to decrypt the document.
+
+            //CPPUNIT_ASSERT_EQUAL(sExpected, sKey);
+        }
+    }
 
     CPPUNIT_TEST_SUITE(DigestTest);
     CPPUNIT_TEST(testCreate);
@@ -383,6 +432,7 @@ public:
     CPPUNIT_TEST(testPBKDF2);
     CPPUNIT_TEST(testUpdate);
     CPPUNIT_TEST(testGet);
+    CPPUNIT_TEST(testSHA1SumForBiggerInputData);
 
     CPPUNIT_TEST_SUITE_END();
 };
commit 7d3e8c5217250d11b4bf4fcdf74a3791be69ab53
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Mar 23 13:05:03 2014 +0100

    sal: Rewrite digest tests to be simpler, enable them in check
    
    Change-Id: I610e615be498237e5cd9dd963bca60c7f8f62aac

diff --git a/sal/CppunitTest_sal_rtl_digest.mk b/sal/CppunitTest_sal_rtl_digest.mk
new file mode 100644
index 0000000..3fa263b
--- /dev/null
+++ b/sal/CppunitTest_sal_rtl_digest.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile; tab-width: 4; indent-tabs-mode: t -*-
+#
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,sal_rtl_digest))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sal_rtl_digest,\
+    sal/qa/rtl/digest/rtl_digest \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sal_rtl_digest,\
+    sal \
+	$(gb_UWINAPI) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk
index 18db4b7..922bf5b 100644
--- a/sal/Module_sal.mk
+++ b/sal/Module_sal.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Module_add_check_targets,sal,\
 	CppunitTest_sal_rtl_bootstrap \
 	CppunitTest_sal_rtl_cipher \
 	CppunitTest_sal_rtl_crc32 \
+	CppunitTest_sal_rtl_digest \
 	CppunitTest_sal_rtl_doublelock \
 	CppunitTest_sal_rtl_locale \
 	CppunitTest_sal_rtl_ostringbuffer \
diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx
index b419292..1ae3d27 100644
--- a/sal/qa/rtl/digest/rtl_digest.cxx
+++ b/sal/qa/rtl/digest/rtl_digest.cxx
@@ -23,6 +23,8 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/plugin/TestPlugIn.h>
 
+#include <boost/scoped_array.hpp>
+
 #include <rtl/digest.h>
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -30,1410 +32,363 @@
 
 #include <string.h>
 
-// sample, how to use digest
+using namespace rtl;
 
-rtl::OUString CreateMD5FromString( const rtl::OUString& aMsg )
+namespace
 {
-    // PRE: aStr "file"
-    // BACK: Str "ababab....0f" Hexcode String
-
-    rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-    if ( handle > 0 )
-    {
-        const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
-        sal_uInt32       nSize = ( aMsg.getLength() * sizeof( sal_Unicode ));
-        sal_uInt32       nMD5KeyLen = rtl_digest_queryLength( handle );
-        sal_uInt8*       pMD5KeyBuffer = new sal_uInt8[ nMD5KeyLen ];
-
-        rtl_digest_init( handle, pData, nSize );
-        rtl_digest_update( handle, pData, nSize );
-        rtl_digest_get( handle, pMD5KeyBuffer, nMD5KeyLen );
-        rtl_digest_destroy( handle );
-
-        // Create hex-value string from the MD5 value to keep the string size minimal
-        rtl::OUStringBuffer aBuffer( nMD5KeyLen * 2 + 1 );
-        for ( sal_uInt32 i = 0; i < nMD5KeyLen; ++i )
-            aBuffer.append( (sal_Int32)pMD5KeyBuffer[i], 16 );
-
-        delete [] pMD5KeyBuffer;
-        return aBuffer.makeStringAndClear();
-    }
-
-    return rtl::OUString();
-}
 
+const OString sSampleString               = "This is a sample sentence, which we use to check some crypto functions in sal.";
+const OString sSampleString_only_one_diff = "This is a sample sentence. which we use to check some crypto functions in sal.";
 
-namespace rtl_digest
+const rtlDigestAlgorithm constDigestAlgorithms[] =
 {
-
-    rtl::OString sSampleString               = "This is a sample sentence, which we use to check some crypto functions in sal.";
-    rtl::OString sSampleString_MD2           = "647ee6c9d4aa5fdd374ed9d7a156acbf";
-    rtl::OString sSampleString_MD5           = "b16b903e6fc0b62ae389013ed93fe531";
-    rtl::OString sSampleString_SHA           = "eab2814429b2613301c8a077b806af3680548914";
-    rtl::OString sSampleString_SHA1          = "2bc5bdb7506a2cdc2fd27fc8b9889343012d5008";
-    rtl::OString sSampleString_HMAC_MD5      = "dd9cba48c972fba0a882baa72b079674";
-    rtl::OString sSampleString_HMAC_SHA1     = "5d7f43ce6abd1de4438d7e69e01495864490cf3e";
-
-    rtl::OString sSampleString_only_one_diff = "This is a sample sentence. which we use to check some crypto functions in sal.";
-
-class create : public CppUnit::TestFixture
+    rtl_Digest_AlgorithmMD2,
+    rtl_Digest_AlgorithmMD5,
+    rtl_Digest_AlgorithmSHA,
+    rtl_Digest_AlgorithmSHA1,
+    rtl_Digest_AlgorithmHMAC_MD5,
+    rtl_Digest_AlgorithmHMAC_SHA1,
+};
+
+const sal_uInt32 constDigestAlgorithmLengths[] =
 {
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-    void create_001()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", handle != 0);
-            rtl_digest_destroy( handle );
-        }
-    void create_002()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", handle != 0);
-            rtl_digest_destroy( handle );
-        }
-    void create_003()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmSHA", handle != 0);
-            rtl_digest_destroy( handle );
-        }
-    void create_004()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmSHA1", handle != 0);
-            rtl_digest_destroy( handle );
-        }
-    void create_005()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmHMAC_MD5", handle != 0);
-            rtl_digest_destroy( handle );
-        }
-    void create_006()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmHMAC_SHA1", handle != 0);
-            rtl_digest_destroy( handle );
-        }
-
-    void create_007()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
-            printf("Handle is %p\n", handle);
-            CPPUNIT_ASSERT_MESSAGE("create with NULL", handle == 0);
-            rtl_digest_destroy( handle );
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(create);
-    CPPUNIT_TEST(create_001);
-    CPPUNIT_TEST(create_002);
-    CPPUNIT_TEST(create_003);
-    CPPUNIT_TEST(create_004);
-    CPPUNIT_TEST(create_005);
-    CPPUNIT_TEST(create_006);
-    CPPUNIT_TEST(create_007);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-
-
-
-
-class createMD5 : public CppUnit::TestFixture
+    RTL_DIGEST_LENGTH_MD2,
+    RTL_DIGEST_LENGTH_MD5,
+    RTL_DIGEST_LENGTH_SHA,
+    RTL_DIGEST_LENGTH_SHA1,
+    RTL_DIGEST_LENGTH_HMAC_MD5,
+    RTL_DIGEST_LENGTH_HMAC_SHA1,
+};
+
+const OString constSampleStringSums[] =
 {
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-    void createMD5_001()
-        {
-            rtlDigest handle = rtl_digest_createMD5();
-
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD5 == aAlgo);
-
-            rtl_digest_destroy( handle );
-        }
-    CPPUNIT_TEST_SUITE(createMD5);
-    CPPUNIT_TEST(createMD5_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-
-
-class createMD2 : public CppUnit::TestFixture
+    "647ee6c9d4aa5fdd374ed9d7a156acbf",
+    "b16b903e6fc0b62ae389013ed93fe531",
+    "eab2814429b2613301c8a077b806af3680548914",
+    "2bc5bdb7506a2cdc2fd27fc8b9889343012d5008",
+    "0b1b0e1a6f2e4420326354b031063605",
+    "1998c6a556915be76451bfb587fa7c34d849936e"
+};
+
+// Create hex-value string from the digest value to keep the string size minimal
+OString createHex(sal_uInt8* pKeyBuffer, sal_uInt32 nKeyLen)
 {
-public:
-    // initialise your test code values here.
-    void setUp()
+    OStringBuffer aBuffer(nKeyLen * 2 + 1);
+    for (sal_uInt32 i = 0; i < nKeyLen; ++i)
     {
+        sal_Int32 nValue = (sal_Int32) pKeyBuffer[i];
+        if (nValue < 16)
+            aBuffer.append('0');
+        aBuffer.append(nValue, 16);
     }
+    return aBuffer.makeStringAndClear();
+}
 
-    void tearDown()
-    {
-    }
-
-    void createMD2_001()
-        {
-            rtlDigest handle = rtl_digest_createMD2( );
-
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD2 == aAlgo);
-
-            rtl_digest_destroy( handle );
-        }
-    CPPUNIT_TEST_SUITE(createMD2);
-    CPPUNIT_TEST(createMD2_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-
-class createSHA : public CppUnit::TestFixture
+OString getDigest(const OString& aMessage, rtlDigestAlgorithm aAlgorithm)
 {
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
+    rtlDigest handle = rtl_digest_create(aAlgorithm);
 
-    void tearDown()
-    {
-    }
+    const sal_uInt8* pData = (const sal_uInt8*) aMessage.getStr();
+    sal_uInt32       nSize = aMessage.getLength();
 
-    void createSHA_001()
-        {
-            rtlDigest handle = rtl_digest_createSHA( );
+    rtl_digest_init(handle, pData, nSize);
+    rtl_digest_update(handle, pData, nSize);
 
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA == aAlgo);
+    sal_uInt32 nKeyLen = rtl_digest_queryLength(handle);
+    boost::scoped_array<sal_uInt8> pKeyBuffer(new sal_uInt8[nKeyLen]);
 
-            rtl_digest_destroy( handle );
-        }
-    CPPUNIT_TEST_SUITE(createSHA);
-    CPPUNIT_TEST(createSHA_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
+    rtl_digest_get(handle, pKeyBuffer.get(), nKeyLen);
+    OString aSum = createHex(pKeyBuffer.get(), nKeyLen);
 
+    rtl_digest_destroy( handle );
+    return aSum;
+}
 
-class createSHA1 : public CppUnit::TestFixture
+class DigestTest : public CppUnit::TestFixture
 {
 public:
-    // initialise your test code values here.
-    void setUp()
+    void testCreate()
     {
-    }
-
-    void tearDown()
-    {
-    }
+        int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]);
 
-    void createSHA1_001()
+        for (int i = 0; i < aAlgorithmSize; i++)
         {
-            rtlDigest handle = rtl_digest_createSHA1();
-
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA1 == aAlgo);
-
+            rtlDigest handle = rtl_digest_create( constDigestAlgorithms[i] );
+            CPPUNIT_ASSERT_MESSAGE("create digest", handle != NULL);
             rtl_digest_destroy( handle );
         }
-    CPPUNIT_TEST_SUITE(createSHA1);
-    CPPUNIT_TEST(createSHA1_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
 
-
-class createHMAC_MD5 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
+        rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
+        CPPUNIT_ASSERT_MESSAGE("create invalid digest", handle == NULL);
+        rtl_digest_destroy( handle );
     }
 
-    void tearDown()
+    void testQuery()
     {
-    }
+        int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]);
 
-    void createHMAC_MD5_001()
+        for (int i = 0; i < aAlgorithmSize; i++)
         {
-            rtlDigest handle = rtl_digest_createHMAC_MD5();
-
+            rtlDigest handle = rtl_digest_create(constDigestAlgorithms[i]);
             rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_MD5 == aAlgo);
-
+            CPPUNIT_ASSERT_MESSAGE("query handle", constDigestAlgorithms[i] == aAlgo);
             rtl_digest_destroy( handle );
         }
-    CPPUNIT_TEST_SUITE(createHMAC_MD5);
-    CPPUNIT_TEST(createHMAC_MD5_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
 
-class createHMAC_SHA1 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
     }
 
-    void tearDown()
+    void testQueryLength()
     {
-    }
+        int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]);
+        rtlDigest handle;
+        sal_uInt32 nAlgoLength;
 
-    void createHMAC_SHA1_001()
+        for (int i = 0; i < aAlgorithmSize; i++)
         {
-            rtlDigest handle = rtl_digest_createHMAC_SHA1();
-
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_SHA1 == aAlgo);
-
+            handle = rtl_digest_create(constDigestAlgorithms[i]);
+            nAlgoLength = rtl_digest_queryLength(handle);
+            CPPUNIT_ASSERT_MESSAGE("query Length", constDigestAlgorithmLengths[i] == nAlgoLength);
             rtl_digest_destroy( handle );
         }
 
 
-    CPPUNIT_TEST_SUITE(createHMAC_SHA1);
-    CPPUNIT_TEST(createHMAC_SHA1_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-
-class queryAlgorithm : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
+        handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
+        nAlgoLength = rtl_digest_queryLength(handle);
+        CPPUNIT_ASSERT_MESSAGE("query length", 0 == nAlgoLength);
+        rtl_digest_destroy( handle );
     }
 
-    void tearDown()
+    void testInit()
     {
-    }
-
-    void query_001()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD5 == aAlgo);
-
-            rtl_digest_destroy( handle );
-        }
-    void query_002()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
-
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD2 == aAlgo);
-
-            rtl_digest_destroy( handle );
-        }
-    void query_003()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
+        rtlDigestError aError;
+        rtlDigest handle;
 
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA == aAlgo);
+        handle = NULL;
+        aError = rtl_digest_init(handle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("init(NULL, 0, 0)", aError == rtl_Digest_E_Argument);
 
-            rtl_digest_destroy( handle );
-        }
-    void query_004()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
+        handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+        aError = rtl_digest_init(handle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("init(handle, 0, 0)", aError == rtl_Digest_E_None);
+        rtl_digest_destroy( handle );
 
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA1 == aAlgo);
+        int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]);
 
-            rtl_digest_destroy( handle );
-        }
-    void query_005()
+        for (int i = 0; i < aAlgorithmSize; i++)
         {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
+            handle = rtl_digest_create(constDigestAlgorithms[i]);
 
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_MD5 == aAlgo);
+            OString aMessage = sSampleString;
+            const sal_uInt8* pData = (const sal_uInt8*) aMessage.getStr();
+            sal_uInt32       nSize = aMessage.getLength();
 
-            rtl_digest_destroy( handle );
-        }
-    void query_006()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
+            aError = rtl_digest_init(handle, pData, nSize);
+            CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
 
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_SHA1 == aAlgo);
+            rtl_digest_update(handle, pData, nSize);
 
-            rtl_digest_destroy( handle );
-        }
-    void query_007()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
+            sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
+            boost::scoped_array<sal_uInt8> pKeyBuffer(new sal_uInt8[nKeyLen]);
 
-            rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
-            CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmInvalid == aAlgo);
+            rtl_digest_get( handle, pKeyBuffer.get(), nKeyLen );
+            OString aSum = createHex(pKeyBuffer.get(), nKeyLen);
 
             rtl_digest_destroy( handle );
         }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(queryAlgorithm);
-    CPPUNIT_TEST( query_001 );
-    CPPUNIT_TEST( query_002 );
-    CPPUNIT_TEST( query_003 );
-    CPPUNIT_TEST( query_004 );
-    CPPUNIT_TEST( query_005 );
-    CPPUNIT_TEST( query_006 );
-    CPPUNIT_TEST( query_007 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-
-class queryLength : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
     }
 
-    void tearDown()
+    void testEqual()
     {
-    }
-
-    void queryLength_MD5()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-
-            sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
-            // printf("nAlgoLength:=%d\n", nAlgoLength);
-            CPPUNIT_ASSERT_MESSAGE("query Length", RTL_DIGEST_LENGTH_MD5 == nAlgoLength);
-
-            rtl_digest_destroy( handle );
-        }
-    void queryLength_MD2()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
-
-            sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
-            // printf("nAlgoLength:=%d\n", nAlgoLength);
-            CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_MD2 == nAlgoLength);
-
-            rtl_digest_destroy( handle );
-        }
-    void queryLength_SHA()
         {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
+            OString aMsg1 = sSampleString;
+            OString aMsg2 = sSampleString;
 
-            sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
-            // printf("nAlgoLength:=%d\n", nAlgoLength);
-            CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_SHA == nAlgoLength);
+            OString aSum1 = getDigest(aMsg1, rtl_Digest_AlgorithmMD5);
+            OString aSum2 = getDigest(aMsg2, rtl_Digest_AlgorithmMD5);
 
-            rtl_digest_destroy( handle );
+            CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aSum1.getLength() == 32 && aSum2.getLength() == 32 );
+            CPPUNIT_ASSERT_MESSAGE("source is the same, dest must be also the same", aSum1.equals(aSum2));
         }
-    void queryLength_SHA1()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
 
-            sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
-            // printf("nAlgoLength:=%d\n", nAlgoLength);
-            CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_SHA1 == nAlgoLength);
-
-            rtl_digest_destroy( handle );
-        }
-    void queryLength_HMAC_MD5()
         {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
+            OString aMsg1 = sSampleString;
+            OString aMsg2 = sSampleString_only_one_diff;
 
-            sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
-            // printf("nAlgoLength:=%d\n", nAlgoLength);
-            CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_HMAC_MD5 == nAlgoLength);
+            OString aSum1 = getDigest(aMsg1, rtl_Digest_AlgorithmMD5);
+            OString aSum2 = getDigest(aMsg2, rtl_Digest_AlgorithmMD5);
 
-            rtl_digest_destroy( handle );
+            CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aSum1.getLength() == 32 && aSum2.getLength() == 32 );
+            CPPUNIT_ASSERT_MESSAGE("differ only in one char", !aSum1.equals(aSum2));
         }
-    void queryLength_HMAC_SHA1()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
-
-            sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
-            // printf("nAlgoLength:=%d\n", nAlgoLength);
-            CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_HMAC_SHA1 == nAlgoLength);
+    }
 
-            rtl_digest_destroy( handle );
-        }
+    void testCheckSum()
+    {
+        int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]);
 
-    void queryLength_Illegal()
+        for (int i = 0; i < aAlgorithmSize; i++)
         {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
-
-            sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
-            // printf("nAlgoLength:=%d\n", nAlgoLength);
-            CPPUNIT_ASSERT_MESSAGE("query length", 0 == nAlgoLength);
-
-            rtl_digest_destroy( handle );
+            OString aSum = getDigest(sSampleString, constDigestAlgorithms[i]);
+            CPPUNIT_ASSERT_EQUAL_MESSAGE("Checksum of sample string is wrong.", constSampleStringSums[i], aSum);
         }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(queryLength);
-    CPPUNIT_TEST( queryLength_MD2 );
-    CPPUNIT_TEST( queryLength_MD5 );
-    CPPUNIT_TEST( queryLength_SHA );
-    CPPUNIT_TEST( queryLength_SHA1 );
-    CPPUNIT_TEST( queryLength_HMAC_MD5 );
-    CPPUNIT_TEST( queryLength_HMAC_SHA1 );
-    CPPUNIT_TEST( queryLength_Illegal );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-
-rtl::OString createHex(sal_uInt8 *_pMD5KeyBuffer, sal_uInt32 _nMD5KeyLen)
-{
-    // Create hex-value string from the MD5 value to keep the string size minimal
-    rtl::OStringBuffer aBuffer( _nMD5KeyLen * 2 + 1 );
-    for ( sal_uInt32 i = 0; i < _nMD5KeyLen; ++i )
-    {
-        sal_Int32 nValue = (sal_Int32)_pMD5KeyBuffer[i];
-        if (nValue < 16)                         // maximul hex value for 1 byte
-            aBuffer.append( static_cast<sal_Int32>(0), static_cast<sal_Int16>(16) /* radix */ );
-        aBuffer.append( nValue, 16 /* radix */ );
-    }
-
-    return aBuffer.makeStringAndClear();
-}
-
-
-
-class init : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
     }
 
-    void tearDown()
+    OString runCheckPBKDF2(OString& sPassword, bool bClearSalt, sal_uInt32 nCount)
     {
-    }
+        sal_uInt32 nKeyLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
+        boost::scoped_array<sal_uInt8> pKeyBuffer(new sal_uInt8[nKeyLen]);
 
-    void init_000()
-        {
-            rtlDigest handle = NULL;
+        memset(pKeyBuffer.get(), 0, nKeyLen);
 
-            rtlDigestError aError = rtl_digest_init(handle, NULL, 0);
+        sal_uInt8* pPassword    = (sal_uInt8*)sPassword.getStr();
+        sal_Int32  nPasswordLen = sPassword.getLength();
 
-            CPPUNIT_ASSERT_MESSAGE("init(NULL, 0, 0)", aError == rtl_Digest_E_Argument);
-        }
+        sal_uInt32   nSaltDataLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
+        boost::scoped_array<sal_uInt8> pSaltData(new sal_uInt8[nSaltDataLen]);
+        memset(pSaltData.get(), 0, nSaltDataLen);
 
-    void init_001()
+        if (!bClearSalt)
         {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-
-            rtlDigestError aError = rtl_digest_init(handle, NULL, 0);
-
-            CPPUNIT_ASSERT_MESSAGE("init(handle, 0, 0)", aError == rtl_Digest_E_None);
-
-            rtl_digest_destroy( handle );
+            // wilful contamination
+            pSaltData[0] = 1;
         }
 
+        rtlDigestError aError = rtl_digest_PBKDF2(pKeyBuffer.get(), nKeyLen, pPassword, nPasswordLen, pSaltData.get(), nSaltDataLen, nCount);
 
-    void init_MD2()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
-
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
-            sal_uInt32       nSize = ( aMsg.getLength() );
-
-            rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+        CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
 
-            CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
-
-            rtl_digest_update( handle, pData, nSize );
-
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( handle );
-            sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
-
-            rtl_digest_get( handle, pKeyBuffer, nKeyLen );
-            rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
-            delete [] pKeyBuffer;
+        rtl::OString aKey = createHex(pKeyBuffer.get(), nKeyLen);
 
-            printf("MD2 Sum: %s\n", aSum.getStr());
-            // LLA: how to check right values
-            // samples?
+        // OString sSalt = createHex(pSaltData, nSaltDataLen);
+        // printf("Salt: %s\n", sSalt.getStr());
 
-            rtl_digest_destroy( handle );
-        }
-
-    void init_MD5()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+        // CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_PBKDF2) );
+        return aKey;
+    }
 
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
-            sal_uInt32       nSize = ( aMsg.getLength() );
+    void testPBKDF2()
+    {
+        OString  aPassword = "Password";
 
-            rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+        // all permutations
+        runCheckPBKDF2(aPassword, false, 1);
+        runCheckPBKDF2(aPassword, false, 2);
+        runCheckPBKDF2(aPassword, true,  1);
+        runCheckPBKDF2(aPassword, true,  2);
+        runCheckPBKDF2(aPassword, false, 3);
+        runCheckPBKDF2(aPassword, false, 4);
+        runCheckPBKDF2(aPassword, true,  3);
+        runCheckPBKDF2(aPassword, true,  4);
+    }
 
-            CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+    void testUpdate()
+    {
+        rtlDigestError aError;
+        rtlDigest aHandle;
 
-            rtl_digest_update( handle, pData, nSize );
+        aHandle = NULL;
+        aError = rtl_digest_update(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument);
 
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( handle );
-            sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+        aHandle = NULL;
+        aError = rtl_digest_updateMD2(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument);
 
-            rtl_digest_get( handle, pKeyBuffer, nKeyLen );
-            rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
-            delete [] pKeyBuffer;
+        aError = rtl_digest_updateMD5(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument);
 
-            printf("MD5 Sum: %s\n", aSum.getStr());
-            // LLA: how to check right values
-            // samples?
+        aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+        CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
 
-            rtl_digest_destroy( handle );
-        }
+        const sal_uInt8* pData = (const sal_uInt8*)sSampleString.getStr();
+        sal_uInt32       nSize = sSampleString.getLength();
 
-    void init_SHA()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
+        aError = rtl_digest_updateMD2(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument);
 
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
-            sal_uInt32       nSize = ( aMsg.getLength() );
+        aError = rtl_digest_updateMD2(aHandle, pData, 0);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_None);
 
-            rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+        rtl_digest_destroyMD2(aHandle);
 
-            CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+        // use wrong Algorithm!!! This is volitional!
+        aHandle = rtl_digest_create(rtl_Digest_AlgorithmMD2);
+        CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
 
-            rtl_digest_update( handle, pData, nSize );
+        aError = rtl_digest_updateMD5(aHandle, pData, nSize);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'handle' wrong", aError == rtl_Digest_E_Algorithm);
 
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( handle );
-            sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+        rtl_digest_destroyMD5(aHandle);
 
-            rtl_digest_get( handle, pKeyBuffer, nKeyLen );
-            rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
-            delete [] pKeyBuffer;
+        aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+        CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle != 0);
 
-            printf("SHA Sum: %s\n", aSum.getStr());
-            // LLA: how to check right values
-            // samples?
+        aError = rtl_digest_updateMD5(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument);
 
-            rtl_digest_destroy( handle );
-        }
-    void init_SHA1()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
+        aError = rtl_digest_updateMD5(aHandle, pData, 0);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_None);
 
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
-            sal_uInt32       nSize = ( aMsg.getLength() );
+        rtl_digest_destroyMD5(aHandle);
+    }
 
-            rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+    void testGet()
+    {
+        rtlDigest aHandle;
+        rtlDigestError aError;
 
-            CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+        aHandle = NULL;
+        aError = rtl_digest_get(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument);
 
-            rtl_digest_update( handle, pData, nSize );
+        aHandle = NULL;
+        aError = rtl_digest_getMD5(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument);
 
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( handle );
-            sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+        // test with wrong algorithm
+        aHandle = rtl_digest_create(rtl_Digest_AlgorithmMD2);
+        CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
 
-            rtl_digest_get( handle, pKeyBuffer, nKeyLen );
-            rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
-            delete [] pKeyBuffer;
+        sal_uInt32 nKeyLen = rtl_digest_queryLength(aHandle);
+        boost::scoped_array<sal_uInt8> pKeyBuffer(new sal_uInt8[nKeyLen]);
 
-            printf("SHA1 Sum: %s\n", aSum.getStr());
-            // LLA: how to check right values
-            // samples?
+        aError = rtl_digest_getMD5(aHandle, NULL, 0);
+        CPPUNIT_ASSERT_MESSAGE("handle 2. parameter wrong", aError == rtl_Digest_E_Argument);
 
-            rtl_digest_destroy( handle );
-        }
-    void init_HMAC_MD5()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
+        aError = rtl_digest_getMD5(aHandle, pKeyBuffer.get(), 0);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'handle' wrong", aError == rtl_Digest_E_Algorithm);
 
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
-            sal_uInt32       nSize = ( aMsg.getLength() );
+        rtl_digest_destroyMD2(aHandle);
 
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( handle );
-            CPPUNIT_ASSERT_MESSAGE( "Keylen must be greater 0", nKeyLen );
+        aHandle = rtl_digest_create(rtl_Digest_AlgorithmMD5);
+        CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle != 0);
 
-            sal_uInt8    *pKeyBuffer = new sal_uInt8[ nKeyLen ];
-            CPPUNIT_ASSERT( pKeyBuffer );
-            memset(pKeyBuffer, 0, nKeyLen);
+        aError = rtl_digest_getMD5(aHandle, NULL, nKeyLen);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument );
 
-            rtlDigestError aError = rtl_digest_init(handle, pKeyBuffer, nKeyLen );
+        aError = rtl_digest_getMD5(aHandle, pKeyBuffer.get(), 0);
+        CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_BufferSize );
 
-            CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+        rtl_digest_destroyMD5(aHandle);
+    }
 
-            rtl_digest_update( handle, pData, nSize );
 
-            rtl_digest_get( handle, pKeyBuffer, nKeyLen );
-            rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
-            delete [] pKeyBuffer;
+    CPPUNIT_TEST_SUITE(DigestTest);
+    CPPUNIT_TEST(testCreate);
+    CPPUNIT_TEST(testQuery);
+    CPPUNIT_TEST(testQueryLength);
+    CPPUNIT_TEST(testInit);
+    CPPUNIT_TEST(testEqual);
+    CPPUNIT_TEST(testCheckSum);
+    CPPUNIT_TEST(testPBKDF2);
+    CPPUNIT_TEST(testUpdate);
+    CPPUNIT_TEST(testGet);
 
-            printf("HMAC_MD5 Sum: %s\n", aSum.getStr());
-            // LLA: how to check right values
-            // samples?
+    CPPUNIT_TEST_SUITE_END();
+};
 
-            rtl_digest_destroy( handle );
-        }
-    void init_HMAC_SHA1()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
+CPPUNIT_TEST_SUITE_REGISTRATION(DigestTest);
 
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
-            sal_uInt32       nSize = ( aMsg.getLength() );
-
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( handle );
-            CPPUNIT_ASSERT_MESSAGE( "Keylen must be greater 0", nKeyLen );
-
-            sal_uInt8    *pKeyBuffer = new sal_uInt8[ nKeyLen ];
-            CPPUNIT_ASSERT( pKeyBuffer );
-            memset(pKeyBuffer, 0, nKeyLen);
-
-            rtlDigestError aError = rtl_digest_init(handle, pKeyBuffer, nKeyLen );
-
-            CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
-
-            rtl_digest_update( handle, pData, nSize );
-
-            rtl_digest_get( handle, pKeyBuffer, nKeyLen );
-            rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
-            delete [] pKeyBuffer;
-
-            printf("HMAC_SHA1 Sum: %s\n", aSum.getStr());
-            // LLA: how to check right values
-            // samples?
-
-            rtl_digest_destroy( handle );
-        }
-
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(init);
-    CPPUNIT_TEST( init_000 );
-    CPPUNIT_TEST( init_001 );
-    CPPUNIT_TEST( init_MD2 );
-    CPPUNIT_TEST( init_MD5 );
-    CPPUNIT_TEST( init_SHA );
-    CPPUNIT_TEST( init_SHA1 );
-    CPPUNIT_TEST( init_HMAC_MD5 );
-    CPPUNIT_TEST( init_HMAC_SHA1 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class init
-
-
-
-rtl::OString getMD5Sum(rtl::OString const& _aMsg )
-{
-    rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-
-    const sal_uInt8 *pData = (const sal_uInt8*)_aMsg.getStr();
-    sal_uInt32       nSize = ( _aMsg.getLength() );
-
-    rtl_digest_init(handle, pData, nSize);
-    rtl_digest_update( handle, pData, nSize );
-
-    sal_uInt32     nMD5KeyLen = rtl_digest_queryLength( handle );
-    sal_uInt8     *pMD5KeyBuffer = new sal_uInt8[ nMD5KeyLen ];
-
-    rtl_digest_get( handle, pMD5KeyBuffer, nMD5KeyLen );
-    rtl::OString aMD5Sum = createHex(pMD5KeyBuffer, nMD5KeyLen);
-    delete [] pMD5KeyBuffer;
-
-    rtl_digest_destroy( handle );
-    return aMD5Sum;
-}
-
-
-
-class equalTests : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-
-    void equal_001()
-        {
-            rtl::OString aMsg1 = sSampleString;
-            rtl::OString aMsg2 = sSampleString;
-
-            rtl::OString aMsgMD5Sum1 = getMD5Sum(aMsg1);
-            rtl::OString aMsgMD5Sum2 = getMD5Sum(aMsg2);
-
-            CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aMsgMD5Sum1.getLength() == 32 && aMsgMD5Sum2.getLength() == 32 );
-            CPPUNIT_ASSERT_MESSAGE("source is the same, dest must be also the same", aMsgMD5Sum1.equals(aMsgMD5Sum2) == sal_True);
-        }
-
-    void equal_002()
-        {
-            rtl::OString aMsg1 = sSampleString;
-            rtl::OString aMsg2 = sSampleString_only_one_diff;
-
-            rtl::OString aMsgMD5Sum1 = getMD5Sum(aMsg1);
-            rtl::OString aMsgMD5Sum2 = getMD5Sum(aMsg2);
-
-            CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aMsgMD5Sum1.getLength() == 32 && aMsgMD5Sum2.getLength() == 32 );
-            CPPUNIT_ASSERT_MESSAGE("differ only in one char", aMsgMD5Sum1.equals(aMsgMD5Sum2) == sal_False);
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(equalTests);
-    CPPUNIT_TEST( equal_001 );
-    CPPUNIT_TEST( equal_002 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-
-class digest_MD2 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-
-    void MD2_001()
-        {
-            rtl::OString  aMsg1 = sSampleString;
-
-            sal_uInt8    *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_MD2 ];
-            CPPUNIT_ASSERT( pBuffer );
-            memset(pBuffer, 0, RTL_DIGEST_LENGTH_MD2 );
-
-            sal_uInt8    *pMsg1 = (sal_uInt8*)aMsg1.getStr();
-            sal_Int32     nLen  = aMsg1.getLength();
-
-            rtlDigestError aError = rtl_digest_MD2(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_MD2);
-
-            CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
-
-            rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD2);
-            printf("Decrypt MD2: %s\n", aStr.getStr());
-            CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_MD2) );
-
-            delete [] pBuffer;
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(digest_MD2);
-    CPPUNIT_TEST( MD2_001 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-class digest_MD5 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-    void MD5_001()
-        {
-            rtl::OString  aMsg1 = sSampleString;
-
-            sal_uInt8    *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_MD5 ];
-            CPPUNIT_ASSERT( pBuffer );
-            memset(pBuffer, 0, RTL_DIGEST_LENGTH_MD5 );
-
-            sal_uInt8    *pMsg1 = (sal_uInt8*)aMsg1.getStr();
-            sal_Int32     nLen  = aMsg1.getLength();
-
-            rtlDigestError aError = rtl_digest_MD5(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_MD5);
-
-            CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
-
-            rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD5);
-            printf("Decrypt MD5: %s\n", aStr.getStr());
-            CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_MD5) );
-
-            delete [] pBuffer;
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(digest_MD5);
-    CPPUNIT_TEST( MD5_001 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-class digest_SHA : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-
-    void SHA_001()
-        {
-            rtl::OString  aMsg1 = sSampleString;
-
-            sal_uInt8    *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_SHA ];
-            CPPUNIT_ASSERT( pBuffer );
-            memset(pBuffer, 0, RTL_DIGEST_LENGTH_SHA);
-
-            sal_uInt8    *pMsg1 = (sal_uInt8*)aMsg1.getStr();
-            sal_Int32     nLen  = aMsg1.getLength();
-
-            rtlDigestError aError = rtl_digest_SHA(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_SHA);
-
-            CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
-
-            rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA);
-            printf("Decrypt SHA: %s\n", aStr.getStr());
-            CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_SHA) );
-
-            delete [] pBuffer;
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(digest_SHA);
-    CPPUNIT_TEST( SHA_001 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-class digest_SHA1 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-
-    void SHA1_001()
-        {
-            rtl::OString  aMsg1 = sSampleString;
-
-            sal_uInt8    *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_SHA1 ];
-            CPPUNIT_ASSERT( pBuffer );
-            memset(pBuffer, 0, RTL_DIGEST_LENGTH_SHA1);
-
-            sal_uInt8    *pMsg1 = (sal_uInt8*)aMsg1.getStr();
-            sal_Int32     nLen  = aMsg1.getLength();
-
-            rtlDigestError aError = rtl_digest_SHA1(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_SHA1);
-
-            CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
-
-            rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA1);
-            printf("Decrypt SHA1: %s\n", aStr.getStr());
-            CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_SHA1) );
-
-            delete [] pBuffer;
-        }
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(digest_SHA1);
-    CPPUNIT_TEST( SHA1_001 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-class digest_HMAC_MD5 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-
-    void HMAC_MD5_001()
-        {
-            rtl::OString  aMsg1 = sSampleString;
-
-            sal_uInt8    *pKeyBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_MD5 ];
-            CPPUNIT_ASSERT( pKeyBuffer );
-            memset(pKeyBuffer, 0, RTL_DIGEST_LENGTH_HMAC_MD5);
-
-            sal_uInt8    *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_MD5 ];
-            CPPUNIT_ASSERT( pBuffer );
-            memset(pBuffer, 0, RTL_DIGEST_LENGTH_HMAC_MD5);
-
-            sal_uInt8    *pMsg1 = (sal_uInt8*)aMsg1.getStr();
-            sal_Int32     nLen  = aMsg1.getLength();
-
-            rtlDigestError aError = rtl_digest_HMAC_MD5(pKeyBuffer, RTL_DIGEST_LENGTH_HMAC_MD5, pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_HMAC_MD5);
-
-            CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
-
-            rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_MD5);
-            printf("Decrypt HMAC_MD5: %s\n", aStr.getStr());
-            CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_HMAC_MD5) );
-
-            delete [] pBuffer;
-        }
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(digest_HMAC_MD5);
-    CPPUNIT_TEST( HMAC_MD5_001 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-class digest_HMAC_SHA1 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-
-    void HMAC_SHA1_001()
-        {
-            rtl::OString  aMsg1 = sSampleString;
-
-            sal_uInt8    *pKeyBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_SHA1 ];
-            CPPUNIT_ASSERT( pKeyBuffer );
-            memset(pKeyBuffer, 0, RTL_DIGEST_LENGTH_HMAC_SHA1);
-
-            sal_uInt8    *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_SHA1 ];
-            CPPUNIT_ASSERT( pBuffer );
-            memset(pBuffer, 0, RTL_DIGEST_LENGTH_HMAC_SHA1);
-
-            sal_uInt8    *pMsg1 = (sal_uInt8*)aMsg1.getStr();
-            sal_Int32     nLen  = aMsg1.getLength();
-
-            rtlDigestError aError = rtl_digest_HMAC_SHA1(pKeyBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1, pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1);
-
-            CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
-
-            rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1);
-            printf("Decrypt HMAC_SHA1: %s\n", aStr.getStr());
-            CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_HMAC_SHA1) );
-
-            delete [] pBuffer;
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(digest_HMAC_SHA1);
-    CPPUNIT_TEST( HMAC_SHA1_001 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-class digest_PBKDF2 : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-
-    rtl::OString /* key */ run_check_PBKDF2(rtl::OString const& _sPassword, bool _bClearSalt, sal_uInt32 _nCount)
-        {
-            sal_uInt32   nKeyLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
-            sal_uInt8    *pKeyBuffer = new sal_uInt8[ nKeyLen ];
-            CPPUNIT_ASSERT( pKeyBuffer );
-            memset(pKeyBuffer, 0, nKeyLen);
-
-            sal_uInt8    *pPassword    = (sal_uInt8*)_sPassword.getStr();
-            sal_Int32     nPasswordLen = _sPassword.getLength();
-
-            sal_uInt32   nSaltDataLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
-            sal_uInt8    *pSaltData = new sal_uInt8[ nSaltDataLen ];
-            CPPUNIT_ASSERT( pSaltData );
-            memset(pSaltData, 0, nSaltDataLen);
-
-            if (! _bClearSalt)
-            {
-                // wilful contamination
-                pSaltData[0] = 1;
-            }
-
-            rtlDigestError aError = rtl_digest_PBKDF2(pKeyBuffer, nKeyLen, pPassword, nPasswordLen, pSaltData, nSaltDataLen, _nCount);
-
-            CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
-
-            rtl::OString aKey = createHex(pKeyBuffer, nKeyLen);
-            printf("Key: %s\n", aKey.getStr());
-
-            // rtl::OString sSalt = createHex(pSaltData, nSaltDataLen);
-            // printf("Salt: %s\n", sSalt.getStr());
-
-            // CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_PBKDF2) );
-
-            delete [] pSaltData;
-            delete [] pKeyBuffer;
-            return aKey;
-        }
-
-    void PBKDF2_001()
-        {
-            rtl::OString  aPassword = "Password";
-
-            // all permutations
-            run_check_PBKDF2(aPassword, false, 1);
-            run_check_PBKDF2(aPassword, false, 2);
-            run_check_PBKDF2(aPassword, true,  1);
-            run_check_PBKDF2(aPassword, true,  2);
-            run_check_PBKDF2(aPassword, false, 3);
-            run_check_PBKDF2(aPassword, false, 4);
-            run_check_PBKDF2(aPassword, true,  3);
-            run_check_PBKDF2(aPassword, true,  4);
-        }
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(digest_PBKDF2);
-    CPPUNIT_TEST( PBKDF2_001 );
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-class update : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-    void update_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_update(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-
-    void updateMD2_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_updateMD2(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-
-    void updateMD2_001()
-        {
-            rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
-
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
-
-            rtlDigestError aError = rtl_digest_updateMD2(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument );
-
-            /* rtlDigestError */ aError = rtl_digest_updateMD2(aHandle, pData, 0);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_None );
-
-            rtl_digest_destroyMD2(aHandle);
-        }
-    void updateMD5_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_updateMD5(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-
-    void updateMD5_001()
-        {
-            // use wrong Algorithm!!! This is volitional!
-            rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
-
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
-            sal_uInt32       nSize = ( aMsg.getLength() );
-
-            rtlDigestError aError = rtl_digest_updateMD5(aHandle, pData, nSize);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'handle' wrong", aError == rtl_Digest_E_Algorithm );
-
-            rtl_digest_destroyMD5(aHandle);
-        }
-
-    void updateMD5_002()
-        {
-            rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle != 0);
-
-            rtl::OString aMsg = sSampleString;
-            const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
-
-            rtlDigestError aError = rtl_digest_updateMD5(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument );
-
-            /* rtlDigestError */ aError = rtl_digest_updateMD5(aHandle, pData, 0);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_None );
-
-            rtl_digest_destroyMD5(aHandle);
-        }
-
-    void updateSHA_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_updateSHA(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-
-    void updateSHA1_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_updateSHA1(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-
-    void updateHMAC_MD5_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_updateHMAC_MD5(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-
-    void updateHMAC_SHA1_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_updateHMAC_SHA1(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(update);
-    CPPUNIT_TEST(update_000);
-    CPPUNIT_TEST(updateMD5_000);
-    CPPUNIT_TEST(updateMD5_001);
-    CPPUNIT_TEST(updateMD5_002);
-    CPPUNIT_TEST(updateMD5_000);
-    CPPUNIT_TEST(updateSHA_000);
-    CPPUNIT_TEST(updateSHA1_000);
-    CPPUNIT_TEST(updateHMAC_MD5_000);
-    CPPUNIT_TEST(updateHMAC_SHA1_000);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-class get : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-    void get_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_get(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-    void getMD5_000()
-        {
-            rtlDigest aHandle = NULL;
-            rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
-        }
-    void getMD5_001()
-        {
-            // test with wrong algorithm
-            rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
-
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( aHandle );
-            sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
-
-            rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL, 0);
-            CPPUNIT_ASSERT_MESSAGE("handle 2. parameter wrong", aError == rtl_Digest_E_Argument );
-
-            /* rtlDigestError */ aError = rtl_digest_getMD5(aHandle, pKeyBuffer, 0);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'handle' wrong", aError == rtl_Digest_E_Algorithm );
-
-            rtl_digest_destroyMD2(aHandle);
-        }
-
-    void getMD5_002()
-        {
-            rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle != 0);
-
-            sal_uInt32     nKeyLen = rtl_digest_queryLength( aHandle );
-            sal_uInt8     *pKeyBuffer = new sal_uInt8[ nKeyLen ];
-
-            rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL /* pKeyBuffer */ , nKeyLen);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument );
-
-            /* rtlDigestError */ aError = rtl_digest_getMD5(aHandle, pKeyBuffer, 0);
-            CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_BufferSize );
-
-            rtl_digest_destroyMD5(aHandle);
-            delete [] pKeyBuffer;
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(get);
-    CPPUNIT_TEST(get_000);
-    CPPUNIT_TEST(getMD5_000);
-    CPPUNIT_TEST(getMD5_001);
-    CPPUNIT_TEST(getMD5_002);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-class destroy : public CppUnit::TestFixture
-{
-public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
-    {
-    }
-
-    void destroy_001()
-        {
-            rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-            CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", handle != 0);
-
-            // not really testable
-            // LLA: good will test.
-            rtl_digest_destroy( handle );
-        }
-
-    // Change the following lines only, if you add, remove or rename
-    // member functions of the current class,
-    // because these macros are need by auto register mechanism.
-
-    CPPUNIT_TEST_SUITE(destroy);
-    CPPUNIT_TEST(destroy_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class create
-
-
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::create);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createMD2);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createMD5);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createSHA);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createSHA1);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createHMAC_MD5);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createHMAC_SHA1);
-
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::destroy);
-
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::queryAlgorithm);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::queryLength);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::init);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::equalTests);
-
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_MD2);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_MD5);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_SHA);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_SHA1);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_HMAC_MD5);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_HMAC_SHA1);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_PBKDF2);
-
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::update);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::get);
-CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::destroy);
 } // namespace rtl_digest
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list