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

Encodes and decodes data from protected MSO 97+ documents. More...

#include <mscodec.hxx>

Inheritance diagram for msfilter::MSCodec_Std97:
[legend]
Collaboration diagram for msfilter::MSCodec_Std97:
[legend]

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_Std97operator= (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_uInt8m_aDocId
 
std::vector< sal_uInt8m_aDigestValue
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MSCodec_Std97() [1/2]

msfilter::MSCodec_Std97::MSCodec_Std97 ( )

Definition at line 260 of file mscodec.cxx.

References m_hDigest.

◆ ~MSCodec_Std97()

msfilter::MSCodec_Std97::~MSCodec_Std97 ( )
overridevirtual

Definition at line 279 of file mscodec.cxx.

References m_hDigest.

◆ MSCodec_Std97() [2/2]

msfilter::MSCodec_Std97::MSCodec_Std97 ( const MSCodec_Std97 )
privatedelete

Member Function Documentation

◆ CreateSaltDigest()

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.

◆ GetDigestFromSalt()

void msfilter::MSCodec_Std97::GetDigestFromSalt ( const sal_uInt8 pSaltData,
sal_uInt8 pDigest 
)
overridevirtual

Implements msfilter::MSCodec97.

Definition at line 551 of file mscodec.cxx.

References msfilter::MSCodec97::m_hCipher, and m_hDigest.

Referenced by CreateSaltDigest().

◆ GetEncryptKey()

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.

Parameters
pSaltSalt, a random number.
pSaltDataSalt data block generated from the salt.
pSaltDigestSalt digest generated from the salt.

Definition at line 578 of file mscodec.cxx.

References InitCipher(), msfilter::MSCodec97::m_hCipher, and m_hDigest.

◆ InitCipher()

bool msfilter::MSCodec_Std97::InitCipher ( sal_uInt32  nCounter)
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.

Parameters
nCounterBlock 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().

◆ InitKey()

void msfilter::MSCodec_Std97::InitKey ( const sal_uInt16  pPassData[16],
const sal_uInt8  pDocId[16] 
)
overridevirtual

Initializes the algorithm with the specified password and document ID.

Parameters
pPassDataWide character array containing the password. Must be zero terminated, which results in a maximum length of 15 characters.
pDocIdUnique 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.

◆ operator=()

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

Member Data Documentation

◆ m_hDigest

rtlDigest msfilter::MSCodec_Std97::m_hDigest
private

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