LibreOffice Module filter (master) 1
|
Encodes and decodes data from protected MSO 95- documents. More...
#include <mscodec.hxx>
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_Xor95 & | operator= (const MSCodec_Xor95 &)=delete |
Private Attributes | |
sal_uInt16 | mnKey |
sal_uInt16 | mnHash |
Base key from password. More... | |
int | mnRotateDistance |
Hash value from password. More... | |
Encodes and decodes data from protected MSO 95- documents.
Definition at line 40 of file mscodec.hxx.
|
explicit |
Definition at line 121 of file mscodec.cxx.
|
virtual |
Definition at line 129 of file mscodec.cxx.
|
privatedelete |
Key offset.
|
pure virtual |
Decodes a block of memory inplace.
@precond The codec must be initialized with InitKey() before this function can be used.
pnData | Encrypted data block. Will contain the decrypted data afterwards. |
nBytes | Size of the passed data block. |
Implemented in msfilter::MSCodec_XorXLS95, and msfilter::MSCodec_XorWord95.
uno::Sequence< beans::NamedValue > msfilter::MSCodec_Xor95::GetEncryptionData | ( | ) |
Retrieves the encryption data.
Definition at line 186 of file mscodec.cxx.
References comphelper::SequenceAsHashMap::getAsConstNamedValueList(), mnHash, mnKey, and mpnKey.
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.
bool msfilter::MSCodec_Xor95::InitCodec | ( | const css::uno::Sequence< css::beans::NamedValue > & | aData | ) |
Initializes the algorithm with the encryption data.
aData | The 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.
void msfilter::MSCodec_Xor95::InitKey | ( | const sal_uInt8 | pnPassData[16] | ) |
Initializes the algorithm with the specified password.
pPassData | Character 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.
|
privatedelete |
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.
nBytes | Number 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().
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.
nKey | Password key value read from the file. |
nHash | Password hash value read from the file. |
Definition at line 197 of file mscodec.cxx.
|
private |
Base key from password.
Definition at line 133 of file mscodec.hxx.
Referenced by GetEncryptionData(), InitCodec(), InitKey(), VerifyKey(), and ~MSCodec_Xor95().
|
private |
Definition at line 132 of file mscodec.hxx.
Referenced by GetEncryptionData(), InitCodec(), InitKey(), VerifyKey(), and ~MSCodec_Xor95().
|
protected |
Encryption key.
Definition at line 126 of file mscodec.hxx.
Referenced by msfilter::MSCodec_XorXLS95::Decode(), msfilter::MSCodec_XorWord95::Decode(), InitCipher(), and Skip().
|
private |
|
protected |
Definition at line 125 of file mscodec.hxx.
Referenced by msfilter::MSCodec_XorXLS95::Decode(), msfilter::MSCodec_XorWord95::Decode(), GetEncryptionData(), InitCodec(), InitKey(), and ~MSCodec_Xor95().