Fix formatting
This commit is contained in:
parent
7a24fdfa06
commit
d98ae40879
|
@ -20,7 +20,7 @@ use rand::RngCore;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_with::serde_as;
|
use serde_with::serde_as;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::convert::{TryInto, TryFrom};
|
use std::convert::{TryFrom, TryInto};
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
|
|
||||||
/// Each bridge information line is serialized into this many bytes
|
/// Each bridge information line is serialized into this many bytes
|
||||||
|
@ -221,7 +221,9 @@ pub struct WrongSliceLengthError;
|
||||||
impl TryFrom<Vec<u8>> for EncryptedBucket {
|
impl TryFrom<Vec<u8>> for EncryptedBucket {
|
||||||
type Error = WrongSliceLengthError;
|
type Error = WrongSliceLengthError;
|
||||||
fn try_from(v: Vec<u8>) -> Result<EncryptedBucket, Self::Error> {
|
fn try_from(v: Vec<u8>) -> Result<EncryptedBucket, Self::Error> {
|
||||||
Ok(EncryptedBucket(*Box::<[u8; ENC_BUCKET_BYTES]>::try_from(v).map_err(|_| WrongSliceLengthError)?))
|
Ok(EncryptedBucket(
|
||||||
|
*Box::<[u8; ENC_BUCKET_BYTES]>::try_from(v).map_err(|_| WrongSliceLengthError)?,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +232,6 @@ struct K {
|
||||||
encbucket: EncryptedBucket,
|
encbucket: EncryptedBucket,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// A BridgeTable is the internal structure holding the buckets
|
/// A BridgeTable is the internal structure holding the buckets
|
||||||
/// containing the bridges, the keys used to encrypt the buckets, and
|
/// containing the bridges, the keys used to encrypt the buckets, and
|
||||||
/// the encrypted buckets. The encrypted buckets will be exposed to the
|
/// the encrypted buckets. The encrypted buckets will be exposed to the
|
||||||
|
|
|
@ -24,16 +24,16 @@ pub mod migration_table;
|
||||||
|
|
||||||
use sha2::Sha512;
|
use sha2::Sha512;
|
||||||
|
|
||||||
use rand::rngs::OsRng;
|
|
||||||
use rand::Rng;
|
|
||||||
use std::convert::{TryFrom, TryInto};
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use curve25519_dalek::constants as dalek_constants;
|
use curve25519_dalek::constants as dalek_constants;
|
||||||
use curve25519_dalek::ristretto::RistrettoBasepointTable;
|
use curve25519_dalek::ristretto::RistrettoBasepointTable;
|
||||||
use curve25519_dalek::ristretto::RistrettoPoint;
|
use curve25519_dalek::ristretto::RistrettoPoint;
|
||||||
use curve25519_dalek::scalar::Scalar;
|
use curve25519_dalek::scalar::Scalar;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use curve25519_dalek::traits::IsIdentity;
|
use curve25519_dalek::traits::IsIdentity;
|
||||||
|
use rand::rngs::OsRng;
|
||||||
|
use rand::Rng;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::convert::{TryFrom, TryInto};
|
||||||
|
|
||||||
use ed25519_dalek::{Keypair, PublicKey, Signature, SignatureError, Signer, Verifier};
|
use ed25519_dalek::{Keypair, PublicKey, Signature, SignatureError, Signer, Verifier};
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
|
|
|
@ -171,7 +171,8 @@ impl TestHarness {
|
||||||
let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap();
|
let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap();
|
||||||
let encbuckets = self.ba.enc_bridge_table();
|
let encbuckets = self.ba.enc_bridge_table();
|
||||||
let bucket =
|
let bucket =
|
||||||
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets.get(&id).unwrap()).unwrap();
|
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets.get(&id).unwrap())
|
||||||
|
.unwrap();
|
||||||
let reachcred = bucket.1.unwrap();
|
let reachcred = bucket.1.unwrap();
|
||||||
|
|
||||||
// Use the Bucket Reachability credential to advance to the next
|
// Use the Bucket Reachability credential to advance to the next
|
||||||
|
@ -219,7 +220,8 @@ impl TestHarness {
|
||||||
let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap();
|
let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap();
|
||||||
let encbuckets = self.ba.enc_bridge_table();
|
let encbuckets = self.ba.enc_bridge_table();
|
||||||
let bucket =
|
let bucket =
|
||||||
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets.get(&id).unwrap()).unwrap();
|
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets.get(&id).unwrap())
|
||||||
|
.unwrap();
|
||||||
let reachcred = bucket.1.unwrap();
|
let reachcred = bucket.1.unwrap();
|
||||||
|
|
||||||
let req_start = Instant::now();
|
let req_start = Instant::now();
|
||||||
|
@ -741,7 +743,7 @@ fn test_bridge_replace() {
|
||||||
let mut num = 100000;
|
let mut num = 100000;
|
||||||
while !th.ba.bridge_table.buckets.contains_key(&num) {
|
while !th.ba.bridge_table.buckets.contains_key(&num) {
|
||||||
num = rand::thread_rng().gen_range(0, th.ba.bridge_table.counter) as u32;
|
num = rand::thread_rng().gen_range(0, th.ba.bridge_table.counter) as u32;
|
||||||
};
|
}
|
||||||
let replaceable_bucket = th.ba.bridge_table.buckets.get(&num).unwrap().clone();
|
let replaceable_bucket = th.ba.bridge_table.buckets.get(&num).unwrap().clone();
|
||||||
let replacement_bridge = &replaceable_bucket[0];
|
let replacement_bridge = &replaceable_bucket[0];
|
||||||
assert!(
|
assert!(
|
||||||
|
|
Loading…
Reference in New Issue