@Test
    public void test_getInstance() throws Exception {
        final ByteArrayOutputStream errBuffer = new ByteArrayOutputStream();
        PrintStream out = new PrintStream(errBuffer);

        Set<String> seenBaseCipherNames = new HashSet<>();
        Set<String> seenCiphersWithModeAndPadding = new HashSet<>();

        Provider[] providers = Security.getProviders();
        for (Provider provider : providers) {
            Set<Provider.Service> services = provider.getServices();
            for (Provider.Service service : services) {
                String type = service.getType();
                if (!type.equals("Cipher")) {
                    continue;
                }

                String algorithm = service.getAlgorithm().toUpperCase(Locale.US);

                /*
                 * Any specific modes and paddings aren't tested directly here,
                 * but we need to make sure we see the bare algorithm from some
                 * provider. We will test each mode specifically when we get the
                 * base cipher.
                 */
                final int firstSlash = algorithm.indexOf('/');
                if (firstSlash == -1) {
                    seenBaseCipherNames.add(algorithm);
                } else {
                    final int secondSlash = algorithm.indexOf('/', firstSlash + 1);
                    if (secondSlash > 0) {
                        // Only look for a base Cipher if there are two slashes, to avoid SunJCE
                        // quirks like PBEWithHmacSHA512/224AndAES_128
                        final String baseCipherName = algorithm.substring(0, firstSlash);
                        if (!seenBaseCipherNames.contains(baseCipherName)
                            && !(baseCipherName.equals("AES_128")
                            || baseCipherName.equals("AES_192")
                            || baseCipherName.equals("AES_256"))) {
                            seenCiphersWithModeAndPadding.add(baseCipherName);
                        }
                        if (!Conscrypt.isConscrypt(provider)) {
                            continue;
                        }
                    }
                }

                if (provider.getName().equals("SunJCE")) {
                    // The SunJCE provider acts in numerous idiosyncratic ways that don't
                    // match any other provider.  Examples include returning non-null IVs
                    // when no IV was provided on init, NullPointerExceptions when null
                    // SecureRandoms are supplied (but only to PBE ciphers), and not
                    // supplying KeyGenerators for some algorithms.  We aren't sufficiently
                    // interested in verifying this provider's behavior to adapt the
                    // tests and Oracle presumably tests them well anyway, so just skip
                    // verifying them.
                    continue;
                }

                try {
                    test_Cipher_Algorithm(provider, algorithm);
                } catch (Throwable e) {
                    out.append("Error encountered checking " + algorithm
                               + " with provider " + provider.getName() + "\n");
                    e.printStackTrace(out);
                }

                Set<String> modes = StandardNames.getModesForCipher(algorithm);
                if (modes != null) {
                    for (String mode : modes) {
                        Set<String> paddings = StandardNames.getPaddingsForCipher(algorithm);
                        if (paddings != null) {
                            for (String padding : paddings) {
                                final String algorithmName = algorithm + "/" + mode + "/" + padding;
                                try {
                                    if (isSupported(algorithmName, provider.getName())) {
                                        test_Cipher_Algorithm(provider, algorithmName);
                                    }
                                } catch (Throwable e) {
                                    out.append("Error encountered checking " + algorithmName
                                               + " with provider " + provider.getName() + "\n");
                                    e.printStackTrace(out);
                                }
                            }
                        }
                    }
                }
            }
        }

        seenCiphersWithModeAndPadding.removeAll(seenBaseCipherNames);
        assertEquals("Ciphers seen with mode and padding but not base cipher",
                Collections.EMPTY_SET, seenCiphersWithModeAndPadding);

        out.flush();
        if (errBuffer.size() > 0) {
            throw new Exception("Errors encountered:\n\n" + errBuffer + "\n\n");
        }
    }
Returns the key meant for deciphering for {@code algorithm}.
common/src/test/java/org/conscrypt/javax/crypto/CipherTest.java