LibreOffice Module filter (master) 1
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
msfilter::MSCodec_Xor95 Class Referenceabstract

Encodes and decodes data from protected MSO 95- documents. More...

#include <mscodec.hxx>

Inheritance diagram for msfilter::MSCodec_Xor95:
[legend]

Public Member Functions

 MSCodec_Xor95 (int nRotateDistance)
 
virtual ~MSCodec_Xor95 ()
 
void InitKey (const sal_uInt8 pnPassData[16])
 Initializes the algorithm with the specified password. More...
 
bool InitCodec (const css::uno::Sequence< css::beans::NamedValue > &aData)
 Initializes the algorithm with the encryption data. More...
 
css::uno::Sequence< css::beans::NamedValue > GetEncryptionData ()
 Retrieves the encryption data. More...
 
bool VerifyKey (sal_uInt16 nKey, sal_uInt16 nHash) const
 Verifies the validity of the password using the passed key and hash. More...
 
void InitCipher ()
 Reinitializes the codec to start a new memory block. More...
 
virtual void Decode (sal_uInt8 *pnData, std::size_t nBytes)=0
 Decodes a block of memory inplace. More...
 
void Skip (std::size_t nBytes)
 Lets the cipher skip a specific amount of bytes. More...
 

Protected Attributes

sal_uInt8 mpnKey [16] = {}
 
std::size_t mnOffset
 Encryption key. More...
 

Private Member Functions

 MSCodec_Xor95 (const MSCodec_Xor95 &)=delete
 Key offset. More...
 
MSCodec_Xor95operator= (const MSCodec_Xor95 &)=delete
 

Private Attributes

sal_uInt16 mnKey
 
sal_uInt16 mnHash
 Base key from password. More...
 
int mnRotateDistance
 Hash value from password. More...
 

Detailed Description

Encodes and decodes data from protected MSO 95- documents.

Definition at line 40 of file mscodec.hxx.

Constructor & Destructor Documentation

◆ MSCodec_Xor95() [1/2]

msfilter::MSCodec_Xor95::MSCodec_Xor95 ( int  nRotateDistance)
explicit

Definition at line 121 of file mscodec.cxx.

◆ ~MSCodec_Xor95()

msfilter::MSCodec_Xor95::~MSCodec_Xor95 ( )
virtual

Definition at line 129 of file mscodec.cxx.

References mnHash, mnKey, and mpnKey.

◆ MSCodec_Xor95() [2/2]

msfilter::MSCodec_Xor95::MSCodec_Xor95 ( const MSCodec_Xor95 )
privatedelete

Key offset.

Member Function Documentation

◆ Decode()

virtual void msfilter::MSCodec_Xor95::Decode ( sal_uInt8 pnData,
std::size_t  nBytes 
)
pure virtual

Decodes a block of memory inplace.

@precond The codec must be initialized with InitKey() before this function can be used.

Parameters
pnDataEncrypted data block. Will contain the decrypted data afterwards.
nBytesSize of the passed data block.

Implemented in msfilter::MSCodec_XorXLS95, and msfilter::MSCodec_XorWord95.

◆ GetEncryptionData()

uno::Sequence< beans::NamedValue > msfilter::MSCodec_Xor95::GetEncryptionData ( )

Retrieves the encryption data.

Returns
The sequence contains the necessary data to initialize the codec.

Definition at line 186 of file mscodec.cxx.

References comphelper::SequenceAsHashMap::getAsConstNamedValueList(), mnHash, mnKey, and mpnKey.

◆ InitCipher()

void msfilter::MSCodec_Xor95::InitCipher ( )

Reinitializes the codec to start a new memory block.

Resets the internal key offset to 0.

@precond The codec must be initialized with InitKey() before this function can be used.

Definition at line 202 of file mscodec.cxx.

References mnOffset.

◆ InitCodec()

bool msfilter::MSCodec_Xor95::InitCodec ( const css::uno::Sequence< css::beans::NamedValue > &  aData)

Initializes the algorithm with the encryption data.

Parameters
aDataThe sequence contains the necessary data to initialize the codec.

Definition at line 165 of file mscodec.cxx.

References aData, comphelper::SequenceAsHashMap::getUnpackedValueOrDefault(), mnHash, mnKey, and mpnKey.

◆ InitKey()

void msfilter::MSCodec_Xor95::InitKey ( const sal_uInt8  pnPassData[16])

Initializes the algorithm with the specified password.

Parameters
pPassDataCharacter array containing the password. Must be zero terminated, which results in a maximum length of 15 characters.

Definition at line 135 of file mscodec.cxx.

References mnHash, mnKey, mnRotateDistance, mpnKey, and nIndex.

◆ operator=()

MSCodec_Xor95 & msfilter::MSCodec_Xor95::operator= ( const MSCodec_Xor95 )
privatedelete

◆ Skip()

void msfilter::MSCodec_Xor95::Skip ( std::size_t  nBytes)

Lets the cipher skip a specific amount of bytes.

This function sets the cipher to the same state as if the specified amount of data has been decoded with one or more calls of Decode().

@precond The codec must be initialized with InitKey() before this function can be used.

Parameters
nBytesNumber of bytes to be skipped (cipher "seeks" forward).

Definition at line 245 of file mscodec.cxx.

References mnOffset.

Referenced by msfilter::MSCodec_XorXLS95::Decode(), and msfilter::MSCodec_XorWord95::Decode().

◆ VerifyKey()

bool msfilter::MSCodec_Xor95::VerifyKey ( sal_uInt16  nKey,
sal_uInt16  nHash 
) const

Verifies the validity of the password using the passed key and hash.

@precond The codec must be initialized with InitKey() before this function can be used.

Parameters
nKeyPassword key value read from the file.
nHashPassword hash value read from the file.
Returns
true = Test was successful.

Definition at line 197 of file mscodec.cxx.

References mnHash, and mnKey.

Member Data Documentation

◆ mnHash

sal_uInt16 msfilter::MSCodec_Xor95::mnHash
private

Base key from password.

Definition at line 133 of file mscodec.hxx.

Referenced by GetEncryptionData(), InitCodec(), InitKey(), VerifyKey(), and ~MSCodec_Xor95().

◆ mnKey

sal_uInt16 msfilter::MSCodec_Xor95::mnKey
private

Definition at line 132 of file mscodec.hxx.

Referenced by GetEncryptionData(), InitCodec(), InitKey(), VerifyKey(), and ~MSCodec_Xor95().

◆ mnOffset

std::size_t msfilter::MSCodec_Xor95::mnOffset
protected

Encryption key.

Definition at line 126 of file mscodec.hxx.

Referenced by msfilter::MSCodec_XorXLS95::Decode(), msfilter::MSCodec_XorWord95::Decode(), InitCipher(), and Skip().

◆ mnRotateDistance

int msfilter::MSCodec_Xor95::mnRotateDistance
private

Hash value from password.

Definition at line 134 of file mscodec.hxx.

Referenced by InitKey().

◆ mpnKey

sal_uInt8 msfilter::MSCodec_Xor95::mpnKey[16] = {}
protected

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