Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / oox / crypto / AgileEngine.hxx
blob2bb73305d441a8b3dd0a5360a15bae16abf0dbf4
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 const sal_uInt32 SEGMENT_LENGTH = 4096;
31 struct AgileEncryptionInfo
33 sal_Int32 spinCount;
34 sal_Int32 saltSize;
35 sal_Int32 keyBits;
36 sal_Int32 hashSize;
37 sal_Int32 blockSize;
39 OUString cipherAlgorithm;
40 OUString cipherChaining;
41 OUString hashAlgorithm;
43 std::vector<sal_uInt8> keyDataSalt;
44 std::vector<sal_uInt8> saltValue;
45 std::vector<sal_uInt8> encryptedVerifierHashInput;
46 std::vector<sal_uInt8> encryptedVerifierHashValue;
47 std::vector<sal_uInt8> encryptedKeyValue;
50 class AgileEngine : public CryptoEngine
52 AgileEncryptionInfo mInfo;
54 void calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal);
56 void calculateBlock(
57 const sal_uInt8* rBlock,
58 sal_uInt32 aBlockSize,
59 std::vector<sal_uInt8>& rHashFinal,
60 std::vector<sal_uInt8>& rInput,
61 std::vector<sal_uInt8>& rOutput);
63 static Crypto::CryptoType cryptoType(const AgileEncryptionInfo& rInfo);
65 public:
66 AgileEngine();
67 virtual ~AgileEngine();
69 AgileEncryptionInfo& getInfo() { return mInfo;}
71 virtual void writeEncryptionInfo(
72 const OUString& rPassword,
73 BinaryXOutputStream& rStream) override;
75 virtual bool generateEncryptionKey(const OUString& rPassword) override;
77 virtual bool decrypt(
78 BinaryXInputStream& aInputStream,
79 BinaryXOutputStream& aOutputStream) override;
81 virtual void encrypt(
82 BinaryXInputStream& aInputStream,
83 BinaryXOutputStream& aOutputStream) override;
86 } // namespace core
87 } // namespace oox
89 #endif
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */