1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#![cfg(feature = "unstable-pre-spec")]
#![cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
pub mod add_backup_key_session;
pub mod add_backup_key_sessions;
pub mod add_backup_keys;
pub mod create_backup;
pub mod delete_backup;
pub mod delete_backup_key_session;
pub mod delete_backup_key_sessions;
pub mod delete_backup_keys;
pub mod get_backup;
pub mod get_backup_key_session;
pub mod get_backup_key_sessions;
pub mod get_backup_keys;
pub mod get_latest_backup;
pub mod update_backup;
use std::collections::BTreeMap;
use js_int::UInt;
use ruma_identifiers::{DeviceKeyId, UserId};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RoomKeyBackup {
pub sessions: BTreeMap<String, KeyBackupData>,
}
impl RoomKeyBackup {
pub fn new(sessions: BTreeMap<String, KeyBackupData>) -> Self {
Self { sessions }
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "algorithm", content = "auth_data")]
pub enum BackupAlgorithm {
#[serde(rename = "m.megolm_backup.v1.curve25519-aes-sha2")]
MegolmBackupV1Curve25519AesSha2 {
public_key: String,
signatures: BTreeMap<UserId, BTreeMap<DeviceKeyId, String>>,
},
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct KeyBackupData {
pub first_message_index: UInt,
pub forwarded_count: UInt,
pub is_verified: bool,
pub session_data: SessionData,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SessionData {
pub ephemeral: String,
pub ciphertext: String,
pub mac: String,
}