remove assert looking for new compatibilityMode DOCX
[LibreOffice.git] / vcl / inc / pdf / EncryptionHashTransporter.hxx
blob9b523f3f90f0deaf170c36c2bba2c61ab3f7e485
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/.
8 */
10 #pragma once
12 #include <com/sun/star/beans/XMaterialHolder.hpp>
13 #include <comphelper/hash.hxx>
14 #include <cppuhelper/implbase.hxx>
15 #include <sal/log.hxx>
17 #include <map>
19 namespace vcl::pdf
21 /* a crutch to transport a ::comphelper::Hash safely though UNO API
22 this is needed for the PDF export dialog, which otherwise would have to pass
23 clear text passwords down till they can be used in PDFWriter. Unfortunately
24 the MD5 sum of the password (which is needed to create the PDF encryption key)
25 is not sufficient, since an MD5 digest cannot be created in an arbitrary state
26 which would be needed in computeEncryptionKey.
28 class EncryptionHashTransporter : public cppu::WeakImplHelper<css::beans::XMaterialHolder>
30 // V2R3
31 std::unique_ptr<comphelper::Hash> m_pDigest;
32 std::vector<sal_uInt8> maOValue;
34 // V5R6
35 std::vector<sal_uInt8> mU;
36 std::vector<sal_uInt8> mUE;
37 std::vector<sal_uInt8> mO;
38 std::vector<sal_uInt8> mOE;
39 std::vector<sal_uInt8> maEncryptionKey;
41 // ID
42 sal_IntPtr maID;
44 public:
45 EncryptionHashTransporter();
47 virtual ~EncryptionHashTransporter() override;
49 comphelper::Hash* getUDigest() { return m_pDigest.get(); };
51 std::vector<sal_uInt8>& getOValue() { return maOValue; }
53 void invalidate() { m_pDigest.reset(); }
55 std::vector<sal_uInt8> getU() { return mU; }
56 void setU(std::vector<sal_uInt8> const& rU) { mU = rU; }
58 std::vector<sal_uInt8> getUE() { return mUE; }
59 void setUE(std::vector<sal_uInt8> const& rUE) { mUE = rUE; }
61 std::vector<sal_uInt8> getO() { return mO; }
62 void setO(std::vector<sal_uInt8> const& rO) { mO = rO; }
64 std::vector<sal_uInt8> getOE() { return mOE; }
65 void setOE(std::vector<sal_uInt8> const& rOE) { mOE = rOE; }
67 std::vector<sal_uInt8> getEncryptionKey() { return maEncryptionKey; }
68 void setEncryptionKey(std::vector<sal_uInt8> const& rEncryptionKey)
70 maEncryptionKey = rEncryptionKey;
73 // XMaterialHolder
74 virtual css::uno::Any SAL_CALL getMaterial() override { return css::uno::Any(sal_Int64(maID)); }
76 static EncryptionHashTransporter*
77 getEncHashTransporter(const css::uno::Reference<css::beans::XMaterialHolder>& xReference);
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */