Hashed value for xadesSignedProperties not accurate

627 Views Asked by At

I have an UBL XML file and need to hash sha256 for xadesSignedProperties and the part need to be hash is :

<xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="signature">
                           <xades:SignedProperties Id="xadesSignedProperties">
                              <xades:SignedSignatureProperties>
                                 <xades:SigningTime>2021-02-25T12:57:51Z</xades:SigningTime>
                                 <xades:SigningCertificate>
                                    <xades:Cert>
                                       <xades:CertDigest>
                                          <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                                          <ds:DigestValue>9ef6c0b90ae609868bb614772e1d5375464ed1a1793ded751feb1e3414980f7c</ds:DigestValue>
                                       </xades:CertDigest>
                                       <xades:IssuerSerial>
                                          <ds:X509IssuerName>CN=CommonName,O=GAZT,L=Katowice,ST=Silesia,C=PL</ds:X509IssuerName>
                                          <ds:X509SerialNumber>15007377309689649296</ds:X509SerialNumber>
                                       </xades:IssuerSerial>
                                    </xades:Cert>
                                 </xades:SigningCertificate>
 </xades:SignedSignatureProperties>

The value it should be this 2ab365b063238318fdeac9c2957b135ef8a6727691fc4d81982b5bdd2cec9792:

 <ds:Reference Type="http://www.w3.org/2000/09/xmldsig#SignatureProperties"
                                      URI="#xadesSignedProperties">
                           <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                           <ds:DigestValue>2ab365b063238318fdeac9c2957b135ef8a6727691fc4d81982b5bdd2cec9792</ds:DigestValue>
</ds:Reference>

but don't know how to get the same DigestValue?

Any Idea about it?

1

There are 1 best solutions below

0
On

The ds:Reference dereferences not the 'xades:QualifyingProperties' element, but the 'xades:SignedProperties' element by its Id='xadesSignedProperties'. See XMLDSig specification for more details about referencing XML nodes.

Therefore, you need to compute hash not on the node copied above, but on the 'xades:SignedProperties' and its content.