public static void decrypt(OutputStream out, InputStream in, int outLen, Decryptor d)
    throws IOException {
    InputStream cin = d.createDecryptionStream(in);
    byte buf[] = new byte[8 * 1024];
    long remaining = outLen;
    try {
      while (remaining > 0) {
        int toRead = (int) (remaining < buf.length ? remaining : buf.length);
        int read = cin.read(buf, 0, toRead);
        if (read < 0) {
          break;
        }
        out.write(buf, 0, read);
        remaining -= read;
      }
    } finally {
      cin.close();
    }
  }
Decrypt a stream of ciphertext given a decryptor
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/Encryption.java