tpm2_protocol/message/
context.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3
4//! 28.2 `TPM2_ContextSave`
5//! 28.3 `TPM2_ContextLoad`
6//! 28.4 `TPM2_FlushContext`
7//! 28.5 `TPM2_EvictControl`
8
9use crate::{
10    data::{TpmCc, TpmsContext},
11    tpm_struct, TpmPersistent, TpmTransient,
12};
13
14tpm_struct! {
15    #[derive(Debug, PartialEq, Eq, Clone)]
16    kind: Command,
17    name: TpmContextLoadCommand,
18    cc: TpmCc::ContextLoad,
19    handles: {},
20    parameters: {
21        pub context: TpmsContext,
22    }
23}
24
25tpm_struct! {
26    #[derive(Debug, PartialEq, Eq, Clone)]
27    kind: Response,
28    name: TpmContextLoadResponse,
29    cc: TpmCc::ContextLoad,
30    handles: {
31        pub loaded_handle: TpmTransient,
32    },
33    parameters: {}
34}
35
36tpm_struct! {
37    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
38    kind: Command,
39    name: TpmContextSaveCommand,
40    cc: TpmCc::ContextSave,
41    handles: {
42        pub save_handle: TpmTransient,
43    },
44    parameters: {}
45}
46
47tpm_struct! {
48    #[derive(Debug, PartialEq, Eq, Clone)]
49    kind: Response,
50    name: TpmContextSaveResponse,
51    cc: TpmCc::ContextSave,
52    handles: {},
53    parameters: {
54        pub context: TpmsContext,
55    }
56}
57
58tpm_struct! {
59    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
60    kind: Command,
61    name: TpmFlushContextCommand,
62    cc: TpmCc::FlushContext,
63    handles: {},
64    parameters: {
65        pub flush_handle: u32,
66    }
67}
68
69tpm_struct! {
70    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
71    kind: Response,
72    name: TpmFlushContextResponse,
73    cc: TpmCc::FlushContext,
74    handles: {},
75    parameters: {}
76}
77
78tpm_struct! {
79    #[derive(Debug, PartialEq, Eq, Clone)]
80    kind: Command,
81    name: TpmEvictControlCommand,
82    cc: TpmCc::EvictControl,
83    handles: {
84        pub auth: crate::data::TpmiRhHierarchy,
85        pub object_handle: crate::data::TpmiDhObject,
86    },
87    parameters: {
88        pub persistent_handle: TpmPersistent,
89    }
90}
91
92tpm_struct! {
93    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
94    kind: Response,
95    name: TpmEvictControlResponse,
96    cc: TpmCc::EvictControl,
97    handles: {},
98    parameters: {}
99}