summaryrefslogtreecommitdiffstats
path: root/sc/source/filter/inc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-10-20 16:07:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-10-21 11:16:11 +0100
commit1473ce030314027c01c98f513407ed0897328585 (patch)
tree857b5173bcaf0ca44dff6533f69eb92440088a56 /sc/source/filter/inc
parentsplit MSCodec_Std97 into a baseclass MSCodec97 (diff)
downloadcore-1473ce030314027c01c98f513407ed0897328585.tar.gz
core-1473ce030314027c01c98f513407ed0897328585.zip
implement CryptoAPI RC4+SHA1 encryption scheme for xls import
there might be other variants out there in practice, but this works for default encrypted xls of excel 2013 Change-Id: I91c0e1d1d95fbd1c68966650e7ac7d23276bcbe3
Diffstat (limited to 'sc/source/filter/inc')
-rw-r--r--sc/source/filter/inc/xistream.hxx67
1 files changed, 54 insertions, 13 deletions
diff --git a/sc/source/filter/inc/xistream.hxx b/sc/source/filter/inc/xistream.hxx
index 4e0e63bd84e5..3a53643ef1cf 100644
--- a/sc/source/filter/inc/xistream.hxx
+++ b/sc/source/filter/inc/xistream.hxx
@@ -119,16 +119,7 @@ private:
/** Decrypts BIFF8 stream contents using the given document identifier. */
class XclImpBiff8Decrypter : public XclImpDecrypter
{
-public:
- explicit XclImpBiff8Decrypter( sal_uInt8 pnSalt[ 16 ],
- sal_uInt8 pnVerifier[ 16 ], sal_uInt8 pnVerifierHash[ 16 ] );
-
private:
- /** Private copy c'tor for OnClone(). */
- explicit XclImpBiff8Decrypter( const XclImpBiff8Decrypter& rSrc );
-
- /** Implementation of cloning this object. */
- virtual XclImpBiff8Decrypter* OnClone() const override;
/** Implements password verification and initialization of the decoder. */
virtual css::uno::Sequence< css::beans::NamedValue >
OnVerifyPassword( const OUString& rPassword ) override;
@@ -143,12 +134,62 @@ private:
/** Returns the block offset corresponding to the passed stream position. */
static sal_uInt16 GetOffset( std::size_t nStrmPos );
+protected:
+ explicit XclImpBiff8Decrypter(const std::vector<sal_uInt8>& rSalt,
+ const std::vector<sal_uInt8>& rVerifier,
+ const std::vector<sal_uInt8>& rVerifierHash);
+
+ explicit XclImpBiff8Decrypter(const XclImpBiff8Decrypter& rSrc);
+
+ css::uno::Sequence< css::beans::NamedValue > maEncryptionData;
+ std::vector< sal_uInt8 > maSalt;
+ std::vector< sal_uInt8 > maVerifier;
+ std::vector< sal_uInt8 > maVerifierHash;
+ msfilter::MSCodec97* mpCodec; /// Crypto algorithm implementation.
+};
+
+class XclImpBiff8StdDecrypter : public XclImpBiff8Decrypter
+{
+public:
+ explicit XclImpBiff8StdDecrypter(const std::vector<sal_uInt8>& rSalt,
+ const std::vector<sal_uInt8>& rVerifier,
+ const std::vector<sal_uInt8>& rVerifierHash)
+ : XclImpBiff8Decrypter(rSalt, rVerifier, rVerifierHash)
+ {
+ mpCodec = &maCodec;
+ }
+
+private:
+ /** Private copy c'tor for OnClone(). */
+ explicit XclImpBiff8StdDecrypter(const XclImpBiff8StdDecrypter& rSrc);
+
+ /** Implementation of cloning this object. */
+ virtual XclImpBiff8StdDecrypter* OnClone() const override;
+
private:
::msfilter::MSCodec_Std97 maCodec; /// Crypto algorithm implementation.
- css::uno::Sequence< css::beans::NamedValue > maEncryptionData;
- ::std::vector< sal_uInt8 > maSalt;
- ::std::vector< sal_uInt8 > maVerifier;
- ::std::vector< sal_uInt8 > maVerifierHash;
+};
+
+class XclImpBiff8CryptoAPIDecrypter : public XclImpBiff8Decrypter
+{
+public:
+ explicit XclImpBiff8CryptoAPIDecrypter(const std::vector<sal_uInt8>& rSalt,
+ const std::vector<sal_uInt8>& rVerifier,
+ const std::vector<sal_uInt8>& rVerifierHash)
+ : XclImpBiff8Decrypter(rSalt, rVerifier, rVerifierHash)
+ {
+ mpCodec = &maCodec;
+ }
+
+private:
+ /** Private copy c'tor for OnClone(). */
+ explicit XclImpBiff8CryptoAPIDecrypter(const XclImpBiff8CryptoAPIDecrypter& rSrc);
+
+ /** Implementation of cloning this object. */
+ virtual XclImpBiff8CryptoAPIDecrypter* OnClone() const override;
+
+private:
+ ::msfilter::MSCodec_CryptoAPI maCodec; /// Crypto algorithm implementation.
};
// Stream