/**
* This class provides a communication API to the webserver. It also
* validates the HMACs on the slots and handles encryption.
/**
* This class provides a communication API to the webserver. It also
* validates the HMACs on the slots and handles encryption.
private byte[] createIV(long machineId, long localSequenceNumber) {
ByteBuffer buffer = ByteBuffer.allocate(IV_SIZE);
buffer.putLong(machineId);
private byte[] createIV(long machineId, long localSequenceNumber) {
ByteBuffer buffer = ByteBuffer.allocate(IV_SIZE);
buffer.putLong(machineId);
private byte[] encryptSlotAndPrependIV(byte[] rawData, byte[] ivBytes) {
try {
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
private byte[] encryptSlotAndPrependIV(byte[] rawData, byte[] ivBytes) {
try {
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec);
byte[] encryptedBytes = cipher.doFinal(rawData);
cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec);
byte[] encryptedBytes = cipher.doFinal(rawData);