[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - 2 commits - filter/source include/comphelper

Michael Stahl mstahl at redhat.com
Wed Jan 17 08:56:29 UTC 2018


 filter/source/msfilter/mscodec.cxx |   14 ++++++++++----
 include/comphelper/hash.hxx        |    5 +++++
 2 files changed, 15 insertions(+), 4 deletions(-)

New commits:
commit 82e19b3a0cb0f51761fe2081729f7d739cae01eb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Jan 11 10:28:42 2018 +0100

    tdf#114939 filter: don't use StarOffice SHA1 in MS Office filters
    
    Always use real SHA1 here, to avoid interop issues.
    
    Change-Id: I28388db34f923bfc476a7eae526934b14d4473b5
    (cherry picked from commit f66fbd947f70f6be6b22ab372facaeb9e2fb63ae)
    Reviewed-on: https://gerrit.libreoffice.org/47998
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/msfilter/mscodec.cxx b/filter/source/msfilter/mscodec.cxx
index 1d7cd35b1125..02a1a1b444d1 100644
--- a/filter/source/msfilter/mscodec.cxx
+++ b/filter/source/msfilter/mscodec.cxx
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <tools/solar.h>
 
+#include <comphelper/hash.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <comphelper/docpasswordhelper.hxx>
 
@@ -373,7 +374,10 @@ void MSCodec_CryptoAPI::InitKey (
     }
 
     // calculate SHA1 hash of initialData
-    rtl_digest_SHA1(initialData.data(), initialData.size(), m_aDigestValue.data(), m_aDigestValue.size());
+    std::vector<unsigned char> const sha1(::comphelper::Hash::calculateHash(
+            initialData.data(), initialData.size(),
+            ::comphelper::HashType::SHA1));
+    m_aDigestValue = sha1;
 
     lcl_PrintDigest(m_aDigestValue.data(), "digest value");
 
@@ -419,7 +423,9 @@ void MSCodec_CryptoAPI::GetDigestFromSalt(const sal_uInt8* pSaltData, sal_uInt8*
     rtl_cipher_decode(m_hCipher,
         pSaltData, 16, verifier.data(), verifier.size());
 
-    rtl_digest_SHA1(verifier.data(), verifier.size(), pDigest, RTL_DIGEST_LENGTH_SHA1);
+    std::vector<unsigned char> const sha1(::comphelper::Hash::calculateHash(
+            verifier.data(), verifier.size(), ::comphelper::HashType::SHA1));
+    ::std::copy(sha1.begin(), sha1.end(), pDigest);
 }
 
 bool MSCodec_Std97::InitCipher(sal_uInt32 nCounter)
@@ -467,8 +473,8 @@ bool MSCodec_CryptoAPI::InitCipher(sal_uInt32 nCounter)
     aKeyData.push_back(sal_uInt8((nCounter >> 16) & 0xff));
     aKeyData.push_back(sal_uInt8((nCounter >> 24) & 0xff));
 
-    std::vector<sal_uInt8> hash(RTL_DIGEST_LENGTH_SHA1);
-    rtl_digest_SHA1(aKeyData.data(), aKeyData.size(), hash.data(), RTL_DIGEST_LENGTH_SHA1);
+    std::vector<unsigned char> const hash(::comphelper::Hash::calculateHash(
+            aKeyData.data(), aKeyData.size(), ::comphelper::HashType::SHA1));
 
     rtlCipherError result =
         rtl_cipher_init(m_hCipher, rtl_Cipher_DirectionDecode,
commit 8f7546a35106b03932d51089bcf4f85aeac07bbb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Jan 16 17:13:22 2018 +0100

    comphelper: put some include guards around stark naked header
    
    Change-Id: I407dc215ea6948518d0d744c73ff2de717063962
    (cherry picked from commit 6339072a5638995925ea403e71f01a454fdac74e)
    Reviewed-on: https://gerrit.libreoffice.org/48020
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/comphelper/hash.hxx b/include/comphelper/hash.hxx
index d8145604ac6b..df70757f4042 100644
--- a/include/comphelper/hash.hxx
+++ b/include/comphelper/hash.hxx
@@ -7,6 +7,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef INCLUDED_COMPHELPER_HASH_HXX
+#define INCLUDED_COMPHELPER_HASH_HXX
+
 #include <comphelper/comphelperdllapi.h>
 
 #include <memory>
@@ -45,4 +48,6 @@ public:
 
 }
 
+#endif // INCLUDED_COMPHELPER_HASH_HXX
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list