Skip to content

Add negative test cases for the PQC (ML-DSA / ML-KEM) tests - #1

Open
Arpan0995 wants to merge 1 commit into
ffang:PQCfrom
Arpan0995:pqc-negative-tests
Open

Add negative test cases for the PQC (ML-DSA / ML-KEM) tests#1
Arpan0995 wants to merge 1 commit into
ffang:PQCfrom
Arpan0995:pqc-negative-tests

Conversation

@Arpan0995

Copy link
Copy Markdown

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 tampered ds:SignatureValue is 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 corrupted xenc:CipherValue (bit flip in the encapsulation part) is rejected.

All four are parameterized across the three parameter sets in the same @CsvSource style 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 skipped
  • without the bouncycastle profile: compiles and all cases skip via the existing assumeTrue guards

One 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant