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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
//! [`KeySpecifier`](tor_keymgr::KeySpecifier) implementations for hidden service keys.
use derive_adhoc::Adhoc;
use tor_hscrypto::time::TimePeriod;
use tor_keymgr::{derive_adhoc_template_KeySpecifierDefault, KeyPathPattern};
use crate::HsNickname;
#[derive(Adhoc)]
#[derive_adhoc(KeySpecifierDefault)]
#[adhoc(prefix = "hs")]
#[adhoc(role = "KP_hs_id")]
/// The public part of the identity key of the service.
pub struct HsIdPublicKeySpecifier<'a> {
/// The nickname of the hidden service.
nickname: &'a HsNickname,
}
#[derive(Adhoc)]
#[derive_adhoc(KeySpecifierDefault)]
#[adhoc(prefix = "hs")]
#[adhoc(role = "KS_hs_id")]
/// The long-term identity keypair of the service.
pub struct HsIdKeypairSpecifier<'a> {
/// The nickname of the hidden service.
nickname: &'a HsNickname,
}
#[derive(Adhoc)]
#[derive_adhoc(KeySpecifierDefault)]
#[adhoc(prefix = "hs")]
#[adhoc(role = "KS_hs_blind_id")]
/// The blinded signing keypair.
pub struct BlindIdKeypairSpecifier<'a> {
/// The nickname of the hidden service.
nickname: &'a HsNickname,
#[adhoc(denotator)]
/// The time period associated with this key.
period: TimePeriod,
}
#[derive(Adhoc)]
#[derive_adhoc(KeySpecifierDefault)]
#[adhoc(prefix = "hs")]
#[adhoc(role = "KP_hs_blind_id")]
/// The blinded public key.
pub struct BlindIdPublicKeySpecifier<'a> {
/// The nickname of the hidden service.
nickname: &'a HsNickname,
#[adhoc(denotator)]
/// The time period associated with this key.
period: TimePeriod,
}
#[derive(Adhoc)]
#[derive_adhoc(KeySpecifierDefault)]
#[adhoc(prefix = "hs")]
#[adhoc(role = "KS_hs_desc_sign")]
/// The descriptor signing key.
pub struct DescSigningKeypairSpecifier<'a> {
/// The nickname of the hidden service.
nickname: &'a HsNickname,
#[adhoc(denotator)]
/// The time period associated with this key.
period: TimePeriod,
}
#[cfg(test)]
mod test {
// @@ begin test lint list maintained by maint/add_warning @@
#![allow(clippy::bool_assert_comparison)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::dbg_macro)]
#![allow(clippy::print_stderr)]
#![allow(clippy::print_stdout)]
#![allow(clippy::single_char_pattern)]
#![allow(clippy::unwrap_used)]
#![allow(clippy::unchecked_duration_subtraction)]
#![allow(clippy::useless_vec)]
#![allow(clippy::needless_pass_by_value)]
//! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
use super::*;
use tor_keymgr::KeySpecifier;
#[test]
fn hsid_key_specifiers() {
let nickname = HsNickname::try_from("shallot".to_string()).unwrap();
let key_spec = HsIdPublicKeySpecifier::new(&nickname);
assert_eq!(
key_spec.arti_path().unwrap().as_str(),
"hs/shallot/KP_hs_id"
);
let key_spec = HsIdKeypairSpecifier::new(&nickname);
assert_eq!(
key_spec.arti_path().unwrap().as_str(),
"hs/shallot/KS_hs_id"
);
}
#[test]
fn blind_id_key_specifiers() {
let nickname = HsNickname::try_from("shallot".to_string()).unwrap();
let period = TimePeriod::from_parts(1, 2, 3);
let key_spec = BlindIdPublicKeySpecifier::new(&nickname, period);
assert_eq!(
key_spec.arti_path().unwrap().as_str(),
"hs/shallot/KP_hs_blind_id+2_1_3"
);
let key_spec = BlindIdKeypairSpecifier::new(&nickname, period);
assert_eq!(
key_spec.arti_path().unwrap().as_str(),
"hs/shallot/KS_hs_blind_id+2_1_3"
);
}
#[test]
fn desc_signing_key_specifiers() {
let nickname = HsNickname::try_from("shallot".to_string()).unwrap();
let period = TimePeriod::from_parts(1, 2, 3);
let key_spec = DescSigningKeypairSpecifier::new(&nickname, period);
assert_eq!(
key_spec.arti_path().unwrap().as_str(),
"hs/shallot/KS_hs_desc_sign+2_1_3"
);
}
}
|