Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : */
10 :
11 : #ifndef INCLUDED_OOX_CRYPTO_DOCUMENTDECRYPTION_HXX
12 : #define INCLUDED_OOX_CRYPTO_DOCUMENTDECRYPTION_HXX
13 :
14 : #include <oox/dllapi.h>
15 :
16 : #include <oox/ole/olestorage.hxx>
17 : #include <oox/helper/binaryinputstream.hxx>
18 : #include <oox/helper/binaryoutputstream.hxx>
19 :
20 : #include <com/sun/star/io/XStream.hpp>
21 : #include <com/sun/star/beans/NamedValue.hpp>
22 : #include <com/sun/star/uno/Sequence.hxx>
23 :
24 : #include <oox/crypto/CryptTools.hxx>
25 : #include <oox/crypto/AgileEngine.hxx>
26 : #include <oox/crypto/Standard2007Engine.hxx>
27 :
28 : #include <boost/scoped_ptr.hpp>
29 : #include <vector>
30 :
31 : namespace oox {
32 : namespace core {
33 :
34 30 : class OOX_DLLPUBLIC DocumentDecryption
35 : {
36 : private:
37 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext;
38 :
39 : enum CryptoType
40 : {
41 : UNKNOWN,
42 : STANDARD_2007,
43 : AGILE
44 : };
45 :
46 : oox::ole::OleStorage& mrOleStorage;
47 : boost::scoped_ptr<CryptoEngine> mEngine;
48 : CryptoType mCryptoType;
49 :
50 : bool readAgileEncryptionInfo( com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& rStream );
51 : bool readStandard2007EncryptionInfo( BinaryInputStream& rStream );
52 :
53 : public:
54 : DocumentDecryption(
55 : oox::ole::OleStorage& rOleStorage,
56 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext);
57 :
58 : bool decrypt(com::sun::star::uno::Reference< com::sun::star::io::XStream > xDocumentStream);
59 : bool readEncryptionInfo();
60 : bool generateEncryptionKey(const OUString& rPassword);
61 :
62 : com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > createEncryptionData(const OUString& rPassword);
63 :
64 : static bool checkEncryptionData( const com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue >& rEncryptionData );
65 : };
66 :
67 : } // namespace core
68 : } // namespace oox
69 :
70 : #endif
71 :
72 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|