Changed to no padding
authorAli Younis <ayounis@uci.edu>
Thu, 5 Oct 2017 23:28:41 +0000 (16:28 -0700)
committerAli Younis <ayounis@uci.edu>
Thu, 5 Oct 2017 23:28:41 +0000 (16:28 -0700)
version2/src/Control/app/src/main/java/iotcloud/CloudComm.java
version2/src/java/iotcloud/CloudComm.java

index aa0791f..744c0fe 100644 (file)
@@ -482,7 +482,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);
@@ -509,7 +509,7 @@ 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);
index 1b10efe..f12c276 100644 (file)
@@ -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) {