[Libreoffice-commits] core.git: Branch 'libreoffice-6-0-0' - 3 commits - filter/source include/rtl package/inc package/source
Michael Stahl
mstahl at redhat.com
Wed Jan 24 15:35:26 UTC 2018
filter/source/msfilter/mscodec.cxx | 14 +++--
include/rtl/digest.h | 63 +++++++++++++++++++++++++
package/inc/ZipPackageStream.hxx | 4 -
package/source/zippackage/ZipPackage.cxx | 2
package/source/zippackage/ZipPackageStream.cxx | 6 +-
5 files changed, 79 insertions(+), 10 deletions(-)
New commits:
commit 36b39bb10da8d1887ee1bab755a71180909a84cf
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jan 12 18:34:04 2018 +0100
tdf#114939 package: change ODF 1.1 export to use real SHA1
Change-Id: I20d4965cc467df56536ca03b773b3f0f61b1f2a3
(cherry picked from commit 50382b9e9256d7361e3770daa654fb8d09448635)
Reviewed-on: https://gerrit.libreoffice.org/48002
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
(cherry picked from commit 0fbc3a1a90a649bc6353aca9fe3332556961f1a5)
Reviewed-on: https://gerrit.libreoffice.org/48090
Reviewed-by: Eike Rathke <erack at redhat.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
diff --git a/package/inc/ZipPackageStream.hxx b/package/inc/ZipPackageStream.hxx
index 4abb74a684da..3fc124973704 100644
--- a/package/inc/ZipPackageStream.hxx
+++ b/package/inc/ZipPackageStream.hxx
@@ -84,9 +84,9 @@ public:
void SetFromManifest( bool bValue ) { m_bFromManifest = bValue; }
enum class Bugs { None, WinEncodingWrongSHA1, WrongSHA1 };
- ::rtl::Reference<EncryptionData> GetEncryptionData(Bugs bugs = Bugs::WrongSHA1);
+ ::rtl::Reference<EncryptionData> GetEncryptionData(Bugs bugs = Bugs::None);
- css::uno::Sequence<sal_Int8> GetEncryptionKey(Bugs bugs = Bugs::WrongSHA1);
+ css::uno::Sequence<sal_Int8> GetEncryptionKey(Bugs bugs = Bugs::None);
sal_Int32 GetStartKeyGenID();
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 9a4853f439c6..087a77461d90 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1625,7 +1625,7 @@ const uno::Sequence< sal_Int8 > ZipPackage::GetEncryptionKey()
if ( m_nStartKeyGenerationID == xml::crypto::DigestID::SHA256 )
aNameToFind = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
else if ( m_nStartKeyGenerationID == xml::crypto::DigestID::SHA1 )
- aNameToFind = PACKAGE_ENCRYPTIONDATA_SHA1UTF8;
+ aNameToFind = PACKAGE_ENCRYPTIONDATA_SHA1CORRECT;
else
throw uno::RuntimeException(THROW_WHERE "No expected key is provided!" );
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 59efbcc33ad8..2bcdb073bf3c 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -1011,7 +1011,7 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream()
uno::Reference< io::XInputStream > xResult;
try
{
- xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(Bugs::WrongSHA1), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() );
+ xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(Bugs::None), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() );
}
catch( const packages::WrongPasswordException& )
{
@@ -1019,8 +1019,8 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream()
{
SAL_WARN("package", "ZipPackageStream::getDataStream(): SHA1 mismatch, trying fallbacks...");
try
- { // tdf#114939 try without legacy StarOffice SHA1 bug
- xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(Bugs::None), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() );
+ { // tdf#114939 try with legacy StarOffice SHA1 bug
+ xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(Bugs::WrongSHA1), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() );
return xResult;
}
catch (const packages::WrongPasswordException&)
commit 2fe6bfe0fe270a8cc45c52b95e94b87ce672a4a7
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Jan 11 10:28:42 2018 +0100
tdf#114939 filter: don't use StarOffice SHA1 in MS Office filters
Always use real SHA1 here, to avoid interop issues.
Change-Id: I28388db34f923bfc476a7eae526934b14d4473b5
(cherry picked from commit f66fbd947f70f6be6b22ab372facaeb9e2fb63ae)
Reviewed-on: https://gerrit.libreoffice.org/47998
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
(cherry picked from commit 82e19b3a0cb0f51761fe2081729f7d739cae01eb)
Reviewed-on: https://gerrit.libreoffice.org/48031
Reviewed-by: Eike Rathke <erack at redhat.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
diff --git a/filter/source/msfilter/mscodec.cxx b/filter/source/msfilter/mscodec.cxx
index 1d7cd35b1125..02a1a1b444d1 100644
--- a/filter/source/msfilter/mscodec.cxx
+++ b/filter/source/msfilter/mscodec.cxx
@@ -24,6 +24,7 @@
#include <string.h>
#include <tools/solar.h>
+#include <comphelper/hash.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/docpasswordhelper.hxx>
@@ -373,7 +374,10 @@ void MSCodec_CryptoAPI::InitKey (
}
// calculate SHA1 hash of initialData
- rtl_digest_SHA1(initialData.data(), initialData.size(), m_aDigestValue.data(), m_aDigestValue.size());
+ std::vector<unsigned char> const sha1(::comphelper::Hash::calculateHash(
+ initialData.data(), initialData.size(),
+ ::comphelper::HashType::SHA1));
+ m_aDigestValue = sha1;
lcl_PrintDigest(m_aDigestValue.data(), "digest value");
@@ -419,7 +423,9 @@ void MSCodec_CryptoAPI::GetDigestFromSalt(const sal_uInt8* pSaltData, sal_uInt8*
rtl_cipher_decode(m_hCipher,
pSaltData, 16, verifier.data(), verifier.size());
- rtl_digest_SHA1(verifier.data(), verifier.size(), pDigest, RTL_DIGEST_LENGTH_SHA1);
+ std::vector<unsigned char> const sha1(::comphelper::Hash::calculateHash(
+ verifier.data(), verifier.size(), ::comphelper::HashType::SHA1));
+ ::std::copy(sha1.begin(), sha1.end(), pDigest);
}
bool MSCodec_Std97::InitCipher(sal_uInt32 nCounter)
@@ -467,8 +473,8 @@ bool MSCodec_CryptoAPI::InitCipher(sal_uInt32 nCounter)
aKeyData.push_back(sal_uInt8((nCounter >> 16) & 0xff));
aKeyData.push_back(sal_uInt8((nCounter >> 24) & 0xff));
- std::vector<sal_uInt8> hash(RTL_DIGEST_LENGTH_SHA1);
- rtl_digest_SHA1(aKeyData.data(), aKeyData.size(), hash.data(), RTL_DIGEST_LENGTH_SHA1);
+ std::vector<unsigned char> const hash(::comphelper::Hash::calculateHash(
+ aKeyData.data(), aKeyData.size(), ::comphelper::HashType::SHA1));
rtlCipherError result =
rtl_cipher_init(m_hCipher, rtl_Cipher_DirectionDecode,
commit 2ba7890c6c07e1459e3a429c4641391ae5f06422
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jan 12 22:44:43 2018 +0100
tdf#114939 sal: deprecate rtl_digest_*SHA* and rtl_digest_PBKDF2
Document the disaster but don't fix it so this implementation can be
used to import existing documents with bad SHA1 hashes.
Change-Id: I4f3648dd0987392ef49dc149a9213bcafcefb202
(cherry picked from commit efc06e9bb696110350ab3e14344de53db992280e)
Reviewed-on: https://gerrit.libreoffice.org/48003
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
(cherry picked from commit 47b21d7bc342102c79b40a868709814ee771e49c)
Reviewed-on: https://gerrit.libreoffice.org/48015
Reviewed-by: Eike Rathke <erack at redhat.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
diff --git a/include/rtl/digest.h b/include/rtl/digest.h
index 7e225e18d0ea..6652038874fe 100644
--- a/include/rtl/digest.h
+++ b/include/rtl/digest.h
@@ -288,11 +288,18 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_MD5 (
FIPS PUB 180 (Superseded by FIPS PUB 180-1)
Secure Hash Standard
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_create()
*/
SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA (void) SAL_THROW_EXTERN_C();
/** Destroy a SHA digest handle.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_destroy()
*/
SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA (
@@ -301,6 +308,10 @@ SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA (
/** Update a SHA digest with given data.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_update()
*/
SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA (
@@ -309,6 +320,10 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA (
) SAL_THROW_EXTERN_C();
/** Finalize a SHA digest and retrieve the digest value.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_get()
*/
SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA (
@@ -321,6 +336,9 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA (
This function performs an optimized call sequence on a
single data buffer, avoiding digest creation and destruction.
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_updateSHA()
@see rtl_digest_getSHA()
@@ -349,11 +367,18 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_SHA (
FIPS PUB 180-1 (Supersedes FIPS PUB 180)
Secure Hash Standard
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_create()
*/
SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createSHA1 (void) SAL_THROW_EXTERN_C();
/** Destroy a SHA1 digest handle.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_destroy()
*/
SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA1 (
@@ -361,6 +386,10 @@ SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroySHA1 (
) SAL_THROW_EXTERN_C();
/** Update a SHA1 digest with given data.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_update()
*/
SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA1 (
@@ -369,6 +398,10 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateSHA1 (
) SAL_THROW_EXTERN_C();
/** Finalize a SHA1 digest and retrieve the digest value.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_get()
*/
SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA1 (
@@ -381,6 +414,9 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getSHA1 (
This function performs an optimized call sequence on a
single data buffer, avoiding digest creation and destruction.
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_updateSHA1()
@see rtl_digest_getSHA1()
@@ -480,11 +516,18 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_MD5 (
RFC 2898 (Informational)
PKCS #5: Password-Based Cryptography Specification Version 2.0
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_create()
*/
SAL_DLLPUBLIC rtlDigest SAL_CALL rtl_digest_createHMAC_SHA1 (void) SAL_THROW_EXTERN_C();
/** Destroy a HMAC_SHA1 digest handle.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_destroy()
*/
SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyHMAC_SHA1 (
@@ -492,6 +535,10 @@ SAL_DLLPUBLIC void SAL_CALL rtl_digest_destroyHMAC_SHA1 (
) SAL_THROW_EXTERN_C();
/** Initialize a HMAC_SHA1 digest.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_init()
@param Digest [in] digest handle.
@@ -506,6 +553,10 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 (
) SAL_THROW_EXTERN_C();
/** Update a HMAC_SHA1 digest with given data.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_update()
*/
SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 (
@@ -514,6 +565,10 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 (
) SAL_THROW_EXTERN_C();
/** Finalize a HMAC_SHA1 digest and retrieve the digest value.
+
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_get()
*/
SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 (
@@ -526,6 +581,9 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 (
This function performs an optimized call sequence on a
single data buffer, avoiding digest creation and destruction.
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility.
+
@see rtl_digest_initHMAC_SHA1()
@see rtl_digest_updateHMAC_SHA1()
@see rtl_digest_getHMAC_SHA1()
@@ -551,6 +609,11 @@ SAL_DLLPUBLIC rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1 (
RFC 2898 (Informational)
PKCS #5: Password-Based Cryptography Specification Version 2.0
+ @deprecated The implementation is buggy and generates incorrect results
+ for 52 <= (len % 64) <= 55; use only for bug-compatibility
+ or if the input is guaranteed to have a good length
+ by a start-key derivation round.
+
@param pKeyData [out] derived key
@param nKeyLen [in] derived key length
@param pPassData [in] password
More information about the Libreoffice-commits
mailing list