[Libreoffice-commits] core.git: include/oox oox/source
Tomaž Vajngerl
quikee at gmail.com
Sat Aug 24 14:08:58 PDT 2013
include/oox/crypto/AgileEngine.hxx | 3 ++-
oox/source/crypto/AgileEngine.cxx | 21 +++++++++++----------
2 files changed, 13 insertions(+), 11 deletions(-)
New commits:
commit 1bff0dbf79cf11269122bb3ebba8b80120ef8b8e
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Sat Aug 24 23:05:01 2013 +0200
Convert vector block* to const array block*.
Looks like my compiler eats a lot of things thrown at him but
others don't.
Change-Id: If1d080a545e6c2a17e19b389eeb1714aa0569644
diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx
index ddd7a3f..9a38488 100644
--- a/include/oox/crypto/AgileEngine.hxx
+++ b/include/oox/crypto/AgileEngine.hxx
@@ -45,7 +45,8 @@ class AgileEngine : public CryptoEngine
bool calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal);
bool calculateBlock(
- const std::vector<sal_uInt8>& rBlock,
+ const sal_uInt8* rBlock,
+ sal_uInt32 aBlockSize,
std::vector<sal_uInt8>& rHashFinal,
std::vector<sal_uInt8>& rInput,
std::vector<sal_uInt8>& rOutput);
diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx
index d0bebe9..f56e669 100644
--- a/oox/source/crypto/AgileEngine.cxx
+++ b/oox/source/crypto/AgileEngine.cxx
@@ -17,9 +17,9 @@ using namespace std;
namespace {
-static const vector<sal_uInt8> vectorBlock1({ 0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79 });
-static const vector<sal_uInt8> vectorBlock2({ 0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e });
-static const vector<sal_uInt8> vectorBlock3({ 0x14, 0x6e, 0x0b, 0xe7, 0xab, 0xac, 0xd0, 0xd6 });
+const sal_uInt8 constBlock1[] = { 0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79 };
+const sal_uInt8 constBlock2[] = { 0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e };
+const sal_uInt8 constBlock3[] = { 0x14, 0x6e, 0x0b, 0xe7, 0xab, 0xac, 0xd0, 0xd6 };
bool hashCalc( std::vector<sal_uInt8>& output,
std::vector<sal_uInt8>& input,
@@ -56,18 +56,19 @@ Crypto::CryptoType AgileEngine::cryptoType(const AgileEncryptionInfo& rInfo)
}
bool AgileEngine::calculateBlock(
- const vector<sal_uInt8>& rBlock,
+ const sal_uInt8* rBlock,
+ sal_uInt32 aBlockSize,
vector<sal_uInt8>& rHashFinal,
vector<sal_uInt8>& rInput,
vector<sal_uInt8>& rOutput)
{
vector<sal_uInt8> hash(mInfo.hashSize, 0);
vector<sal_uInt8> salt = mInfo.saltValue;
- vector<sal_uInt8> dataFinal(mInfo.hashSize + rBlock.size(), 0);
+ vector<sal_uInt8> dataFinal(mInfo.hashSize + aBlockSize, 0);
std::copy(rHashFinal.begin(), rHashFinal.end(), dataFinal.begin());
std::copy(
- rBlock.begin(),
- rBlock.begin() + rBlock.size(),
+ rBlock,
+ rBlock + aBlockSize,
dataFinal.begin() + mInfo.hashSize);
hashCalc(hash, dataFinal, mInfo.hashAlgorithm);
@@ -127,11 +128,11 @@ bool AgileEngine::generateEncryptionKey(const OUString& rPassword)
vector<sal_uInt8> encryptedHashInput = mInfo.encryptedVerifierHashInput;
vector<sal_uInt8> hashInput(mInfo.saltSize, 0);
- calculateBlock(vectorBlock1, hashFinal, encryptedHashInput, hashInput);
+ calculateBlock(constBlock1, sizeof(constBlock1), hashFinal, encryptedHashInput, hashInput);
vector<sal_uInt8> encryptedHashValue = mInfo.encryptedVerifierHashValue;
vector<sal_uInt8> hashValue(encryptedHashValue.size(), 0);
- calculateBlock(vectorBlock2, hashFinal, encryptedHashValue, hashValue);
+ calculateBlock(constBlock2, sizeof(constBlock2), hashFinal, encryptedHashValue, hashValue);
vector<sal_uInt8> hash(mInfo.hashSize, 0);
hashCalc(hash, hashInput, mInfo.hashAlgorithm);
@@ -139,7 +140,7 @@ bool AgileEngine::generateEncryptionKey(const OUString& rPassword)
if (std::equal (hash.begin(), hash.end(), hashValue.begin()) )
{
vector<sal_uInt8> encryptedKeyValue = mInfo.encryptedKeyValue;
- calculateBlock(vectorBlock3, hashFinal, encryptedKeyValue, mKey);
+ calculateBlock(constBlock3, sizeof(constBlock3), hashFinal, encryptedKeyValue, mKey);
return true;
}
More information about the Libreoffice-commits
mailing list