StarEncryption.hxx Source File documentation

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
43#include "libstaroffice_internal.hxx"
44#include "STOFFDebug.hxx"
45
51 class StarEncryption
52{
53public:
55 StarEncryption();
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:
STOFFDebug.hxx
StarEncryption
the main class to read/.
Definition: StarEncryption.hxx:52
StarEncryption::getMaskToDecodeStream
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
StarEncryption::checkPassword
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
StarEncryption::~StarEncryption
virtual ~StarEncryption()
destructor
Definition: StarEncryption.cxx:70
StarEncryption::decode
bool decode(std::vector< uint8_t > &data) const
decodes a string
Definition: StarEncryption.hxx:62
StarEncryption::StarEncryption
StarEncryption()
constructor
Definition: StarEncryption.cxx:49
StarEncryption::m_password
std::vector< uint8_t > m_password
the crypted password
Definition: StarEncryption.hxx:115
StarEncryption::findEncryptedPassword
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
StarEncryption::guessPassword
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
StarEncryption::decodeStream
static STOFFInputStreamPtr decodeStream(STOFFInputStreamPtr input, uint8_t mask)
decode a zone given a mask
Definition: StarEncryption.cxx:192
libstaroffice_internal.hxx
STOFFInputStreamPtr
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition: libstaroffice_internal.hxx:489