diff options
author | Mikhail Voytenko <mav@openoffice.org> | 2011-03-17 09:16:41 +0100 |
---|---|---|
committer | Mikhail Voytenko <mav@openoffice.org> | 2011-03-17 09:16:41 +0100 |
commit | 5dd2784030e00fa1857b30ee8c5da62e221bfd32 (patch) | |
tree | aeabc21347ed925f17b7844dda650e817264c774 | |
parent | 45bb18f3f90eb96a2a6a41c028188d5787e8952b (diff) |
mav60: #164341# support AES encryption
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Common.xcs | 20 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 39 |
2 files changed, 50 insertions, 9 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index ae171230dd13..4516c884bb0f 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2392,9 +2392,23 @@ <desc>ODFVER_LATEST</desc> </info> </enumeration> - </constraints> - <value>3</value> - </prop> + </constraints> + <value>3</value> + </prop> + <prop oor:name="UseSHA1InODF12" oor:type="xs:boolean"> + <info> + <author>MAV</author> + <desc>Specifies whether SHA1 algorithm instead of SHA256 should be used in ODF12 for StartKey and Checksum generation during encryption.</desc> + </info> + <value>false</value> + </prop> + <prop oor:name="UseBlowfishInODF12" oor:type="xs:boolean"> + <info> + <author>MAV</author> + <desc>Specifies whether Blowfish algorithm instead of AES should be used in ODF12 for encryption.</desc> + </info> + <value>false</value> + </prop> </group> </group> <group oor:name="Load"> diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 9a86e962cac6..a80ba1ddc2a1 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -357,24 +357,51 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } - ::rtl::OUString aVersion; SvtSaveOptions aSaveOpt; SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion(); - // older versions can not have this property set, it exists only starting from ODF1.2 - if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) - aVersion = ODFVER_012_TEXT; + uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); + aEncryptionAlg[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartKeyGenerationAlgorithm" ) ); + aEncryptionAlg[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionAlgorithm" ) ); + aEncryptionAlg[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChecksumAlgorithm" ) ); + // the default values, that should be used for ODF1.1 and older formats + aEncryptionAlg[0].Value <<= xml::crypto::CipherID::SHA1; + aEncryptionAlg[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; + aEncryptionAlg[2].Value <<= xml::crypto::CipherID::SHA1_1K; - if ( aVersion.getLength() ) + if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) { try { - xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( aVersion ) ); + // older versions can not have this property set, it exists only starting from ODF1.2 + xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( ODFVER_012_TEXT ) ); } catch( uno::Exception& ) { } + + if ( !aSaveOpt.IsUseSHA1_ODF12() ) + { + aEncryptionAlg[0].Value <<= xml::crypto::CipherID::SHA256; + aEncryptionAlg[2].Value <<= xml::crypto::CipherID::SHA256_1K; + } + if ( !aSaveOpt.IsUseBlowfish_ODF12() ) + aEncryptionAlg[1].Value <<= xml::crypto::CipherID::AES_CBC; + } + + try + { + // set the encryption algorithms accordingly; + // the setting does not trigger encryption, + // it just provides the format for the case that contents should be encrypted + uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); + xEncr->setEncryptionAlgorithms( aEncryptionAlg ); } + catch( uno::Exception& ) + { + const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); + } + } } } |