private void checkCipher_ShortBlock_Failure(CipherTestParam p, String provider) throws Exception {
        // Do not try to test ciphers with no padding already.
        String noPaddingTransform = getCipherTransformationWithNoPadding(p.transformation);
        if (p.transformation.equals(noPaddingTransform)) {
            return;
        }

        Cipher c = Cipher.getInstance(
                getCipherTransformationWithNoPadding(p.transformation), provider);
        if (c.getBlockSize() == 0) {
            return;
        }

        if (!p.transformation.endsWith("NOPADDING")) {
            c.init(Cipher.ENCRYPT_MODE, p.encryptKey);
            try {
                c.doFinal(new byte[] { 0x01, 0x02, 0x03 });
                fail("Should throw IllegalBlockSizeException on wrong-sized block; transform="
                        + p.transformation + " provider=" + provider);
            } catch (IllegalBlockSizeException expected) {
            }
        }
    }
Helper for testing that Cipher.unwrap() throws IllegalStateException when
initialized in modes other than UNWRAP.
common/src/test/java/org/conscrypt/javax/crypto/CipherTest.java