LibreOffice Module filter (master) 1
|
Encodes and decodes data from protected MSO 97+ documents. More...
#include <mscodec.hxx>
Public Member Functions | |
MSCodec_Std97 () | |
virtual | ~MSCodec_Std97 () override |
virtual void | InitKey (const sal_uInt16 pPassData[16], const sal_uInt8 pDocId[16]) override |
Initializes the algorithm with the specified password and document ID. More... | |
virtual bool | InitCipher (sal_uInt32 nCounter) override |
Rekeys the codec using the specified counter. More... | |
void | CreateSaltDigest (const sal_uInt8 nSaltData[16], sal_uInt8 nSaltDigest[16]) |
Creates an MD5 digest of salt digest. More... | |
void | GetEncryptKey (const sal_uInt8 pSalt[16], sal_uInt8 pSaltData[16], sal_uInt8 pSaltDigest[16]) |
Gets salt data and salt digest. More... | |
virtual void | GetDigestFromSalt (const sal_uInt8 *pSaltData, sal_uInt8 *pDigest) override |
Public Member Functions inherited from msfilter::MSCodec97 | |
MSCodec97 (size_t nHashLen, OUString aEncKeyName) | |
virtual | ~MSCodec97 () |
bool | InitCodec (const css::uno::Sequence< css::beans::NamedValue > &aData) |
Initializes the algorithm with the encryption data. More... | |
virtual css::uno::Sequence< css::beans::NamedValue > | GetEncryptionData () |
Retrieves the encryption data. More... | |
virtual void | InitKey (const sal_uInt16 pPassData[16], const sal_uInt8 pDocId[16])=0 |
Initializes the algorithm with the specified password and document ID. More... | |
bool | VerifyKey (const sal_uInt8 *pSaltData, const sal_uInt8 *pSaltDigest) |
Verifies the validity of the password using the passed salt data. More... | |
virtual void | GetDigestFromSalt (const sal_uInt8 *pSaltData, sal_uInt8 *pDigest)=0 |
virtual bool | InitCipher (sal_uInt32 nCounter)=0 |
Rekeys the codec using the specified counter. More... | |
bool | Encode (const void *pData, std::size_t nDatLen, sal_uInt8 *pBuffer, std::size_t nBufLen) |
Encodes a block of memory. More... | |
bool | Decode (const void *pData, std::size_t nDatLen, sal_uInt8 *pBuffer, std::size_t nBufLen) |
Decodes a block of memory. More... | |
bool | Skip (std::size_t nDatLen) |
Lets the cipher skip a specific amount of bytes. More... | |
void | GetDocId (sal_uInt8 pDocId[16]) |
Private Member Functions | |
MSCodec_Std97 (const MSCodec_Std97 &)=delete | |
MSCodec_Std97 & | operator= (const MSCodec_Std97 &)=delete |
Private Attributes | |
rtlDigest | m_hDigest |
Additional Inherited Members | |
Protected Attributes inherited from msfilter::MSCodec97 | |
OUString | m_sEncKeyName |
size_t | m_nHashLen |
rtlCipher | m_hCipher |
std::vector< sal_uInt8 > | m_aDocId |
std::vector< sal_uInt8 > | m_aDigestValue |
Encodes and decodes data from protected MSO 97+ documents.
This is a wrapper class around low level cryptographic functions from RTL. Implementation is based on the wvDecrypt package by Caolan McNamara: http://www.csn.ul.ie/~caolan/docs/wvDecrypt.html
Definition at line 334 of file mscodec.hxx.
msfilter::MSCodec_Std97::MSCodec_Std97 | ( | ) |
Definition at line 260 of file mscodec.cxx.
References m_hDigest.
|
overridevirtual |
Definition at line 279 of file mscodec.cxx.
References m_hDigest.
|
privatedelete |
void msfilter::MSCodec_Std97::CreateSaltDigest | ( | const sal_uInt8 | nSaltData[16], |
sal_uInt8 | nSaltDigest[16] | ||
) |
Creates an MD5 digest of salt digest.
Definition at line 498 of file mscodec.cxx.
References GetDigestFromSalt(), InitCipher(), msfilter::lcl_PrintDigest(), and msfilter::MSCodec97::m_hCipher.
|
overridevirtual |
Implements msfilter::MSCodec97.
Definition at line 551 of file mscodec.cxx.
References msfilter::MSCodec97::m_hCipher, and m_hDigest.
Referenced by CreateSaltDigest().
void msfilter::MSCodec_Std97::GetEncryptKey | ( | const sal_uInt8 | pSalt[16], |
sal_uInt8 | pSaltData[16], | ||
sal_uInt8 | pSaltDigest[16] | ||
) |
Gets salt data and salt digest.
@precond The codec must be initialized with InitKey() before this function can be used.
pSalt | Salt, a random number. |
pSaltData | Salt data block generated from the salt. |
pSaltDigest | Salt digest generated from the salt. |
Definition at line 578 of file mscodec.cxx.
References InitCipher(), msfilter::MSCodec97::m_hCipher, and m_hDigest.
|
overridevirtual |
Rekeys the codec using the specified counter.
After reading a specific amount of data the cipher algorithm needs to be rekeyed using a counter that counts the data blocks.
The block size is for example 512 Bytes for Word files and 1024 Bytes for Excel files.
@precond The codec must be initialized with InitKey() before this function can be used.
nCounter | Block counter used to rekey the cipher. |
Implements msfilter::MSCodec97.
Definition at line 437 of file mscodec.cxx.
References msfilter::MSCodec97::m_aDigestValue, msfilter::MSCodec97::m_hCipher, m_hDigest, and result.
Referenced by CreateSaltDigest(), and GetEncryptKey().
|
overridevirtual |
Initializes the algorithm with the specified password and document ID.
pPassData | Wide character array containing the password. Must be zero terminated, which results in a maximum length of 15 characters. |
pDocId | Unique document identifier read from or written to the file. |
Implements msfilter::MSCodec97.
Definition at line 340 of file mscodec.cxx.
References comphelper::DocPasswordHelper::GenerateStd97Key(), msfilter::lcl_PrintDigest(), msfilter::MSCodec97::m_aDigestValue, and msfilter::MSCodec97::m_aDocId.
|
privatedelete |
|
private |
Definition at line 396 of file mscodec.hxx.
Referenced by GetDigestFromSalt(), GetEncryptKey(), InitCipher(), MSCodec_Std97(), and ~MSCodec_Std97().