Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / crypto / AgileEngine.hxx
blob22233b0510113aab0d39f9be5316b6709e1d761e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #ifndef INCLUDED_OOX_CRYPTO_AGILEENGINE_HXX
12 #define INCLUDED_OOX_CRYPTO_AGILEENGINE_HXX
14 #include <vector>
16 #include <oox/crypto/CryptTools.hxx>
17 #include <oox/crypto/CryptoEngine.hxx>
18 #include <rtl/ustring.hxx>
19 #include <sal/types.h>
21 namespace oox {
22 class BinaryXInputStream;
23 class BinaryXOutputStream;
26 namespace oox {
27 namespace core {
29 struct AgileEncryptionInfo
31 sal_Int32 spinCount;
32 sal_Int32 saltSize;
33 sal_Int32 keyBits;
34 sal_Int32 hashSize;
35 sal_Int32 blockSize;
37 OUString cipherAlgorithm;
38 OUString cipherChaining;
39 OUString hashAlgorithm;
41 std::vector<sal_uInt8> keyDataSalt;
42 std::vector<sal_uInt8> saltValue;
43 std::vector<sal_uInt8> encryptedVerifierHashInput;
44 std::vector<sal_uInt8> encryptedVerifierHashValue;
45 std::vector<sal_uInt8> encryptedKeyValue;
48 class AgileEngine : public CryptoEngine
50 AgileEncryptionInfo mInfo;
52 void calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal);
54 void calculateBlock(
55 std::vector<sal_uInt8> const & rBlock,
56 std::vector<sal_uInt8>& rHashFinal,
57 std::vector<sal_uInt8>& rInput,
58 std::vector<sal_uInt8>& rOutput);
60 static Crypto::CryptoType cryptoType(const AgileEncryptionInfo& rInfo);
62 public:
63 AgileEngine() = default;
65 AgileEncryptionInfo& getInfo() { return mInfo;}
67 virtual void writeEncryptionInfo(
68 const OUString& rPassword,
69 BinaryXOutputStream& rStream) override;
71 virtual bool generateEncryptionKey(const OUString& rPassword) override;
73 virtual bool decrypt(
74 BinaryXInputStream& aInputStream,
75 BinaryXOutputStream& aOutputStream) override;
77 virtual void encrypt(
78 BinaryXInputStream& aInputStream,
79 BinaryXOutputStream& aOutputStream) override;
82 } // namespace core
83 } // namespace oox
85 #endif
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */