Class SecureFileStore
java.lang.Object
org.h2.store.FileStore
org.h2.security.SecureFileStore
A file store that encrypts all data before writing, and decrypts all data
after reading. Areas that were never written to (for example after calling
setLength to enlarge the file) are not encrypted (contains 0 bytes).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private final byte[]private final BlockCipherprivate final BlockCipherprivate byte[]private final intprivate longFields inherited from class FileStore
HEADER_LENGTH, name -
Constructor Summary
ConstructorsConstructorDescriptionSecureFileStore(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations) -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Generate the random salt bytes if required.protected voidinitKey(byte[] salt) Initialize the key using the given salt.voidreadFully(byte[] b, int off, int len) Read a number of bytes.voidreadFullyDirect(byte[] b, int off, int len) Read a number of bytes without decrypting.voidseek(long x) Go to the specified file location.voidwrite(byte[] b, int off, int len) Write a number of bytes.protected voidwriteDirect(byte[] b, int off, int len) Write a number of bytes without encrypting.private voidxorInitVector(byte[] b, int off, int len, long p) Methods inherited from class FileStore
autoDelete, close, closeAndDeleteSilently, closeFile, closeSilently, getFilePointer, init, length, open, open, open, openFile, releaseLock, setCheckedWriting, setLength, stopAutoDelete, sync, tryLock
-
Field Details
-
key
private byte[] key -
cipher
-
cipherForInitVector
-
buffer
private byte[] buffer -
pos
private long pos -
bufferForInitVector
private final byte[] bufferForInitVector -
keyIterations
private final int keyIterations
-
-
Constructor Details
-
SecureFileStore
public SecureFileStore(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations)
-
-
Method Details
-
generateSalt
protected byte[] generateSalt()Description copied from class:FileStoreGenerate the random salt bytes if required.- Overrides:
generateSaltin classFileStore- Returns:
- the random salt or the magic
-
initKey
-
writeDirect
protected void writeDirect(byte[] b, int off, int len) Description copied from class:FileStoreWrite a number of bytes without encrypting.- Overrides:
writeDirectin classFileStore- Parameters:
b- the source bufferoff- the offsetlen- the number of bytes to write
-
write
-
readFullyDirect
public void readFullyDirect(byte[] b, int off, int len) Description copied from class:FileStoreRead a number of bytes without decrypting.- Overrides:
readFullyDirectin classFileStore- Parameters:
b- the target bufferoff- the offsetlen- the number of bytes to read
-
readFully
-
seek
-
xorInitVector
private void xorInitVector(byte[] b, int off, int len, long p)
-