Struct matrix_sdk::encryption::secret_storage::SecretStorage
source · pub struct SecretStorage { /* private fields */ }
e2e-encryption
only.Expand description
A high-level API to manage secret storage.
To get this, use [Client::encryption()::secret_storage()
].
Implementations§
source§impl SecretStorage
impl SecretStorage
sourcepub async fn open_secret_store(
&self,
secret_storage_key: &str
) -> Result<SecretStore>
pub async fn open_secret_store( &self, secret_storage_key: &str ) -> Result<SecretStore>
Open the SecretStore
with the given key
.
The secret_storage_key
can be a passphrase or a Base58 encoded secret
storage key.
§Examples
use ruma::events::secret::request::SecretName;
let secret_store = client
.encryption()
.secret_storage()
.open_secret_store("It's a secret to everybody")
.await?;
let my_secret = "Top secret secret";
let my_secret_name = "m.treasure";
secret_store.put_secret(my_secret_name, my_secret);
sourcepub fn create_secret_store(&self) -> CreateStore<'_>
pub fn create_secret_store(&self) -> CreateStore<'_>
Create a new SecretStore
.
The SecretStore
will be protected by a randomly generated key, or
optionally a passphrase can be provided as well.
In both cases, whether a passphrase was provided or not, the key to open
the SecretStore
can be obtained using the
SecretStore::secret_storage_key()
method.
Note: This method will set the new secret storage key as the default
key in the m.secret_storage.default_key
event. All the known secrets
will be re-encrypted and uploaded to the homeserver as well. This
includes the following secrets:
m.cross_signing.master
: The master cross-signing key.m.cross_signing.self_signing
: The self-signing cross-signing key.m.cross_signing.user_signing
: The user-signing cross-signing key.
§Examples
use ruma::events::secret::request::SecretName;
let secret_store = client
.encryption()
.secret_storage()
.create_secret_store()
.await?;
let my_secret = "Top secret secret";
let my_secret_name = SecretName::from("m.treasure");
secret_store.put_secret(my_secret_name, my_secret);
let secret_storage_key = secret_store.secret_storage_key();
println!("Your secret storage key is {secret_storage_key}, save it somewhere safe.");
sourcepub async fn is_enabled(&self) -> Result<bool>
pub async fn is_enabled(&self) -> Result<bool>
Is secret storage set up for this user?