From 5e1abb1cc753f2e8d65e862a6c2325fcb551cb8e Mon Sep 17 00:00:00 2001 From: Ali Younis Date: Wed, 4 Oct 2017 13:16:21 -0700 Subject: [PATCH] IV changes --- version2/src/java/iotcloud/CloudComm.java | 3 ++- version2/src/java/iotcloud/Slot.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/version2/src/java/iotcloud/CloudComm.java b/version2/src/java/iotcloud/CloudComm.java index d0a514d..1b10efe 100644 --- a/version2/src/java/iotcloud/CloudComm.java +++ b/version2/src/java/iotcloud/CloudComm.java @@ -247,7 +247,8 @@ class CloudComm { private byte[] createIV(long machineId, long localSequenceNumber) { ByteBuffer buffer = ByteBuffer.allocate(IV_SIZE); buffer.putLong(machineId); - buffer.putLong(localSequenceNumber); + long localSequenceNumberShifted = localSequenceNumber << 16; + buffer.putLong(localSequenceNumberShifted); return buffer.array(); } diff --git a/version2/src/java/iotcloud/Slot.java b/version2/src/java/iotcloud/Slot.java index b881efe..153ef80 100644 --- a/version2/src/java/iotcloud/Slot.java +++ b/version2/src/java/iotcloud/Slot.java @@ -222,11 +222,11 @@ class Slot implements Liveness { public byte[] getSlotCryptIV() { ByteBuffer buffer = ByteBuffer.allocate(CloudComm.IV_SIZE); buffer.putLong(machineid); - buffer.putLong(localSequenceNumber); + long localSequenceNumberShift = localSequenceNumber << 16; + buffer.putLong(localSequenceNumberShift); return buffer.array(); } - public String toString() { return "<" + getSequenceNumber() + ">"; } -- 2.34.1