StarEncryption Class Reference documentation

Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
StarEncryption Class Reference

the main class to read/. More...

`#include <StarEncryption.hxx>`

## Public Member Functions
| StarEncryption ()
| constructor More...
| StarEncryption (std::string const &password)
| constructor knowing the original password More...
virtual | ~StarEncryption ()
| destructor More...
bool | decode (std::vector< uint8_t > &data) const
| decodes a string More...
bool | checkPassword (uint32_t date, uint32_t time, std::vector< uint8_t > const &cryptDateTime) const
| checks that the password is correct More...
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. More...

## Static Public Member Functions
static STOFFInputStreamPtr | decodeStream (STOFFInputStreamPtr input, uint8_t mask)
| decode a zone given a mask More...
static uint8_t | getMaskToDecodeStream (uint8_t src, uint8_t dest)
| retrieves a mask needed to decode a stream knowing a src and dest bytes More...

## Static Protected Member Functions
static bool | decode (std::vector< uint8_t > &data, std::vector< uint8_t > const &cryptPasswd)
| decodes a string More...
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 of c0+c1 More...

## Protected Attributes
std::vector< uint8_t > | m_password
| the crypted password More...

## Detailed Description

the main class to read/.

. some basic encryption in StarOffice documents

## Constructor & Destructor Documentation

## ◆ StarEncryption() [1/2]

StarEncryption::StarEncryption | ( |  | ) |

constructor

## ◆ StarEncryption() [2/2]

StarEncryption::StarEncryption | ( | std::string const & | password | ) |
| explicit

constructor knowing the original password

## ◆ ~StarEncryption()

StarEncryption::~StarEncryption | ( |  | ) |
| virtual

destructor

## Member Function Documentation

## ◆ checkPassword()

bool StarEncryption::checkPassword | ( | uint32_t | date,
|  | uint32_t | time,
|  | std::vector< uint8_t > const & | cryptDateTime
| ) |  | const

checks that the password is correct

## ◆ decode() [1/2]

bool StarEncryption::decode | ( | std::vector< uint8_t > & | data | ) | const
| inline

decodes a string

Referenced by checkPassword(), decode(), guessPassword(), and StarEncryption().

## ◆ decode() [2/2]

bool StarEncryption::decode | ( | std::vector< uint8_t > & | data,
|  | std::vector< uint8_t > const & | cryptPasswd
| ) |  |
| staticprotected

decodes a string

## ◆ decodeStream()

STOFFInputStreamPtr StarEncryption::decodeStream | ( | STOFFInputStreamPtr | input,
|  | uint8_t | mask
| ) |  |
| static

decode a zone given a mask

Referenced by StarObjectSpreadsheet::readCalcDocument(), and StarObjectDraw::readDrawDocument().

## ◆ findEncryptedPassword()

bool StarEncryption::findEncryptedPassword | ( | std::vector< uint8_t > const & | src,
|  | std::vector< uint8_t > const & | dest,
|  | uint8_t | c0c1,
|  | std::vector< uint8_t > & | crypter
| ) |  |
| staticprotected

try to find the crypter knowing the original data(16 bytes), the final data(16 bytes) and the value of c0+c1

Note
  if we know the value of crypter[0]+crypter[1] (modulo 256), there is at most one potential candidate. So we compute it checking that crypter[0]+crypter[1] verifies the modulo relation.

Referenced by guessPassword().

## ◆ getMaskToDecodeStream()

uint8_t StarEncryption::getMaskToDecodeStream | ( | uint8_t | src,
|  | uint8_t | dest
| ) |  |
| static

retrieves a mask needed to decode a stream knowing a src and dest bytes

Note
  given a passwd, SvStream creates a mask from the passwd and used it to decode a stream, thus we need only this mask for decoding a crypt stream.

Moreover as this method is used to crypt a StarCalcDocument stream, and we know that a valid StarCalcDocument stream must begin by XX42, we can easily retrieve the password mask and use it to uncrypt this stream...

Referenced by StarObjectSpreadsheet::readCalcDocument(), and StarObjectDraw::readDrawDocument().

## ◆ guessPassword()

bool StarEncryption::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.

Note
  if we know the date, the time and the encrypted date time string, there is at most 256 encrypted passwords which can correspond (in pratical case, I find about 10 potential candidates). So we loop over these potential encrypted passwords and recompute the original password to select the passwords which ends with more ' ' characters than the other one. We fail if we find no encrypted password or if we can not select an unique best canditate.

As the StarOffice's algorithm adds trailing spaces if the password does not contain 16 characters, this may give almost alway good result if the user has not chosen a password with 16 characters.

If we success, we store the encrypted password to be used for further encryption.

## Member Data Documentation

## ◆ m_password

std::vector<uint8_t> StarEncryption::m_password
| protected

the crypted password

Referenced by decode(), guessPassword(), and StarEncryption().

The documentation for this class was generated from the following files:

- StarEncryption.hxx
- StarEncryption.cxx