test(seal): prove each signature carries its own seal - #218
Merged
Conversation
The claim was true by construction and untested. SealTest covered a seal on one signature, the multi-signature tests covered revisions without seals, and nothing covered both at once, so a regression would have been silent until somebody opened a file. Two things are asserted, and both were checked against a deliberately wrong document first, since an assertion that cannot fail is not one: One image and one form XObject per signature. A single sealed signature produces one of each, so counting two is counting per revision rather than matching a constant. Two distinct rectangles. Signing twice at the same placement produces "155 250 205 275" both times, so the difference assertion is sensitive to placement rather than trivially true. The filters differ too, DCTDecode for the rendered seal against FlateDecode for the supplied PNG, which shows the second signature carries the caller's image and not a re-render of the certificate. samples/two-seals.pdf ships the same case for readers rather than for the suite. poppler 25.12 reports both valid, the first covering its own revision and the second the whole file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the gap noticed while answering a question: the claim that each signature carries an independent seal was true by construction and untested.
SealTestcovered a seal on one signature. The multi-signature tests covered several revisions without seals. Nothing covered both at once, so a regression would have stayed silent until someone opened a file in a reader.What is asserted
One image and one form XObject per signature. Not one pair reused by both.
Two distinct rectangles, neither of them the invisible
0 0 0 0.Different filters,
DCTDecodefor the rendered seal againstFlateDecodefor the supplied PNG, which shows the second signature carries the caller's image rather than a re-render of the certificate.Both signatures then validate, and the report counts two.
Both assertions were checked against a wrong document first
An assertion that cannot fail is not an assertion. Measured before writing them:
images=1 forms=1, so counting two counts per revision rather than matching a constantrectA=[155 250 205 275],rectB=[155 250 205 275], identical, so the difference assertion is sensitive to placement rather than trivially truesamples/two-seals.pdfThe same case shipped for readers rather than for the suite, since the point of this one is visual: the first seal is rendered from the certificate at x 150 / y 240, the second is
src/Resources/img/sign-seal.pngat x 30 / y 60.Verified with poppler
pdfsig25.12:The first covering only its own revision is the expected reading, not a defect: the second signature came after it.
samples/README.mdsays so explicitly, since that line reads like a warning to anyone who has not met incremental signing before.poc/sign-samples.phpregenerates it alongside the others.Verification
composer checkon PHP 8.5 through.docker: green, 136 tests, one more than before.