Bouncy Castle Cryptography Library 1.86

org.bouncycastle.pqc.crypto.test
Class PqcUnmappedAlgorithmOidTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.bouncycastle.pqc.crypto.test.PqcUnmappedAlgorithmOidTest
All Implemented Interfaces:
junit.framework.Test

public class PqcUnmappedAlgorithmOidTest
extends junit.framework.TestCase

Regression tests for the algorithm-identifier dispatch in the PQC PrivateKeyFactory / PublicKeyFactory.

The private-key dispatch used to select a branch with , a subtree test that matches every leaf below the arc — including leaves that have no entry in the matching table. The branch then passed the lookup result straight into a constructor, so a PKCS#8 blob naming such an OID escaped with a NullPointerException (or, where the constructor merely stores the parameters, returned a key object carrying parameters that failed later, far from the parse). Both are wrong for a method whose contract is .

The concrete reported case is the OQS interop arc 1.3.9999.6, which carries 16 hybrid (ECDSA-P256 / RSA-3072 / P-384 / P-521 combined with SPHINCS+) OIDs that are declared in BCObjectIdentifiers but deliberately not implemented — e.g. = 1.3.9999.6.4.14.


Constructor Summary
PqcUnmappedAlgorithmOidTest()
           
 
Method Summary
 void testDeclaredOidsUnderDispatchArcsStillDispatch()
          Compatibility assertion and drift guard in one.
 void testOqsHybridP256Sphincs128fPrivateKeyRejected()
          The reported case: a PKCS#8 PrivateKeyInfo tagged with the OQS hybrid OID 1.3.9999.6.4.14 used to leave createKey as a NullPointerException.
 void testOqsHybridPrivateKeysRejected()
          All 16 OQS hybrid OIDs, over every private-key body shape.
 void testOqsInteropArcRealKeyStillRoundTrips()
          End-to-end compatibility on the arc that carries the reported hybrids: a real SPHINCS+ key whose OID (1.3.9999.6.4.13) is a sibling leaf of 1.3.9999.6.4.14 must still round-trip.
 void testUnbackedPublicKeyRegistrationsRejected()
          Public-key side.
 void testUndeclaredLeafUnderEachDispatchArcRejected()
          The general form: an undeclared leaf under each arc the dispatch used to accept wholesale.
 
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

PqcUnmappedAlgorithmOidTest

public PqcUnmappedAlgorithmOidTest()
Method Detail

testOqsHybridP256Sphincs128fPrivateKeyRejected

public void testOqsHybridP256Sphincs128fPrivateKeyRejected()
                                                    throws java.lang.Exception
The reported case: a PKCS#8 PrivateKeyInfo tagged with the OQS hybrid OID 1.3.9999.6.4.14 used to leave createKey as a NullPointerException.

Throws:
java.lang.Exception

testOqsHybridPrivateKeysRejected

public void testOqsHybridPrivateKeysRejected()
                                      throws java.lang.Exception
All 16 OQS hybrid OIDs, over every private-key body shape.

Throws:
java.lang.Exception

testUndeclaredLeafUnderEachDispatchArcRejected

public void testUndeclaredLeafUnderEachDispatchArcRejected()
                                                    throws java.lang.Exception
The general form: an undeclared leaf under each arc the dispatch used to accept wholesale.

Throws:
java.lang.Exception

testUnbackedPublicKeyRegistrationsRejected

public void testUnbackedPublicKeyRegistrationsRejected()
                                                throws java.lang.Exception
Public-key side. The 16 hybrid OIDs are not in the PublicKeyFactory converter table at all, so they were already rejected cleanly; the leak there came from converter registrations whose OID has no entry in the matching parameters table — the bare SPHINCS+ arc, the OQS round-3 OID 1.3.9999.6.4.10, and the vestigial Kyber-AES OIDs.

Throws:
java.lang.Exception

testDeclaredOidsUnderDispatchArcsStillDispatch

public void testDeclaredOidsUnderDispatchArcsStillDispatch()
                                                    throws java.lang.Exception
Compatibility assertion and drift guard in one. Every OID declared in BCObjectIdentifiers below one of the dispatch arcs must either still reach its branch, or be one of the 16 known-unimplemented OQS hybrids. A declared OID that stops dispatching means the narrowed predicate cut too deep; a newly declared OID with no parameters table entry shows up here as an unexpected "not recognised", which is exactly the drift that produced this defect.

Throws:
java.lang.Exception

testOqsInteropArcRealKeyStillRoundTrips

public void testOqsInteropArcRealKeyStillRoundTrips()
                                             throws java.lang.Exception
End-to-end compatibility on the arc that carries the reported hybrids: a real SPHINCS+ key whose OID (1.3.9999.6.4.13) is a sibling leaf of 1.3.9999.6.4.14 must still round-trip.

Throws:
java.lang.Exception

Bouncy Castle Cryptography Library 1.86