summaryrefslogtreecommitdiffstats
path: root/comphelper
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-05-27 20:47:31 +0200
committerJan Holesovsky <kendy@suse.cz>2011-05-27 20:47:31 +0200
commit9e5584a82633442467a53ccc08c3380070178a38 (patch)
tree03ecad6d69523ff70217dd583ac757500135697d /comphelper
parentRemove all traces of SvLongsSort (diff)
parentAdd forgotten vcl/source/app/brand.cxx. (diff)
downloadcore-9e5584a82633442467a53ccc08c3380070178a38.tar.gz
core-9e5584a82633442467a53ccc08c3380070178a38.zip
Merge remote-tracking branch 'origin/integration/dev300_m106'
Conflicts: cppcanvas/source/mtfrenderer/implrenderer.cxx i18npool/inc/i18npool/lang.h i18npool/source/isolang/isolang.cxx svtools/source/filter/exportdialog.cxx svtools/source/graphic/grfmgr.cxx vcl/aqua/source/dtrans/aqua_service.cxx vcl/aqua/source/window/salframe.cxx vcl/inc/sft.hxx vcl/inc/unx/pspgraphics.h vcl/inc/vcl/cursor.hxx vcl/inc/vcl/gdimtf.hxx vcl/inc/vcl/settings.hxx vcl/prj/d.lst vcl/source/app/settings.cxx vcl/source/control/edit.cxx vcl/source/gdi/gdimtf.cxx vcl/source/window/cursor.cxx vcl/source/window/window.cxx vcl/unx/generic/fontmanager/fontconfig.cxx vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx vcl/unx/kde4/KDESalGraphics.cxx
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/inc/comphelper/servicedecl.hxx31
-rw-r--r--comphelper/inc/comphelper/storagehelper.hxx6
-rw-r--r--comphelper/source/misc/storagehelper.cxx39
3 files changed, 49 insertions, 27 deletions
diff --git a/comphelper/inc/comphelper/servicedecl.hxx b/comphelper/inc/comphelper/servicedecl.hxx
index 4574406db031..b025cc7ffdce 100644
--- a/comphelper/inc/comphelper/servicedecl.hxx
+++ b/comphelper/inc/comphelper/servicedecl.hxx
@@ -28,26 +28,17 @@
#if ! defined(COMPHELPER_SERVICEDECL_HXX_INCLUDED)
#define COMPHELPER_SERVICEDECL_HXX_INCLUDED
-#if ! defined(INCLUDED_COMPHELPERDLLAPI_H)
-#include "comphelper/comphelperdllapi.h"
-#endif
-#if ! defined(_CPPUHELPER_IMPLBASE1_HXX_)
-#include "cppuhelper/implbase1.hxx"
-#endif
-#if ! defined(_COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_)
-#include "com/sun/star/uno/XComponentContext.hpp"
-#endif
-#if ! defined(_COM_SUN_STAR_LANG_XSERVICEINFO_HPP_)
-#include "com/sun/star/lang/XServiceInfo.hpp"
-#endif
-#if ! defined(_COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_)
-#include "com/sun/star/registry/XRegistryKey.hpp"
-#endif
-#include "boost/utility.hpp"
-#include "boost/function.hpp"
-#include "boost/preprocessor/cat.hpp"
-#include "boost/preprocessor/repetition.hpp"
-#include "boost/preprocessor/seq/enum.hpp"
+#include <comphelper/comphelperdllapi.h>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <uno/environment.h>
+#include <boost/utility.hpp>
+#include <boost/function.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/repetition.hpp>
+#include <boost/preprocessor/seq/enum.hpp>
namespace comphelper {
namespace service_decl {
diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx
index 05afd901fc57..00da529ab967 100644
--- a/comphelper/inc/comphelper/storagehelper.hxx
+++ b/comphelper/inc/comphelper/storagehelper.hxx
@@ -45,6 +45,7 @@
#define ZIP_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZipFormat" ) )
#define OFOPXML_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OFOPXMLFormat" ) )
+#define PACKAGE_ENCRYPTIONDATA_SHA256UTF8 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA256UTF8EncryptionKey" ) )
#define PACKAGE_ENCRYPTIONDATA_SHA1UTF8 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1UTF8EncryptionKey" ) )
#define PACKAGE_ENCRYPTIONDATA_SHA1MS1252 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1MS1252EncryptionKey" ) )
@@ -165,7 +166,10 @@ public:
throw ( ::com::sun::star::uno::Exception );
static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
- CreatePackageEncryptionData( const ::rtl::OUString& aPassword );
+ CreatePackageEncryptionData(
+ const ::rtl::OUString& aPassword,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
+ = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() );
static sal_Bool IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed );
static sal_Bool IsValidZipEntryFileName( const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed );
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 039ad82dacb3..3441e0a1736f 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -35,6 +35,9 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/IllegalTypeException.hpp>
+#include <com/sun/star/xml/crypto/XDigestContext.hpp>
+#include <com/sun/star/xml/crypto/XDigestContextSupplier.hpp>
+#include <com/sun/star/xml/crypto/DigestID.hpp>
#include <rtl/digest.h>
@@ -423,18 +426,42 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream(
}
// ----------------------------------------------------------------------
-uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData( const ::rtl::OUString& aPassword )
+uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData( const ::rtl::OUString& aPassword, const uno::Reference< lang::XMultiServiceFactory >& xSF )
{
// TODO/LATER: Should not the method be part of DocPasswordHelper?
uno::Sequence< beans::NamedValue > aEncryptionData;
+ sal_Int32 nSha1Ind = 0;
if ( aPassword.getLength() )
{
+ // generate SHA256 start key
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ if ( !xFactory.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< xml::crypto::XDigestContextSupplier > xDigestContextSupplier( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.crypto.NSSInitializer" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< xml::crypto::XDigestContext > xDigestContext( xDigestContextSupplier->getDigestContext( xml::crypto::DigestID::SHA256, uno::Sequence< beans::NamedValue >() ), uno::UNO_SET_THROW );
+
+ ::rtl::OString aUTF8Password( ::rtl::OUStringToOString( aPassword, RTL_TEXTENCODING_UTF8 ) );
+ xDigestContext->updateDigest( uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aUTF8Password.getStr() ), aUTF8Password.getLength() ) );
+ uno::Sequence< sal_Int8 > aDigest = xDigestContext->finalizeDigestAndDispose();
+
+ aEncryptionData.realloc( ++nSha1Ind );
+ aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
+ aEncryptionData[0].Value <<= aDigest;
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_ENSURE( false, "Can not create SHA256 digest!" );
+ }
+
// MS_1252 encoding was used for SO60 document format password encoding,
// this encoding supports only a minor subset of nonascii characters,
// but for compatibility reasons it has to be used for old document formats
- aEncryptionData.realloc( 2 );
- aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA1UTF8;
- aEncryptionData[1].Name = PACKAGE_ENCRYPTIONDATA_SHA1MS1252;
+ aEncryptionData.realloc( nSha1Ind + 2 );
+ aEncryptionData[nSha1Ind].Name = PACKAGE_ENCRYPTIONDATA_SHA1UTF8;
+ aEncryptionData[nSha1Ind + 1].Name = PACKAGE_ENCRYPTIONDATA_SHA1MS1252;
rtl_TextEncoding pEncoding[2] = { RTL_TEXTENCODING_UTF8, RTL_TEXTENCODING_MS_1252 };
@@ -450,11 +477,11 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
if ( nError != rtl_Digest_E_None )
{
- aEncryptionData.realloc( 0 );
+ aEncryptionData.realloc( nSha1Ind );
break;
}
- aEncryptionData[nInd].Value <<= uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
+ aEncryptionData[nSha1Ind+nInd].Value <<= uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
}
}