LibreOffice Module comphelper (master)  1
docpasswordhelper.hxx
Go to the documentation of this file.
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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_COMPHELPER_DOCPASSWORDHELPER_HXX
21 #define INCLUDED_COMPHELPER_DOCPASSWORDHELPER_HXX
22 
24 #include <vector>
26 #include <comphelper/hash.hxx>
27 
28 namespace com { namespace sun { namespace star { namespace task { class XInteractionHandler; } } } }
29 namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } }
30 namespace com { namespace sun { namespace star { namespace beans { struct NamedValue; } } } }
31 
32 namespace comphelper {
33 
35 {
36  OK,
38  Abort
39 };
40 
41 
49 {
50 public:
51  virtual ~IDocPasswordVerifier();
52 
72  virtual DocPasswordVerifierResult verifyPassword( const OUString& rPassword, css::uno::Sequence< css::beans::NamedValue >& o_rEncryptionData ) = 0;
73 
88  virtual DocPasswordVerifierResult verifyEncryptionData( const css::uno::Sequence< css::beans::NamedValue >& o_rEncryptionData ) = 0;
89 
90 };
91 
92 
96 {
97 public:
98 
99 
112  static css::uno::Sequence< css::beans::PropertyValue >
113  GenerateNewModifyPasswordInfo( const OUString& aPassword );
114 
115 
130  static bool IsModifyPasswordCorrect(
131  const OUString& aPassword,
132  const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
133 
134 
145  static sal_uInt32 GetWordHashAsUINT32(
146  const OUString& aString );
147 
148 
164  static sal_uInt16 GetXLHashAsUINT16(
165  const OUString& aString,
166  rtl_TextEncoding nEnc = RTL_TEXTENCODING_UTF8 );
167 
168 
180  static css::uno::Sequence< sal_Int8 > GetXLHashAsSequence(
181  const OUString& aString );
182 
183 
221  static css::uno::Sequence<sal_Int8> GetOoxHashAsSequence(
222  const OUString& rPassword,
223  const OUString& rSaltValue,
224  sal_uInt32 nSpinCount,
225  comphelper::Hash::IterCount eIterCount,
226  const OUString& rAlgorithmName);
227 
228 
267  static OUString GetOoxHashAsBase64(
268  const OUString& rPassword,
269  const OUString& rSaltValue,
270  sal_uInt32 nSpinCount,
271  comphelper::Hash::IterCount eIterCount,
272  const OUString& rAlgorithmName);
273 
274 
311  static std::vector<unsigned char> GetOoxHashAsVector(
312  const OUString& rPassword,
313  const std::vector<unsigned char>& rSaltValue,
314  sal_uInt32 nSpinCount,
315  comphelper::Hash::IterCount eIterCount,
316  const OUString& rAlgorithmName);
317 
318 
323  static css::uno::Sequence< sal_Int8 > GenerateRandomByteSequence(
324  sal_Int32 nLength );
325 
326 
331  static css::uno::Sequence< sal_Int8 > GenerateStd97Key(
332  const OUString& aPassword,
333  const css::uno::Sequence< sal_Int8 >& aDocId );
334 
335 
340  static css::uno::Sequence< sal_Int8 > GenerateStd97Key(
341  const sal_uInt16 pPassData[16],
342  const css::uno::Sequence< sal_Int8 >& aDocId );
343 
348  static css::uno::Sequence< sal_Int8 > GenerateStd97Key(
349  const sal_uInt16 pPassData[16],
350  const sal_uInt8 pDocId[16] );
351 
352 
406  static css::uno::Sequence< css::beans::NamedValue > requestAndVerifyDocPassword(
407  IDocPasswordVerifier& rVerifier,
408  const css::uno::Sequence< css::beans::NamedValue >& rMediaEncData,
409  const OUString& rMediaPassword,
410  const css::uno::Reference< css::task::XInteractionHandler >& rxInteractHandler,
411  const OUString& rDocumentUrl,
412  DocPasswordRequestType eRequestType,
413  const ::std::vector< OUString >* pDefaultPasswords = nullptr,
414  bool* pbIsDefaultPassword = nullptr );
415 
416  static css::uno::Sequence< css::beans::NamedValue > decryptGpgSession(
417  const css::uno::Sequence< css::uno::Sequence< css::beans::NamedValue > >& rGpgProperties);
418 
419 private:
421 };
422 
423 
424 } // namespace comphelper
425 
426 #endif
427 
428 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper that asks for a document password and checks its validity.
DocPasswordRequestType
Selects which UNO document password request type to use.
unsigned char sal_uInt8
Base class for a password verifier used by the DocPasswordHelper class below.
#define COMPHELPER_DLLPUBLIC
sal_Int32 const nLength