【发布时间】:2022-09-27 18:02:13
【问题描述】:
我想解析一个 XML-DSIG 文件及其内容。我在wikipedia 上读过它的结构和一点RFC。但我无法弄清楚一些事情,假设这是我得到的一个 XML-DSIG 示例:
<?xml version=\"1.0\"?>
<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\">
<SignedInfo>
<CanonicalizationMethod Algorithm=\"urn:xml-dsig:transformation:v1.1\"/>
<SignatureMethod Algorithm=\"some-algo\"/>
<Reference URI=\"#KeyInfo\">
<Transforms>
<Transform Algorithm=\"urn:xml-dsig:transformation:v1.1\"/>
</Transforms>
<DigestMethod Algorithm=\"some-algo-256\"/>
<DigestValue>some-hash-256</DigestValue>
</Reference>
<Reference URI=\"#Object\">
<Transforms>
<Transform Algorithm=\"urn:xml-dsig:transformation:v1.1\"/>
</Transforms>
<DigestMethod Algorithm=\"some-algo-256\"/>
<DigestValue>some-hash-256</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>signature-value-in-base-64</SignatureValue>
<KeyInfo Id=\"KeyInfo\">
<X509Data>
<X509Certificate>x509-cert-in-base-64</X509Certificate>
</X509Data>
</KeyInfo>
<Object Id=\"Object\">
<Result>
...Initial XML I was signing...
</Result>
</Object>
</Signature>
我的问题是:
- 如果
#KeyInfo在<Reference>标记中,这意味着<KeyInfo>部分也被签名了吗? (因为 wiki 说“一个或多个 Reference 元素指定由 URI 引用签名的资源”)。这就引出了第二个问题 - 如果签名值对标签
<KeyInfo>和<Object>中的数据都进行了签名,那么实际签名的是什么?它只是计算出的 xml 的这两部分的哈希值并且在<DigestValue>标签中,还是从<KeyInfo开始到</KeyInfo>结束标签的整个标签以及它之间的数据? (与<Object>相同的问题)。Wiki 没有指定这些内容,我迷失在 RFC 中,找不到这些问题的答案。
标签: cryptography certificate digital-signature xml-signature xml-dsig