tpm2_protocol/message/
duplication.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3
4//! 13.1 `TPM2_Duplicate`
5//! 13.2 `TPM2_Rewrap`
6//! 13.3 `TPM2_Import`
7
8use crate::{
9    data::{
10        Tpm2bData, Tpm2bEncryptedSecret, Tpm2bName, Tpm2bPrivate, Tpm2bPublic, TpmCc, TpmtSymDef,
11        TpmtSymDefObject,
12    },
13    tpm_struct,
14};
15use core::fmt::Debug;
16
17tpm_struct! {
18    #[derive(Debug, PartialEq, Eq, Clone)]
19    kind: Command,
20    name: TpmDuplicateCommand,
21    cc: TpmCc::Duplicate,
22    no_sessions: false,
23    with_sessions: true,
24    handles: {
25        pub object_handle: crate::data::TpmiDhObject,
26        pub new_parent_handle: crate::data::TpmiDhObject,
27    },
28    parameters: {
29        pub encryption_key_in: Tpm2bData,
30        pub symmetric_alg: TpmtSymDefObject,
31    }
32}
33
34tpm_struct! {
35    #[derive(Debug, PartialEq, Eq, Clone)]
36    kind: Response,
37    name: TpmDuplicateResponse,
38    cc: TpmCc::Duplicate,
39    no_sessions: false,
40    with_sessions: true,
41    handles: {},
42    parameters: {
43        pub encryption_key_out: Tpm2bData,
44        pub duplicate: Tpm2bPrivate,
45        pub out_sym_seed: Tpm2bEncryptedSecret,
46    }
47}
48
49tpm_struct! {
50    #[derive(Debug, PartialEq, Eq, Clone)]
51    kind: Command,
52    name: TpmRewrapCommand,
53    cc: TpmCc::Rewrap,
54    no_sessions: false,
55    with_sessions: true,
56    handles: {
57        pub old_parent: crate::data::TpmiDhObject,
58        pub new_parent: crate::data::TpmiDhObject,
59    },
60    parameters: {
61        pub in_duplicate: Tpm2bPrivate,
62        pub name: Tpm2bName,
63        pub in_sym_seed: Tpm2bEncryptedSecret,
64    }
65}
66
67tpm_struct! {
68    #[derive(Debug, PartialEq, Eq, Clone)]
69    kind: Response,
70    name: TpmRewrapResponse,
71    cc: TpmCc::Rewrap,
72    no_sessions: false,
73    with_sessions: true,
74    handles: {},
75    parameters: {
76        pub out_duplicate: Tpm2bPrivate,
77        pub out_sym_seed: Tpm2bEncryptedSecret,
78    }
79}
80
81tpm_struct! {
82    #[derive(Debug, PartialEq, Eq, Clone)]
83    kind: Command,
84    name: TpmImportCommand,
85    cc: TpmCc::Import,
86    no_sessions: false,
87    with_sessions: true,
88    handles: {
89        pub parent_handle: crate::data::TpmiDhObject,
90    },
91    parameters: {
92        pub encryption_key: Tpm2bData,
93        pub object_public: Tpm2bPublic,
94        pub duplicate: Tpm2bPrivate,
95        pub in_sym_seed: Tpm2bEncryptedSecret,
96        pub symmetric_alg: TpmtSymDef,
97    }
98}
99
100tpm_struct! {
101    #[derive(Debug, Default, PartialEq, Eq, Clone)]
102    kind: Response,
103    name: TpmImportResponse,
104    cc: TpmCc::Import,
105    no_sessions: false,
106    with_sessions: true,
107    handles: {},
108    parameters: {
109        pub out_private: Tpm2bPrivate,
110    }
111}