summaryrefslogtreecommitdiff
path: root/include/oox/crypto/AgileEngine.hxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-08-24 22:40:54 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-08-24 22:53:04 +0200
commit4323c66840e4c7dcacda0e33d33d7e67fdb08f09 (patch)
tree5359bfda1a78e99f8fa2f8543b918e0f847ae230 /include/oox/crypto/AgileEngine.hxx
parent4d688beb2b2183ced387270e051dc25ee340fb4b (diff)
fdo#35422 Support to open encrypted Office 2010 and 2013 formats
Additionally encryption and decryption has been refactored. 2 engines have been added: AgileEngine and Standard2007Engine, which contain core functions for encryption and decryption. Standard2007Engine refers to encryption and decryption as used in Office 2007 and AgileEngine refers to encryption and decryption as used in Office 2010 and 2013. AgileEngine does not yet support encryption. Change-Id: Ica1d4d5a109fb204012b92a0c39325fe0b99b793
Diffstat (limited to 'include/oox/crypto/AgileEngine.hxx')
-rw-r--r--include/oox/crypto/AgileEngine.hxx81
1 files changed, 81 insertions, 0 deletions
diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx
new file mode 100644
index 000000000000..ddd7a3fffb50
--- /dev/null
+++ b/include/oox/crypto/AgileEngine.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef AGILE_ENGINE_HXX
+#define AGILE_ENGINE_HXX
+
+#include "CryptTools.hxx"
+#include "CryptoEngine.hxx"
+
+namespace oox {
+namespace core {
+
+const sal_uInt32 SEGMENT_LENGTH = 4096;
+
+struct AgileEncryptionInfo
+{
+ sal_Int32 spinCount;
+ sal_Int32 saltSize;
+ sal_Int32 keyBits;
+ sal_Int32 hashSize;
+ sal_Int32 blockSize;
+
+ OUString cipherAlgorithm;
+ OUString cipherChaining;
+ OUString hashAlgorithm;
+
+ std::vector<sal_uInt8> keyDataSalt;
+ std::vector<sal_uInt8> saltValue;
+ std::vector<sal_uInt8> encryptedVerifierHashInput;
+ std::vector<sal_uInt8> encryptedVerifierHashValue;
+ std::vector<sal_uInt8> encryptedKeyValue;
+};
+
+class AgileEngine : public CryptoEngine
+{
+ AgileEncryptionInfo mInfo;
+
+ bool calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal);
+
+ bool calculateBlock(
+ const std::vector<sal_uInt8>& rBlock,
+ std::vector<sal_uInt8>& rHashFinal,
+ std::vector<sal_uInt8>& rInput,
+ std::vector<sal_uInt8>& rOutput);
+
+ Crypto::CryptoType cryptoType(const AgileEncryptionInfo& rInfo);
+
+public:
+ AgileEngine();
+ virtual ~AgileEngine();
+
+ AgileEncryptionInfo& getInfo();
+
+ virtual bool writeEncryptionInfo(
+ const OUString& rPassword,
+ BinaryXOutputStream& rStream);
+
+ virtual bool generateEncryptionKey(const OUString& rPassword);
+
+ virtual bool decrypt(
+ BinaryXInputStream& aInputStream,
+ BinaryXOutputStream& aOutputStream);
+
+ virtual bool encrypt(
+ BinaryXInputStream& aInputStream,
+ BinaryXOutputStream& aOutputStream);
+};
+
+} // namespace core
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */