private void testJceAvailability(int keyBitLength)
            throws
            EncryptionUnsupportedByPlatformException, PDFParseException {

        // we need to supply a little buffer for AES, which will look
        // for an initialisation vector of 16 bytes
        final byte[] junkBuffer = new byte[16];
        Arrays.fill(junkBuffer, (byte) 0xAE);
        // test using the longer key length for salted content so that
        // we can check for maximum key length problems
        final byte[] junkKey =
                new byte[getSaltedContentKeyByteLength(keyBitLength / 8)];
        Arrays.fill(junkKey, (byte) 0xAE);

        try {
            createAndInitialiseContentCipher(
                    ByteBuffer.wrap(junkBuffer),
                    junkKey);
        } catch (PDFParseException e) {
            throw new PDFParseException("Internal error; " +
                    "failed to produce test cipher: " + e.getMessage());
        } catch (NoSuchAlgorithmException e) {
            throw new EncryptionUnsupportedByPlatformException(
                    "JCE does not offer required cipher", e);
        } catch (NoSuchPaddingException e) {
            throw new EncryptionUnsupportedByPlatformException(
                    "JCE does not offer required padding", e);
        } catch (InvalidKeyException e) {
            throw new EncryptionUnsupportedByPlatformException(
                    "JCE does accept key size of " +
                            (getSaltedContentKeyByteLength() * 8) +
                            " bits- could it be a policy restriction?", e);
        } catch (InvalidAlgorithmParameterException e) {
            throw new EncryptionUnsupportedByPlatformException(
                    "JCE did not accept cipher parameter", e);
        }

        try {
            createMD5Digest();
        } catch (NoSuchAlgorithmException e) {
            throw new EncryptionUnsupportedByPlatformException(
                    "No MD5 digest available from JCE", e);
        }

        if (encryptionAlgorithm != EncryptionAlgorithm.RC4) {
            // we still need RC4 for U and O value checks. Check again!
            final Cipher rc4;
            try {
                rc4 = createRC4Cipher();
            } catch (GeneralSecurityException e) {
                throw new EncryptionUnsupportedByPlatformException(
                        "JCE did not offer RC4 cipher", e);
            }
            // 40 byte key is used for base U and O ciphers
            final byte[] rc4JunkKey = new byte[5];
            Arrays.fill(junkKey, (byte) 0xAE);
            try {
                initDecryption(rc4, createRC4Key(rc4JunkKey));
            } catch (InvalidKeyException ex) {
                throw new EncryptionUnsupportedByPlatformException(
                        "JCE did not accept 40-bit RC4 key; " +
                                "policy problem?",
                        ex);
            }
        }
    }