edits
authorBrian Demsky <bdemsky@plrg.eecs.uci.edu>
Sun, 24 Jul 2016 08:10:08 +0000 (01:10 -0700)
committerBrian Demsky <bdemsky@plrg.eecs.uci.edu>
Sun, 24 Jul 2016 08:10:08 +0000 (01:10 -0700)
src/java/iotcloud/CloudComm.java
src/java/iotcloud/Slot.java
src/java/iotcloud/Table.java

index 85c95bb..2c9e0c7 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 ea30ddb..9de69db 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 1d27932..d4a62c6 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);
                }
        }
 }