summaryrefslogtreecommitdiff
path: root/package/inc
diff options
context:
space:
mode:
authorMikhail Voytenko <mav@openoffice.org>2011-03-17 09:16:41 +0100
committerMikhail Voytenko <mav@openoffice.org>2011-03-17 09:16:41 +0100
commit99e3106a3e2185f521930f5a42adc4e5c1287245 (patch)
tree01ab245c0323a05e487edb36188aeed5563ca315 /package/inc
parentb52c8fd79b8089608b9bc979b598602ffb171a90 (diff)
mav60: #164341# support AES encryption
Diffstat (limited to 'package/inc')
-rw-r--r--package/inc/EncryptionData.hxx6
-rw-r--r--package/inc/PackageConstants.hxx22
-rw-r--r--package/inc/ZipFile.hxx26
-rw-r--r--package/inc/ZipOutputStream.hxx33
-rw-r--r--package/inc/ZipPackageStream.hxx14
5 files changed, 63 insertions, 38 deletions
diff --git a/package/inc/EncryptionData.hxx b/package/inc/EncryptionData.hxx
index 1182ee66e14b..a3df8b550768 100644
--- a/package/inc/EncryptionData.hxx
+++ b/package/inc/EncryptionData.hxx
@@ -33,9 +33,9 @@
class BaseEncryptionData : public cppu::OWeakObject
{
public:
- ::com::sun::star::uno::Sequence< sal_uInt8 > m_aSalt;
- ::com::sun::star::uno::Sequence< sal_uInt8 > m_aInitVector;
- ::com::sun::star::uno::Sequence< sal_uInt8 > m_aDigest;
+ ::com::sun::star::uno::Sequence< sal_Int8 > m_aSalt;
+ ::com::sun::star::uno::Sequence< sal_Int8 > m_aInitVector;
+ ::com::sun::star::uno::Sequence< sal_Int8 > m_aDigest;
sal_Int32 m_nIterationCount;
BaseEncryptionData()
diff --git a/package/inc/PackageConstants.hxx b/package/inc/PackageConstants.hxx
index 9314d0866cef..3695f023ec58 100644
--- a/package/inc/PackageConstants.hxx
+++ b/package/inc/PackageConstants.hxx
@@ -34,15 +34,19 @@ const sal_Int32 n_ConstMaxMemoryStreamSize = 20480;
const sal_Int32 n_ConstDigestLength = 1024;
// the constants related to the manifest.xml entries
-#define PKG_MNFST_MEDIATYPE 0
-#define PKG_MNFST_VERSION 1
-#define PKG_MNFST_FULLPATH 2
-
-#define PKG_MNFST_INIVECTOR 3
-#define PKG_MNFST_SALT 4
-#define PKG_MNFST_ITERATION 5
-#define PKG_MNFST_UCOMPSIZE 6
-#define PKG_MNFST_DIGEST 7
+#define PKG_MNFST_MEDIATYPE 0
+#define PKG_MNFST_VERSION 1
+#define PKG_MNFST_FULLPATH 2
+
+#define PKG_MNFST_INIVECTOR 3
+#define PKG_MNFST_SALT 4
+#define PKG_MNFST_ITERATION 5
+#define PKG_MNFST_UCOMPSIZE 6
+#define PKG_MNFST_DIGEST 7
+#define PKG_MNFST_ENCALG 8
+#define PKG_MNFST_STARTALG 9
+#define PKG_MNFST_DIGESTALG 10
+#define PKG_MNFST_DERKEYSIZE 11
#define PKG_SIZE_NOENCR_MNFST 3
#define PKG_SIZE_ENCR_MNFST 8
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
index 7ea53e78602b..fcb5d17713c2 100644
--- a/package/inc/ZipFile.hxx
+++ b/package/inc/ZipFile.hxx
@@ -31,6 +31,8 @@
#include <com/sun/star/packages/zip/ZipIOException.hpp>
#include <com/sun/star/packages/NoEncryptionException.hpp>
#include <com/sun/star/packages/WrongPasswordException.hpp>
+#include <com/sun/star/xml/crypto/XCipherContext.hpp>
+#include <com/sun/star/xml/crypto/XDigestContext.hpp>
#include <rtl/ref.hxx>
@@ -54,7 +56,6 @@ namespace com { namespace sun { namespace star {
#define ZIP_MAXEXTRA 256
#define ZIP_MAXENTRIES (0x10000 - 2)
-typedef void* rtlCipher;
class ZipEnumeration;
class ZipFile
@@ -68,7 +69,7 @@ protected:
Inflater aInflater;
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
- const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xFactory;
+ const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory;
::com::sun::star::uno::Reference < ::com::sun::star::ucb::XProgressHandler > xProgressHandler;
sal_Bool bRecoveryMode;
@@ -130,7 +131,15 @@ public:
SotMutexHolderRef aMutexHolder )
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
- static sal_Bool StaticGetCipher ( const ::rtl::Reference < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode );
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XDigestContext > StaticGetDigestContextForChecksum(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xArgFactory,
+ const ::rtl::Reference< EncryptionData >& xEncryptionData );
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > StaticGetCipher(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xArgFactory,
+ const ::rtl::Reference< EncryptionData >& xEncryptionData,
+ bool bEncrypt );
static void StaticFillHeader ( const ::rtl::Reference < EncryptionData > & rData,
sal_Int32 nSize,
@@ -146,14 +155,21 @@ public:
::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &rStream );
static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > StaticGetDataFromRawStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream,
const ::rtl::Reference < EncryptionData > &rData )
throw ( ::com::sun::star::packages::WrongPasswordException,
::com::sun::star::packages::zip::ZipIOException,
::com::sun::star::uno::RuntimeException );
- static sal_Bool StaticHasValidPassword ( const ::com::sun::star::uno::Sequence< sal_Int8 > &aReadBuffer,
- const ::rtl::Reference < EncryptionData > &rData );
+ static void StaticRemoveW3CPadding(
+ const ::rtl::Reference< EncryptionData >& rEncData,
+ ::com::sun::star::uno::Sequence< sal_Int8 >& o_rPaddedData );
+
+ static sal_Bool StaticHasValidPassword (
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
+ const ::com::sun::star::uno::Sequence< sal_Int8 > &aReadBuffer,
+ const ::rtl::Reference < EncryptionData > &rData );
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index ebfb6f52f944..b33e7c13a243 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -27,34 +27,35 @@
#ifndef _ZIP_OUTPUT_STREAM_HXX
#define _ZIP_OUTPUT_STREAM_HXX
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/xml/crypto/XCipherContext.hpp>
+#include <com/sun/star/xml/crypto/XDigestContext.hpp>
+
#include <ByteChucker.hxx>
-#ifndef _DEFLATER_HXX
#include <Deflater.hxx>
-#endif
#include <CRC32.hxx>
-#include <rtl/cipher.h>
-#ifndef RTL_DIGEST_H_
-#include <rtl/digest.h>
-#endif
#include <vector>
struct ZipEntry;
class ZipPackageStream;
-namespace vos
-{
- template < class T > class ORef;
-}
+
class ZipOutputStream
{
protected:
- com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream;
+
::std::vector < ZipEntry * > aZipList;
- com::sun::star::uno::Sequence < sal_Int8 > aBuffer, aEncryptionBuffer;
+ ::com::sun::star::uno::Sequence< sal_Int8 > aBuffer;
::rtl::OUString sComment;
Deflater aDeflater;
- rtlCipher aCipher;
- rtlDigest aDigest;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > m_xCipherContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XDigestContext > m_xDigestContext;
+
CRC32 aCRC;
ByteChucker aChucker;
ZipEntry *pCurrentEntry;
@@ -63,7 +64,9 @@ protected:
ZipPackageStream* m_pCurrentStream;
public:
- ZipOutputStream( com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > &xOStream );
+ ZipOutputStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > &xOStream );
~ZipOutputStream();
// rawWrite to support a direct write to the output stream
diff --git a/package/inc/ZipPackageStream.hxx b/package/inc/ZipPackageStream.hxx
index 5ea0c82ce047..7d22bf71a86d 100644
--- a/package/inc/ZipPackageStream.hxx
+++ b/package/inc/ZipPackageStream.hxx
@@ -97,11 +97,13 @@ public:
::com::sun::star::uno::Sequence< sal_Int8 > GetEncryptionKey( bool bWinEncoding = false );
- const com::sun::star::uno::Sequence < sal_uInt8 >& getInitialisationVector () const
+ sal_Int32 GetKeyGenID();
+
+ const com::sun::star::uno::Sequence < sal_Int8 >& getInitialisationVector () const
{ return m_xBaseEncryptionData->m_aInitVector;}
- const com::sun::star::uno::Sequence < sal_uInt8 >& getDigest () const
+ const com::sun::star::uno::Sequence < sal_Int8 >& getDigest () const
{ return m_xBaseEncryptionData->m_aDigest;}
- const com::sun::star::uno::Sequence < sal_uInt8 >& getSalt () const
+ const com::sun::star::uno::Sequence < sal_Int8 >& getSalt () const
{ return m_xBaseEncryptionData->m_aSalt;}
sal_Int32 getIterationCount () const
{ return m_xBaseEncryptionData->m_nIterationCount;}
@@ -129,11 +131,11 @@ public:
void setKey (const com::sun::star::uno::Sequence < sal_Int8 >& rNewKey )
{ m_aEncryptionKey = rNewKey; m_aStorageEncryptionKeys.realloc( 0 ); }
- void setInitialisationVector (const com::sun::star::uno::Sequence < sal_uInt8 >& rNewVector )
+ void setInitialisationVector (const com::sun::star::uno::Sequence < sal_Int8 >& rNewVector )
{ m_xBaseEncryptionData->m_aInitVector = rNewVector;}
- void setSalt (const com::sun::star::uno::Sequence < sal_uInt8 >& rNewSalt )
+ void setSalt (const com::sun::star::uno::Sequence < sal_Int8 >& rNewSalt )
{ m_xBaseEncryptionData->m_aSalt = rNewSalt;}
- void setDigest (const com::sun::star::uno::Sequence < sal_uInt8 >& rNewDigest )
+ void setDigest (const com::sun::star::uno::Sequence < sal_Int8 >& rNewDigest )
{ m_xBaseEncryptionData->m_aDigest = rNewDigest;}
void setIterationCount (const sal_Int32 nNewCount)
{ m_xBaseEncryptionData->m_nIterationCount = nNewCount;}