private void assertCorrectAlgorithmParameters(String providerName, String cipherID,
            final AlgorithmParameterSpec spec, AlgorithmParameters params)
            throws Exception {
        if (spec == null) {
            return;
        }

        // Bouncycastle has a bug where PBE algorithms sometimes return null parameters.
        if ("BC".equals(providerName) && isPBE(cipherID) && params == null) {
            return;
        }

        assertNotNull(cipherID + " getParameters() should not be null", params);

        if (spec instanceof GCMParameterSpec) {
            GCMParameterSpec gcmDecryptSpec = params.getParameterSpec(GCMParameterSpec.class);
            assertEquals(cipherID + " getIV()", Arrays.toString(((GCMParameterSpec) spec).getIV()),
                    Arrays.toString(gcmDecryptSpec.getIV()));
            assertEquals(cipherID + " getTLen()", ((GCMParameterSpec) spec).getTLen(),
                    gcmDecryptSpec.getTLen());
        } else if (spec instanceof IvParameterSpec) {
            IvParameterSpec ivDecryptSpec = params.getParameterSpec(IvParameterSpec.class);
            assertEquals(cipherID + " getIV()", Arrays.toString(((IvParameterSpec) spec).getIV()),
                    Arrays.toString(ivDecryptSpec.getIV()));
        } else if (spec instanceof PBEParameterSpec) {
            // Bouncycastle seems to be undecided about whether it returns this
            // or not
            if (!"BC".equals(providerName)) {
                assertNotNull(cipherID + " getParameters()", params);
            }
        } else if (spec instanceof OAEPParameterSpec) {
            assertOAEPParametersEqual((OAEPParameterSpec) spec,
                    params.getParameterSpec(OAEPParameterSpec.class));
        } else {
            fail("Unhandled algorithm specification class: " + spec.getClass().getName());
        }
    }
Returns the key meant for deciphering for {@code algorithm}.
common/src/test/java/org/conscrypt/javax/crypto/CipherTest.java