Package org.cryptomator.cryptolib.common
Class DecryptingReadableByteChannel
- java.lang.Object
-
- org.cryptomator.cryptolib.common.DecryptingReadableByteChannel
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ReadableByteChannel
public class DecryptingReadableByteChannel extends Object implements ReadableByteChannel
-
-
Constructor Summary
Constructors Constructor Description DecryptingReadableByteChannel(ReadableByteChannel src, Cryptor cryptor, boolean authenticate)
Creates a DecryptingReadableByteChannel that decrypts a whole ciphertext file beginning at its first byte.DecryptingReadableByteChannel(ReadableByteChannel src, Cryptor cryptor, boolean authenticate, FileHeader header, long firstChunk)
Creates a DecryptingReadableByteChannel with a previously read header, allowing to start decryption at any chunk.
-
-
-
Constructor Detail
-
DecryptingReadableByteChannel
public DecryptingReadableByteChannel(ReadableByteChannel src, Cryptor cryptor, boolean authenticate)
Creates a DecryptingReadableByteChannel that decrypts a whole ciphertext file beginning at its first byte.- Parameters:
src
- A ciphertext channel positioned at the begin of the file headercryptor
- The cryptor to useauthenticate
- Set tofalse
to skip ciphertext authentication (may not be supported)
-
DecryptingReadableByteChannel
public DecryptingReadableByteChannel(ReadableByteChannel src, Cryptor cryptor, boolean authenticate, FileHeader header, long firstChunk)
Creates a DecryptingReadableByteChannel with a previously read header, allowing to start decryption at any chunk.- Parameters:
src
- A ciphertext channel positioned at the beginning of the givenfirstChunk
cryptor
- The cryptor to useauthenticate
- Set tofalse
to skip ciphertext authentication (may not be supported)header
- The file's headerfirstChunk
- The index of the chunk at which thesrc
channel is positioned
-
-
Method Detail
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
read
public int read(ByteBuffer dst) throws IOException
- Specified by:
read
in interfaceReadableByteChannel
- Throws:
IOException
-
-