naruto-lgtm commented on code in PR #1595:
URL: https://github.com/apache/poi/pull/1595#discussion_r4731047291
##########
poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java:
##########
@@ -201,14 +201,22 @@ public void setUriDereferencer(URIDereferencer
uriDereferencer) {
}
/**
- * @return true, if first signature part is valid
+ * @return true, if the package has at least one signature and all of its
signatures are valid
Review Comment:
Added to the "Validating a signed office document" section in
`src/documentation/content/xdocs/encryption.xml`: what changes for an existing
caller, that a registered signature without a part counts as invalid, that an
unparseable one throws, and the `getSignatureParts()` loop for per-signature
results right next to it.
##########
poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java:
##########
@@ -704,6 +704,65 @@ void testDuplicatePackageObjectId() throws Exception {
}
}
+ @Test
+ void testSecondSignatureIsValidated() throws Exception {
+ // a copy of the signature part, registered as a second signature of
the same document
+ try (OPCPackage pkg = OPCPackage.open(addSecondSignature(false))) {
+ SignatureInfo si = new SignatureInfo();
+ si.setOpcPackage(pkg);
+ si.setSignatureConfig(new SignatureConfig());
+ assertTrue(si.verifySignature(), "a copy of a valid signature is
valid as well");
+ }
+
+ // the same copy with a reference digest its signature value doesn't
cover anymore
+ try (OPCPackage pkg = OPCPackage.open(addSecondSignature(true))) {
Review Comment:
Done. `addSecondSignature` takes the relationship id now, so the corrupt
copy can go in as rId0 and sort before rId1, and both orders assert the
per-part results from `getSignatureParts()` next to the `verifySignature()`
result: `[true, false]` with the copy second, `[false, true]` with it first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]