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

#include <mscodec.hxx>

Inheritance diagram for msfilter::MSCodec97:
[legend]

Public Member Functions

 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])
 

Protected Attributes

OUString m_sEncKeyName
 
size_t m_nHashLen
 
rtlCipher m_hCipher
 
std::vector< sal_uInt8m_aDocId
 
std::vector< sal_uInt8m_aDigestValue
 

Private Member Functions

 MSCodec97 (const MSCodec97 &)=delete
 
MSCodec97operator= (const MSCodec97 &)=delete
 

Detailed Description

Definition at line 179 of file mscodec.hxx.

Constructor & Destructor Documentation

◆ MSCodec97() [1/2]

msfilter::MSCodec97::MSCodec97 ( size_t  nHashLen,
OUString  aEncKeyName 
)

Definition at line 250 of file mscodec.cxx.

References m_hCipher.

◆ ~MSCodec97()

msfilter::MSCodec97::~MSCodec97 ( )
virtual

Definition at line 272 of file mscodec.cxx.

References m_aDigestValue, m_aDocId, and m_hCipher.

◆ MSCodec97() [2/2]

msfilter::MSCodec97::MSCodec97 ( const MSCodec97 )
privatedelete

Member Function Documentation

◆ Decode()

bool msfilter::MSCodec97::Decode ( const void *  pData,
std::size_t  nDatLen,
sal_uInt8 pBuffer,
std::size_t  nBufLen 
)

Decodes a block of memory.

See also
rtl_cipher_decode()

@precond The codec must be initialized with InitKey() before this function can be used. The destination buffer must be able to take all encoded data from the source buffer (usually this means it must be as long as or longer than the source buffer).

Parameters
pDataEncrypted source data block.
nDatLenSize of the passed source data block.
pBufferDestination buffer for the decrypted data.
nBufLenSize of the destination buffer.
Returns
true = Decoding was successful (no error occurred).

Definition at line 525 of file mscodec.cxx.

References m_hCipher, pData, and result.

Referenced by Skip().

◆ Encode()

bool msfilter::MSCodec97::Encode ( const void *  pData,
std::size_t  nDatLen,
sal_uInt8 pBuffer,
std::size_t  nBufLen 
)

Encodes a block of memory.

See also
rtl_cipher_encode()

@precond The codec must be initialized with InitKey() before this function can be used. The destination buffer must be able to take all unencoded data from the source buffer (usually this means it must be as long as or longer than the source buffer).

Parameters
pDataUnencrypted source data block.
nDatLenSize of the passed source data block.
pBufferDestination buffer for the encrypted data.
nBufLenSize of the destination buffer.
Returns
true = Encoding was successful (no error occurred).

Definition at line 515 of file mscodec.cxx.

References m_hCipher, pData, and result.

◆ GetDigestFromSalt()

virtual void msfilter::MSCodec97::GetDigestFromSalt ( const sal_uInt8 pSaltData,
sal_uInt8 pDigest 
)
pure virtual

◆ GetDocId()

void msfilter::MSCodec97::GetDocId ( sal_uInt8  pDocId[16])

Definition at line 610 of file mscodec.cxx.

References m_aDocId.

◆ GetEncryptionData()

uno::Sequence< beans::NamedValue > msfilter::MSCodec97::GetEncryptionData ( )
virtual

Retrieves the encryption data.

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

Reimplemented in msfilter::MSCodec_CryptoAPI.

Definition at line 330 of file mscodec.cxx.

References comphelper::SequenceAsHashMap::getAsConstNamedValueList(), m_aDigestValue, m_aDocId, m_nHashLen, and m_sEncKeyName.

Referenced by msfilter::MSCodec_CryptoAPI::GetEncryptionData().

◆ InitCipher()

virtual bool msfilter::MSCodec97::InitCipher ( sal_uInt32  nCounter)
pure virtual

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.

Implemented in msfilter::MSCodec_Std97, and msfilter::MSCodec_CryptoAPI.

Referenced by VerifyKey().

◆ InitCodec()

bool msfilter::MSCodec97::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 298 of file mscodec.cxx.

References aData, comphelper::SequenceAsHashMap::getUnpackedValueOrDefault(), msfilter::lcl_PrintDigest(), m_aDigestValue, m_aDocId, m_nHashLen, and m_sEncKeyName.

◆ InitKey()

virtual void msfilter::MSCodec97::InitKey ( const sal_uInt16  pPassData[16],
const sal_uInt8  pDocId[16] 
)
pure virtual

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.

Implemented in msfilter::MSCodec_Std97, and msfilter::MSCodec_CryptoAPI.

◆ operator=()

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

◆ Skip()

bool msfilter::MSCodec97::Skip ( std::size_t  nDatLen)

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
nDatLenNumber of bytes to be skipped (cipher "seeks" forward).

Definition at line 535 of file mscodec.cxx.

References Decode().

◆ VerifyKey()

bool msfilter::MSCodec97::VerifyKey ( const sal_uInt8 pSaltData,
const sal_uInt8 pSaltDigest 
)

Verifies the validity of the password using the passed salt data.

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

Parameters
pSaltDataSalt data block read from the file.
pSaltDigestSalt digest read from the file.
Returns
true = Test was successful.

Definition at line 395 of file mscodec.cxx.

References aBuffer, GetDigestFromSalt(), InitCipher(), msfilter::lcl_PrintDigest(), m_hCipher, m_nHashLen, and result.

Member Data Documentation

◆ m_aDigestValue

std::vector<sal_uInt8> msfilter::MSCodec97::m_aDigestValue
protected

◆ m_aDocId

std::vector<sal_uInt8> msfilter::MSCodec97::m_aDocId
protected

◆ m_hCipher

rtlCipher msfilter::MSCodec97::m_hCipher
protected

◆ m_nHashLen

size_t msfilter::MSCodec97::m_nHashLen
protected

Definition at line 322 of file mscodec.hxx.

Referenced by GetEncryptionData(), InitCodec(), and VerifyKey().

◆ m_sEncKeyName

OUString msfilter::MSCodec97::m_sEncKeyName
protected

Definition at line 321 of file mscodec.hxx.

Referenced by GetEncryptionData(), and InitCodec().


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