summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2018-02-06 17:35:36 +0100
committerEike Rathke <erack@redhat.com>2018-02-15 11:17:46 +0100
commitd28ceb7511a8df9345b1c9818baaad5532853a12 (patch)
tree3894088718a0a32fe3f9697ca9aef7f9749a1d42 /xmloff
parentdf72c65fdaf5f1276d1759ba3e7eec83eaaa2d20 (diff)
tdf#115483 svl xmloff sc sw: verify all ODF 1.2 protection-key hashes
ODF 1.2 has added some mandatory requirements for protection-key hashes which did not exist in ODF 1.1. This affects sections and indexes in ODT documents, as well as spreadsheets and sheets in ODS documents. 1. Accept the following hashed passwords: * UTF16 LE/BE encoded StarOffice-SHA1, OOo legacy and allowed by ODF 1.1 * UTF8 encoded proper SHA1, as required by ODF 1.2 * UTF8 encoded SHA256, as required by ODF 1.2 - specified either with the wrong URL used in the ODF 1.2 spec or the correct URL from the W3C spec, see OFFICE-3702 * Excel+SHA1 double-hash, only in Calc, see OFFICE-2112 2. Round-trip any of the above as-is * for SHA256 only write the URL from the ODF 1.2 spec 3. Generate only UTF16 LE encoded SHA1 for now, so that older LO releases can still verify the password * some time in the future, switch to generating some valid ODF 1.2 hash More changes are necessary in Calc, which can actually preserve different hashes for the same passwords in its runtime data model, whereas Writer just has a single buffer without even any metadata. For the Calc unit tests we need one document per hash because the protection-key attribute can be set on the entire spreadsheet, which is an unique element in the document. There are further uses of SvlPasswordHelper for change-tracking passwords, but apparently those are stored in settings.xml, so ODF has no requirements for them, so let's leave that as it is. Reviewed-on: https://gerrit.libreoffice.org/49352 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 398275ba9f4d65bebcc78864e70eee6212a84397) Change-Id: Icb720b14ae9c0d9c04d2e082769ae2b74e3af8aa Reviewed-on: https://gerrit.libreoffice.org/49390 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/text/XMLSectionExport.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx
index 899cb51bc068..1413d2d791a5 100644
--- a/xmloff/source/text/XMLSectionExport.cxx
+++ b/xmloff/source/text/XMLSectionExport.cxx
@@ -398,8 +398,16 @@ void XMLSectionExport::ExportRegularSectionStart(
{
OUStringBuffer aBuffer;
::sax::Converter::encodeBase64(aBuffer, aPassword);
+ // in ODF 1.0/1.1 the algorithm was left unspecified so we can write anything
GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTION_KEY,
aBuffer.makeStringAndClear());
+ if (aPassword.getLength() == 32 && GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012)
+ {
+ // attribute exists in ODF 1.2 or later; default is SHA1 so no need to write that
+ GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+ // write the URL from ODF 1.2, not the W3C one
+ "http://www.w3.org/2000/09/xmldsig#sha256");
+ }
}
// export element