summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-07-14 21:16:07 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-07-15 09:16:05 +0200
commit4fcd42afd3ba92f909b48be72c9392314689ec89 (patch)
treed5d21339948547909bd3f1afb81249d89fc28921 /oox
parent96ada688eaf7454791a5d8f8e0abe68e2c417e26 (diff)
comphelper: don't hardcode hash sizes in Hash::getLength()
Instead move the constants from filter to comphelper and reuse them. Change-Id: Ib7061e9028ccf6067b4e86f50145c1472c2b01d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98785 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/crypto/AgileEngine.cxx4
-rw-r--r--oox/source/crypto/Standard2007Engine.cxx14
2 files changed, 9 insertions, 9 deletions
diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx
index df3bf4bb19d8..008b29462c0d 100644
--- a/oox/source/crypto/AgileEngine.cxx
+++ b/oox/source/crypto/AgileEngine.cxx
@@ -531,7 +531,7 @@ bool AgileEngine::readEncryptionInfo(uno::Reference<io::XInputStream> & rxInputS
mInfo.cipherAlgorithm == "AES" &&
mInfo.cipherChaining == "ChainingModeCBC" &&
mInfo.hashAlgorithm == "SHA1" &&
- mInfo.hashSize == msfilter::SHA1_HASH_LENGTH)
+ mInfo.hashSize == comphelper::SHA1_HASH_LENGTH)
{
return true;
}
@@ -541,7 +541,7 @@ bool AgileEngine::readEncryptionInfo(uno::Reference<io::XInputStream> & rxInputS
mInfo.cipherAlgorithm == "AES" &&
mInfo.cipherChaining == "ChainingModeCBC" &&
mInfo.hashAlgorithm == "SHA512" &&
- mInfo.hashSize == msfilter::SHA512_HASH_LENGTH)
+ mInfo.hashSize == comphelper::SHA512_HASH_LENGTH)
{
return true;
}
diff --git a/oox/source/crypto/Standard2007Engine.cxx b/oox/source/crypto/Standard2007Engine.cxx
index 2799ec5286f9..0a367874d2c4 100644
--- a/oox/source/crypto/Standard2007Engine.cxx
+++ b/oox/source/crypto/Standard2007Engine.cxx
@@ -54,11 +54,11 @@ bool Standard2007Engine::generateVerifier()
return false;
std::copy(encryptedVerifier.begin(), encryptedVerifier.end(), mInfo.verifier.encryptedVerifier);
- mInfo.verifier.encryptedVerifierHashSize = msfilter::SHA1_HASH_LENGTH;
+ mInfo.verifier.encryptedVerifierHashSize = comphelper::SHA1_HASH_LENGTH;
std::vector<sal_uInt8> hash = comphelper::Hash::calculateHash(verifier.data(), verifier.size(), comphelper::HashType::SHA1);
- hash.resize(msfilter::SHA256_HASH_LENGTH, 0);
+ hash.resize(comphelper::SHA256_HASH_LENGTH, 0);
- std::vector<sal_uInt8> encryptedHash(msfilter::SHA256_HASH_LENGTH, 0);
+ std::vector<sal_uInt8> encryptedHash(comphelper::SHA256_HASH_LENGTH, 0);
Encrypt aEncryptorHash(mKey, iv, Crypto::AES_128_ECB);
aEncryptorHash.update(encryptedHash, hash, hash.size());
@@ -89,7 +89,7 @@ bool Standard2007Engine::calculateEncryptionKey(const OUString& rPassword)
std::vector<sal_uInt8> hash = comphelper::Hash::calculateHash(initialData.data(), initialData.size(), comphelper::HashType::SHA1);
// data = iterator (4bytes) + hash
- std::vector<sal_uInt8> data(msfilter::SHA1_HASH_LENGTH + 4, 0);
+ std::vector<sal_uInt8> data(comphelper::SHA1_HASH_LENGTH + 4, 0);
for (sal_Int32 i = 0; i < 50000; ++i)
{
@@ -98,7 +98,7 @@ bool Standard2007Engine::calculateEncryptionKey(const OUString& rPassword)
hash = comphelper::Hash::calculateHash(data.data(), data.size(), comphelper::HashType::SHA1);
}
std::copy(hash.begin(), hash.end(), data.begin() );
- std::fill(data.begin() + msfilter::SHA1_HASH_LENGTH, data.end(), 0 );
+ std::fill(data.begin() + comphelper::SHA1_HASH_LENGTH, data.end(), 0 );
hash = comphelper::Hash::calculateHash(data.data(), data.size(), comphelper::HashType::SHA1);
@@ -140,10 +140,10 @@ bool Standard2007Engine::generateEncryptionKey(const OUString& password)
mInfo.verifier.encryptedVerifier + msfilter::ENCRYPTED_VERIFIER_LENGTH,
encryptedVerifier.begin());
- std::vector<sal_uInt8> encryptedHash(msfilter::SHA256_HASH_LENGTH);
+ std::vector<sal_uInt8> encryptedHash(comphelper::SHA256_HASH_LENGTH);
std::copy(
mInfo.verifier.encryptedVerifierHash,
- mInfo.verifier.encryptedVerifierHash + msfilter::SHA256_HASH_LENGTH,
+ mInfo.verifier.encryptedVerifierHash + comphelper::SHA256_HASH_LENGTH,
encryptedHash.begin());
std::vector<sal_uInt8> verifier(encryptedVerifier.size(), 0);