From 3460624e393c6cd754dae0ca17eb9cda44343f30 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 4 Nov 2010 17:56:39 +0100 Subject: pl08: #163778# use EncryptionData from MediaDescriptor --- oox/inc/oox/core/binarycodec.hxx | 50 ++++++++++++++++++++++++++++++++-------- oox/inc/oox/core/filterbase.hxx | 7 +++--- 2 files changed, 44 insertions(+), 13 deletions(-) (limited to 'oox/inc/oox/core') diff --git a/oox/inc/oox/core/binarycodec.hxx b/oox/inc/oox/core/binarycodec.hxx index 8abafffa2481..ce57e190f088 100644 --- a/oox/inc/oox/core/binarycodec.hxx +++ b/oox/inc/oox/core/binarycodec.hxx @@ -28,6 +28,9 @@ #ifndef OOX_CORE_BINARYCODEC_HXX #define OOX_CORE_BINARYCODEC_HXX +#include +#include + #include #include @@ -85,6 +88,22 @@ public: */ void initKey( const sal_uInt8 pnPassData[ 16 ] ); + /** Initializes the algorithm with the encryption data. + + @param aData + The sequence contains the necessary data to initialize + the codec. + */ + bool initCodec( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aData ); + + /** Retrieves the encryption data + + @return + The sequence contains the necessary data to initialize + the codec. + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > getEncryptionData(); + /** Verifies the validity of the password using the passed key and hash. @precond @@ -150,16 +169,6 @@ public: */ bool skip( sal_Int32 nBytes ); - // static ----------------------------------------------------------------- - - /** Calculates the 16-bit hash value for the given password. - - The password data may be longer than 16 bytes. The array does not need - to be terminated with a null byte (but it can without invalidating the - result). - */ - static sal_uInt16 getHash( const sal_uInt8* pnPassData, sal_Int32 nSize ); - private: CodecType meCodecType; /// Codec type. sal_uInt8 mpnKey[ 16 ]; /// Encryption key. @@ -189,6 +198,22 @@ public: ~BinaryCodec_RCF(); + /** Initializes the algorithm with the encryption data. + + @param aData + The sequence contains the necessary data to initialize + the codec. + */ + bool initCodec( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aData ); + + /** Retrieves the encryption data + + @return + The sequence contains the necessary data to initialize + the codec. + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > getEncryptionData(); + /** Initializes the algorithm with the specified password and document ID. @param pnPassData @@ -278,9 +303,14 @@ public: bool skip( sal_Int32 nBytes ); private: + void InitKeyImpl( + const sal_uInt8 pKeyData[64], + const sal_uInt8 pUnique[16] ); + rtlCipher mhCipher; rtlDigest mhDigest; sal_uInt8 mpnDigestValue[ RTL_DIGEST_LENGTH_MD5 ]; + sal_uInt8 mpnUnique[16]; }; // ============================================================================ diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index 1757b2be4334..9d9b8dcca515 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -194,9 +195,9 @@ public: /** Returns a helper for the handling of OLE obejcts. */ ::oox::ole::OleObjectHelper& getOleObjectHelper() const; - /** Requests a password from the media descriptor or from the user. On - success, the password will be inserted into the media descriptor. */ - ::rtl::OUString requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const; + /** Requests the encryption data from the media descriptor or from the user. On + success, the encryption data will be inserted into the media descriptor. */ + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > requestEncryptionData( ::comphelper::IDocPasswordVerifier& rVerifier ) const; /** Imports the raw binary data from the specified stream. @return True, if the data could be imported from the stream. */ -- cgit v1.2.3