A Java program sends a PDF document to an external system and receives a XADES sign of this document.
I would like to check if the hash of the PDF document matches the hash contained inside the Xades sign. So I calculate the SHA1 of the PDF document, but it is different to the hash in the ds:DigestValue (fpm+e6K287hHh1xlYxXoZ3Q3bkQ=). Why? I'm sure I'm calculating properly the PDF document hash.
<documentoSGIFE>
<documentoOriginal Id="original" encoding="base64" nombreFichero="371F1EDC7D2D1B22E0500C0AD23624FD.PDF">...</documentoOriginal>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature001">
<ds:SignedInfo Id="SignedInfo001">
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference Id="Reference001_001" URI="#original">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>fpm+e6K287hHh1xlYxXoZ3Q3bkQ=</ds:DigestValue>
</ds:Reference>
<ds:Reference Id="Reference001_002" Type="http://uri.etsi.org/01903/v1.2.2#SignedProperties" URI="#SignedProperties001">...</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue Id="SignatureValue001">...</ds:SignatureValue>
<ds:KeyInfo Id="KeyInfo001">...</ds:KeyInfo>
<ds:Object>...</ds:Object>
</ds:Signature>
</documentoSGIFE>
Thanks