XAdES-BES Disabled SignedProperties Incorrect DigestValue Link (Java)

Hi I'm looking for an answer why the DigestValue reference in SignedProperties is not correct. I tried to digest the element on a case-by-case basis, I found an example or documentation.

This is my signature file (I got the certificate information):

<?xml version="1.0" encoding="UTF-8"?>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="#Signature-1919784195">
   <ds:SignedInfo>
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" />
      <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
      <ds:Reference Id="Reference1-1552126515" URI="test.zip">
         <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
         <ds:DigestValue>s+zv7GDSuBlZ8PhyI9SAjP6eDlI=</ds:DigestValue>
      </ds:Reference>
      <ds:Reference Id="SignedProperties-Reference-1552126515" Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedProperties-1552126515">
         <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
         <ds:DigestValue>guKwI4aww2EUnGl1toBMSIZOPkk=</ds:DigestValue>
      </ds:Reference>
   </ds:SignedInfo>
   <ds:SignatureValue>m0by6gzpBeBXCvKlsr6cknRCVFPLZ+q+MuMgSz1X6sBS2b93AykpqJA6la1lliqcp+0kp6JPhq9q
igruA7bu/OEOWIn3peUdodkeD1DkrjukOijNwDoJp1c1ssqD/2aKQkCQn9XaRtEnXVtc6jXLBUf+
llJKEUjWBeWoGEKCcbnLw+xl6aqPFntvQC5pR8nYU1pdQizTIOr8uWBgP18B8F8exyGvaJbS6MxK
DaiYpQay31gOBgyaM6jtkAhBP0wkDxFDd15DNlbKF0LYiGz7z0e37Ai4nS/Ae7081a6F5JuOxUJA
gJuUqkgoX6QSxs3BB4Eszu/1kq8JDiMc8q8ucw==</ds:SignatureValue>
   <ds:KeyInfo>
      <ds:X509Data>
         <ds:X509IssuerSerial>
            <ds:X509IssuerName>TEST</ds:X509IssuerName>
            <ds:X509SerialNumber>0000</ds:X509SerialNumber>
         </ds:X509IssuerSerial>
         <ds:X509SubjectName>TEST</ds:X509SubjectName>
         <ds:X509Certificate>Mf6nW1fbhMdhSfKZnykvaG6sebhrE1tYAfShErijYxQd+qA==</ds:X509Certificate>
      </ds:X509Data>
   </ds:KeyInfo>
   <ds:Object Id="QualifyingInfos">
      <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="#Signature-1919784195">
         <xades:SignedProperties Id="SignedProperties-1552126515">
            <xades:SignedSignatureProperties>
               <xades:SigningTime>2015-05-29T13:14:043Z</xades:SigningTime>
               <xades:SigningCertificate>
                  <xades:Cert>
                     <xades:CertDigest>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                        <ds:DigestValue>NlFeJOqtZcEqMYgCBWN46qG1V5g=</ds:DigestValue>
                     </xades:CertDigest>
                     <xades:IssuerSerial>
                        <ds:X509IssuerName>TEST</ds:X509IssuerName>
                        <ds:X509SerialNumber>00000</ds:X509SerialNumber>
                     </xades:IssuerSerial>
                  </xades:Cert>
               </xades:SigningCertificate>
            </xades:SignedSignatureProperties>
            <xades:SignedDataObjectProperties>
               <xades:DataObjectFormat ObjectReference="Reference1-1552126515">
                  <xades:Description>MIME-Version: 1.0 Content-Type: application/zip Content-Transfer-Encoding: binary Content-Disposition: filename="test.zip"</xades:Description>
                  <xades:MimeType>application/zip</xades:MimeType>
               </xades:DataObjectFormat>
            </xades:SignedDataObjectProperties>
         </xades:SignedProperties>
      </xades:QualifyingProperties>
   </ds:Object>
</ds:Signature>

      

This is the code im used to generate the signature file:

        DigestMethod dm = fac.newDigestMethod(DigestMethod.SHA1, null);
        CanonicalizationMethod cn = fac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,(C14NMethodParameterSpec) null);

        List<Reference> refs = new ArrayList<Reference>();
        Reference ref1 = fac.newReference(pathName, dm,null,null,signedRefID,messageDigest2.digest(datax));
        refs.add(ref1);

        Canonicalizer cn14 = Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS);
        byte[] canon;
        canon = cn14.canonicalizeSubtree(SPElement);
        Reference ref2 = fac.newReference("#"+signedPropID,dm, null , sigProp , signedPropRefID,messageDigest2.digest(canon));
        refs.add(ref2);

        SignatureMethod sm = fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null);
        SignedInfo si = fac.newSignedInfo(cn, sm, refs);

        XMLSignature signature = fac.newXMLSignature(si, ki,objects,signatureID,null);

        signature.sign(dsc);

      

When I sign the XAdES envelope, everything is fine. Does anyone solve this problem? Is this canonization correct? I would appreciate your help or suggestions.

+3


source to share





All Articles