Struct matrix_sdk_crypto::store::BackupDecryptionKey
source · 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
Available on non-tarpaulin_include
only.
impl Debug for BackupDecryptionKey
tarpaulin_include
only.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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> CompatExt for T
impl<T> CompatExt for T
source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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