/** * Write to the file. * * @param pos the write position * @param src the source buffer */ public void writeFully(long pos, ByteBuffer src) { int len = src.remaining(); fileSize = Math.max(fileSize, pos + len); DataUtils.writeFully(file, pos, src); writeCount.incrementAndGet(); writeBytes.addAndGet(len); }
/** * Write to the file. * * @param pos the write position * @param src the source buffer */ public void writeFully(long pos, ByteBuffer src) { int len = src.remaining(); fileSize = Math.max(fileSize, pos + len); DataUtils.writeFully(file, pos, src); writeCount++; writeBytes += len; }
/** * Write to the file. * * @param pos the write position * @param src the source buffer */ public void writeFully(long pos, ByteBuffer src) { int len = src.remaining(); fileSize = Math.max(fileSize, pos + len); DataUtils.writeFully(file, pos, src); writeCount++; writeBytes += len; }
/** * Write to the file. * * @param pos the write position * @param src the source buffer */ public void writeFully(long pos, ByteBuffer src) { int len = src.remaining(); fileSize = Math.max(fileSize, pos + len); DataUtils.writeFully(file, pos, src); writeCount.incrementAndGet(); writeBytes.addAndGet(len); }
if (plus > 0) { temp = ByteBuffer.allocate(plus); DataUtils.writeFully(base, p + HEADER_LENGTH + l, temp);
if (plus > 0) { temp = ByteBuffer.allocate(plus); DataUtils.writeFully(base, p + HEADER_LENGTH + l, temp);
private void init() throws IOException { if (xts != null) { return; } this.size = base.size() - HEADER_LENGTH; boolean newFile = size < 0; byte[] salt; if (newFile) { byte[] header = Arrays.copyOf(HEADER, BLOCK_SIZE); salt = MathUtils.secureRandomBytes(SALT_LENGTH); System.arraycopy(salt, 0, header, SALT_POS, salt.length); DataUtils.writeFully(base, 0, ByteBuffer.wrap(header)); size = 0; } else { salt = new byte[SALT_LENGTH]; DataUtils.readFully(base, SALT_POS, ByteBuffer.wrap(salt)); if ((size & BLOCK_SIZE_MASK) != 0) { size -= BLOCK_SIZE; } } AES cipher = new AES(); cipher.setKey(SHA256.getPBKDF2( encryptionKey, salt, HASH_ITERATIONS, 16)); encryptionKey = null; xts = new XTS(cipher); }
private void init() throws IOException { if (xts != null) { return; } this.size = base.size() - HEADER_LENGTH; boolean newFile = size < 0; byte[] salt; if (newFile) { byte[] header = Arrays.copyOf(HEADER, BLOCK_SIZE); salt = MathUtils.secureRandomBytes(SALT_LENGTH); System.arraycopy(salt, 0, header, SALT_POS, salt.length); DataUtils.writeFully(base, 0, ByteBuffer.wrap(header)); size = 0; } else { salt = new byte[SALT_LENGTH]; DataUtils.readFully(base, SALT_POS, ByteBuffer.wrap(salt)); if ((size & BLOCK_SIZE_MASK) != 0) { size -= BLOCK_SIZE; } } AES cipher = new AES(); cipher.setKey(SHA256.getPBKDF2( encryptionKey, salt, HASH_ITERATIONS, 16)); encryptionKey = null; xts = new XTS(cipher); }