From 570d5af407d55c39621575e56c77817dbd429783 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 8 Feb 2016 15:00:21 +0100 Subject: xmlsecurity: initial OOXML support for writing same-document references They are kind of a special case for ODF, but OOXML uses these exclusively, and then one of them refers to the actual package streams. Change-Id: I4663eef4bd718a7563effd6cafa790126db6d8c7 --- xmlsecurity/source/helper/xsecctl.cxx | 26 +++++++++++++++++++++++++- xmlsecurity/source/helper/xsecctl.hxx | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'xmlsecurity') diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx index 81b8d97bcf59..cd1f7e35494a 100644 --- a/xmlsecurity/source/helper/xsecctl.cxx +++ b/xmlsecurity/source/helper/xsecctl.cxx @@ -975,7 +975,7 @@ void XSecController::exportSignature( xDocumentHandler->endElement( tag_Signature ); } -void XSecController::exportOOXMLSignature(const uno::Reference& xDocumentHandler, const SignatureInformation& /*rInformation*/) +void XSecController::exportOOXMLSignature(const uno::Reference& xDocumentHandler, const SignatureInformation& rInformation) { xDocumentHandler->startElement(TAG_SIGNEDINFO, uno::Reference(new SvXMLAttributeList())); @@ -993,6 +993,30 @@ void XSecController::exportOOXMLSignature(const uno::ReferenceendElement(TAG_SIGNATUREMETHOD); } + const SignatureReferenceInformations& rReferences = rInformation.vSignatureReferenceInfors; + for (const SignatureReferenceInformation& rReference : rReferences) + { + if (rReference.nType == SignatureReferenceType::SAMEDOCUMENT) + { + { + std::unique_ptr pAttributeList(new SvXMLAttributeList()); + pAttributeList->AddAttribute("Type", "http://www.w3.org/2000/09/xmldsig#Object"); + pAttributeList->AddAttribute(ATTR_URI, rReference.ouURI); + xDocumentHandler->startElement(TAG_REFERENCE, uno::Reference(pAttributeList.release())); + } + { + std::unique_ptr pAttributeList(new SvXMLAttributeList()); + pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_XMLDSIGSHA256); + xDocumentHandler->startElement(TAG_DIGESTMETHOD, uno::Reference(pAttributeList.release())); + xDocumentHandler->endElement(TAG_DIGESTMETHOD); + } + xDocumentHandler->startElement(TAG_DIGESTVALUE, uno::Reference(new SvXMLAttributeList())); + xDocumentHandler->endElement(TAG_DIGESTVALUE); + xDocumentHandler->characters(rReference.ouDigestValue); + xDocumentHandler->endElement(TAG_REFERENCE); + } + } + xDocumentHandler->endElement(TAG_SIGNEDINFO); } diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx index 589183d4d10c..a67dc34ea3e3 100644 --- a/xmlsecurity/source/helper/xsecctl.hxx +++ b/xmlsecurity/source/helper/xsecctl.hxx @@ -97,6 +97,7 @@ #define ALGO_RSASHA1 "http://www.w3.org/2000/09/xmldsig#rsa-sha1" #define ALGO_RSASHA256 "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" #define ALGO_XMLDSIGSHA1 "http://www.w3.org/2000/09/xmldsig#sha1" +#define ALGO_XMLDSIGSHA256 "http://www.w3.org/2001/04/xmlenc#sha256" #define ALGO_RELATIONSHIP "http://schemas.openxmlformats.org/package/2006/RelationshipTransform" #define CHAR_FRAGMENT "#" -- cgit