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
84
85
86
87
use std::collections::BTreeMap;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{ServerName, ServerSigningKeyId};
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
pub mod discover_homeserver;
pub mod get_remote_server_keys;
pub mod get_remote_server_keys_batch;
pub mod get_server_keys;
pub mod get_server_version;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct VerifyKey {
pub key: Base64,
}
impl VerifyKey {
pub fn new(key: Base64) -> Self {
Self { key }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct OldVerifyKey {
pub expired_ts: MilliSecondsSinceUnixEpoch,
pub key: Base64,
}
impl OldVerifyKey {
pub fn new(expired_ts: MilliSecondsSinceUnixEpoch, key: Base64) -> Self {
Self { expired_ts, key }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ServerSigningKeys {
pub server_name: Box<ServerName>,
pub verify_keys: BTreeMap<Box<ServerSigningKeyId>, VerifyKey>,
pub old_verify_keys: BTreeMap<Box<ServerSigningKeyId>, OldVerifyKey>,
pub signatures: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, String>>,
pub valid_until_ts: MilliSecondsSinceUnixEpoch,
}
impl ServerSigningKeys {
pub fn new(server_name: Box<ServerName>, valid_until_ts: MilliSecondsSinceUnixEpoch) -> Self {
Self {
server_name,
verify_keys: BTreeMap::new(),
old_verify_keys: BTreeMap::new(),
signatures: BTreeMap::new(),
valid_until_ts,
}
}
}