Skip to content

Commit 2e4d5f2

Browse files
committed
feat(crypto): Add a method to get the algorithm of the public backup key
1 parent 534e50d commit 2e4d5f2

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

crates/matrix-sdk-crypto/src/backups/keys/backup.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ impl MegolmV1BackupKey {
6363
key
6464
}
6565

66+
/// Get the full name of the backup algorithm this backup key supports.
67+
pub fn backup_algorithm(&self) -> &str {
68+
"m.megolm_backup.v1.curve25519-aes-sha2"
69+
}
70+
6671
/// Get all the signatures of this `MegolmV1BackupKey`.
6772
pub fn signatures(&self) -> BTreeMap<UserId, BTreeMap<DeviceKeyId, String>> {
6873
self.inner.signatures.to_owned()

crates/matrix-sdk-crypto/src/backups/keys/recovery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ impl RecoveryKey {
228228
.expect("Can't generate a libom PkDecryption object from our private key")
229229
}
230230

231-
/// Extract the public key from this `RecoveryKey`.
232-
pub fn public_key(&self) -> MegolmV1BackupKey {
231+
/// Extract the megolm.v1 public key from this `RecoveryKey`.
232+
pub fn megolm_v1_public_key(&self) -> MegolmV1BackupKey {
233233
let pk = self.get_pk_decrytpion();
234234
let public_key = MegolmV1BackupKey::new(pk.public_key(), None);
235235
public_key

crates/matrix-sdk-crypto/src/backups/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ mod test {
417417
assert_eq!(counts.backed_up, 0, "No room keys have been backed up yet");
418418

419419
let recovery_key = RecoveryKey::new().expect("Can't create new recovery key");
420-
let backup_key = recovery_key.public_key();
420+
let backup_key = recovery_key.megolm_v1_public_key();
421421
backup_key.set_version("1".to_owned());
422422

423423
backup_machine.enable_backup_v1(backup_key).await?;

0 commit comments

Comments
 (0)