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    no_sessions: true,
20    with_sessions: false,
21    handles: {},
22    parameters: {
23        pub context: TpmsContext,
24    }
25}
26
27tpm_struct! {
28    #[derive(Debug, PartialEq, Eq, Clone)]
29    kind: Response,
30    name: TpmContextLoadResponse,
31    cc: TpmCc::ContextLoad,
32    no_sessions: true,
33    with_sessions: false,
34    handles: {
35        pub loaded_handle: TpmTransient,
36    },
37    parameters: {}
38}
39
40tpm_struct! {
41    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
42    kind: Command,
43    name: TpmContextSaveCommand,
44    cc: TpmCc::ContextSave,
45    no_sessions: true,
46    with_sessions: false,
47    handles: {
48        pub save_handle: TpmTransient,
49    },
50    parameters: {}
51}
52
53tpm_struct! {
54    #[derive(Debug, PartialEq, Eq, Clone)]
55    kind: Response,
56    name: TpmContextSaveResponse,
57    cc: TpmCc::ContextSave,
58    no_sessions: true,
59    with_sessions: false,
60    handles: {},
61    parameters: {
62        pub context: TpmsContext,
63    }
64}
65
66tpm_struct! {
67    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
68    kind: Command,
69    name: TpmFlushContextCommand,
70    cc: TpmCc::FlushContext,
71    no_sessions: true,
72    with_sessions: false,
73    handles: {},
74    parameters: {
75        pub flush_handle: u32,
76    }
77}
78
79tpm_struct! {
80    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
81    kind: Response,
82    name: TpmFlushContextResponse,
83    cc: TpmCc::FlushContext,
84    no_sessions: true,
85    with_sessions: false,
86    handles: {},
87    parameters: {}
88}
89
90tpm_struct! {
91    #[derive(Debug, PartialEq, Eq, Clone)]
92    kind: Command,
93    name: TpmEvictControlCommand,
94    cc: TpmCc::EvictControl,
95    no_sessions: false,
96    with_sessions: true,
97    handles: {
98        pub auth: crate::data::TpmiRhHierarchy,
99        pub object_handle: crate::data::TpmiDhObject,
100    },
101    parameters: {
102        pub persistent_handle: TpmPersistent,
103    }
104}
105
106tpm_struct! {
107    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
108    kind: Response,
109    name: TpmEvictControlResponse,
110    cc: TpmCc::EvictControl,
111    no_sessions: false,
112    with_sessions: true,
113    handles: {},
114    parameters: {}
115}