private void test_Cipher_ShortBufferException(Cipher c, String algorithm, int encryptMode,
            AlgorithmParameterSpec spec, Key key, byte[] text) throws Exception {
        c.init(encryptMode, key, spec);
        if (isAEAD(algorithm)) {
            c.updateAAD(new byte[24]);
        }
        if (c.getOutputSize(text.length) > 0) {
            byte[] output;
            if (algorithm.startsWith("RSA/")) {
                // RSA encryption pads the input data to a full block before encrypting,
                // so unlike most algorithms, getOutputSize can't determine how much space
                // is necessary until the data is actually decrypted.
                output = new byte[1];
            } else {
                // Other algorithms can much more easily forsee how much output data there
                // will be, so don't let them get away with being overly conservative.
                output = new byte[c.getOutputSize(text.length) - 1];
            }
            try {
                c.doFinal(text, 0, text.length, output);
                fail("Short buffer should have thrown ShortBufferException");
            } catch (ShortBufferException expected) {
                // Ignored
            }
        }
    }
Try various .init(...) calls with null parameters to make sure it is
handled.
common/src/test/java/org/conscrypt/javax/crypto/CipherTest.java