|
Bouncy Castle Cryptography Library 1.85 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.bouncycastle.pqc.crypto.test.PublicKeyLengthValidationTest
Regression test for the PQC public-key length-validation hardening (finding #14).
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 Summary | |
PublicKeyLengthValidationTest()
|
|
| Method Summary | |
void |
testFalconPublicKeyRejectsMalformedLength()
|
void |
testMLDSAPublicKeyRejectsMalformedLength()
|
void |
testMLDSAValidKeyVerifiesAndMalformedKeyIsRejected()
|
void |
testMLKEMPublicKeyRejectsMalformedLength()
|
| Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString |
| Methods inherited from class junit.framework.Assert |
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, fail, fail |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public PublicKeyLengthValidationTest()
| Method Detail |
public void testMLDSAPublicKeyRejectsMalformedLength()
public void testMLKEMPublicKeyRejectsMalformedLength()
public void testFalconPublicKeyRejectsMalformedLength()
public void testMLDSAValidKeyVerifiesAndMalformedKeyIsRejected()
throws java.lang.Exception
java.lang.Exception
|
Bouncy Castle Cryptography Library 1.85 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||