crypto: Hold on to the private identity in the store.
parent
cb95f576a5
commit
34bec59389
|
@ -415,9 +415,10 @@ pub(crate) mod test {
|
||||||
let user_id = Arc::new(user_id());
|
let user_id = Arc::new(user_id());
|
||||||
let account = ReadOnlyAccount::new(&user_id, &device_id());
|
let account = ReadOnlyAccount::new(&user_id, &device_id());
|
||||||
let store: Arc<Box<dyn CryptoStore>> = Arc::new(Box::new(MemoryStore::new()));
|
let store: Arc<Box<dyn CryptoStore>> = Arc::new(Box::new(MemoryStore::new()));
|
||||||
let verification = VerificationMachine::new(account.clone(), identity, store);
|
let verification = VerificationMachine::new(account.clone(), identity.clone(), store);
|
||||||
let store = Store::new(
|
let store = Store::new(
|
||||||
user_id.clone(),
|
user_id.clone(),
|
||||||
|
identity,
|
||||||
Arc::new(Box::new(MemoryStore::new())),
|
Arc::new(Box::new(MemoryStore::new())),
|
||||||
verification,
|
verification,
|
||||||
);
|
);
|
||||||
|
|
|
@ -721,8 +721,8 @@ mod test {
|
||||||
let account = ReadOnlyAccount::new(&user_id, &alice_device_id());
|
let account = ReadOnlyAccount::new(&user_id, &alice_device_id());
|
||||||
let store: Arc<Box<dyn CryptoStore>> = Arc::new(Box::new(MemoryStore::new()));
|
let store: Arc<Box<dyn CryptoStore>> = Arc::new(Box::new(MemoryStore::new()));
|
||||||
let identity = Arc::new(Mutex::new(PrivateCrossSigningIdentity::empty(bob_id())));
|
let identity = Arc::new(Mutex::new(PrivateCrossSigningIdentity::empty(bob_id())));
|
||||||
let verification = VerificationMachine::new(account, identity, store.clone());
|
let verification = VerificationMachine::new(account, identity.clone(), store.clone());
|
||||||
let store = Store::new(user_id.clone(), store, verification);
|
let store = Store::new(user_id.clone(), identity, store, verification);
|
||||||
|
|
||||||
KeyRequestMachine::new(
|
KeyRequestMachine::new(
|
||||||
user_id,
|
user_id,
|
||||||
|
@ -739,8 +739,8 @@ mod test {
|
||||||
let device = ReadOnlyDevice::from_account(&account).await;
|
let device = ReadOnlyDevice::from_account(&account).await;
|
||||||
let store: Arc<Box<dyn CryptoStore>> = Arc::new(Box::new(MemoryStore::new()));
|
let store: Arc<Box<dyn CryptoStore>> = Arc::new(Box::new(MemoryStore::new()));
|
||||||
let identity = Arc::new(Mutex::new(PrivateCrossSigningIdentity::empty(alice_id())));
|
let identity = Arc::new(Mutex::new(PrivateCrossSigningIdentity::empty(alice_id())));
|
||||||
let verification = VerificationMachine::new(account, identity, store.clone());
|
let verification = VerificationMachine::new(account, identity.clone(), store.clone());
|
||||||
let store = Store::new(user_id.clone(), store, verification);
|
let store = Store::new(user_id.clone(), identity, store, verification);
|
||||||
store.save_devices(&[device]).await.unwrap();
|
store.save_devices(&[device]).await.unwrap();
|
||||||
|
|
||||||
KeyRequestMachine::new(
|
KeyRequestMachine::new(
|
||||||
|
|
|
@ -147,7 +147,12 @@ impl OlmMachine {
|
||||||
let store = Arc::new(store);
|
let store = Arc::new(store);
|
||||||
let verification_machine =
|
let verification_machine =
|
||||||
VerificationMachine::new(account.clone(), user_identity.clone(), store.clone());
|
VerificationMachine::new(account.clone(), user_identity.clone(), store.clone());
|
||||||
let store = Store::new(user_id.clone(), store, verification_machine.clone());
|
let store = Store::new(
|
||||||
|
user_id.clone(),
|
||||||
|
user_identity.clone(),
|
||||||
|
store,
|
||||||
|
verification_machine.clone(),
|
||||||
|
);
|
||||||
let device_id: Arc<DeviceIdBox> = Arc::new(device_id);
|
let device_id: Arc<DeviceIdBox> = Arc::new(device_id);
|
||||||
let outbound_group_sessions = Arc::new(DashMap::new());
|
let outbound_group_sessions = Arc::new(DashMap::new());
|
||||||
let users_for_key_claim = Arc::new(DashMap::new());
|
let users_for_key_claim = Arc::new(DashMap::new());
|
||||||
|
|
|
@ -354,12 +354,13 @@ mod test {
|
||||||
let identity = Arc::new(Mutex::new(PrivateCrossSigningIdentity::empty(
|
let identity = Arc::new(Mutex::new(PrivateCrossSigningIdentity::empty(
|
||||||
user_id.clone(),
|
user_id.clone(),
|
||||||
)));
|
)));
|
||||||
let verification = VerificationMachine::new(account.clone(), identity, store.clone());
|
let verification =
|
||||||
|
VerificationMachine::new(account.clone(), identity.clone(), store.clone());
|
||||||
|
|
||||||
let user_id = Arc::new(user_id);
|
let user_id = Arc::new(user_id);
|
||||||
let device_id = Arc::new(device_id);
|
let device_id = Arc::new(device_id);
|
||||||
|
|
||||||
let store = Store::new(user_id.clone(), store, verification);
|
let store = Store::new(user_id.clone(), identity, store, verification);
|
||||||
|
|
||||||
let account = Account {
|
let account = Account {
|
||||||
inner: account,
|
inner: account,
|
||||||
|
|
|
@ -98,6 +98,7 @@ pub type Result<T> = std::result::Result<T, CryptoStoreError>;
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct Store {
|
pub(crate) struct Store {
|
||||||
user_id: Arc<UserId>,
|
user_id: Arc<UserId>,
|
||||||
|
identity: Arc<Mutex<PrivateCrossSigningIdentity>>,
|
||||||
inner: Arc<Box<dyn CryptoStore>>,
|
inner: Arc<Box<dyn CryptoStore>>,
|
||||||
verification_machine: VerificationMachine,
|
verification_machine: VerificationMachine,
|
||||||
}
|
}
|
||||||
|
@ -130,11 +131,13 @@ pub struct DeviceChanges {
|
||||||
impl Store {
|
impl Store {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
user_id: Arc<UserId>,
|
user_id: Arc<UserId>,
|
||||||
|
identity: Arc<Mutex<PrivateCrossSigningIdentity>>,
|
||||||
store: Arc<Box<dyn CryptoStore>>,
|
store: Arc<Box<dyn CryptoStore>>,
|
||||||
verification_machine: VerificationMachine,
|
verification_machine: VerificationMachine,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
user_id,
|
user_id,
|
||||||
|
identity,
|
||||||
inner: store,
|
inner: store,
|
||||||
verification_machine,
|
verification_machine,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue