summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-17 11:00:01 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-01-17 13:51:34 +0100
commitd27561ad071bbb2b7cabb45203515c2e1669476a (patch)
tree5bd4fc74c413fde2a83ac7f041d77b42faca7b12
parente53c3df2dd0220dfd90d1e81f59097be0cd423df (diff)
tdf#114939: Verify rtl_digest_SHA1 computes broken results, by design
This replaces the known-failing test from 8d2da0b94ac5d679ef697683cacb2c83498cc497 "sal: Add rtl_digest_SHA1 which shows wrong sha1 calculation" with the known-succeeding one (though producing wrong results) from tdf#114939 "rtl_digest SHA1 and MD5 code both have an off by 1 bug". Change-Id: Ib4e8210e1889e5ebf4979d7b1f28f1cfb13ebab9 Reviewed-on: https://gerrit.libreoffice.org/48033 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sal/qa/rtl/digest/rtl_digest.cxx35
1 files changed, 11 insertions, 24 deletions
diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx
index 34932a7e71cb..33b2bfeb3212 100644
--- a/sal/qa/rtl/digest/rtl_digest.cxx
+++ b/sal/qa/rtl/digest/rtl_digest.cxx
@@ -26,6 +26,7 @@
#include <memory>
#include <rtl/digest.h>
+#include <rtl/string.h>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
@@ -387,31 +388,17 @@ public:
CPPUNIT_ASSERT_EQUAL(sExpected, sKey);
}
+ // tdf#114939, verify that rtl_digest_SHA1 computes broken results for certain input (which
+ // is not fixed for compatibility reasons):
{
-#if 0 // Don't remove, but instead fix the test or something
-
- // With this test case rtl_digest_SHA1 computes the wrong sum. This was confirmed
- // by decryption of a MSO encrypted document. Replacing the rtl_digest_SHA1 calculation
- // with sha1 calculation from NSS was able to decrypt the document.
-
- 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
- };
-
- std::unique_ptr<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);
-
- CPPUNIT_ASSERT_EQUAL(sExpected, sKey);
-#endif
+ sal_uInt8 result[RTL_DIGEST_LENGTH_SHA1];
+ rtl_digest_SHA1(
+ RTL_CONSTASCII_STRINGPARAM("1012345678901234567890123456789012345678901234567890"),
+ result, RTL_DIGEST_LENGTH_SHA1);
+ // Rather than correct "9cb1dab34448c1ea460da1f8736869c8852f212f":
+ CPPUNIT_ASSERT_EQUAL(
+ OString("90a461ee9cc69cedaeb25c2dc5cc62544ebd5241"),
+ createHex(result, RTL_DIGEST_LENGTH_SHA1));
}
}