Program: 111298
Project: 111298
Buggy source:
/** 
 * Returns a SeekableByteChannel that allows to access the plaintext.
 * @param ciphertextSource the ciphertext
 * @param associatedData the data associated with the ciphertext.
 * @return a SeekableByteChannel that allows random read access to the plaintext.The following methods of SeekableByteChannel are implemented: <ul> <li> <code>long position()</code> Returns the channel's position in the plaintext. <li> <code>SeekableByteChannel  position(long newPosition)</code> Sets the channel's position. Setting the position to a value greater than the plaintext size is legal. A later attempt to read byte will immediately return an end-of-file indication. <li> <code>int read(ByteBuffer dst)</code> Bytes are read starting at the channel's position, and then the position is updated with the number of bytes actually read. All bytes returned have been authenticated. If the end of the stream has been reached -1 is returned. A result of -1 is authenticated (e.g. by checking the MAC of the last ciphertext chunk.) Throws java.io.IOException if a MAC verification failed. read attempt to fill dst, but may return less bytes than requested if reads to ciphertextSource do not return the requested number of bytes or if the plaintext ended. TODO(bleichen): Should we extend the interface with read(ByteBuffer dst, long position) to avoid race conditions? <li> <code>long size()</code> Returns the size of the plaintext. (TODO: Decide whether the result should be authenticated) <li> <code>SeekableByteChannel truncate(long size)</code> throws NonWritableChannelException because the channel is read-only. <li> <code>int write(ByteBuffer src)</code> throws NonWritableChannelException because the channel is read-only. <li> <code>close()</code> closes the channel <li> <code>isOpen()</code> </ul>
 * @throws GeneralSecurityException if the header of the ciphertext is corrupt or if theassociatedData is not correct.
 * @throws IOException if an IOException occured while reading from ciphertextDestination.
 */
SeekableByteChannel newSeekableDecryptingChannel(SeekableByteChannel ciphertextSource,byte[] associatedData) throws GeneralSecurityException, IOException ;

Fixed version (ground truth):
/** 
 * Returns a SeekableByteChannel that allows to access the plaintext.
 * @param ciphertextSource the ciphertext
 * @param associatedData the data associated with the ciphertext.
 * @return a SeekableByteChannel that allows random read access to the plaintext.The following methods of SeekableByteChannel are implemented: <ul> <li> <code>long position()</code> Returns the channel's position in the plaintext. <li> <code>SeekableByteChannel  position(long newPosition)</code> Sets the channel's position. Setting the position to a value greater than the plaintext size is legal. A later attempt to read byte will immediately return an end-of-file indication. <li> <code>int read(ByteBuffer dst)</code> Bytes are read starting at the channel's position, and then the position is updated with the number of bytes actually read. All bytes returned have been authenticated. If the end of the stream has been reached -1 is returned. A result of -1 is authenticated (e.g. by checking the MAC of the last ciphertext chunk.) Throws java.io.IOException if a MAC verification failed. read attempt to fill dst, but may return less bytes than requested if reads to ciphertextSource do not return the requested number of bytes or if the plaintext ended. TODO(bleichen): Should we extend the interface with read(ByteBuffer dst, long position) to avoid race conditions? <li> <code>long size()</code> Returns the size of the plaintext. (TODO: Decide whether the result should be authenticated) <li> <code>SeekableByteChannel truncate(long size)</code> throws NonWritableChannelException because the channel is read-only. <li> <code>int write(ByteBuffer src)</code> throws NonWritableChannelException because the channel is read-only. <li> <code>close()</code> closes the channel <li> <code>isOpen()</code> </ul>
 * @throws GeneralSecurityException if the header of the ciphertext is corrupt or if theassociatedData is not correct.
 * @throws IOException if an IOException occurred while reading from ciphertextDestination.
 */
SeekableByteChannel newSeekableDecryptingChannel(SeekableByteChannel ciphertextSource,byte[] associatedData) throws GeneralSecurityException, IOException ;