diff options
author | Michael Stahl <mstahl@redhat.com> | 2018-01-11 10:28:42 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-01-11 11:05:00 +0100 |
commit | f66fbd947f70f6be6b22ab372facaeb9e2fb63ae (patch) | |
tree | 7ceb2b5bd5ea3179f90b69ce6c01ad0ef07527a9 /filter | |
parent | (related:tdf#114939) connectivity: use real SHA1 (diff) | |
download | core-f66fbd947f70f6be6b22ab372facaeb9e2fb63ae.tar.gz core-f66fbd947f70f6be6b22ab372facaeb9e2fb63ae.zip |
tdf#114939 filter: don't use StarOffice SHA1 in MS Office filters
Always use real SHA1 here, to avoid interop issues.
Change-Id: I28388db34f923bfc476a7eae526934b14d4473b5
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/msfilter/mscodec.cxx | 14 |
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, |