svx::MSCodec_Std97 Class Reference

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

#include <mscodec.hxx>

List of all members.

Public Member Functions

 MSCodec_Std97 ()
 ~MSCodec_Std97 ()
void InitKey (const sal_uInt16 pPassData[16], const sal_uInt8 pUnique[16])
 Initializes the algorithm with the specified password and document ID.
bool VerifyKey (const sal_uInt8 pSaltData[16], const sal_uInt8 pSaltDigest[16])
 Verifies the validity of the password using the passed salt data.
bool InitCipher (sal_uInt32 nCounter)
 Rekeys the codec using the specified counter.
bool CreateSaltDigest (const sal_uInt8 nSaltData[16], sal_uInt8 nSaltDigest[16])
 Creates an MD5 digest of salt digest.
bool Encode (const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen)
 Encodes a block of memory.
bool Decode (const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen)
 Decodes a block of memory.
bool Skip (sal_Size nDatLen)
 Lets the cipher skip a specific amount of bytes.
void GetEncryptKey (const sal_uInt8 pSalt[16], sal_uInt8 pSaltData[16], sal_uInt8 pSaltDigest[16])
 Gets salt data and salt digest.

Private Member Functions

void GetDigestFromSalt (const sal_uInt8 pSaltData[16], sal_uInt8 pDigest[16])
SVX_DLLPRIVATE MSCodec_Std97 (const MSCodec_Std97 &)
SVX_DLLPRIVATE MSCodec_Std97operator= (const MSCodec_Std97 &)

Private Attributes

rtlCipher m_hCipher
rtlDigest m_hDigest
sal_uInt8 m_pDigestValue [RTL_DIGEST_LENGTH_MD5]


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 182 of file mscodec.hxx.


Constructor & Destructor Documentation

svx::MSCodec_Std97::MSCodec_Std97 (  )  [explicit]

Definition at line 228 of file mscodec.cxx.

References m_hCipher, m_hDigest, and m_pDigestValue.

svx::MSCodec_Std97::~MSCodec_Std97 (  ) 

Definition at line 241 of file mscodec.cxx.

References m_hCipher, m_hDigest, and m_pDigestValue.

SVX_DLLPRIVATE svx::MSCodec_Std97::MSCodec_Std97 ( const MSCodec_Std97  )  [private]


Member Function Documentation

void svx::MSCodec_Std97::InitKey ( const sal_uInt16  pPassData[16],
const sal_uInt8  pUnique[16] 
)

Initializes the algorithm with the specified password and document ID.

Parameters:
pPassData Wide character array containing the password. Must be zero terminated, which results in a maximum length of 15 characters.
pUnique Unique document identifier read from or written to the file.

Definition at line 279 of file mscodec.cxx.

References svx::lcl_PrintDigest(), svx::lcl_PrintKeyData(), m_hDigest, and m_pDigestValue.

bool svx::MSCodec_Std97::VerifyKey ( const sal_uInt8  pSaltData[16],
const sal_uInt8  pSaltDigest[16] 
)

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

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

Parameters:
pSaltData Salt data block read from the file.
pSaltDigest Salt digest read from the file.
Returns:
true = Test was successful.

Definition at line 340 of file mscodec.cxx.

References GetDigestFromSalt(), InitCipher(), svx::lcl_PrintDigest(), and m_hCipher.

bool svx::MSCodec_Std97::InitCipher ( sal_uInt32  nCounter  ) 

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.

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

Parameters:
nCounter Block counter used to rekey the cipher.

Definition at line 374 of file mscodec.cxx.

References m_hCipher, m_hDigest, and m_pDigestValue.

Referenced by CreateSaltDigest(), GetEncryptKey(), and VerifyKey().

bool svx::MSCodec_Std97::CreateSaltDigest ( const sal_uInt8  nSaltData[16],
sal_uInt8  nSaltDigest[16] 
)

Creates an MD5 digest of salt digest.

Definition at line 411 of file mscodec.cxx.

References GetDigestFromSalt(), InitCipher(), svx::lcl_PrintDigest(), and m_hCipher.

bool svx::MSCodec_Std97::Encode ( const void *  pData,
sal_Size  nDatLen,
sal_uInt8 *  pBuffer,
sal_Size  nBufLen 
)

Encodes a block of memory.

See also:
rtl_cipher_encode()
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:
pData Unencrypted source data block.
nDatLen Size of the passed source data block.
pBuffer Destination buffer for the encrypted data.
nBufLen Size of the destination buffer.
Returns:
true = Encoding was successful (no error occured).

Definition at line 432 of file mscodec.cxx.

References m_hCipher.

bool svx::MSCodec_Std97::Decode ( const void *  pData,
sal_Size  nDatLen,
sal_uInt8 *  pBuffer,
sal_Size  nBufLen 
)

Decodes a block of memory.

See also:
rtl_cipher_decode()
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:
pData Encrypted source data block.
nDatLen Size of the passed source data block.
pBuffer Destination buffer for the decrypted data.
nBufLen Size of the destination buffer.
Returns:
true = Decoding was successful (no error occured).

Definition at line 444 of file mscodec.cxx.

References m_hCipher.

Referenced by Skip().

bool svx::MSCodec_Std97::Skip ( sal_Size  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().

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

Parameters:
nDatLen Number of bytes to be skipped (cipher "seeks" forward).

Definition at line 456 of file mscodec.cxx.

References Decode().

void svx::MSCodec_Std97::GetEncryptKey ( const sal_uInt8  pSalt[16],
sal_uInt8  pSaltData[16],
sal_uInt8  pSaltDigest[16] 
)

Gets salt data and salt digest.

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

Parameters:
pSalt Salt, a random number.
pSaltData Salt data block generated from the salt.
pSaltDigest Salt digest generated from the salt.

Definition at line 499 of file mscodec.cxx.

References InitCipher(), m_hCipher, and m_hDigest.

void svx::MSCodec_Std97::GetDigestFromSalt ( const sal_uInt8  pSaltData[16],
sal_uInt8  pDigest[16] 
) [private]

Definition at line 472 of file mscodec.cxx.

References m_hCipher, and m_hDigest.

Referenced by CreateSaltDigest(), and VerifyKey().

SVX_DLLPRIVATE MSCodec_Std97& svx::MSCodec_Std97::operator= ( const MSCodec_Std97  )  [private]


Member Data Documentation

rtlCipher svx::MSCodec_Std97::m_hCipher [private]

rtlDigest svx::MSCodec_Std97::m_hDigest [private]

sal_uInt8 svx::MSCodec_Std97::m_pDigestValue[RTL_DIGEST_LENGTH_MD5] [private]

Definition at line 332 of file mscodec.hxx.

Referenced by InitCipher(), InitKey(), MSCodec_Std97(), and ~MSCodec_Std97().


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

Generated on Thu Apr 29 16:03:11 2010 for ooo-build Module svx (ooo/OOO320_m15) by  doxygen 1.5.6