pub struct BackupMachine { /* private fields */ }
Expand description
A state machine that handles backing up room keys.
The state machine can be activated using the
BackupMachine::enable_backup_v1
method. After the state machine has been
enabled a request that will upload encrypted room keys can be generated
using the BackupMachine::backup
method.
Implementations§
Source§impl BackupMachine
impl BackupMachine
Sourcepub async fn verify_backup(
&self,
backup_info: RoomKeyBackupInfo,
compute_all_signatures: bool,
) -> Result<SignatureVerification, CryptoStoreError>
pub async fn verify_backup( &self, backup_info: RoomKeyBackupInfo, compute_all_signatures: bool, ) -> Result<SignatureVerification, CryptoStoreError>
Verify some backup info that we downloaded from the server.
§Arguments
-
backup_info
: The backup info that should be verified. Should be fetched from the server using the/room_keys/version
endpoint. -
compute_all_signatures
: Useful for debugging only. If this parameter istrue
, the internal machinery will compute the trust state for all signatures before returning, instead of short-circuiting on the first trusted signature. Has no impact on whether the backup will be considered verified.
Sourcepub async fn sign_backup(
&self,
backup_info: &mut RoomKeyBackupInfo,
) -> Result<(), SignatureError>
pub async fn sign_backup( &self, backup_info: &mut RoomKeyBackupInfo, ) -> Result<(), SignatureError>
Sign a RoomKeyBackupInfo
using the device’s identity key and, if
available, the cross-signing master key.
§Arguments
backup_info
: The backup version that should be verified. Should be created from theBackupDecryptionKey
using theBackupDecryptionKey::to_backup_info()
method.
Sourcepub async fn enable_backup_v1(
&self,
key: MegolmV1BackupKey,
) -> Result<(), CryptoStoreError>
pub async fn enable_backup_v1( &self, key: MegolmV1BackupKey, ) -> Result<(), CryptoStoreError>
Activate the given backup key to be used to encrypt and backup room keys.
This will use the m.megolm_backup.v1.curve25519-aes-sha2
algorithm
to encrypt the room keys.
Sourcepub async fn room_key_counts(&self) -> Result<RoomKeyCounts, CryptoStoreError>
pub async fn room_key_counts(&self) -> Result<RoomKeyCounts, CryptoStoreError>
Get the number of backed up room keys and the total number of room keys.
Sourcepub async fn disable_backup(&self) -> Result<(), CryptoStoreError>
pub async fn disable_backup(&self) -> Result<(), CryptoStoreError>
Disable and reset our backup state.
This will remove any pending backup request, remove the backup key and reset the backup state of each room key we have.
Sourcepub async fn backup_version(&self) -> Option<String>
pub async fn backup_version(&self) -> Option<String>
Provide the backup_version
of the current backup_key
, or None if
there is no current key, or the key is not used with any backup
version.
Sourcepub async fn save_decryption_key(
&self,
backup_decryption_key: Option<BackupDecryptionKey>,
version: Option<String>,
) -> Result<(), CryptoStoreError>
pub async fn save_decryption_key( &self, backup_decryption_key: Option<BackupDecryptionKey>, version: Option<String>, ) -> Result<(), CryptoStoreError>
Store the backup decryption key in the crypto store.
This is useful if the client wants to support gossiping of the backup key.
Sourcepub async fn get_backup_keys(&self) -> Result<BackupKeys, CryptoStoreError>
pub async fn get_backup_keys(&self) -> Result<BackupKeys, CryptoStoreError>
Get the backup keys we have saved in our crypto store.
Sourcepub async fn backup(
&self,
) -> Result<Option<(OwnedTransactionId, KeysBackupRequest)>, CryptoStoreError>
pub async fn backup( &self, ) -> Result<Option<(OwnedTransactionId, KeysBackupRequest)>, CryptoStoreError>
Encrypt a batch of room keys and return a request that needs to be sent out to backup the room keys.
Sourcepub async fn import_backed_up_room_keys(
&self,
room_keys: BTreeMap<OwnedRoomId, BTreeMap<String, BackedUpRoomKey>>,
progress_listener: impl Fn(usize, usize),
) -> Result<RoomKeyImportResult, CryptoStoreError>
👎Deprecated: Use the OlmMachine::store::import_room_keys method instead
pub async fn import_backed_up_room_keys( &self, room_keys: BTreeMap<OwnedRoomId, BTreeMap<String, BackedUpRoomKey>>, progress_listener: impl Fn(usize, usize), ) -> Result<RoomKeyImportResult, CryptoStoreError>
Import the given room keys into our store.
§Arguments
room_keys
- A list of previously exported keys that should be imported into our store. If we already have a better version of a key the key will not be imported.
Returns a RoomKeyImportResult
containing information about room keys
which were imported.
Trait Implementations§
Source§impl Clone for BackupMachine
impl Clone for BackupMachine
Source§fn clone(&self) -> BackupMachine
fn clone(&self) -> BackupMachine
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for BackupMachine
impl !RefUnwindSafe for BackupMachine
impl Send for BackupMachine
impl Sync for BackupMachine
impl Unpin for BackupMachine
impl !UnwindSafe for BackupMachine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more