Package org.h2.store.fs.encrypt
Class FileEncrypt
java.lang.Object
java.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.FileChannel
org.h2.store.fs.FileBase
org.h2.store.fs.FileBaseDefault
org.h2.store.fs.encrypt.FileEncrypt
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,GatheringByteChannel,InterruptibleChannel,ReadableByteChannel,ScatteringByteChannel,SeekableByteChannel,WritableByteChannel
An encrypted file with a read cache.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.nio.channels.FileChannel
FileChannel.MapMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FileChannelstatic final intThe block size.(package private) static final intThe block size bit mask.private byte[]private static final intThe number of iterations.private static final byte[](package private) static final intThe length of the file header.private final Stringprivate static final intThe length of the salt, in bytes.private static final intprivate longThe current file size, from a user perspective.private XTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate XTSvoidforce(boolean metaData) protected voidprotected voidimplTruncate(long newSize) The truncate implementation.private XTSinit()intread(ByteBuffer dst, long position) private static voidreadFully(FileChannel file, long pos, ByteBuffer dst) private voidreadInternal(ByteBuffer dst, long position, int len, XTS xts) longsize()toString()tryLock(long position, long size, boolean shared) intwrite(ByteBuffer src, long position) private static voidwriteFully(FileChannel file, long pos, ByteBuffer src) private voidwriteInternal(ByteBuffer src, long position, int len, XTS xts) Methods inherited from class org.h2.store.fs.FileBaseDefault
position, position, read, truncate, writeMethods inherited from class org.h2.store.fs.FileBase
lock, map, read, transferFrom, transferTo, writeMethods inherited from class java.nio.channels.FileChannel
lock, map, open, open, read, tryLock, writeMethods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
Field Details
-
BLOCK_SIZE
public static final int BLOCK_SIZEThe block size.- See Also:
-
BLOCK_SIZE_MASK
static final int BLOCK_SIZE_MASKThe block size bit mask.- See Also:
-
HEADER_LENGTH
static final int HEADER_LENGTHThe length of the file header. Using a smaller header is possible, but would mean reads and writes are not aligned to the block size.- See Also:
-
HEADER
private static final byte[] HEADER -
SALT_POS
private static final int SALT_POS -
SALT_LENGTH
private static final int SALT_LENGTHThe length of the salt, in bytes.- See Also:
-
HASH_ITERATIONS
private static final int HASH_ITERATIONSThe number of iterations. It is relatively low; a higher value would slow down opening files on Android too much.- See Also:
-
base
-
size
private volatile long sizeThe current file size, from a user perspective. -
name
-
xts
-
encryptionKey
private byte[] encryptionKey
-
-
Constructor Details
-
FileEncrypt
-
-
Method Details
-
init
- Throws:
IOException
-
createXTS
- Throws:
IOException
-
implCloseChannel
- Overrides:
implCloseChannelin classFileBase- Throws:
IOException
-
read
- Overrides:
readin classFileBase- Throws:
IOException
-
readInternal
- Throws:
IOException
-
readFully
- Throws:
IOException
-
write
- Overrides:
writein classFileBase- Throws:
IOException
-
writeInternal
- Throws:
IOException
-
writeFully
- Throws:
IOException
-
size
- Specified by:
sizein interfaceSeekableByteChannel- Specified by:
sizein classFileChannel- Throws:
IOException
-
implTruncate
Description copied from class:FileBaseDefaultThe truncate implementation.- Specified by:
implTruncatein classFileBaseDefault- Parameters:
newSize- the new size- Throws:
IOException- on failure
-
force
- Overrides:
forcein classFileBase- Throws:
IOException
-
tryLock
- Overrides:
tryLockin classFileBase- Throws:
IOException
-
toString
-