private void test_KeyPairGenerator(KeyPairGenerator kpg) throws Exception {
        // without a call to initialize
        test_KeyPair(kpg, kpg.genKeyPair());
        test_KeyPair(kpg, kpg.generateKeyPair());

        String algorithm = kpg.getAlgorithm();

        // TODO: detect if we're running in vogar and run the full test
        if ("DH".equals(algorithm) || "DiffieHellman".equalsIgnoreCase(algorithm)) {
            // Disabled because this takes too long on devices.
            // TODO: Re-enable DH test. http://b/5513723.
            return;
        }

        List<Integer> keySizes = getKeySizes(algorithm);
        for (int keySize : keySizes) {
            // TODO(flooey): Remove when we don't support Java 6 anymore
            if ("DSA".equals(algorithm)
                    && ("SUN".equalsIgnoreCase(kpg.getProvider().getName())
                        || "SunPKCS11-NSS".equalsIgnoreCase(kpg.getProvider().getName()))
                    && keySize != 512 && keySize != 1024) {
                // The Sun provider doesn't support DSA in all the key sizes, so ignore
                // the uncommon ones.
                continue;
            }
            kpg.initialize(keySize);
            test_KeyPair(kpg, kpg.genKeyPair());
            test_KeyPair(kpg, kpg.generateKeyPair());

            kpg.initialize(keySize, null);
            test_KeyPair(kpg, kpg.genKeyPair());
            test_KeyPair(kpg, kpg.generateKeyPair());

            kpg.initialize(keySize, new SecureRandom());
            test_KeyPair(kpg, kpg.genKeyPair());
            test_KeyPair(kpg, kpg.generateKeyPair());
        }

        if ("EC".equals(algorithm) || "ECDH".equals(algorithm)
                || "ECDSA".equals(algorithm)) {
            if ("SunPKCS11-NSS".equalsIgnoreCase(kpg.getProvider().getName())) {
                // SunPKCS11 doesn't support some of the named curves that we expect, so it
                // fails.  Skip it.
                return;
            }
            for (String curveName : EC_NAMED_CURVES) {
                kpg.initialize(new ECGenParameterSpec(curveName));
                test_KeyPair(kpg, kpg.genKeyPair());
                test_KeyPair(kpg, kpg.generateKeyPair());

                kpg.initialize(new ECGenParameterSpec(curveName), null);
                test_KeyPair(kpg, kpg.genKeyPair());
                test_KeyPair(kpg, kpg.generateKeyPair());

                kpg.initialize(new ECGenParameterSpec(curveName), new SecureRandom());
                test_KeyPair(kpg, kpg.genKeyPair());
                test_KeyPair(kpg, kpg.generateKeyPair());
            }
        }
    }
Elliptic Curve Crypto named curves that should be supported.
common/src/test/java/org/conscrypt/java/security/KeyPairGeneratorTest.java