/** * Append a long value. This method writes two int values. * * @param x the value */ public void writeLong(long x) { Bits.writeLong(data, pos, x); pos += 8; }
private void xorInitVector(byte[] b, int off, int len, long p) { byte[] iv = bufferForInitVector; while (len > 0) { for (int i = 0; i < Constants.FILE_BLOCK_SIZE; i += 8) { Bits.writeLong(iv, i, (p + i) >>> 3); } cipherForInitVector.encrypt(iv, 0, Constants.FILE_BLOCK_SIZE); for (int i = 0; i < Constants.FILE_BLOCK_SIZE; i++) { b[off + i] ^= iv[i]; } p += Constants.FILE_BLOCK_SIZE; off += Constants.FILE_BLOCK_SIZE; len -= Constants.FILE_BLOCK_SIZE; } }
private byte[] calculateLobMac(long lobId) { if (lobMacSalt == null) { lobMacSalt = MathUtils.secureRandomBytes(LOB_MAC_SALT_LENGTH); } byte[] data = new byte[8]; Bits.writeLong(data, 0, lobId); return SHA256.getHashWithSalt(data, lobMacSalt); }