Browse Source

Fix the rust in a couple of places

Ian Goldberg 3 years ago
parent
commit
33df688155
2 changed files with 11 additions and 11 deletions
  1. 2 2
      src/bridge_table.rs
  2. 9 9
      src/migration_table.rs

+ 2 - 2
src/bridge_table.rs

@@ -121,8 +121,8 @@ impl BridgeLine {
                     + reachability_priv.x[2] * bucket_attr))
                 * Btable;
             res[pos..pos + 4].copy_from_slice(&today.to_le_bytes());
-            res[pos + 4..pos + 36].copy_from_slice(&P.compress().as_bytes()[..]);
-            res[pos + 36..].copy_from_slice(&Q.compress().as_bytes()[..]);
+            res[pos + 4..pos + 36].copy_from_slice(P.compress().as_bytes());
+            res[pos + 36..].copy_from_slice(Q.compress().as_bytes());
         }
         res
     }

+ 9 - 9
src/migration_table.rs

@@ -82,9 +82,9 @@ pub fn encrypt_cred(
 
     // Serialize (to_bucket, P, Q)
     let mut credbytes: [u8; MIGRATION_BYTES] = [0; MIGRATION_BYTES];
-    credbytes[0..32].copy_from_slice(&to_bucket.as_bytes()[..]);
-    credbytes[32..64].copy_from_slice(&P.compress().as_bytes()[..]);
-    credbytes[64..].copy_from_slice(&Q.compress().as_bytes()[..]);
+    credbytes[0..32].copy_from_slice(to_bucket.as_bytes());
+    credbytes[32..64].copy_from_slice(P.compress().as_bytes());
+    credbytes[64..].copy_from_slice(Q.compress().as_bytes());
 
     // Pick a random nonce
     let mut noncebytes: [u8; 12] = [0; 12];
@@ -93,9 +93,9 @@ pub fn encrypt_cred(
 
     // Compute the hash of (id, from_bucket, Qk)
     let mut hasher = Sha256::new();
-    hasher.update(&id.as_bytes()[..]);
-    hasher.update(&from_bucket.as_bytes()[..]);
-    hasher.update(&Qk.compress().as_bytes()[..]);
+    hasher.update(id.as_bytes());
+    hasher.update(from_bucket.as_bytes());
+    hasher.update(Qk.compress().as_bytes());
     let fullhash = hasher.finalize();
 
     // Create the encryption key from the 2nd half of the hash
@@ -182,9 +182,9 @@ pub fn decrypt_cred(
 ) -> Option<Migration> {
     // Compute the hash of (id, from_bucket, Qk)
     let mut hasher = Sha256::new();
-    hasher.update(&lox_id.as_bytes()[..]);
-    hasher.update(&from_bucket.as_bytes()[..]);
-    hasher.update(&Qk.compress().as_bytes()[..]);
+    hasher.update(lox_id.as_bytes());
+    hasher.update(from_bucket.as_bytes());
+    hasher.update(Qk.compress().as_bytes());
     let fullhash = hasher.finalize();
 
     // Use the first half of the above hash as the label