summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-08 15:00:21 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-08 15:34:35 +0100
commit570d5af407d55c39621575e56c77817dbd429783 (patch)
treed5cafdd53642cb7b49a7a73131d8308d81887136 /xmlsecurity
parent5138223ebf7e4bfa6bd13be1b195ff1a7f03c017 (diff)
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
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/helper/xsecctl.cxx26
-rw-r--r--xmlsecurity/source/helper/xsecctl.hxx1
2 files changed, 26 insertions, 1 deletions
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<xml::sax::XDocumentHandler>& xDocumentHandler, const SignatureInformation& /*rInformation*/)
+void XSecController::exportOOXMLSignature(const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler, const SignatureInformation& rInformation)
{
xDocumentHandler->startElement(TAG_SIGNEDINFO, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
@@ -993,6 +993,30 @@ void XSecController::exportOOXMLSignature(const uno::Reference<xml::sax::XDocume
xDocumentHandler->endElement(TAG_SIGNATUREMETHOD);
}
+ const SignatureReferenceInformations& rReferences = rInformation.vSignatureReferenceInfors;
+ for (const SignatureReferenceInformation& rReference : rReferences)
+ {
+ if (rReference.nType == SignatureReferenceType::SAMEDOCUMENT)
+ {
+ {
+ std::unique_ptr<SvXMLAttributeList> 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<xml::sax::XAttributeList>(pAttributeList.release()));
+ }
+ {
+ std::unique_ptr<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
+ pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_XMLDSIGSHA256);
+ xDocumentHandler->startElement(TAG_DIGESTMETHOD, uno::Reference<xml::sax::XAttributeList>(pAttributeList.release()));
+ xDocumentHandler->endElement(TAG_DIGESTMETHOD);
+ }
+ xDocumentHandler->startElement(TAG_DIGESTVALUE, uno::Reference<xml::sax::XAttributeList>(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 "#"