pub struct BackupDecryptionKey { /* private fields */ }
Expand description
The private part of a backup key.
The private part of the key is not used on a regular basis. Rather, it is used only when we need to recover the backup.
Typically, this private key is itself encrypted and stored in server-side secret storage (SSSS), whence it can be retrieved when it is needed for a recovery operation. Alternatively, the key can be “gossiped” between devices via “secret sharing”.
Implementations§
Source§impl BackupDecryptionKey
impl BackupDecryptionKey
Sourcepub fn from_bytes(key: &[u8; 32]) -> Self
pub fn from_bytes(key: &[u8; 32]) -> Self
Create a new decryption key from the given byte array.
Warning: You need to make sure that the byte array contains correct
random data, either by using a random number generator or by using an
exported version of a previously created BackupDecryptionKey
.
Sourcepub fn from_base64(key: &str) -> Result<Self, DecodeError>
pub fn from_base64(key: &str) -> Result<Self, DecodeError>
Try to create a BackupDecryptionKey
from a base64 export.
Sourcepub fn from_base58(value: &str) -> Result<Self, DecodeError>
pub fn from_base58(value: &str) -> Result<Self, DecodeError>
Try to create a BackupDecryptionKey
from a base58 export.
Sourcepub fn to_base58(&self) -> String
pub fn to_base58(&self) -> String
Export the [
BackupDecryptionKey`] as a base58 encoded string.
Sourcepub fn megolm_v1_public_key(&self) -> MegolmV1BackupKey
pub fn megolm_v1_public_key(&self) -> MegolmV1BackupKey
Extract the megolm.v1 public key from this BackupDecryptionKey
.
Sourcepub fn to_backup_info(&self) -> RoomKeyBackupInfo
pub fn to_backup_info(&self) -> RoomKeyBackupInfo
Get the RoomKeyBackupInfo
for this BackupDecryptionKey
.
The RoomKeyBackupInfo
can be uploaded to the homeserver to activate
a new backup version.
Sourcepub fn decrypt_v1(
&self,
ephemeral_key: &str,
mac: &str,
ciphertext: &str,
) -> Result<String, DecryptionError>
pub fn decrypt_v1( &self, ephemeral_key: &str, mac: &str, ciphertext: &str, ) -> Result<String, DecryptionError>
Try to decrypt the given ciphertext using this BackupDecryptionKey
.
This will use the m.megolm_backup.v1.curve25519-aes-sha2
algorithm
to decrypt the given ciphertext.
Sourcepub fn decrypt_session_data(
&self,
session_data: EncryptedSessionData,
) -> Result<BackedUpRoomKey, DecryptionError>
pub fn decrypt_session_data( &self, session_data: EncryptedSessionData, ) -> Result<BackedUpRoomKey, DecryptionError>
Try to decrypt the given EncryptedSessionData
using this
BackupDecryptionKey
.
Sourcepub fn backup_key_matches(&self, info: &RoomKeyBackupInfo) -> bool
pub fn backup_key_matches(&self, info: &RoomKeyBackupInfo) -> bool
Check if the given public key from the RoomKeyBackupInfo
matches to
this BackupDecryptionKey
.
Trait Implementations§
Source§impl Clone for BackupDecryptionKey
impl Clone for BackupDecryptionKey
Source§fn clone(&self) -> BackupDecryptionKey
fn clone(&self) -> BackupDecryptionKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BackupDecryptionKey
impl Debug for BackupDecryptionKey
Source§impl<'de> Deserialize<'de> for BackupDecryptionKey
impl<'de> Deserialize<'de> for BackupDecryptionKey
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for BackupDecryptionKey
impl Display for BackupDecryptionKey
Source§impl Drop for BackupDecryptionKey
impl Drop for BackupDecryptionKey
Source§impl Serialize for BackupDecryptionKey
impl Serialize for BackupDecryptionKey
Source§impl TryFrom<String> for BackupDecryptionKey
impl TryFrom<String> for BackupDecryptionKey
Auto Trait Implementations§
impl Freeze for BackupDecryptionKey
impl RefUnwindSafe for BackupDecryptionKey
impl Send for BackupDecryptionKey
impl Sync for BackupDecryptionKey
impl Unpin for BackupDecryptionKey
impl UnwindSafe for BackupDecryptionKey
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