Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/iotcloud
authorbdemsky <bdemsky@uci.edu>
Sun, 24 Jul 2016 08:11:54 +0000 (01:11 -0700)
committerbdemsky <bdemsky@uci.edu>
Sun, 24 Jul 2016 08:11:54 +0000 (01:11 -0700)
src/java/iotcloud/CloudComm.java
src/java/iotcloud/Slot.java
src/java/iotcloud/Table.java

index 85c95bb0a2e09dbbbd0b6473868b812aeb2e0ff8..2c9e0c772c98886f2201929f68404d87d12f165d 100644 (file)
@@ -27,8 +27,6 @@ class CloudComm {
        private void initKey(String password) {
                try {
                        salt=new byte[SALT_SIZE];
-                       SecureRandom random = new SecureRandom();
-                       random.nextBytes(salt);
                        PBEKeySpec keyspec = new PBEKeySpec(password.toCharArray(), salt, 65536, 128);
                        SecretKey tmpkey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(keyspec);
                        this.key = new SecretKeySpec(tmpkey.getEncoded(), "AES");
@@ -66,11 +64,10 @@ class CloudComm {
                        URLConnection con=url.openConnection();
                        HttpURLConnection http = (HttpURLConnection) con;
                        http.setRequestMethod("POST");
-                       http.setFixedLengthStreamingMode(bytes.length + SALT_SIZE);
+                       http.setFixedLengthStreamingMode(bytes.length);
                        http.setDoOutput(true);
                        http.connect();
                        OutputStream os=http.getOutputStream();
-                       os.write(salt);
                        os.write(bytes);
                        System.out.println(http.getResponseMessage());
 
index ea30ddbe93658c8d6642d1b0cfdb321442855a44..9de69db52d06dd09f786f15a2fc0e9cfce917c52 100644 (file)
@@ -30,11 +30,11 @@ class Slot implements Liveness {
        }
 
        Slot(long _seqnum, long _machineid, byte[] _prevhmac) {
-               this(_seqnum, _machineid, _prevhmac, new byte[HMAC_SIZE]);
+               this(_seqnum, _machineid, _prevhmac, null);
        }
 
        Slot(long _seqnum, long _machineid) {
-               this(_seqnum, _machineid, new byte[HMAC_SIZE], new byte[HMAC_SIZE]);
+               this(_seqnum, _machineid, new byte[HMAC_SIZE], null);
        }
 
        byte[] getHMAC() {
@@ -103,6 +103,7 @@ class Slot implements Liveness {
                //Compute our HMAC
                mac.update(array, HMAC_SIZE, array.length-HMAC_SIZE);
                byte[] realmac=mac.doFinal();
+               hmac = realmac;
                bb.position(0);
                bb.put(realmac);
                return array;
@@ -132,10 +133,6 @@ class Slot implements Liveness {
                return machineid;
        }
 
-       byte[] getBytes() {
-               return null;
-       }
-
        void setDead() {
                decrementLiveCount();
                seqnumlive=false;
@@ -150,6 +147,6 @@ class Slot implements Liveness {
        }
 
        public String toString() {
-               return "<"+getSequenceNumber()+", "+new String(getBytes())+">";
+               return "<"+getSequenceNumber()+">";
        }
 }
index 1d27932350abbd26c2384096b86b7949fb6b0e6d..d4a62c6abda0576fcd9e0dd04180ce3cc43cb47b 100644 (file)
@@ -306,7 +306,7 @@ search:
                        Slot prevslot=indexer.getSlot(currslot.getSequenceNumber()-1);
                        if (prevslot != null &&
                                        !Arrays.equals(prevslot.getHMAC(), currslot.getPrevHMAC()))
-                               throw new Error("Server Error: Invalid HMAC Chain");
+                               throw new Error("Server Error: Invalid HMAC Chain"+currslot+" "+prevslot);
                }
        }
 }