1

I received an example xades signature that I have to reproduce using xades4j ("like a template").

The example signature is this (an excerpt):

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="xmldsig-qualifyingproperties-yada-yada">
    <ds:SignedInfo>
        <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
        <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
        <ds:Reference URI="#xmldsig-signedproperties-yada-yada">
            <ds:Transforms>
                <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/>
            </ds:Transforms>
            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
            <ds:DigestValue>yada-yada-yada-yada-yada-yada-yada</ds:DigestValue>
        </ds:Reference>
(...)

I know that this reference is not xades compliant, because there is no attribute Type there.

My issue is with the Transform in that Reference. I'm not able to find how can I set this option with xades4j. Can this be done?

Also, I don't know if that is here make sense, because at the signature top, it says that the canonicalization method is one then in the signedproperties reference it says the canonicalization method is another one... Am I reading this correctly?

brun0sa
  • 104
  • 7

1 Answers1

1

You cannot set transforms on the signed properties reference. This is motivated by both:

  1. being uncertain about the need - the resource being signed (the actual signed properties element) is actually generated by xades4j so it doesn't make much sense to allow external control.
  2. security - arbitrary transforms cannot be allowed because the library needs to be sure that the reference points to the SignedProperties element.

Probably the only transform that could be used is canonicalization, but XML-DSIG already specifies that if the dereferenced resource is a nodeset it must be canonicalized before digest using C14N as default algorithm, which xades4j/santuario will use. On your example, the algorithm is the same, with the difference that it includes the comment nodes on the digest generation.

As for having 2 canonicalization algorithms, it's because they are different: the one in the reference's transforms is applied over the result of dereferencing that data object. on the other hand, the one at the top specifies the canonicalization algorithm that is used over the SignedInfo element to get the actual signature input (octet stream)

lgoncalves
  • 2,040
  • 1
  • 14
  • 12
  • Totally agree with the second point. Also with the first one from the producer point of view. But, if I'm a verifier, that (obviously) wants the verify a signature that have a canonicalization transform in the signedProperties reference. Should I have the Transform in consideration or not? Personalty, I would prefer to don't have any transform in this reference and use the specified default, for the sake of simplicity and clarity. But I have to play with what they give me... – brun0sa Sep 12 '14 at 13:05
  • Well, if the transform is there, xades4j will use it when processing the reference. What you could do is analyze the dataobjects on the verification output and check if there's any transform that you consider unsafe. Kind of a white list. – lgoncalves Sep 12 '14 at 16:46
  • This may be a silly question, but... You said that the canonicalization algorithm is the same with the included comments difference. In the example, it is "xml-exc-c14n" and "REC-xml-c14n-20010315" (ignoring the comments part). These are the same? – brun0sa Oct 01 '14 at 08:09
  • I meant that REC-xml-c14n-20010315#withComments is the same as the XML-DSIG default (REC-xml-c14n-20010315) but with comments. – lgoncalves Oct 07 '14 at 19:15