Skip to main content

tpm2_protocol/data/
tpma.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3
4use crate::tpm_bitflags;
5
6tpm_bitflags! {
7    /// `TPMA_ACT` (Table 213)
8    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
9    pub struct TpmaAct(TpmUint32) {
10        const SIGNALED = 0x0000_0001, "SIGNALED";
11        const PRESERVE_SIGNALED = 0x0000_0002, "PRESERVE_SIGNALED";
12    }
13}
14
15tpm_bitflags! {
16    /// `TPMA_ALGORITHM`
17    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
18    pub struct TpmaAlgorithm(TpmUint32) {
19        const ASYMMETRIC = 0x0000_0001, "ASYMMETRIC";
20        const SYMMETRIC = 0x0000_0002, "SYMMETRIC";
21        const HASH = 0x0000_0004, "HASH";
22        const OBJECT = 0x0000_0008, "OBJECT";
23        const SIGNING = 0x0000_0100, "SIGNING";
24        const ENCRYPTING = 0x0000_0200, "ENCRYPTING";
25        const METHOD = 0x0000_0400, "METHOD";
26    }
27}
28
29tpm_bitflags! {
30    /// `TPMA_CC` (Table 37)
31    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
32    pub struct TpmaCc(TpmUint32) {
33        const COMMAND_INDEX = 0x0000_FFFF, "COMMAND_INDEX";
34        const NV = 0x0040_0000, "NV";
35        const EXTENSIVE = 0x0080_0000, "EXTENSIVE";
36        const FLUSHED = 0x0100_0000, "FLUSHED";
37        const C_HANDLES = 0x0E00_0000, "C_HANDLES";
38        const R_HANDLE = 0x1000_0000, "R_HANDLE";
39        const V = 0x2000_0000, "V";
40    }
41}
42
43tpm_bitflags! {
44    /// `TPMA_LOCALITY` (Table 41)
45    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
46    pub struct TpmaLocality(TpmUint8) {
47        const TPM_LOC_ZERO = 0x01, "LOC_ZERO";
48        const TPM_LOC_ONE = 0x02, "LOC_ONE";
49        const TPM_LOC_TWO = 0x04, "LOC_TWO";
50        const TPM_LOC_THREE = 0x08, "LOC_THREE";
51        const TPM_LOC_FOUR = 0x10, "LOC_FOUR";
52        const EXTENDED = 0xE0, "EXTENDED";
53    }
54}
55
56tpm_bitflags! {
57    /// `TPMA_NV` (Table 233)
58    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
59    pub struct TpmaNv(TpmUint32) {
60        const PPWRITE = 0x0000_0001, "PPWRITE";
61        const OWNERWRITE = 0x0000_0002, "OWNERWRITE";
62        const AUTHWRITE = 0x0000_0004, "AUTHWRITE";
63        const POLICYWRITE = 0x0000_0008, "POLICYWRITE";
64        const TPM_NT_COUNTER = 0x0000_0010, "COUNTER";
65        const TPM_NT_BITS = 0x0000_0020, "BITS";
66        const TPM_NT_EXTEND = 0x0000_0040, "EXTEND";
67        const POLICY_DELETE = 0x0000_0400, "POLICY_DELETE";
68        const WRITELOCKED = 0x0000_0800, "WRITELOCKED";
69        const WRITEALL = 0x0000_1000, "WRITEALL";
70        const WRITEDEFINE = 0x0000_2000, "WRITEDEFINE";
71        const WRITE_STCLEAR = 0x0000_4000, "WRITE_STCLEAR";
72        const GLOBALLOCK = 0x0000_8000, "GLOBALLOCK";
73        const PPREAD = 0x0001_0000, "PPREAD";
74        const OWNERREAD = 0x0002_0000, "OWNERREAD";
75        const AUTHREAD = 0x0004_0000, "AUTHREAD";
76        const POLICYREAD = 0x0008_0000, "POLICYREAD";
77        const NO_DA = 0x0200_0000, "NO_DA";
78        const ORDERLY = 0x0400_0000, "ORDERLY";
79        const CLEAR_STCLEAR = 0x0800_0000, "CLEAR_STCLEAR";
80        const READLOCKED = 0x1000_0000, "READLOCKED";
81        const WRITTEN = 0x2000_0000, "WRITTEN";
82        const PLATFORMCREATE = 0x4000_0000, "PLATFORMCREATE";
83        const READ_STCLEAR = 0x8000_0000, "READ_STCLEAR";
84    }
85}
86
87tpm_bitflags! {
88    /// `TPMA_NV_EXP` (Table 234)
89    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
90    pub struct TpmaNvExp(TpmUint64) {
91        const ENCRYPTION = 0x0000_0001_0000_0000, "ENCRYPTION";
92        const INTEGRITY = 0x0000_0002_0000_0000, "INTEGRITY";
93        const ANTIROLLBACK = 0x0000_0004_0000_0000, "ANTIROLLBACK";
94    }
95}
96
97tpm_bitflags! {
98    /// `TPMA_OBJECT`
99    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
100    pub struct TpmaObject(TpmUint32) {
101        const FIXED_TPM = 0x0000_0002, "FIXED_TPM";
102        const ST_CLEAR = 0x0000_0004, "ST_CLEAR";
103        const FIXED_PARENT = 0x0000_0010, "FIXED_PARENT";
104        const SENSITIVE_DATA_ORIGIN = 0x0000_0020, "SENSITIVE_DATA_ORIGIN";
105        const USER_WITH_AUTH = 0x0000_0040, "USER_WITH_AUTH";
106        const ADMIN_WITH_POLICY = 0x0000_0080, "ADMIN_WITH_POLICY";
107        const NO_DA = 0x0000_0400, "NO_DA";
108        const ENCRYPTED_DUPLICATION = 0x0000_0800, "ENCRYPTED_DUPLICATION";
109        const RESTRICTED = 0x0001_0000, "RESTRICTED";
110        const DECRYPT = 0x0002_0000, "DECRYPT";
111        const SIGN_ENCRYPT = 0x0004_0000, "SIGN_ENCRYPT";
112    }
113}
114
115tpm_bitflags! {
116    /// `TPMA_SESSION`
117    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
118    pub struct TpmaSession(TpmUint8) {
119        const CONTINUE_SESSION = 0x01, "CONTINUE_SESSION";
120        const AUDIT_EXCLUSIVE = 0x02, "AUDIT_EXCLUSIVE";
121        const AUDIT_RESET = 0x04, "AUDIT_RESET";
122        const DECRYPT = 0x20, "DECRYPT";
123        const ENCRYPT = 0x40, "ENCRYPT";
124        const AUDIT = 0x80, "AUDIT";
125    }
126}