gpt4 book ai didi

XmlDSig : The Reference Processing Model (Node set vs Octet stream)

转载 作者:行者123 更新时间:2023-12-04 04:43:41 25 4
gpt4 key购买 nike

我在学习 XML Advanced Electronic Signatures .

要创建“ArchiveTimeStamp”(第 58 页),规范说:

Process the retrieved ds:Reference element according to the reference processing model of XMLDSIG.

If the result is a XML node set, canonicalize it. (...)



引用处理模型在此结束:
<ds:Reference Id="myId" URI="http://fakefile.xml">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod/>
<ds:DigestValue/>
</ds:Reference>

该过程使用“URI=...”和“ds:Transforms”来检索数据。

以下是从( 4.3.3.2 The Reference Processing Model )中提取的一些部分:

The data-type of the result of URI dereferencing or subsequent Transforms is either an octet stream or an XPath node-set. (...)

In this specification, a 'same-document' reference is defined as a URI-Reference that consists of a hash sign ('#') followed by a fragment or alternatively consists of an empty URI (...)

Unless the URI-Reference is such a 'same-document' reference, the result of dereferencing the URI-Reference MUST be an octet stream. In particular, an XML document identified by URI is not parsed by the signature application unless the URI is a same-document reference or unless a transform that requires XML parsing is applied.

The following examples demonstrate what the URI attribute identifies and how it is dereferenced:

URI="http://example.com/bar.xml"
Identifies the octets (...)

URI="http://example.com/bar.xml#chapter1"
Identifies the element with ID attribute value 'chapter1' of the external XML resource (...), provided as an octet stream. (...)

URI=""
Identifies the node-set (...)

URI="#chapter1"
Identifies a node-set containing the (...)



问题。

对于这些引用:
<ds:Reference Id="myId" URI="http://fakefile.xml">
...
(empty transform list)
...
</ds:Reference>

结果 1#: ( <file> ... childs ... <file> )。 不应用摘要转换
<ds:Reference Id="myId" URI="http://fakefile.xml">
...
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
...
</ds:Reference>

结果 2#: ( xml with exc-c14n )。 不应用摘要转换
<ds:Reference Id="myId" URI="http://fakefile.xml">
...
<ds:Transform "fake_Xpath_transform_to_get_all_childs"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
...
</ds:Reference>

结果 3#:(只有 exc-c14n <child_1/>...<child_x/> 的 child )没有应用摘要转换。这不是要解析的有效 XML 文件,没有单根。但可以在 fakefile.xml 上下文中使用“节点集”。

结果(1#、2# 和 3#)是“八位字节流”吗?

因为:
除非 URI-Reference 是这样一个“相同文档”的引用,否则取消引用 URI-Reference 的结果必须是一个八位字节流。

或者它们是否是 XML 高级电子签名规范化所需的“XML 节点集”?

因为:
(...) 特别是,由 URI 标识的 XML 文档不会被签名应用程序解析,除非 URI 是同一文档引用,或者除非应用了需要 XML 解析的转换。

或者(除非应用需要 XML 解析的转换)仅在引用上下文中有效并且结果是八位字节流?

欢迎发表文章。

最佳答案

它们都是八位字节流,即二进制,但处理方式不同。

除了 Reference Processing Model部分还考虑了Transforms element部分进行以下说明。

1 : 因为http://fakefile.xml不是同一个文件引用,并且:

Unless the URI-Reference is such a 'same-document' reference, the result of dereferencing the URI-Reference MUST be an octet stream



由于没有转换,这个八位字节流是摘要计算的输入

2 : 如 中所述1 http://fakefile.xml不是相同的文档引用,因此转换的输入是八位字节流。

自规范化变换 works over XML nodes ,其输入必须转换为 XML 节点集,如部分 Reference Processing Model 所述。 :

If the data object is an octet stream and the next transform requires a node-set, the signature application MUST attempt to parse the octets yielding the required node-set via [XML] well-formed processing.



根据定义,规范化转换的输出是一个八位字节流。

3 : 如 中所述1 http://fakefile.xml不是相同的文档引用,因此转换的输入是八位字节流。

XPath 转换在 XML 节点上工作,这意味着必须将八位字节流转换为节点集(在 XPath filtering 部分再次说明)。 XPath 变换的输出也是一个节点集。

下面的转换是规范化,它需要一个 XML 节点集作为输入。由于输入/输出是链接的( Transforms element 部分)并且先前的输出已经是节点集,因此不需要转换。

最后,规范化转换的输出根据定义是一个八位字节流。

在您的示例中,转换的输出始终是一个八位字节流,但例如,如果您有一个 XPath 转换,则转换的结果是一个 XML 节点集。然后必须按照 ArchiveTimeStamp 属性定义的要求对其进行规范化。在这种情况下,您使用在 ArchiveTimeStamp 属性本身上定义的规范化算法,或 XML-DSIG 默认值(如果未指定)。

希望这会有所帮助。

关于XmlDSig : The Reference Processing Model (Node set vs Octet stream),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18522211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com