From 1bff0dbf79cf11269122bb3ebba8b80120ef8b8e Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 24 Aug 2013 23:05:01 +0200 Subject: 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 --- oox/source/crypto/AgileEngine.cxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'oox/source') diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx index d0bebe9c1a7d..f56e669e9dce 100644 --- a/oox/source/crypto/AgileEngine.cxx +++ b/oox/source/crypto/AgileEngine.cxx @@ -17,9 +17,9 @@ using namespace std; namespace { -static const vector vectorBlock1({ 0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79 }); -static const vector vectorBlock2({ 0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e }); -static const vector 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& output, std::vector& input, @@ -56,18 +56,19 @@ Crypto::CryptoType AgileEngine::cryptoType(const AgileEncryptionInfo& rInfo) } bool AgileEngine::calculateBlock( - const vector& rBlock, + const sal_uInt8* rBlock, + sal_uInt32 aBlockSize, vector& rHashFinal, vector& rInput, vector& rOutput) { vector hash(mInfo.hashSize, 0); vector salt = mInfo.saltValue; - vector dataFinal(mInfo.hashSize + rBlock.size(), 0); + vector 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 encryptedHashInput = mInfo.encryptedVerifierHashInput; vector hashInput(mInfo.saltSize, 0); - calculateBlock(vectorBlock1, hashFinal, encryptedHashInput, hashInput); + calculateBlock(constBlock1, sizeof(constBlock1), hashFinal, encryptedHashInput, hashInput); vector encryptedHashValue = mInfo.encryptedVerifierHashValue; vector hashValue(encryptedHashValue.size(), 0); - calculateBlock(vectorBlock2, hashFinal, encryptedHashValue, hashValue); + calculateBlock(constBlock2, sizeof(constBlock2), hashFinal, encryptedHashValue, hashValue); vector 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 encryptedKeyValue = mInfo.encryptedKeyValue; - calculateBlock(vectorBlock3, hashFinal, encryptedKeyValue, mKey); + calculateBlock(constBlock3, sizeof(constBlock3), hashFinal, encryptedKeyValue, mKey); return true; } -- cgit