-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform nodes in a Signature Policy #271
Comments
The policy document itself contains those transformations, right? My understanding - hence the way xades4j is implemented - is that the The XAdES spec allows for transforms to be applied over the policy document (this kind of confirms the reasoning above):
This isn't supported by xades4j as I think the use case is rather limited. More recent versions of the XAdES spec (namely EN 319 132-1) also seem to indicate that the reasoning above is correct. When describing
Notice how it mentions the "policy document" again. Do you have any other indication in a different direction? So, to sum-up: processing of the policy itself is not handled by xades4j. The verifier has access to |
Thanks for the response. When I currently feed Xades4J this policy with the code below the resulting digest is different from the one specified in the policy. I think this is because the transform actions aren't being executed.
What would be the best way I can assure Xades4J produces signatures with the same SigPolicyHash as the one specified in the policy? |
xades4j already produces the correct hash, as I tried to explain in my previous reply. There's no way to change this behavior via configuration. I don't know if that policy file obeys to some standard that also defines processing rules, but, trying to explain again, my understanding is the following:
The digest value in
As expected, in this case there's a transform to remove
The digest value within the
In this case we just look at the policy file/resource as a whole, for integrity. It just happens that the policy format also defines a digest, but it probably didn't have to. From the XAdES spec, section 7.2.3:
Another argument is that it wouldn't make sense for a library producing signature to also have to know how to process any signature format. Also, read the arguments in my previous reply. To sum up: my understanding is that the two mechanisms are different and xades4j is doing the correct thing. If you have any evidence that indicates something different, please share. Otherwise, I'm closing this issue. |
With all this, I didn't ask: why did you want xades4j to calculated the digest in |
In this EU guideline (section 5.2.9.) it clearly describes how Transform elements inside a signature policy should be processed before computing the hash that will be placed in the SignaturePolicyIdentifier. It's up to you if you want to add this support. I have already solved my problem by using the DSS-xades library from the EU to perform the transform actions and giving the resulting policy document to xades4j. For anyone who has a similar problem, with the following code DSS-Xades will canonicalise your document and perform a filter2 xpath tranform, removing the "SignPolicyDigest" from the policy document:
|
Thanks for sharing more details. An important note is that xades4j is based on ETSI TS 101 903 1.4.1. The link you shared is for the more recent XAdES spec. That said, we still have different interpretations. I believe that - even on the newer EN 319 132-1 V1.2.1 spec - the Note that signature policies don't need to be XML-based. TS 119 172-1 defines both PDF and XML formats for policies. You asked:
Even assuming the policy is XML, my understanding is that the digest value in If this wasn't the case, how would signatures be handled (produced and verified) in cases where Note how the section on the spec that you linked even defines a (kind of hacky) transform to indicate that the digest should be calculated accordingly to some other specification:
Given all the above, it's clear to me that
I must ask: how did you conclude that? On the side of trying to understand what's the correct thing to do, I still didn't understand why you needed to have the same digest values. Are you verifying the signatures produced by xades4j in another platform that has this rule? If that's the case, the verifier may be wrong. Note that by transforming the policy document before providing the byte stream to xades4j, you may actually break other verifiers that do things as xades4j. It may be worth mentioning that a few years ago xades4j participated in interoperability tests organized by ETSI. I don't recall all the test cases, but I'm pretty sure this wasn't an issue. |
I'm using Xades4j v2.2.0 and want to create a signature based on a signature policy which contains transform nodes.
The policy contains an expected signature policy at the end of the xml-file which needs to be removed with a filter2 subtract action. additionally the entire file needs to be Canonicalized. Both these transformations are defined in the signature policy file.
These transform actions need to be executed before the policy digest is calculated. It seems like these transformations aren't automatically preformed in the current version. Is there a way to execute these transformations through xades4j?
The text was updated successfully, but these errors were encountered: