/** * Does the decryption using inBuffer as input and outBuffer as output. Upon * return, inBuffer is cleared; the decrypted data starts at * outBuffer.position() and ends at outBuffer.limit(). * * @throws IOException if an I/O error occurs. */ @Override protected void decrypt() throws IOException { Utils.checkState(inBuffer.position() >= padding); if (inBuffer.position() == padding) { // There is no real data in inBuffer. return; } inBuffer.flip(); outBuffer.clear(); decryptBuffer(outBuffer); inBuffer.clear(); outBuffer.flip(); if (padding > 0) { /* * The plain text and cipher text have a 1:1 mapping, they start at * the same position. */ outBuffer.position(padding); } }
/** * Does the decryption using inBuffer as input and buf as output. Upon * return, inBuffer is cleared; the buf's position will be equal to * <i>p</i> <tt>+</tt> <i>n</i> where <i>p</i> is the position * before decryption, <i>n</i> is the number of bytes decrypted. The buf's * limit will not have changed. * * @param buf The buffer into which bytes are to be transferred. * @throws IOException if an I/O error occurs. */ protected void decryptInPlace(ByteBuffer buf) throws IOException { Utils.checkState(inBuffer.position() >= padding); Utils.checkState(buf.isDirect()); Utils.checkState(buf.remaining() >= inBuffer.position()); Utils.checkState(padding == 0); if (inBuffer.position() == padding) { // There is no real data in inBuffer. return; } inBuffer.flip(); decryptBuffer(buf); inBuffer.clear(); }