StarEncryption.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3/* libstaroffice
4* Version: MPL 2.0 / LGPLv2+
5*
6* The contents of this file are subject to the Mozilla Public License Version
7* 2.0 (the "License"); you may not use this file except in compliance with
8* the License or as specified alternatively below. You may obtain a copy of
9* the License at http://www.mozilla.org/MPL/
10*
11* Software distributed under the License is distributed on an "AS IS" basis,
12* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13* for the specific language governing rights and limitations under the
14* License.
15*
16* Major Contributor(s):
17* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20* Copyright (C) 2006, 2007 Andrew Ziem
21* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22*
23*
24* All Rights Reserved.
25*
26* For minor contributions see the git repository.
27*
28* Alternatively, the contents of this file may be used under the terms of
29* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30* in which case the provisions of the LGPLv2+ are applicable
31* instead of those above.
32*/
33
34/*
35 * StarEncryption to read/parse some basic encryption in StarOffice documents
36 *
37 */
38#ifndef STAR_ENCRYPTION
39# define STAR_ENCRYPTION
40
41#include <vector>
42
44#include "STOFFDebug.hxx"
45
52{
53public:
57 explicit StarEncryption(std::string const &password);
59 virtual ~StarEncryption();
60
62 bool decode(std::vector<uint8_t> &data) const
63 {
64 return decode(data, m_password);
65 }
67 bool checkPassword(uint32_t date, uint32_t time, std::vector<uint8_t> const &cryptDateTime) const;
88 bool guessPassword(uint32_t date, uint32_t time, std::vector<uint8_t> const &cryptDateTime);
89
91 static STOFFInputStreamPtr decodeStream(STOFFInputStreamPtr input, uint8_t mask);
102 static uint8_t getMaskToDecodeStream(uint8_t src, uint8_t dest);
103protected:
105 static bool decode(std::vector<uint8_t> &data, std::vector<uint8_t> const &cryptPasswd);
113 static bool findEncryptedPassword(std::vector<uint8_t> const &src, std::vector<uint8_t> const &dest, uint8_t c0c1, std::vector<uint8_t> &crypter);
115 std::vector<uint8_t> m_password;
116};
117#endif
118// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
the main class to read/.
Definition: StarEncryption.hxx:52
static uint8_t getMaskToDecodeStream(uint8_t src, uint8_t dest)
retrieves a mask needed to decode a stream knowing a src and dest bytes
Definition: StarEncryption.cxx:216
bool checkPassword(uint32_t date, uint32_t time, std::vector< uint8_t > const &cryptDateTime) const
checks that the password is correct
Definition: StarEncryption.cxx:101
virtual ~StarEncryption()
destructor
Definition: StarEncryption.cxx:70
bool decode(std::vector< uint8_t > &data) const
decodes a string
Definition: StarEncryption.hxx:62
StarEncryption()
constructor
Definition: StarEncryption.cxx:49
std::vector< uint8_t > m_password
the crypted password
Definition: StarEncryption.hxx:115
static bool findEncryptedPassword(std::vector< uint8_t > const &src, std::vector< uint8_t > const &dest, uint8_t c0c1, std::vector< uint8_t > &crypter)
try to find the crypter knowing the original data(16 bytes), the final data(16 bytes) and the value o...
Definition: StarEncryption.cxx:173
bool guessPassword(uint32_t date, uint32_t time, std::vector< uint8_t > const &cryptDateTime)
tries to guess the password, assuming that the user's password has at most 15 characters.
Definition: StarEncryption.cxx:119
static STOFFInputStreamPtr decodeStream(STOFFInputStreamPtr input, uint8_t mask)
decode a zone given a mask
Definition: StarEncryption.cxx:192
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition: libstaroffice_internal.hxx:489

Generated on Fri Apr 14 2023 04:41:10 for libstaroffice by doxygen 1.9.6