xmlsecurity/source/helper/xsecctl.cxx  |   21 +++++++++++++++++++--
 xmlsecurity/source/helper/xsecctl.hxx  |    2 +-
 xmlsecurity/source/helper/xsecsign.cxx |   33 +++++++++++++++++++++++----------
 3 files changed, 43 insertions(+), 13 deletions(-)

New commits:
commit 1688228bec7f5cc4e7c252dea0ef5002bf26cec9
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Mon Feb 8 16:22:42 2016 +0100

    xmlsecurity: export OOXML <SignatureValue>
    
    Change-Id: I7c5055e3bfaa81cae4c91842e9e3681d41d5c3b6

diff --git a/xmlsecurity/source/helper/xsecctl.cxx 
b/xmlsecurity/source/helper/xsecctl.cxx
index cffb298..dad4c39 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -1024,13 +1024,17 @@ void XSecController::exportOOXMLSignature(const 
uno::Reference<xml::sax::XDocume
                 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_DIGESTVALUE);
             xDocumentHandler->endElement(TAG_REFERENCE);
         }
     }
 
     xDocumentHandler->endElement(TAG_SIGNEDINFO);
+
+    xDocumentHandler->startElement(TAG_SIGNATUREVALUE, 
uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+    xDocumentHandler->characters(rInformation.ouSignatureValue);
+    xDocumentHandler->endElement(TAG_SIGNATUREVALUE);
 }
 
 SignatureInformation XSecController::getSignatureInformation( sal_Int32 
nSecurityId ) const
commit dd641965351b2b83e4ffc7ba7a97ace318765dcb
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Mon Feb 8 16:12:58 2016 +0100

    xmlsecurity: fix reference type of OOXML idSignedProperties
    
    Change-Id: I5a2924c3c0af02a4630921bae6117f11655206c2

diff --git a/xmlsecurity/source/helper/xsecctl.cxx 
b/xmlsecurity/source/helper/xsecctl.cxx
index cd1f7e3..cffb298 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -1000,10 +1000,23 @@ void XSecController::exportOOXMLSignature(const 
uno::Reference<xml::sax::XDocume
         {
             {
                 std::unique_ptr<SvXMLAttributeList> pAttributeList(new 
SvXMLAttributeList());
-                pAttributeList->AddAttribute("Type", 
"http://www.w3.org/2000/09/xmldsig#Object";);
+                if (rReference.ouURI != "#idSignedProperties")
+                    pAttributeList->AddAttribute("Type", 
"http://www.w3.org/2000/09/xmldsig#Object";);
+                else
+                    pAttributeList->AddAttribute("Type", 
"http://uri.etsi.org/01903#SignedProperties";);
                 pAttributeList->AddAttribute(ATTR_URI, rReference.ouURI);
                 xDocumentHandler->startElement(TAG_REFERENCE, 
uno::Reference<xml::sax::XAttributeList>(pAttributeList.release()));
             }
+            if (rReference.ouURI == "#idSignedProperties")
+            {
+                xDocumentHandler->startElement(TAG_TRANSFORMS, 
uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+                std::unique_ptr<SvXMLAttributeList> pAttributeList(new 
SvXMLAttributeList());
+                pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_C14N);
+                xDocumentHandler->startElement(TAG_TRANSFORM, 
uno::Reference<xml::sax::XAttributeList>(pAttributeList.release()));
+                xDocumentHandler->endElement(TAG_TRANSFORM);
+                xDocumentHandler->endElement(TAG_TRANSFORMS);
+            }
+
             {
                 std::unique_ptr<SvXMLAttributeList> pAttributeList(new 
SvXMLAttributeList());
                 pAttributeList->AddAttribute(ATTR_ALGORITHM, 
ALGO_XMLDSIGSHA256);
commit 349a0ddc316bfab61a0989eb7658fe82972fbd43
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Mon Feb 8 16:05:26 2016 +0100

    xmlsecurity: write correct number of non-manifest OOXML references
    
    Change-Id: I1d8556487608e5a0bee2ae5f7a4b25a60579f4a9

diff --git a/xmlsecurity/source/helper/xsecctl.hxx 
b/xmlsecurity/source/helper/xsecctl.hxx
index a67dc34..9aad6c6 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -356,7 +356,7 @@ private:
     static OUString createId();
     com::sun::star::uno::Reference<
         com::sun::star::xml::crypto::sax::XReferenceResolvedListener > 
prepareSignatureToWrite(
-        InternalSignatureInformation& signatureInfo );
+        InternalSignatureInformation& signatureInfo, sal_Int32 nStorageFormat 
= 0 );
 
     /*
      * For signature verification
diff --git a/xmlsecurity/source/helper/xsecsign.cxx 
b/xmlsecurity/source/helper/xsecsign.cxx
index 4f1e523..778381e 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
 #include <com/sun/star/xml/crypto/sax/XSignatureCreationResultBroadcaster.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/embed/StorageFormats.hpp>
 #include <rtl/uuid.h>
 
 #include <stdio.h>
@@ -58,7 +59,7 @@ OUString XSecController::createId()
 }
 
 cssu::Reference< cssxc::sax::XReferenceResolvedListener > 
XSecController::prepareSignatureToWrite(
-    InternalSignatureInformation& internalSignatureInfor )
+    InternalSignatureInformation& internalSignatureInfor, sal_Int32 
nStorageFormat )
 {
     sal_Int32 nSecurityId = internalSignatureInfor.signatureInfor.nSecurityId;
     SignatureReferenceInformations& vReferenceInfors = 
internalSignatureInfor.signatureInfor.vSignatureReferenceInfors;
@@ -164,16 +165,28 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > 
XSecController::prepar
     cssu::Reference<cssxc::sax::XKeyCollector> keyCollector 
(xReferenceResolvedListener, cssu::UNO_QUERY);
     keyCollector->setKeyId(0);
 
-    internalSignatureInfor.signatureInfor.ouSignatureId = createId();
-    internalSignatureInfor.signatureInfor.ouPropertyId = createId();
-    internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, 
internalSignatureInfor.signatureInfor.ouPropertyId, -1 );
-    size++;
+    if (nStorageFormat != embed::StorageFormats::OFOPXML)
+    {
+        internalSignatureInfor.signatureInfor.ouSignatureId = createId();
+        internalSignatureInfor.signatureInfor.ouPropertyId = createId();
+        
internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, 
internalSignatureInfor.signatureInfor.ouPropertyId, -1 );
+        size++;
 
-    if (!internalSignatureInfor.signatureInfor.ouDescription.isEmpty())
+        if (!internalSignatureInfor.signatureInfor.ouDescription.isEmpty())
+        {
+            // Only mention the hash of the description in the signature if 
it's non-empty.
+            internalSignatureInfor.signatureInfor.ouDescriptionPropertyId = 
createId();
+            
internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, 
internalSignatureInfor.signatureInfor.ouDescriptionPropertyId, -1);
+            size++;
+        }
+    }
+    else
     {
-        // Only mention the hash of the description in the signature if it's 
non-empty.
-        internalSignatureInfor.signatureInfor.ouDescriptionPropertyId = 
createId();
-        
internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, 
internalSignatureInfor.signatureInfor.ouDescriptionPropertyId, -1);
+        
internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, 
"#idPackageObject", -1);
+        size++;
+        
internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, 
"#idOfficeObject", -1);
+        size++;
+        
internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, 
"#idSignedProperties", -1);
         size++;
     }
 
@@ -381,7 +394,7 @@ bool XSecController::WriteOOXMLSignature(const 
uno::Reference<xml::sax::XDocumen
                 InternalSignatureInformation& rInformation = 
m_vInternalSignatureInformations[i];
 
                 // Prepare the signature creator.
-                rInformation.xReferenceResolvedListener = 
prepareSignatureToWrite(rInformation);
+                rInformation.xReferenceResolvedListener = 
prepareSignatureToWrite(rInformation, embed::StorageFormats::OFOPXML);
 
                 exportOOXMLSignature(xSEKHandler, rInformation.signatureInfor);
             }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to