<div dir="ltr"><div><div>Sorry for the confusion.<br></div><div><br></div><div>The digest transform require an "octet stream". So all retrieved data can be used as "octet stream". </div><div><br></div><div>
But, ArchiveTimeStamp from <i><a href="http://www.etsi.org/deliver/etsi_ts%5C101900_101999%5C101903%5C01.04.02_60%5Cts_101903v010402p.pdf">XML Advanced Electronic Signatures</a></i> (page 58) seems refers to "<a href="http://www.w3.org/TR/xmldsig-core/#sec-ReferenceProcessingModel">The Reference Process Model</a>" without the digest transform, because the digest algorithm may be weak.</div>
</div><div><br></div><div><b>I will try to explain:</b></div><div><br></div>If I signed a detached file, using Xpath to get the node "<b>child</b>" and apply exc-c14n:<div><br></div><div>- FakeFile.xml</div><div>
<br></div><div><file xmlns:ns1="ns1"></div><div><b><child>Text<child></b></div><div><file/></div><div><br></div><div>I know that the <b><child>Text<child> </b>is a "node set" with in FakeFile.xml. So I can use exc-c14n or inc-c14n.</div>
<div><br></div><div>But after retrieved process without apply digest transform. Is this "nod set" or "octet strem"?</div><div><br></div><div><b>The Reference process Model says:</b></div><div><br></div>
<div><i>Unless the URI-Reference is such a 'same-document' reference , the result of dereferencing the URI-Reference MUST be an octet stream.<br></i></div><div><i><br></i></div><div><i>URI="<a href="http://example.com/bar.xml#chapter1">http://example.com/bar.xml#chapter1</a>" </i></div>
<div><i>Identifies the element with ID attribute value 'chapter1' of the external XML resource '<a href="http://example.com/bar.xml">http://example.com/bar.xml</a>', provided as an octet stream.</i><br></div>
<div><br></div><div>"provided as an octet stream" is the resource or the element?</div><div><br></div><div>Consider a signature over the digest "sha1" of "<b><child>Text<child></b>"</div>
<div><br></div><div><b>Now the algorithm is weak, and I want to add ArchiveTimeStamp, the Specification says:</b></div><div><br></div><div><div><i>Process the retrieved ds:Reference element according to the reference processing model of XMLDSIG.</i></div>
<div><i><br></i></div><div><i>If the result is a XML node set, canonicalize it. If ds:Canonicalization is present, the algorithm indicated by this element is used. If not, the standard canonicalization method specified by XMLDSIG is used.</i></div>
</div><div><br></div><div><b>I can understand this like: Get data using URI and ds:Transforms without apply digest transform.</b></div><div><br></div><div>So I will get <b><child>Text<child> (</b>without digest transform)<b>, </b>if this is XML node set, canonicalize it.</div>
<div><b><br></b></div><div>But this is a problem.</div><div><b><br></b></div><div>If I consider the result of extern URI as a "node set" to apply ArchiveTimeStamp and the canonicalize transform used by Archive is inc-c14n, I will archive another file.</div>
<div><b><br></b></div><div><b><child </b>xmlns:ns1="ns1"<b>>Text<child></b></div><div><b><br></b></div><div><b>If the documento change:</b></div><div><b><br></b></div><div><div><file xmlns:ns1="ns1" xmlns:ns2="ns2"></div>
<div><b><child>Text<child></b></div><div><file/></div></div><div><b><br></b></div><div><b>I will try to verify the </b><b>ArchiveTimeStamp with:</b></div><div><b><br></b></div><div><b><child </b>xmlns:ns1="ns1" xmlns:ns2="ns2"<b>>Text<child>. </b></div>
<div><b><br></b></div><div><b>The process to verify will fail. Because the Archive is over:</b></div><div><b><br></b></div><div><b><child </b>xmlns:ns1="ns1"<b>>Text<child></b><b><br></b></div><div><b><br>
</b></div><div><b>The question.</b></div><div><b><br></b></div><div><div style="font-family:arial,sans-serif;font-size:13px"><b>For these References:</b></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div>
<div style="font-family:arial,sans-serif;font-size:13px"><ds:Reference Id="myId" URI="<a href="http://fakefile.xml/" target="_blank">http://fakefile.xml</a>"></div><div style="font-family:arial,sans-serif;font-size:13px">
...</div><div style="font-family:arial,sans-serif;font-size:13px">(empty transform list)</div><div style="font-family:arial,sans-serif;font-size:13px">...</div><div style="font-family:arial,sans-serif;font-size:13px"></ds:Reference></div>
<div style="font-family:arial,sans-serif;font-size:13px"><b>Result 1#: ( <file> ... childs ... <file> ).</b></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
<ds:Reference Id="myId" URI="<a href="http://fakefile.xml/" target="_blank">http://fakefile.xml</a>"></div><div style="font-family:arial,sans-serif;font-size:13px">...</div><div style="font-family:arial,sans-serif;font-size:13px">
<ds:Transform Algorithm="<a href="http://www.w3.org/2001/10/xml-exc-c14n#" target="_blank">http://www.w3.org/2001/10/xml-exc-c14n#</a>"/></div><div style="font-family:arial,sans-serif;font-size:13px">...</div>
<div style="font-family:arial,sans-serif;font-size:13px"></ds:Reference></div><div style="font-family:arial,sans-serif;font-size:13px"><b>Result 2#: (xml with exc-c14n).</b></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><ds:Reference Id="myId" URI="<a href="http://fakefile.xml/" target="_blank">http://fakefile.xml</a>"></div><div style="font-family:arial,sans-serif;font-size:13px">
...</div><div style="font-family:arial,sans-serif;font-size:13px"><ds:Transform "fake_Xpath_transform_to_get_all_childs"/></div><div style="font-family:arial,sans-serif;font-size:13px"><ds:Transform Algorithm="<a href="http://www.w3.org/2001/10/xml-exc-c14n#" target="_blank">http://www.w3.org/2001/10/xml-exc-c14n#</a>"/></div>
<div style="font-family:arial,sans-serif;font-size:13px">...</div><div style="font-family:arial,sans-serif;font-size:13px"></ds:Reference></div><div style="font-family:arial,sans-serif;font-size:13px"><b>Result 3#: ( only childs with exc-c14n <child_1/>...<child_x/> ) This is not valid XML file to parse, does not has single root. But can be "node set" with in fakefile.xml context.</b></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><b>Are results (1#, 2# and 3#) "octet stream" ?</b></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Because: <i>Unless the URI-Reference is such a 'same-document' reference, the result of dereferencing the URI-Reference MUST be an octet stream.</i></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><b>Or are they "XML node set" required by XML Advanced Electronic Signatures to canonicalize?</b></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Because: <i>(...) In particular, an XML document identified by URI is not parsed by the signature application unless the URI is a same-document reference <b>or unless a transform that requires XML parsing is applied</b>.</i></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><b>Or the (unless a transform that requires XML parsing is applied) is valid only with in Reference context and the results are octet stream?</b></div>
</div><div><br></div><div>Thanks</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 30, 2013 at 12:05 PM, Aleksey Sanin <span dir="ltr"><<a href="mailto:aleksey@aleksey.com" target="_blank">aleksey@aleksey.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't understand your question. At the end, digest is always<br>
applied to the octet stream. The rules in the spec describe how<br>
to get to the octet stream. In human language, there are only<br>
two rules:<br>
<br>
1) Do not parse to XML unless it is necessary: it is already<br>
parsed (same document) or there is an XML transform (e.g. XPath)<br>
2) To convert back to octet stream use the specified c14n method.<br>
<br>
IMHO, it's pretty straightforward and logical.<br>
<br>
Best,<br>
<br>
Aleksey<br>
<div class="im"><br>
On 8/30/13 6:50 AM, Alexwell Sandro wrote:<br>
> I do not know if this is the list for this discussion.<br>
><br>
> I added this question to stackoverflow<br>
</div>> <<a href="http://stackoverflow.com/questions/18522211/xmldsig-the-reference-processing-model-node-set-vs-octet-stream" target="_blank">http://stackoverflow.com/questions/18522211/xmldsig-the-reference-processing-model-node-set-vs-octet-stream</a>>.<br>

<div class="im">><br>
> I'm studying XML Advanced Electronic Signatures<br>
</div>> <<a href="http://www.etsi.org/deliver/etsi_ts%5C101900_101999%5C101903%5C01.04.02_60%5Cts_101903v010402p.pdf" target="_blank">http://www.etsi.org/deliver/etsi_ts%5C101900_101999%5C101903%5C01.04.02_60%5Cts_101903v010402p.pdf</a>>.<br>

><br>
> *To create "ArchiveTimeStamp" (page 58) the Specification says:*<br>
><br>
> /Process the retrieved ds:Reference element according to the reference<br>
> processing model of XMLDSIG./<br>
> /<br>
> /<br>
> /If the result is a XML node set, canonicalize it. (...)/<br>
><br>
> *The Reference Processing Model is over this:*<br>
><br>
> <*ds:Reference *Id="myId" URI="<a href="http://fakefile.xml" target="_blank">http://fakefile.xml</a>"><br>
>     <*ds:Transforms*><br>
<div class="im">>         <ds:Transform Algorithm="<a href="http://www.w3.org/2001/10/xml-exc-c14n#" target="_blank">http://www.w3.org/2001/10/xml-exc-c14n#</a>"/><br>
>     </ds:Transforms><br>
>     <ds:DigestMethod/><br>
>     <ds:DigestValue/><br>
> </ds:Reference><br>
><br>
> The process uses "URI=..." and "ds:Transforms" to retrieve the data.<br>
><br>
</div>> *Below are some parts extracted from (4.3.3.2 The Reference Processing<br>
> Model <<a href="http://www.w3.org/TR/xmldsig-core/#sec-ReferenceProcessingModel" target="_blank">http://www.w3.org/TR/xmldsig-core/#sec-ReferenceProcessingModel</a>>):*<br>
><br>
> /The data-type of the result of URI dereferencing or subsequent<br>
> Transforms is either an octet stream or an XPath node-set. (...)/<br>
> /<br>
> /<br>
> /In this specification, a 'same-document' reference is defined as a<br>
<div class="im">> URI-Reference that consists of a hash sign ('#') followed by a fragment<br>
</div>> or alternatively consists of an empty URI (...)/<br>
> /<br>
> /<br>
> /Unless the URI-Reference is such a 'same-document' reference, the<br>
<div class="im">> result of dereferencing the URI-Reference MUST be an octet stream. In<br>
> particular, an XML document identified by URI is not parsed by the<br>
> signature application unless the URI is a same-document reference or<br>
</div>> unless a transform that requires XML parsing is applied./<br>
> /<br>
> /<br>
> /The following examples demonstrate what the URI attribute identifies<br>
> and how it is dereferenced:/<br>
> /<br>
> /<br>
> /URI="<a href="http://example.com/bar.xml" target="_blank">http://example.com/bar.xml</a>" /<br>
> /Identifies the octets (...)/<br>
> /<br>
> /<br>
> /URI="<a href="http://example.com/bar.xml#chapter1" target="_blank">http://example.com/bar.xml#chapter1</a>" /<br>
> /Identifies the element with ID attribute value 'chapter1' of the<br>
> external XML resource (...), provided as an octet stream. (...)/<br>
> /<br>
> /<br>
> /URI="" /<br>
> /Identifies the node-set (...)/<br>
> /<br>
> /<br>
> /URI="#chapter1" /<br>
> /Identifies a node-set containing the (...)/<br>
><br>
> *The question.*<br>
><br>
> *For these References:*<br>
<div class="im">><br>
> <ds:Reference Id="myId" URI="<a href="http://fakefile.xml" target="_blank">http://fakefile.xml</a>"><br>
> ...<br>
> (empty transform list)<br>
> ...<br>
> </ds:Reference><br>
</div>> *Result 1#: ( <file> ... childs ... <file> ).*<br>
<div class="im">><br>
> <ds:Reference Id="myId" URI="<a href="http://fakefile.xml" target="_blank">http://fakefile.xml</a>"><br>
> ...<br>
> <ds:Transform Algorithm="<a href="http://www.w3.org/2001/10/xml-exc-c14n#" target="_blank">http://www.w3.org/2001/10/xml-exc-c14n#</a>"/><br>
> ...<br>
> </ds:Reference><br>
</div>> *Result 2#: (xml with exc-c14n).*<br>
<div class="im">><br>
> <ds:Reference Id="myId" URI="<a href="http://fakefile.xml" target="_blank">http://fakefile.xml</a>"><br>
> ...<br>
> <ds:Transform "fake_Xpath_transform_to_get_all_childs"/><br>
> <ds:Transform Algorithm="<a href="http://www.w3.org/2001/10/xml-exc-c14n#" target="_blank">http://www.w3.org/2001/10/xml-exc-c14n#</a>"/><br>
> ...<br>
> </ds:Reference><br>
</div>> *Result 3#: ( only childs with exc-c14n <child_1/>...<child_x/> ) This<br>
<div class="im">> is not valid XML file to parse, does not has single root. But can be<br>
</div>> "node set" with in fakefile.xml context.*<br>
><br>
> *Are results (1#, 2# and 3#) "octet stream" ?*<br>
><br>
> Because: /Unless the URI-Reference is such a 'same-document' reference,<br>
> the result of dereferencing the URI-Reference MUST be an octet stream./<br>
><br>
> *Or are they "XML node set" required by XML Advanced Electronic<br>
> Signatures to canonicalize?*<br>
><br>
> Because: /(...) In particular, an XML document identified by URI is not<br>
<div class="im">> parsed by the signature application unless the URI is a same-document<br>
</div>> reference *or unless a transform that requires XML parsing is applied*./<br>
><br>
> *Or the (unless a transform that requires XML parsing is applied) is<br>
> valid only with in Reference context and the results are octet stream?*<br>
><br>
> Articles are welcome.<br>
><br>
><br>
> _______________________________________________<br>
> xmlsec mailing list<br>
> <a href="mailto:xmlsec@aleksey.com">xmlsec@aleksey.com</a><br>
> <a href="http://www.aleksey.com/mailman/listinfo/xmlsec" target="_blank">http://www.aleksey.com/mailman/listinfo/xmlsec</a><br>
><br>
</blockquote></div><br></div>