StarEncryption.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libstaroffice
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/*
* StarEncryption to read/parse some basic encryption in StarOffice documents
*
*/
#ifndef STAR_ENCRYPTION
# define STAR_ENCRYPTION
#include <vector>
#include "libstaroffice_internal.hxx"
#include "STOFFDebug.hxx"
class StarEncryption
{
public:
StarEncryption();
explicit StarEncryption(std::string const &password);
virtual ~StarEncryption();
bool decode(std::vector<uint8_t> &data) const
{
return decode(data, m_password);
}
bool checkPassword(uint32_t date, uint32_t time, std::vector<uint8_t> const &cryptDateTime) const;
bool guessPassword(uint32_t date, uint32_t time, std::vector<uint8_t> const &cryptDateTime);
static STOFFInputStreamPtr decodeStream(STOFFInputStreamPtr input, uint8_t mask);
static uint8_t getMaskToDecodeStream(uint8_t src, uint8_t dest);
protected:
static bool decode(std::vector<uint8_t> &data, std::vector<uint8_t> const &cryptPasswd);
static bool findEncryptedPassword(std::vector<uint8_t> const &src, std::vector<uint8_t> const &dest, uint8_t c0c1, std::vector<uint8_t> &crypter);
std::vector<uint8_t> m_password;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFDebug.hxx
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