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
use super::generate_key::GenerateKeyParams;
use super::{Command, Response};
use {
Adapter, Capability, CommandType, Domain, ObjectId, ObjectLabel, Session, SessionError, WrapAlg,
};
pub fn generate_wrap_key<A: Adapter>(
session: &mut Session<A>,
key_id: ObjectId,
label: ObjectLabel,
domains: Domain,
capabilities: Capability,
delegated_capabilities: Capability,
algorithm: WrapAlg,
) -> Result<ObjectId, SessionError> {
session
.send_command(GenWrapKeyCommand {
params: GenerateKeyParams {
key_id,
label,
domains,
capabilities,
algorithm: algorithm.into(),
},
delegated_capabilities,
}).map(|response| response.key_id)
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct GenWrapKeyCommand {
pub params: GenerateKeyParams,
pub delegated_capabilities: Capability,
}
impl Command for GenWrapKeyCommand {
type ResponseType = GenWrapKeyResponse;
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct GenWrapKeyResponse {
pub key_id: ObjectId,
}
impl Response for GenWrapKeyResponse {
const COMMAND_TYPE: CommandType = CommandType::GenerateWrapKey;
}