diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-02 11:38:22 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-02 11:43:04 +0100 |
commit | 11ad93f4ba84f190c908e92a2c960f7a9fa800c0 (patch) | |
tree | da16bc3981c899d860f95310cb5325b8e2777d97 /package | |
parent | f7f421670206d265024a99da6bc1ad8781c30c99 (diff) |
Resolves: rhbz#1013844 fdo#47482 encrypted OOo 1.0 docs cannot be reopened
Workaround for the encrypted OpenOffice.org 1.0 documents generated by
Libreoffice <= 3.6 with the new encryption format and using SHA256, but missing
a specified startkey of SHA256
Change-Id: Ib1acc4441b5adc6721cb3cde7a1191aa978e9a1b
Diffstat (limited to 'package')
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 78e647e35812..bb96203bb141 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -535,13 +535,37 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream() { xResult = rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(), bIsEncrypted, rZipPackage.GetSharedMutexRef() ); } - catch( packages::WrongPasswordException& ) + catch( const packages::WrongPasswordException& ) { - // workaround for the encrypted documents generated with the old OOo1.x bug. - if ( rZipPackage.GetStartKeyGenID() == xml::crypto::DigestID::SHA1 && !m_bUseWinEncoding ) + if ( rZipPackage.GetStartKeyGenID() == xml::crypto::DigestID::SHA1 ) { - xResult = rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData( true ), bIsEncrypted, rZipPackage.GetSharedMutexRef() ); - m_bUseWinEncoding = true; + try + { + // rhbz#1013844 / fdo#47482 workaround for the encrypted + // OpenOffice.org 1.0 documents generated by Libreoffice <= + // 3.6 with the new encryption format and using SHA256, but + // missing a specified startkey of SHA256 + + // force SHA256 and see if that works + m_nImportedStartKeyAlgorithm = xml::crypto::DigestID::SHA256; + xResult = rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(), bIsEncrypted, rZipPackage.GetSharedMutexRef() ); + return xResult; + } + catch (const packages::WrongPasswordException&) + { + // if that didn't work, restore to SHA1 and trundle through the *other* earlier + // bug fix + m_nImportedStartKeyAlgorithm = xml::crypto::DigestID::SHA1; + } + + // workaround for the encrypted documents generated with the old OOo1.x bug. + if ( !m_bUseWinEncoding ) + { + xResult = rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData( true ), bIsEncrypted, rZipPackage.GetSharedMutexRef() ); + m_bUseWinEncoding = true; + } + else + throw; } else throw; |