X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=blobdiff_plain;f=version2%2Fsrc%2Fjava%2Fiotcloud%2FCloudComm.java;h=f12c2764e0a04520c94b6a094fd25c43266cf4f0;hp=1b10efe621dd526d8985699c5ab2bfac99911fbf;hb=b7ed1849727b50e226f3b9d1c432d3071d739368;hpb=5e1abb1cc753f2e8d65e862a6c2325fcb551cb8e diff --git a/version2/src/java/iotcloud/CloudComm.java b/version2/src/java/iotcloud/CloudComm.java index 1b10efe..f12c276 100644 --- a/version2/src/java/iotcloud/CloudComm.java +++ b/version2/src/java/iotcloud/CloudComm.java @@ -8,6 +8,9 @@ import javax.crypto.spec.*; import java.security.SecureRandom; import java.nio.ByteBuffer; + +import java.util.*; + /** * This class provides a communication API to the webserver. It also * validates the HMACs on the slots and handles encryption. @@ -256,7 +259,7 @@ class CloudComm { private byte[] encryptSlotAndPrependIV(byte[] rawData, byte[] ivBytes) { try { IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); - Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding"); + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec); byte[] encryptedBytes = cipher.doFinal(rawData); @@ -283,9 +286,8 @@ class CloudComm { IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); - Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding"); + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding"); cipher.init(Cipher.DECRYPT_MODE, key, ivSpec); - return cipher.doFinal(encryptedBytes); } catch (Exception e) {