summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-23 13:06:40 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-23 13:11:59 +0100
commit8d2da0b94ac5d679ef697683cacb2c83498cc497 (patch)
tree3bbe9d8e7da21583f9979160adc3a3f1acb15435 /sal
parent7d3e8c5217250d11b4bf4fcdf74a3791be69ab53 (diff)
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
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/rtl/digest/rtl_digest.cxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx
index 1ae3d27e7b15..09538544d150 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();
};