/** * Encrypts or decrypts data in a single-part operation, or finishes a * multiple-part operation. * * @param output the byte array for the result * @param outputOffset the offset in output where the result is stored * @return the number of bytes stored in output * @throws ShortBufferException if the given output byte array is too small * to hold the result * @throws BadPaddingException if this cipher is in decryption mode, and * (un)padding has been requested, but the decrypted data is not * bounded by the appropriate padding bytes * @throws IllegalBlockSizeException if this cipher is a block cipher, no * padding has been requested (only in encryption mode), and the * total input length of the data processed by this cipher is not a * multiple of block size; or if this encryption algorithm is unable * to process the input data provided. */ public int doFinal(byte[] output, int outputOffset) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException { checkState(); return OpenSslNative.doFinalByteArray(context, output, outputOffset, output.length - outputOffset); }