Coverage Report

Created: 2026-09-14 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwpd/src/lib/WPXEncryption.h
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* libwpd
3
 * Version: MPL 2.0 / LGPLv2.1+
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
 * Major Contributor(s):
10
 * Copyright (C) 2007 Jaroslav Fojtik (JaFojtik@seznam.cz)
11
 * Copyright (C) 2007 Fridrich Strba (fridrich.strba@bluewin.ch)
12
 *
13
 * For minor contributions see the git repository.
14
 *
15
 * Alternatively, the contents of this file may be used under the terms
16
 * of the GNU Lesser General Public License Version 2.1 or later
17
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18
 * applicable instead of those above.
19
 *
20
 * For further information visit http://libwpd.sourceforge.net
21
 */
22
23
/* "This product is not manufactured, approved, or supported by
24
 * Corel Corporation or Corel Corporation Limited."
25
 */
26
27
#ifndef WPXENCRYPTION_H
28
#define WPXENCRYPTION_H
29
30
#include <memory>
31
32
#include <librevenge/librevenge.h>
33
#include <libwpd/libwpd.h>
34
35
class WPXEncryption
36
{
37
public:
38
  WPXEncryption(const char *password, const unsigned long encryptionStartOffset = 0);
39
  ~WPXEncryption();
40
41
  const unsigned char *readAndDecrypt(librevenge::RVNGInputStream *input, unsigned long numBytes, unsigned long &numBytesRead);
42
  unsigned short getCheckSum() const;
43
44
  void setEncryptionStartOffset(unsigned long encryptionStartOffset)
45
0
  {
46
0
    m_encryptionStartOffset = encryptionStartOffset;
47
0
  }
48
  unsigned long getEncryptionStartOffset() const
49
0
  {
50
0
    return m_encryptionStartOffset;
51
0
  }
52
53
  void setEncryptionMaskBase(unsigned char encryptionMaskBase)
54
0
  {
55
0
    m_encryptionMaskBase = encryptionMaskBase;
56
0
  }
57
  unsigned char getEncryptionMaskBase() const
58
0
  {
59
0
    return m_encryptionMaskBase;
60
0
  }
61
62
  const librevenge::RVNGString &getEncryptionPassword() const
63
0
  {
64
0
    return m_password;
65
0
  }
66
67
private:
68
  std::unique_ptr<unsigned char[]> m_buffer;
69
  librevenge::RVNGString m_password;
70
  unsigned long m_encryptionStartOffset;
71
  unsigned char m_encryptionMaskBase;
72
  // Unimplemented to prevent compiler from creating crasher ones
73
  WPXEncryption(const WPXEncryption &);
74
  WPXEncryption &operator=(const WPXEncryption &);
75
};
76
77
#endif /* WPXENCRYPTION_H */
78
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */