SHA1 摘要或 Xades SignedProperties 的计算不起作用
Calculation of SHA1 Digest or a Xades SignedProperties is not working
我有以下 XML 文件:
<xad:SignedProperties Id="Sig_20151117_172752_SP">
<xad:SignedSignatureProperties>
<xad:SigningTime>2015-11-17T16:27:59Z</xad:SigningTime>
<xad:SigningCertificate>
<xad:Cert>
<xad:CertDigest>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>vkVMqVMRsiSbo3Zgvk9sTfVtRDs=</ds:DigestValue>
</xad:CertDigest>
<xad:IssuerSerial>
<ds:X509IssuerName>CN=CERTEUROPE ADVANCED CA V4, OU=0002 434202180, O=Certeurope, C=FR</ds:X509IssuerName>
<ds:X509SerialNumber>747583</ds:X509SerialNumber>
</xad:IssuerSerial>
</xad:Cert>
</xad:SigningCertificate>
<xad:SignaturePolicyIdentifier>
<xad:SignaturePolicyId>
<xad:SigPolicyId>
<xad:Identifier>1234567</xad:Identifier>
<xad:Description>Description de la politique de signature numérique</xad:Description>
</xad:SigPolicyId>
<xad:SigPolicyHash>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>ZXphcmxramhxZGY=</ds:DigestValue>
</xad:SigPolicyHash>
<xad:SigPolicyQualifiers>
<xad:SigPolicyQualifier>
<xad:SPURI>1234567</xad:SPURI>
</xad:SigPolicyQualifier>
</xad:SigPolicyQualifiers>
</xad:SignaturePolicyId>
</xad:SignaturePolicyIdentifier>
<xad:SignerRole>
<xad:ClaimedRoles/>
</xad:SignerRole>
</xad:SignedSignatureProperties>
<xad:SignedDataObjectProperties>
<xad:CommitmentTypeIndication>
<xad:CommitmentTypeId>
<xad:Identifier>1.2.840.113549.1.9.16.6.1</xad:Identifier>
<xad:Description>1.2.840.113549.1.9.16.6.1</xad:Description>
</xad:CommitmentTypeId>
<xad:ObjectReference>#D0-Reference</xad:ObjectReference>
</xad:CommitmentTypeIndication>
</xad:SignedDataObjectProperties>
</xad:SignedProperties>
(我是故意缩进的,一开始是线性的 XML)。
我需要获取以下摘要:
<ds:Reference Id="Sig_20151117_172752_SP-Reference" Type="http://uri.etsi.org/01903/#SignedProperties" URI="#Sig_20151117_172752_SP">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>euEROs8DacsBe3xqXBY5T+M07AI=</ds:DigestValue>
</ds:Reference>
我正在使用规范化 C14N 来执行此操作。
我尝试将这些命名空间添加到第一个标签中:
xmlns:xad="http://uri.etsi.org/01903/v1.3.2#"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
顺序如下:
或
但这些尝试中 none 会奏效。有什么东西不见了吗? (这是我用来计算 SHA-1 摘要的 C# 方法:
public string CalculateHashSHA1(string input)
{
using (SHA1Managed sha1 = new SHA1Managed())
{
return Convert.ToBase64String(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(input)));
}
}
编辑:
- 源文件在这里:https://1fichier.com/?y9spk6g2zk
- 有缩进的源文件:https://1fichier.com/?11r0i8izzt
我正在尝试获取此摘要:euEROs8DacsBe3xqXBY5T+M07AI=
事实上,我需要使用这个方法:
XmlDsigExcC14NTransform innerTransform = new XmlDsigExcC14NTransform(false);
结果是正确的。
我有以下 XML 文件:
<xad:SignedProperties Id="Sig_20151117_172752_SP">
<xad:SignedSignatureProperties>
<xad:SigningTime>2015-11-17T16:27:59Z</xad:SigningTime>
<xad:SigningCertificate>
<xad:Cert>
<xad:CertDigest>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>vkVMqVMRsiSbo3Zgvk9sTfVtRDs=</ds:DigestValue>
</xad:CertDigest>
<xad:IssuerSerial>
<ds:X509IssuerName>CN=CERTEUROPE ADVANCED CA V4, OU=0002 434202180, O=Certeurope, C=FR</ds:X509IssuerName>
<ds:X509SerialNumber>747583</ds:X509SerialNumber>
</xad:IssuerSerial>
</xad:Cert>
</xad:SigningCertificate>
<xad:SignaturePolicyIdentifier>
<xad:SignaturePolicyId>
<xad:SigPolicyId>
<xad:Identifier>1234567</xad:Identifier>
<xad:Description>Description de la politique de signature numérique</xad:Description>
</xad:SigPolicyId>
<xad:SigPolicyHash>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>ZXphcmxramhxZGY=</ds:DigestValue>
</xad:SigPolicyHash>
<xad:SigPolicyQualifiers>
<xad:SigPolicyQualifier>
<xad:SPURI>1234567</xad:SPURI>
</xad:SigPolicyQualifier>
</xad:SigPolicyQualifiers>
</xad:SignaturePolicyId>
</xad:SignaturePolicyIdentifier>
<xad:SignerRole>
<xad:ClaimedRoles/>
</xad:SignerRole>
</xad:SignedSignatureProperties>
<xad:SignedDataObjectProperties>
<xad:CommitmentTypeIndication>
<xad:CommitmentTypeId>
<xad:Identifier>1.2.840.113549.1.9.16.6.1</xad:Identifier>
<xad:Description>1.2.840.113549.1.9.16.6.1</xad:Description>
</xad:CommitmentTypeId>
<xad:ObjectReference>#D0-Reference</xad:ObjectReference>
</xad:CommitmentTypeIndication>
</xad:SignedDataObjectProperties>
</xad:SignedProperties>
(我是故意缩进的,一开始是线性的 XML)。
我需要获取以下摘要:
<ds:Reference Id="Sig_20151117_172752_SP-Reference" Type="http://uri.etsi.org/01903/#SignedProperties" URI="#Sig_20151117_172752_SP">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>euEROs8DacsBe3xqXBY5T+M07AI=</ds:DigestValue>
</ds:Reference>
我正在使用规范化 C14N 来执行此操作。
我尝试将这些命名空间添加到第一个标签中:
xmlns:xad="http://uri.etsi.org/01903/v1.3.2#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
顺序如下:
或
但这些尝试中 none 会奏效。有什么东西不见了吗? (这是我用来计算 SHA-1 摘要的 C# 方法:
public string CalculateHashSHA1(string input)
{
using (SHA1Managed sha1 = new SHA1Managed())
{
return Convert.ToBase64String(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(input)));
}
}
编辑:
- 源文件在这里:https://1fichier.com/?y9spk6g2zk
- 有缩进的源文件:https://1fichier.com/?11r0i8izzt
我正在尝试获取此摘要:euEROs8DacsBe3xqXBY5T+M07AI=
事实上,我需要使用这个方法:
XmlDsigExcC14NTransform innerTransform = new XmlDsigExcC14NTransform(false);
结果是正确的。