none
Relationship Transform Algorithm Issue

    Question

  • Hi,

    I need some help in transforming and canonicalization of Office XML relationship file mentioned in title i.e. Document.xml.rels

    I have seen that in the final signature file in OOXML Package, in which this document is referred i.e _xmlsignatures\sig1.xml

    the document.xml.rels is mentioned like this:

    <Reference URI="/word/_rels/document.xml.rels?ContentType=application/vnd.openxmlformats-package.relationships+xml"><Transforms><Transform Algorithm="http://schemas.openxmlformats.org/package/2006/RelationshipTransform"><mdssi:RelationshipReference SourceId="rId13"/><mdssi:RelationshipReference SourceId="rId18"/><mdssi:RelationshipReference SourceId="rId26"/><mdssi:RelationshipReference SourceId="rId39"/><mdssi:RelationshipReference SourceId="rId21"/><mdssi:RelationshipReference SourceId="rId34"/><mdssi:RelationshipReference SourceId="rId42"/><mdssi:RelationshipReference SourceId="rId47"/><mdssi:RelationshipReference SourceId="rId50"/><mdssi:RelationshipReference SourceId="rId55"/><mdssi:RelationshipReference SourceId="rId7"/><mdssi:RelationshipReference SourceId="rId12"/><mdssi:RelationshipReference SourceId="rId17"/><mdssi:RelationshipReference SourceId="rId25"/><mdssi:RelationshipReference SourceId="rId33"/><mdssi:RelationshipReference SourceId="rId38"/><mdssi:RelationshipReference SourceId="rId46"/><mdssi:RelationshipReference SourceId="rId16"/><mdssi:RelationshipReference SourceId="rId20"/><mdssi:RelationshipReference SourceId="rId29"/><mdssi:RelationshipReference SourceId="rId41"/><mdssi:RelationshipReference SourceId="rId54"/><mdssi:RelationshipReference SourceId="rId11"/><mdssi:RelationshipReference SourceId="rId24"/><mdssi:RelationshipReference SourceId="rId32"/><mdssi:RelationshipReference SourceId="rId37"/><mdssi:RelationshipReference SourceId="rId40"/><mdssi:RelationshipReference SourceId="rId45"/><mdssi:RelationshipReference SourceId="rId53"/><mdssi:RelationshipReference SourceId="rId15"/><mdssi:RelationshipReference SourceId="rId23"/><mdssi:RelationshipReference SourceId="rId28"/><mdssi:RelationshipReference SourceId="rId36"/><mdssi:RelationshipReference SourceId="rId49"/><mdssi:RelationshipReference SourceId="rId10"/><mdssi:RelationshipReference SourceId="rId19"/><mdssi:RelationshipReference SourceId="rId31"/><mdssi:RelationshipReference SourceId="rId44"/><mdssi:RelationshipReference SourceId="rId52"/><mdssi:RelationshipReference SourceId="rId9"/><mdssi:RelationshipReference SourceId="rId14"/><mdssi:RelationshipReference SourceId="rId22"/><mdssi:RelationshipReference SourceId="rId27"/><mdssi:RelationshipReference SourceId="rId30"/><mdssi:RelationshipReference SourceId="rId35"/><mdssi:RelationshipReference SourceId="rId43"/><mdssi:RelationshipReference SourceId="rId48"/><mdssi:RelationshipReference SourceId="rId8"/><mdssi:RelationshipReference SourceId="rId51"/></Transform><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>OUXcZjyg0v3dbMCu6fSq/ws2VEc=</DigestValue></Reference></Manifest>

    i need to know how Office has generated this output along with resulting hash i.e. "OUXcZjyg0v3dbMCu6fSq/ws2VEc=".

    What i am doing is as follows:

    1) Firstly removing all the nodes of Custom Xml from Document.xml.rels

    2) Canonicalization of the resulting XML (using an sdk)

    3) Generating Hash of the Resulting XML ( using C# library)

    but i never get the same hash as mentioned above.

    Please guide me what i am missing 

    OR guide me how to transform n canonicalize the document to get the mentioned hash???




    • Edited by Haseeb Hasan Wednesday, March 19, 2014 2:13 PM Easy to find
    Monday, January 20, 2014 10:45 AM

Answers

  • Have you tried asking about this in OpenXMLDeveloper.org?

    This forum tends to focus more on the SDK, and the SDK doesn't work directly with any of the "plumbing" files (rels, content types). You might have more luck in a venue that supports the actual file formats, rather than a specific tool that isn't designed to do what you require.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, January 23, 2014 7:54 PM
    Moderator
  • hi,

    i had solved the issue with the relationship transform algorithm implementation

    and successfully signing the word documents with custom signature


    Haseeb Hasan Principle Software Engineer Ascertia Pvt Ltd

    • Marked as answer by Haseeb Hasan Wednesday, March 19, 2014 2:14 PM
    Wednesday, March 19, 2014 2:14 PM

All replies

  • Hi,

    >> I need to know how Office has generated this output along with resulting hash <<

    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>

    The digest method is above, according to XML Digital Signature Cryptographic Algorithms, it should be wszURI_XMLNS_DIGSIG_SHA1.

    Reference: Sign a Document

    I suggest you to Windows Desktop SDK get more effective response.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 23, 2014 12:53 PM
    Moderator
  • hi

    thanks for the reply

    actually  i am not stucked in producing hash

    but rather Transformation of Relationship files in Open Office XML packages.

    I am doing exactly what stated in "Office Open XML Part 2- Open Packaging Convention_final"

    i.e.

    Relationships Transform Algorithm

    The relationships transform takes the XML document from the Relationships part and converts it to another XML document.

    The package implementer might create relationships XML that contains content from several namespaces, along with versioning instructions as defined in Part 5: “Markup Compatibility and Extensibility”. [O6.11]

    The relationships transform algorithm is as follows:

    Step 1: Process versioning instructions

        The package implementer shall process the versioning instructions, considering that the only known namespace is the Relationships namespace.
        The package implementer shall remove all ignorable content, ignoring preservation attributes.
        The package implementer shall remove all versioning instructions.

    Step 2: Sort and filter relationships

        The package implementer shall remove all namespace declarations except the Relationships namespace declaration.
        The package implementer shall remove the Relationships namespace prefix, if it is present.
        The package implementer shall sort relationship elements by Id value in lexicographical order, considering Id values as case-sensitive Unicode strings.
        The package implementer shall remove all  Relationship elements that do not have eitheran Id value that matches any SourceId valueor a Type value that matches any SourceType value, among the SourceId and SourceType values specified in the transform definition. Producers and consumers shall compare values as case-sensitive Unicode strings. [M6.27] The resulting XML document holds all Relationship elements that either have an Id value that matches a SourceId value or a Type value that matches a SourceType value specified in the transform definition.

    Step 3: Prepare for canonicalization

        The package implementer shall remove all characters between the Relationships start tag and the first Relationship start tag.
        The package implementer shall remove any contents of the Relationship element.
        The package implementer shall remove all characters between the last Relationship end tag and the Relationships end tag.
        If there are no Relationship elements, the package implementer shall remove all characters between the Relationships start tag and the Relationships end tag.

    but the resulting hash produced after this whole process is still not matching with sample docx signed by

    MS Office.

    The resulting xml after whole process mentioned above is as follows: (word/_rels/document.xml.rels)

    <Relationships xmlns="schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId13" Target="endnotes.xml" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"/><Relationship Id="rId18" Target="embeddings/oleObject2.bin" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"/><Relationship Id="rId26" Target="embeddings/oleObject6.bin" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"/><Relationship Id="rId39" Target="media/image17.png" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId21" Target="media/image5.emf" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId34" Target="media/image12.png" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId42" Target="media/image20.png" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId47" Target="media/image23.jpeg" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId50" Target="media/image26.png" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId55" Target="fontTable.xml" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"/><Relationship Id="rId7" Target="numbering.xml" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"/><Relationship Id="rId12" Target="footnotes.xml" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"/><Relationship Id="rId17" Target="media/image3.emf" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId25" Target="media/image7.emf" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/><Relationship Id="rId33" Target="media/image11.png" Type="schemas.openxmlformats.org/officeDocument/2006/relationships/image"/></Relationships>


    Thursday, January 23, 2014 1:41 PM
  • Have you tried asking about this in OpenXMLDeveloper.org?

    This forum tends to focus more on the SDK, and the SDK doesn't work directly with any of the "plumbing" files (rels, content types). You might have more luck in a venue that supports the actual file formats, rather than a specific tool that isn't designed to do what you require.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, January 23, 2014 7:54 PM
    Moderator
  • thanks for you reply,i am trying "OpenXMLDeveloper.org" now..let see
    • Marked as answer by Haseeb Hasan Wednesday, March 19, 2014 2:10 PM
    • Unmarked as answer by Haseeb Hasan Wednesday, March 19, 2014 2:11 PM
    Friday, January 24, 2014 6:10 AM
  • hi,

    i had solved the issue with the relationship transform algorithm implementation

    and successfully signing the word documents with custom signature


    Haseeb Hasan Principle Software Engineer Ascertia Pvt Ltd

    • Marked as answer by Haseeb Hasan Wednesday, March 19, 2014 2:14 PM
    Wednesday, March 19, 2014 2:14 PM
  • can you please unmark as answer as it didnt helped me....

    Haseeb Hasan Principle Software Engineer Ascertia Pvt Ltd

    Wednesday, March 19, 2014 2:17 PM