Add negative test cases for the PQC (ML-DSA / ML-KEM) tests - #1
Open
Arpan0995 wants to merge 1 commit into
Open
Conversation
Covers the four cases discussed on apache#645: tampered signature rejection, wrong-key verification failure, wrong-recipient-key decryption failure, and corrupted KEM encapsulation rejection. All parameterized across ML-DSA-44/65/87 and ML-KEM-512/768/1024.
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.
This adds the four negative cases discussed on apache#645 to the two DOM test classes, so they are in place before the Signature/Encryption split:
XMLSignatureMLDSATest: a tamperedds:SignatureValueis rejected, and verification against a different ML-DSA public key of the same parameter set fails.XMLEncryptionMLKEMTest: decryption with a non-matching ML-KEM private key fails, and a corruptedxenc:CipherValue(bit flip in the encapsulation part) is rejected.All four are parameterized across the three parameter sets in the same
@CsvSourcestyle as the existing tests. The change is additive; the existing happy-path tests are untouched.Verified locally:
mvn test -Dtest=XMLSignatureMLDSATest,XMLEncryptionMLKEMTest -P bouncycastle: 9 + 9 executions, 0 failures, 0 skippedbouncycastleprofile: compiles and all cases skip via the existingassumeTrueguardsOne note on the corrupted-encapsulation case: since ML-KEM decapsulation has implicit rejection, a corrupted encapsulation does not fail at decapsulation itself; it yields a different shared secret, and the failure surfaces at the AES key-unwrap integrity check. The test asserts that decryption fails as a whole, which keeps it independent of where exactly the failure surfaces.
If you would rather fold these into the split PRs, the ML-DSA cases go with the Signature one and the ML-KEM cases with the Encryption one; happy to rebase either way.