public class PublicKeyLengthValidationTest
extends junit.framework.TestCase
ML-DSA and Falcon public-key parameter classes must reject a malformed-length encoding with an
IllegalArgumentException at decode time, rather than storing it and throwing an
ArrayIndexOutOfBoundsException later during signature verification. The crash was a
denial of service reachable when verifying with an attacker-supplied key (e.g. a malformed ML-DSA
certificate exercised during certification-path validation). This mirrors the ML-KEM / SLH-DSA
parameter classes, which already validate the encoding length.
Each negative case is constructed from a 33-byte buffer: long enough that the old ML-DSA code
accepted it (splitting off a 1-byte t1), short enough that Packing then
indexed past it (arraycopy: length -319 is negative) at verify time.
| Constructor and Description |
|---|
PublicKeyLengthValidationTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
testFalconPublicKeyRejectsMalformedLength() |
void |
testMLDSAPublicKeyRejectsMalformedLength() |
void |
testMLDSAValidKeyVerifiesAndMalformedKeyIsRejected() |
void |
testMLKEMPublicKeyRejectsMalformedLength() |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toStringpublic void testMLDSAPublicKeyRejectsMalformedLength()
public void testMLKEMPublicKeyRejectsMalformedLength()
public void testFalconPublicKeyRejectsMalformedLength()
public void testMLDSAValidKeyVerifiesAndMalformedKeyIsRejected()
throws java.lang.Exception
java.lang.Exception