private void test_Key(KeyPairGenerator kpg, Key k) throws Exception {
        String expectedAlgorithm = kpg.getAlgorithm().toUpperCase(Locale.ROOT);
        if (StandardNames.IS_RI && expectedAlgorithm.equals("DIFFIEHELLMAN")) {
            expectedAlgorithm = "DH";
        }
        assertEquals(expectedAlgorithm, k.getAlgorithm().toUpperCase(Locale.ROOT));
        if (expectedAlgorithm.equals("DH")) {
            if (k instanceof DHPublicKey) {
                DHPublicKey dhPub = (DHPublicKey) k;
                assertEquals(dhPub.getParams().getP(), getDHParams().getP());
            } else if (k instanceof DHPrivateKey) {
                DHPrivateKey dhPriv = (DHPrivateKey) k;
                assertEquals(dhPriv.getParams().getP(), getDHParams().getP());
            } else {
                fail("not a public or private key!?");
            }
        }
        if (kpg.getProvider().getName().equalsIgnoreCase("SunMSCAPI")
                && expectedAlgorithm.equals("RSA")) {
            // The SunMSCAPI RSA keys don't provide encoded versions at all, nor are they
            // serializable, so just skip them.
            return;
        }
        if (expectedAlgorithm.equals("ML-DSA")) {
            // ML-DSA keys are not yet serializable, so just skip them.
            return;
        }
        if (expectedAlgorithm.equals("SLH-DSA-SHA2-128S")) {
            // SLH-DSA keys are not yet serializable, so just skip them.
            return;
        }
        assertNotNull(k.getEncoded());
        assertNotNull(k.getFormat());

        // Test serialization
        // SunPKCS11-NSS on Java 6 replaces serialized keys with one from the default provider,
        // so the deserialized key doesn't match the original.
        if (!kpg.getProvider().getName().equalsIgnoreCase("SunPKCS11-NSS")) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream(16384);
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(k);

            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            ObjectInputStream ois = new ObjectInputStream(bais);
            Key inflatedKey = (Key) ois.readObject();

            assertEquals("Provider: " + kpg.getProvider(), k, inflatedKey);
        }

        test_KeyWithAllKeyFactories(k);
    }
Elliptic Curve Crypto named curves that should be supported.
common/src/test/java/org/conscrypt/java/security/KeyPairGeneratorTest.java