diff --git a/benchmarks/benches/crypto_bench.rs b/benchmarks/benches/crypto_bench.rs index 5b2ac0f52..c9dff71cd 100644 --- a/benchmarks/benches/crypto_bench.rs +++ b/benchmarks/benches/crypto_bench.rs @@ -71,9 +71,7 @@ pub fn keys_query(c: &mut Criterion) { }); let dir = tempfile::tempdir().unwrap(); - let store = Arc::new( - runtime.block_on(SledCryptoStore::open_with_passphrase(dir.path(), None)).unwrap(), - ); + let store = Arc::new(runtime.block_on(SledCryptoStore::open(dir.path(), None)).unwrap()); let machine = runtime.block_on(OlmMachine::with_store(alice_id(), alice_device_id(), store)).unwrap(); @@ -120,11 +118,8 @@ pub fn keys_claiming(c: &mut Criterion) { b.iter_batched( || { let dir = tempfile::tempdir().unwrap(); - let store = Arc::new( - runtime - .block_on(SledCryptoStore::open_with_passphrase(dir.path(), None)) - .unwrap(), - ); + let store = + Arc::new(runtime.block_on(SledCryptoStore::open(dir.path(), None)).unwrap()); let machine = runtime .block_on(OlmMachine::with_store(alice_id(), alice_device_id(), store)) @@ -186,9 +181,7 @@ pub fn room_key_sharing(c: &mut Criterion) { }) }); let dir = tempfile::tempdir().unwrap(); - let store = Arc::new( - runtime.block_on(SledCryptoStore::open_with_passphrase(dir.path(), None)).unwrap(), - ); + let store = Arc::new(runtime.block_on(SledCryptoStore::open(dir.path(), None)).unwrap()); let machine = runtime.block_on(OlmMachine::with_store(alice_id(), alice_device_id(), store)).unwrap(); @@ -243,9 +236,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) { }); let dir = tempfile::tempdir().unwrap(); - let store = Arc::new( - runtime.block_on(SledCryptoStore::open_with_passphrase(dir.path(), None)).unwrap(), - ); + let store = Arc::new(runtime.block_on(SledCryptoStore::open(dir.path(), None)).unwrap()); let machine = runtime.block_on(OlmMachine::with_store(alice_id(), alice_device_id(), store)).unwrap(); diff --git a/bindings/matrix-sdk-crypto-ffi/src/lib.rs b/bindings/matrix-sdk-crypto-ffi/src/lib.rs index dd13c8b54..debabbb1f 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/lib.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/lib.rs @@ -196,8 +196,7 @@ pub fn migrate( }; let runtime = Runtime::new()?; - let store = - runtime.block_on(SledCryptoStore::open_with_passphrase(path, passphrase.as_deref()))?; + let store = runtime.block_on(SledCryptoStore::open(path, passphrase.as_deref()))?; processed_steps += 1; listener(processed_steps, total_steps); diff --git a/bindings/matrix-sdk-crypto-ffi/src/machine.rs b/bindings/matrix-sdk-crypto-ffi/src/machine.rs index 63cc5e9df..7d307a2d6 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/machine.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/machine.rs @@ -158,23 +158,20 @@ impl OlmMachine { let store = Arc::new( runtime - .block_on(matrix_sdk_sled::SledCryptoStore::open_with_passphrase( - path, - passphrase.as_deref(), - )) + .block_on(matrix_sdk_sled::SledCryptoStore::open(path, passphrase.as_deref())) .map_err(|e| { - match e { - // This is a bit of an error in the sled store, the - // CryptoStore returns an `OpenStoreError` which has a - // variant for the state store. Not sure what to do about - // this. - matrix_sdk_sled::OpenStoreError::Crypto(r) => r.into(), - matrix_sdk_sled::OpenStoreError::Sled(s) => CryptoStoreError::CryptoStore( - matrix_sdk_crypto::store::CryptoStoreError::backend(s), - ), - _ => unreachable!(), - } - })?, + match e { + // This is a bit of an error in the sled store, the + // CryptoStore returns an `OpenStoreError` which has a + // variant for the state store. Not sure what to do about + // this. + matrix_sdk_sled::OpenStoreError::Crypto(r) => r.into(), + matrix_sdk_sled::OpenStoreError::Sled(s) => CryptoStoreError::CryptoStore( + matrix_sdk_crypto::store::CryptoStoreError::backend(s), + ), + _ => unreachable!(), + } + })?, ); passphrase.zeroize(); diff --git a/bindings/matrix-sdk-crypto-nodejs/src/machine.rs b/bindings/matrix-sdk-crypto-nodejs/src/machine.rs index d98919653..ec01b769d 100644 --- a/bindings/matrix-sdk-crypto-nodejs/src/machine.rs +++ b/bindings/matrix-sdk-crypto-nodejs/src/machine.rs @@ -65,13 +65,10 @@ impl OlmMachine { let store = if let Some(store_path) = store_path { Some( - matrix_sdk_sled::SledCryptoStore::open_with_passphrase( - store_path, - store_passphrase.as_deref(), - ) - .await - .map(Arc::new) - .map_err(into_err)?, + matrix_sdk_sled::SledCryptoStore::open(store_path, store_passphrase.as_deref()) + .await + .map(Arc::new) + .map_err(into_err)?, ) } else { None diff --git a/crates/matrix-sdk-sled/src/crypto_store.rs b/crates/matrix-sdk-sled/src/crypto_store.rs index 1c244154c..1e1338a58 100644 --- a/crates/matrix-sdk-sled/src/crypto_store.rs +++ b/crates/matrix-sdk-sled/src/crypto_store.rs @@ -208,7 +208,7 @@ impl std::fmt::Debug for SledCryptoStore { impl SledCryptoStore { /// Open the sled-based crypto store at the given path using the given /// passphrase to encrypt private data. - pub async fn open_with_passphrase( + pub async fn open( path: impl AsRef, passphrase: Option<&str>, ) -> Result { @@ -1061,7 +1061,7 @@ mod tests { async fn get_store(name: &str, passphrase: Option<&str>) -> SledCryptoStore { let tmpdir_path = TMP_DIR.path().join(name); - SledCryptoStore::open_with_passphrase(tmpdir_path.to_str().unwrap(), passphrase) + SledCryptoStore::open(tmpdir_path.to_str().unwrap(), passphrase) .await .expect("Can't create a passphrase protected store") } @@ -1083,7 +1083,7 @@ mod encrypted_tests { let tmpdir_path = TMP_DIR.path().join(name); let pass = passphrase.unwrap_or("default_test_password"); - SledCryptoStore::open_with_passphrase(tmpdir_path.to_str().unwrap(), Some(pass)) + SledCryptoStore::open(tmpdir_path.to_str().unwrap(), Some(pass)) .await .expect("Can't create a passphrase protected store") } diff --git a/crates/matrix-sdk-sled/src/lib.rs b/crates/matrix-sdk-sled/src/lib.rs index a282a0c81..9eb38fbe8 100644 --- a/crates/matrix-sdk-sled/src/lib.rs +++ b/crates/matrix-sdk-sled/src/lib.rs @@ -57,7 +57,7 @@ pub async fn make_store_config( #[cfg(all(feature = "crypto-store", not(feature = "state-store")))] { - let crypto_store = SledCryptoStore::open_with_passphrase(path, passphrase).await?; + let crypto_store = SledCryptoStore::open(path, passphrase).await?; Ok(StoreConfig::new().crypto_store(crypto_store)) }