Function matrix_sdk_crypto::encrypt_room_key_export
source · pub fn encrypt_room_key_export(
keys: &[ExportedRoomKey],
passphrase: &str,
rounds: u32,
) -> Result<String, Error>
Expand description
Encrypt the list of exported room keys using the given passphrase.
§Arguments
-
keys
- A list of sessions that should be encrypted. -
passphrase
- The passphrase that will be used to encrypt the exported room keys. -
rounds
- The number of rounds that should be used for the key derivation when the passphrase gets turned into an AES key. More rounds are increasingly computationally intensive and as such help against brute-force attacks. Should be at least10_000
, while values in the100_000
ranges should be preferred.
§Panics
This method will panic if it can’t get enough randomness from the OS to encrypt the exported keys securely.
§Examples
let room_id = room_id!("!test:localhost");
let exported_keys = machine.store().export_room_keys(|s| s.room_id() == room_id).await.unwrap();
let encrypted_export = encrypt_room_key_export(&exported_keys, "1234", 1);