private static OutputStream createApacheEncryptedStream(OutputStream output, KeyMaterial keyMaterial) throws IOException { SecretKey secretKey = keyMaterial.getSecretKey(); byte[] iv = keyMaterial.getIv(); return new CtrCryptoOutputStream(PROPS, output, secretKey.getEncoded(), iv); }