Ensure cloud sync IV is 12 bytes

master
M66B 4 months ago
parent 9ffa60c05b
commit e63ebe1594

@ -777,7 +777,8 @@ public class CloudSync {
private static byte[] getIv(long revision) { private static byte[] getIv(long revision) {
byte[] iv = ByteBuffer.allocate(12) byte[] iv = ByteBuffer.allocate(12)
.putLong(revision) .putLong(revision) // 8 bytes
.putInt(0) // 4 bytes
.array(); .array();
return iv; return iv;
} }
@ -785,7 +786,7 @@ public class CloudSync {
private static byte[] getAd(String key, long revision) throws NoSuchAlgorithmException { private static byte[] getAd(String key, long revision) throws NoSuchAlgorithmException {
byte[] k = MessageDigest.getInstance("SHA256").digest(key.getBytes()); byte[] k = MessageDigest.getInstance("SHA256").digest(key.getBytes());
byte[] ad = ByteBuffer.allocate(8 + 8) byte[] ad = ByteBuffer.allocate(8 + 8)
.putLong(revision) .putLong(revision) // 8 bytes
.put(Arrays.copyOfRange(k, 0, 8)) .put(Arrays.copyOfRange(k, 0, 8))
.array(); .array();
return ad; return ad;

Loading…
Cancel
Save