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_ALGORITHM`
8    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
9    pub struct TpmaAlgorithm(u32) {
10        const ASYMMETRIC = 0x0000_0001, "ASYMMETRIC";
11        const SYMMETRIC = 0x0000_0002, "SYMMETRIC";
12        const HASH = 0x0000_0004, "HASH";
13        const OBJECT = 0x0000_0008, "OBJECT";
14        const SIGNING = 0x0000_0100, "SIGNING";
15        const ENCRYPTING = 0x0000_0200, "ENCRYPTING";
16        const METHOD = 0x0000_0400, "METHOD";
17    }
18}
19
20tpm_bitflags! {
21    /// `TPMA_LOCALITY` (Table 41)
22    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
23    pub struct TpmaLocality(u8) {
24        const TPM_LOC_ZERO = 0x01, "LOC_ZERO";
25        const TPM_LOC_ONE = 0x02, "LOC_ONE";
26        const TPM_LOC_TWO = 0x04, "LOC_TWO";
27        const TPM_LOC_THREE = 0x08, "LOC_THREE";
28        const TPM_LOC_FOUR = 0x10, "LOC_FOUR";
29        const EXTENDED = 0xE0, "EXTENDED";
30    }
31}
32
33tpm_bitflags! {
34    /// `TPMA_NV` (Table 233)
35    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
36    pub struct TpmaNv(u32) {
37        const PPWRITE = 0x0000_0001, "PPWRITE";
38        const OWNERWRITE = 0x0000_0002, "OWNERWRITE";
39        const AUTHWRITE = 0x0000_0004, "AUTHWRITE";
40        const POLICYWRITE = 0x0000_0008, "POLICYWRITE";
41        const TPM_NT_COUNTER = 0x0000_0010, "COUNTER";
42        const TPM_NT_BITS = 0x0000_0020, "BITS";
43        const TPM_NT_EXTEND = 0x0000_0040, "EXTEND";
44        const POLICY_DELETE = 0x0000_0400, "POLICY_DELETE";
45        const WRITELOCKED = 0x0000_0800, "WRITELOCKED";
46        const WRITEALL = 0x0000_1000, "WRITEALL";
47        const WRITEDEFINE = 0x0000_2000, "WRITEDEFINE";
48        const WRITE_STCLEAR = 0x0000_4000, "WRITE_STCLEAR";
49        const GLOBALLOCK = 0x0000_8000, "GLOBALLOCK";
50        const PPREAD = 0x0001_0000, "PPREAD";
51        const OWNERREAD = 0x0002_0000, "OWNERREAD";
52        const AUTHREAD = 0x0004_0000, "AUTHREAD";
53        const POLICYREAD = 0x0008_0000, "POLICYREAD";
54        const NO_DA = 0x0200_0000, "NO_DA";
55        const ORDERLY = 0x0400_0000, "ORDERLY";
56        const CLEAR_STCLEAR = 0x0800_0000, "CLEAR_STCLEAR";
57        const READLOCKED = 0x1000_0000, "READLOCKED";
58        const WRITTEN = 0x2000_0000, "WRITTEN";
59        const PLATFORMCREATE = 0x4000_0000, "PLATFORMCREATE";
60        const READ_STCLEAR = 0x8000_0000, "READ_STCLEAR";
61    }
62}
63
64tpm_bitflags! {
65    /// `TPMA_NV_EXP` (Table 234)
66    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
67    pub struct TpmaNvExp(u64) {
68        const ENCRYPTION = 0x0000_0001_0000_0000, "ENCRYPTION";
69        const INTEGRITY = 0x0000_0002_0000_0000, "INTEGRITY";
70        const ANTIROLLBACK = 0x0000_0004_0000_0000, "ANTIROLLBACK";
71    }
72}
73
74tpm_bitflags! {
75    /// `TPMA_OBJECT`
76    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
77    pub struct TpmaObject(u32) {
78        const FIXED_TPM = 0x0000_0002, "FIXED_TPM";
79        const ST_CLEAR = 0x0000_0004, "ST_CLEAR";
80        const FIXED_PARENT = 0x0000_0010, "FIXED_PARENT";
81        const SENSITIVE_DATA_ORIGIN = 0x0000_0020, "SENSITIVE_DATA_ORIGIN";
82        const USER_WITH_AUTH = 0x0000_0040, "USER_WITH_AUTH";
83        const ADMIN_WITH_POLICY = 0x0000_0080, "ADMIN_WITH_POLICY";
84        const NO_DA = 0x0000_0400, "NO_DA";
85        const ENCRYPTED_DUPLICATION = 0x0000_0800, "ENCRYPTED_DUPLICATION";
86        const RESTRICTED = 0x0001_0000, "RESTRICTED";
87        const DECRYPT = 0x0002_0000, "DECRYPT";
88        const SIGN_ENCRYPT = 0x0004_0000, "SIGN_ENCRYPT";
89    }
90}
91
92tpm_bitflags! {
93    /// `TPMA_SESSION`
94    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
95    pub struct TpmaSession(u8) {
96        const CONTINUE_SESSION = 0x01, "CONTINUE_SESSION";
97        const AUDIT_EXCLUSIVE = 0x02, "AUDIT_EXCLUSIVE";
98        const AUDIT_RESET = 0x04, "AUDIT_RESET";
99        const DECRYPT = 0x20, "DECRYPT";
100        const ENCRYPT = 0x40, "ENCRYPT";
101        const AUDIT = 0x80, "AUDIT";
102    }
103}