summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2018-01-11 10:28:42 +0100
committerMichael Stahl <mstahl@redhat.com>2018-01-11 11:05:00 +0100
commitf66fbd947f70f6be6b22ab372facaeb9e2fb63ae (patch)
tree7ceb2b5bd5ea3179f90b69ce6c01ad0ef07527a9
parent162ffd57de49b1f007b88fb247a592acbac0aaf7 (diff)
tdf#114939 filter: don't use StarOffice SHA1 in MS Office filters
Always use real SHA1 here, to avoid interop issues. Change-Id: I28388db34f923bfc476a7eae526934b14d4473b5
-rw-r--r--filter/source/msfilter/mscodec.cxx14
1 files changed, 10 insertions, 4 deletions
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,