/** * This method is executed immediately after decryption. Check whether * cipher should be updated and recalculate padding if needed. * * @param state the CipherState instance. * @param inByteBuffer the input buffer. * @param position the offset from the start of the stream. * @param iv the iv. * @return the padding. * @throws IOException if an I/O error occurs. */ private byte postDecryption(CipherState state, ByteBuffer inByteBuffer, long position, byte[] iv) throws IOException { byte padding = 0; if (state.isReset()) { /* * This code is generally not executed since the cipher usually * maintains cipher context (e.g. the counter) internally. However, * some implementations can't maintain context so a re-init is * necessary after each decryption call. */ resetCipher(state, position, iv); padding = getPadding(position); inByteBuffer.position(padding); } return padding; }
state = getCipherState(); byte[] iv = getInitIV().clone(); resetCipher(state, position, iv); byte padding = getPadding(position);