VirtualBox

source: vbox/trunk/include/iprt/formats/tpm.h@ 104893

最後變更 在這個檔案從104893是 104893,由 vboxsync 提交於 9 月 前

include/formats/tpm.h: Add more constants, bugref:10701

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 24.9 KB
 
1/* $Id: tpm.h 104893 2024-06-12 13:52:28Z vboxsync $ */
2/** @file
3 * IPRT, TPM common definitions (this is actually a protocol and not a format).
4 */
5
6/*
7 * Copyright (C) 2021-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.alldomusa.eu.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_formats_tpm_h
38#define IPRT_INCLUDED_formats_tpm_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/asm.h>
44#include <iprt/cdefs.h>
45#include <iprt/types.h>
46#include <iprt/assertcompile.h>
47#include <iprt/string.h>
48
49
50/**
51 * TPM request header (everything big endian).
52 */
53#pragma pack(1)
54typedef struct TPMREQHDR
55{
56 /** The tag for this request. */
57 uint16_t u16Tag;
58 /** Size of the request in bytes. */
59 uint32_t cbReq;
60 /** The request ordinal to execute. */
61 uint32_t u32Ordinal;
62} TPMREQHDR;
63#pragma pack()
64AssertCompileSize(TPMREQHDR, 2 + 4 + 4);
65/** Pointer to a TPM request header. */
66typedef TPMREQHDR *PTPMREQHDR;
67/** Pointer to a const TPM request header. */
68typedef const TPMREQHDR *PCTPMREQHDR;
69
70
71/** @name TPM 1.2 request tags
72 * @{ */
73/** Command with no authentication. */
74#define TPM_TAG_RQU_COMMAND UINT16_C(0x00c1)
75/** An authenticated command with one authentication handle. */
76#define TPM_TAG_RQU_AUTH1_COMMAND UINT16_C(0x00c2)
77/** An authenticated command with two authentication handles. */
78#define TPM_TAG_RQU_AUTH2_COMMAND UINT16_C(0x00c3)
79/** @} */
80
81
82/** @name TPM 2.0 request/response tags
83 * @{ */
84/** Command with no associated session. */
85#define TPM2_ST_NO_SESSIONS UINT16_C(0x8001)
86/** Command with an associated session. */
87#define TPM2_ST_SESSIONS UINT16_C(0x8002)
88/** @} */
89
90
91/** @name TPM 1.2 request ordinals.
92 * @{ */
93/** Perform a full self test. */
94#define TPM_ORD_SELFTESTFULL UINT32_C(80)
95/** Continue the selftest. */
96#define TPM_ORD_CONTINUESELFTEST UINT32_C(83)
97/** Return the test result. */
98#define TPM_ORD_GETTESTRESULT UINT32_C(84)
99/** Get a capability. */
100#define TPM_ORD_GETCAPABILITY UINT32_C(101)
101/** @} */
102
103
104/** @name TPM 2.0 Algorithm ID codes.
105 * @{ */
106/** Invalid algorithm ID - should not occur. */
107#define TPM2_ALG_ERROR UINT16_C(0x0000)
108/** RSA algorithm ID. */
109#define TPM2_ALG_RSA UINT16_C(0x0001)
110/** TDES (Triple Data Encryption Standard) algorithm ID. */
111#define TPM2_ALG_TDES UINT16_C(0x0003)
112/** SHA1 algorithm ID. */
113#define TPM2_ALG_SHA1 UINT16_C(0x0004)
114/** HMAC (Hash Message Authentication Code) algorithm ID. */
115#define TPM2_ALG_HMAC UINT16_C(0x0005)
116/** AES algorithm ID. */
117#define TPM2_ALG_AES UINT16_C(0x0006)
118/** Hash-based mask-generation function algorithm ID. */
119#define TPM2_ALG_MGF1 UINT16_C(0x0007)
120/** Object type that may use XOR for encryption or an HMAC for signing. */
121#define TPM2_ALG_KEYEDHASH UINT16_C(0x0008)
122/** XOR algorithm ID. */
123#define TPM2_ALG_XOR UINT16_C(0x000a)
124/** SHA256 algorithm ID. */
125#define TPM2_ALG_SHA256 UINT16_C(0x000b)
126/** SHA384 algorithm ID. */
127#define TPM2_ALG_SHA384 UINT16_C(0x000c)
128/** SHA512 algorithm ID. */
129#define TPM2_ALG_SHA512 UINT16_C(0x000d)
130/** SHA256 with only 192 most significant bits algorithm ID. */
131#define TPM2_ALG_SHA256_192 UINT16_C(0x000e)
132/** Null algorithm ID. */
133#define TPM2_ALG_NULL UINT16_C(0x0010)
134/** SM3 hash algorithm ID. */
135#define TPM2_ALG_SM3_256 UINT16_C(0x0012)
136/** SM4 symmetric block cipher algorithm ID. */
137#define TPM2_ALG_SM4 UINT16_C(0x0013)
138/** RSASSA-PKCS1-v1_5 signature algorithm ID. */
139#define TPM2_ALG_RSASSA UINT16_C(0x0014)
140/** RSAES-PKCS1-v1_5 padding algorithm ID. */
141#define TPM2_ALG_RSAES UINT16_C(0x0015)
142/** RSASSA-PSS signature algorithm ID. */
143#define TPM2_ALG_RSAPSS UINT16_C(0x0016)
144/** RSAES_OAEP padding algorithm ID. */
145#define TPM2_ALG_OAEP UINT16_C(0x0017)
146/** Elliptic curve cryptography signature algorithm ID. */
147#define TPM2_ALG_ECDSA UINT16_C(0x0018)
148/** Secret sharing using ECC algorithm ID. */
149#define TPM2_ALG_ECDH UINT16_C(0x0019)
150/** Elliptic curve based anonymous signing scheme algorithm ID. */
151#define TPM2_ALG_ECDAA UINT16_C(0x001a)
152/** SM2 algorithm ID. */
153#define TPM2_ALG_SM2 UINT16_C(0x001b)
154/** Elliptic-curve based Schnorr signature algorithm ID. */
155#define TPM2_ALG_ECSCHNORR UINT16_C(0x001c)
156/** Two phase elliptic curve key exchange algorithm ID. */
157#define TPM2_ALG_ECMQV UINT16_C(0x001d)
158/** NIST SP800-56A Concatenation key derivation function algorithm ID. */
159#define TPM2_ALG_KDF1_SP800_56A UINT16_C(0x0020)
160/** Key derivation function KDF2 algorithm ID. */
161#define TPM2_ALG_KDF2 UINT16_C(0x0021)
162/** NIST SP800-108 key derivation function algorithm ID. */
163#define TPM2_ALG_KDF1_SP800_108 UINT16_C(0x0022)
164/** Prime field ECC algorithm ID. */
165#define TPM2_ALG_ECC UINT16_C(0x0023)
166/** Object type for a symmetric block cipher algorithm ID. */
167#define TPM2_ALG_SYMCIPHER UINT16_C(0x0025)
168/** Camellia symmetric block cipher algorithm ID. */
169#define TPM2_ALG_CAMELLIA UINT16_C(0x0026)
170/** SHA3 hash algorithm ID - produces 256-bit digest. */
171#define TPM2_ALG_SHA3_256 UINT16_C(0x0027)
172/** SHA3 hash algorithm ID - produces 384-bit digest. */
173#define TPM2_ALG_SHA3_384 UINT16_C(0x0028)
174/** SHA3 hash algorithm ID - produces 512-bit digest. */
175#define TPM2_ALG_SHA3_512 UINT16_C(0x0029)
176/** ISO/IEC 10118-3 extendable output function algorithm ID - provides 128-bits of collision and preimage resistance. */
177#define TPM2_ALG_SHAKE128 UINT16_C(0x002a)
178/** ISO/IEC 10118-3 extendable output function algorithm ID - provides 256-bits of collision and preimage resistance. */
179#define TPM2_ALG_SHAKE256 UINT16_C(0x002b)
180/** ISO/IEC 10118-3 extendable output function algorithm ID - the first 192 bits of SHAKE256 output. */
181#define TPM2_ALG_SHAKE256_192 UINT16_C(0x002c)
182/** ISO/IEC 10118-3 extendable output function algorithm ID - the first 256 bits of SHAKE256 output. */
183#define TPM2_ALG_SHAKE256_256 UINT16_C(0x002d)
184/** ISO/IEC 10118-3 extendable output function algorithm ID - the first 512 bits of SHAKE256 output. */
185#define TPM2_ALG_SHAKE256_512 UINT16_C(0x002e)
186/** ISO/IEC 9797-1:2011 Block Cipher based Message Authentication Code algorithm ID. */
187#define TPM2_ALG_CMAC UINT16_C(0x003f)
188/** ISO/IEC 10116 Counter mode for symmetric block ciphers algorithm ID. */
189#define TPM2_ALG_CTR UINT16_C(0x0040)
190/** ISO/IEC 10116 Output feedback mode for symmetric block ciphers algorithm ID. */
191#define TPM2_ALG_OFB UINT16_C(0x0041)
192/** ISO/IEC 10116 Cipher Block Chaining mode for symmetric block ciphers algorithm ID. */
193#define TPM2_ALG_CBC UINT16_C(0x0042)
194/** ISO/IEC 10116 Cipher Feedback mode for symmetric block ciphers algorithm ID. */
195#define TPM2_ALG_CFB UINT16_C(0x0043)
196/** ISO/IEC 10116 Electronic codebook mode for symmetric block ciphers algorithm ID. */
197#define TPM2_ALG_ECB UINT16_C(0x0044)
198/** NIST SP800-38C Counter with Cipher Block Chaining Message Authentication Code algorithm ID. */
199#define TPM2_ALG_CCM UINT16_C(0x0050)
200/** NIST SP800-38D Galois/Counter Mode algorithm ID. */
201#define TPM2_ALG_GCM UINT16_C(0x0051)
202/** NIST SP800-38F AES Key Wrap (KW) algorithm ID. */
203#define TPM2_ALG_KW UINT16_C(0x0052)
204/** NIST SP800-38F AES Key Wrap with Padding (KWP) algorithm ID. */
205#define TPM2_ALG_KWP UINT16_C(0x0053)
206/** ISO/IEC 19772 Authentication Encryption Mode algorithm ID. */
207#define TPM2_ALG_EAX UINT16_C(0x0054)
208/** IETF RFC 8083 Edwards curve Digital Signature Algorithm (PureEdDSA) algorithm ID. */
209#define TPM2_ALG_EDDSA UINT16_C(0x0060)
210/** IETF RFC 8082 Edwards curve Digital Signature Algorithm (HashEdDSA) algorithm ID. */
211#define TPM2_ALG_EDDSA_PH UINT16_C(0x0061)
212/** NIST SP800-208 Leighton-Micali Signatures algorithm ID. */
213#define TPM2_ALG_LMS UINT16_C(0x0070)
214/** NIST SP800-208 eXtended Merkle Signature Scheme algorithm ID. */
215#define TPM2_ALG_XMSS UINT16_C(0x0071)
216/** Keyed XOF algorithm ID. */
217#define TPM2_ALG_KEYEDXOF UINT16_C(0x0080)
218/** NIST SP800-185 Keyed XOF providing 128-bit security strength algorithm ID. */
219#define TPM2_ALG_KMACXOF128 UINT16_C(0x0081)
220/** NIST SP800-185 Keyed XOF providing 256-bit security strength algorithm ID. */
221#define TPM2_ALG_KMACXOF256 UINT16_C(0x0082)
222/** NIST SP800-185 Variable length MAC providing 128-bit security strength algorithm ID. */
223#define TPM2_ALG_KMAC128 UINT16_C(0x0090)
224/** NIST SP800-185 Variable length MAC providing 256-bit security strength algorithm ID. */
225#define TPM2_ALG_KMAC256 UINT16_C(0x0091)
226/** @} */
227
228
229/** @name TPM 2.0 ECC Curve codes.
230 * @{ */
231#define TPM2_ECC_NONE UINT16_C(0x0000)
232#define TPM2_ECC_NIST_P192 UINT16_C(0x0001)
233#define TPM2_ECC_NIST_P224 UINT16_C(0x0002)
234#define TPM2_ECC_NIST_P256 UINT16_C(0x0003)
235#define TPM2_ECC_NIST_P384 UINT16_C(0x0004)
236#define TPM2_ECC_NIST_P521 UINT16_C(0x0005)
237#define TPM2_ECC_BN_P256 UINT16_C(0x0010)
238#define TPM2_ECC_BN_P638 UINT16_C(0x0011)
239#define TPM2_ECC_SM2_P256 UINT16_C(0x0020)
240#define TPM2_ECC_BP_P256_R1 UINT16_C(0x0030)
241#define TPM2_ECC_BP_P384_R1 UINT16_C(0x0031)
242#define TPM2_ECC_BP_P512_R1 UINT16_C(0x0032)
243#define TPM2_ECC_CURVE_25519 UINT16_C(0x0040)
244#define TPM2_ECC_CURVE_448 UINT16_C(0x0041)
245/** @} */
246
247
248/** @name TPM 2.0 command codes.
249 * @{ */
250#define TPM2_CC_NV_UNDEFINE_SPACE_SPECIAL UINT32_C(0x11f)
251#define TPM2_CC_EVICT_CONTROL UINT32_C(0x120)
252#define TPM2_CC_HIERARCHY_CONTROL UINT32_C(0x121)
253#define TPM2_CC_NV_UNDEFINE_SPACE UINT32_C(0x122)
254#define TPM2_CC_CHANGE_EPS UINT32_C(0x124)
255#define TPM2_CC_CHANGE_PPS UINT32_C(0x125)
256#define TPM2_CC_CLEAR UINT32_C(0x126)
257#define TPM2_CC_CLEAR_CONTROL UINT32_C(0x127)
258#define TPM2_CC_CLOCK_SET UINT32_C(0x128)
259#define TPM2_CC_HIERARCHY_CHANGE_AUTH UINT32_C(0x129)
260#define TPM2_CC_NV_DEFINE_SPACE UINT32_C(0x12a)
261#define TPM2_CC_PCR_ALLOCATE UINT32_C(0x12b)
262#define TPM2_CC_PCR_SET_AUTH_POLICY UINT32_C(0x12c)
263#define TPM2_CC_PP_COMMANDS UINT32_C(0x12d)
264#define TPM2_CC_SET_PRIMARY_POLICY UINT32_C(0x12e)
265#define TPM2_CC_FIELD_UPGRADE_START UINT32_C(0x12f)
266#define TPM2_CC_CLOCK_RATE_ADJUST UINT32_C(0x130)
267#define TPM2_CC_CREATE_PRIMARY UINT32_C(0x131)
268#define TPM2_CC_NV_GLOBAL_WRITE_LOCK UINT32_C(0x132)
269#define TPM2_CC_GET_COMMAND_AUDIT_DIGEST UINT32_C(0x133)
270#define TPM2_CC_NV_INCREMENT UINT32_C(0x134)
271#define TPM2_CC_NV_SET_BITS UINT32_C(0x135)
272#define TPM2_CC_NV_EXTEND UINT32_C(0x136)
273#define TPM2_CC_NV_WRITE UINT32_C(0x137)
274#define TPM2_CC_NV_WRITE_LOCK UINT32_C(0x138)
275#define TPM2_CC_DICTIONARY_ATTACK_LOCK_RESET UINT32_C(0x139)
276#define TPM2_CC_DICTIONARY_ATTACK_PARAMETERS UINT32_C(0x13a)
277#define TPM2_CC_NV_CHANGE_AUTH UINT32_C(0x13b)
278#define TPM2_CC_PCR_EVENT UINT32_C(0x13c)
279#define TPM2_CC_PCR_RESET UINT32_C(0x13d)
280#define TPM2_CC_SEQUENCE_COMPLETE UINT32_C(0x13e)
281#define TPM2_CC_SET_ALGORITHM_SET UINT32_C(0x13f)
282#define TPM2_CC_SET_COMMAND_CODE_AUDIT_STATUS UINT32_C(0x140)
283#define TPM2_CC_FIELD_UPGRADE_DATA UINT32_C(0x141)
284#define TPM2_CC_INCREMENTAL_SELF_TEST UINT32_C(0x142)
285#define TPM2_CC_SELF_TEST UINT32_C(0x143)
286#define TPM2_CC_STARTUP UINT32_C(0x144)
287#define TPM2_CC_SHUTDOWN UINT32_C(0x145)
288#define TPM2_CC_STIR_RANDOM UINT32_C(0x146)
289#define TPM2_CC_ACTIVATE_CREDENTIAL UINT32_C(0x147)
290#define TPM2_CC_CERTIFY UINT32_C(0x148)
291#define TPM2_CC_POLICY_NV UINT32_C(0x149)
292#define TPM2_CC_CERTIFY_CREATION UINT32_C(0x14a)
293#define TPM2_CC_DUPLICATE UINT32_C(0x14b)
294#define TPM2_CC_GET_TIME UINT32_C(0x14c)
295#define TPM2_CC_GET_SESSION_AUDIT_DIGEST UINT32_C(0x14d)
296#define TPM2_CC_NV_READ UINT32_C(0x14e)
297#define TPM2_CC_NV_READ_LOCK UINT32_C(0x14f)
298#define TPM2_CC_OBJECT_CHANGE_AUTH UINT32_C(0x150)
299#define TPM2_CC_POLICY_SECRET UINT32_C(0x151)
300#define TPM2_CC_REWRAP UINT32_C(0x152)
301#define TPM2_CC_CREATE UINT32_C(0x153)
302#define TPM2_CC_ECDH_ZGEN UINT32_C(0x154)
303#define TPM2_CC_HMAC_MAC UINT32_C(0x155)
304#define TPM2_CC_IMPORT UINT32_C(0x156)
305#define TPM2_CC_LOAD UINT32_C(0x157)
306#define TPM2_CC_QUOTE UINT32_C(0x158)
307#define TPM2_CC_RSA_DECRYPT UINT32_C(0x159)
308#define TPM2_CC_HMAC_MAC_START UINT32_C(0x15b)
309#define TPM2_CC_SEQUENCE_UPDATE UINT32_C(0x15c)
310#define TPM2_CC_SIGN UINT32_C(0x15d)
311#define TPM2_CC_UNSEAL UINT32_C(0x15e)
312#define TPM2_CC_POLICY_SIGNED UINT32_C(0x160)
313#define TPM2_CC_CONTEXT_LOAD UINT32_C(0x161)
314#define TPM2_CC_CONTEXT_SAVE UINT32_C(0x162)
315#define TPM2_CC_ECDH_KEY_GEN UINT32_C(0x163)
316#define TPM2_CC_ENCRYPT_DECRYPT UINT32_C(0x164)
317#define TPM2_CC_FLUSH_CONTEXT UINT32_C(0x165)
318#define TPM2_CC_LOAD_EXTERNAL UINT32_C(0x167)
319#define TPM2_CC_MAKE_CREDENTIAL UINT32_C(0x168)
320#define TPM2_CC_NV_READ_PUBLIC UINT32_C(0x169)
321#define TPM2_CC_POLICY_AUTHORIZE UINT32_C(0x16a)
322#define TPM2_CC_POLICY_AUTH_VALUE UINT32_C(0x16b)
323#define TPM2_CC_POLICY_COMMAND_CODE UINT32_C(0x16c)
324#define TPM2_CC_POLICY_COUNTER_TIMER UINT32_C(0x16d)
325#define TPM2_CC_POLICY_CP_HASH UINT32_C(0x16e)
326#define TPM2_CC_POLICY_LOCALITY UINT32_C(0x16f)
327#define TPM2_CC_POLICY_NAME_HASH UINT32_C(0x170)
328#define TPM2_CC_POLICY_OR UINT32_C(0x171)
329#define TPM2_CC_POLICY_TICKET UINT32_C(0x172)
330#define TPM2_CC_READ_PUBLIC UINT32_C(0x173)
331#define TPM2_CC_RSA_ENCRYPT UINT32_C(0x174)
332#define TPM2_CC_START_AUTH_SESSION UINT32_C(0x176)
333#define TPM2_CC_VERIFY_SIGNATURE UINT32_C(0x177)
334#define TPM2_CC_ECC_PARAMETERS UINT32_C(0x178)
335#define TPM2_CC_FIRMWARE_READ UINT32_C(0x179)
336#define TPM2_CC_GET_CAPABILITY UINT32_C(0x17a)
337#define TPM2_CC_GET_RANDOM UINT32_C(0x17b)
338#define TPM2_CC_GET_TEST_RESULT UINT32_C(0x17c)
339#define TPM2_CC_GET_HASH UINT32_C(0x17d)
340#define TPM2_CC_PCR_READ UINT32_C(0x17e)
341#define TPM2_CC_POLICY_PCR UINT32_C(0x17f)
342#define TPM2_CC_POLICY_RESTART UINT32_C(0x180)
343#define TPM2_CC_READ_CLOCK UINT32_C(0x181)
344#define TPM2_CC_PCR_EXTEND UINT32_C(0x182)
345#define TPM2_CC_PCR_SET_AUTH_VALUE UINT32_C(0x183)
346#define TPM2_CC_NV_CERTIFY UINT32_C(0x184)
347#define TPM2_CC_EVENT_SEQUENCE_COMPLETE UINT32_C(0x185)
348#define TPM2_CC_HASH_SEQUENCE_START UINT32_C(0x186)
349#define TPM2_CC_POLICY_PHYSICAL_PRESENCE UINT32_C(0x187)
350#define TPM2_CC_POLICY_DUPLICATION_SELECT UINT32_C(0x188)
351#define TPM2_CC_POLICY_GET_DIGEST UINT32_C(0x189)
352#define TPM2_CC_TEST_PARMS UINT32_C(0x18a)
353#define TPM2_CC_COMMIT UINT32_C(0x18b)
354#define TPM2_CC_POLICY_PASSWORD UINT32_C(0x18c)
355#define TPM2_CC_ZGEN_2PHASE UINT32_C(0x18d)
356#define TPM2_CC_EC_EPHEMERAL UINT32_C(0x18e)
357#define TPM2_CC_POLICY_NV_WRITTEN UINT32_C(0x18f)
358#define TPM2_CC_POLICY_TEMPLATE UINT32_C(0x190)
359#define TPM2_CC_CREATE_LOADED UINT32_C(0x191)
360#define TPM2_CC_POLICY_AUTHORIZE_NV UINT32_C(0x192)
361#define TPM2_CC_ENCRYPT_DECRYPT_2 UINT32_C(0x193)
362#define TPM2_CC_AC_GET_CAPABILITY UINT32_C(0x194)
363#define TPM2_CC_AC_SEND UINT32_C(0x195)
364#define TPM2_CC_POLICY_AC_SEND_SELECT UINT32_C(0x196)
365#define TPM2_CC_CERTIFY_X509 UINT32_C(0x197)
366#define TPM2_CC_ACT_SET_TIMEOUT UINT32_C(0x198)
367#define TPM2_CC_ECC_ENCRYPT UINT32_C(0x199)
368#define TPM2_CC_ECC_DECRYPT UINT32_C(0x19a)
369#define TPM2_CC_POLICY_CAPABILITY UINT32_C(0x19b)
370#define TPM2_CC_POLICY_PARAMETERS UINT32_C(0x19c)
371#define TPM2_CC_NV_DEFINE_SPACE_2 UINT32_C(0x19d)
372#define TPM2_CC_NV_READ_PUBLIC_2 UINT32_C(0x19e)
373#define TPM2_CC_SET_CAPABILITY UINT32_C(0x19f)
374/** @} */
375
376
377/** @name Defines related to TPM_ORD_GETCAPABILITY.
378 * @{ */
379/** Return a TPM related property. */
380#define TPM_CAP_PROPERTY UINT32_C(5)
381
382/** Returns the size of the input buffer. */
383#define TPM_CAP_PROP_INPUT_BUFFER UINT32_C(0x124)
384
385/**
386 * TPM_ORD_GETCAPABILITY request.
387 */
388#pragma pack(1)
389typedef struct TPMREQGETCAPABILITY
390{
391 /** Request header. */
392 TPMREQHDR Hdr;
393 /** The capability group to query. */
394 uint32_t u32Cap;
395 /** Length of the capability. */
396 uint32_t u32Length;
397 /** The sub capability to query. */
398 uint32_t u32SubCap;
399} TPMREQGETCAPABILITY;
400#pragma pack()
401/** Pointer to a TPM_ORD_GETCAPABILITY request. */
402typedef TPMREQGETCAPABILITY *PTPMREQGETCAPABILITY;
403/** Pointer to a const TPM_ORD_GETCAPABILITY request. */
404typedef const TPMREQGETCAPABILITY *PCTPMREQGETCAPABILITY;
405/** @} */
406
407
408/** @name Defines related to TPM2_CC_GET_CAPABILITY.
409 * @{ */
410/** Return a TPM related property. */
411#define TPM2_CAP_TPM_PROPERTIES UINT32_C(6)
412
413/** Returns the size of the input buffer. */
414#define TPM2_PT_INPUT_BUFFER UINT32_C(0x10d)
415
416/**
417 * TPM2_CC_GET_CAPABILITY request.
418 */
419#pragma pack(1)
420typedef struct TPM2REQGETCAPABILITY
421{
422 /** Request header. */
423 TPMREQHDR Hdr;
424 /** The capability group to query. */
425 uint32_t u32Cap;
426 /** Property to query. */
427 uint32_t u32Property;
428 /** Number of values to return. */
429 uint32_t u32Count;
430} TPM2REQGETCAPABILITY;
431#pragma pack()
432/** Pointer to a TPM2_CC_GET_CAPABILITY request. */
433typedef TPM2REQGETCAPABILITY *PTPM2REQGETCAPABILITY;
434/** Pointer to a const TPM2_CC_GET_CAPABILITY request. */
435typedef const TPM2REQGETCAPABILITY *PCTPM2REQGETCAPABILITY;
436/** @} */
437
438
439/**
440 * TPM response header (everything big endian).
441 */
442#pragma pack(1)
443typedef struct TPMRESPHDR
444{
445 /** The tag for this request. */
446 uint16_t u16Tag;
447 /** Size of the response in bytes. */
448 uint32_t cbResp;
449 /** The error code for the response. */
450 uint32_t u32ErrCode;
451} TPMRESPHDR;
452#pragma pack()
453AssertCompileSize(TPMRESPHDR, 2 + 4 + 4);
454/** Pointer to a TPM response header. */
455typedef TPMRESPHDR *PTPMRESPHDR;
456/** Pointer to a const TPM response header. */
457typedef const TPMRESPHDR *PCTPMRESPHDR;
458
459
460/** @name TPM 1.2 response tags
461 * @{ */
462/** A response from a command with no authentication. */
463#define TPM_TAG_RSP_COMMAND UINT16_C(0x00c4)
464/** An authenticated response with one authentication handle. */
465#define TPM_TAG_RSP_AUTH1_COMMAND UINT16_C(0x00c5)
466/** An authenticated response with two authentication handles. */
467#define TPM_TAG_RSP_AUTH2_COMMAND UINT16_C(0x00c6)
468/** @} */
469
470
471/** @name TPM status codes.
472 * @{ */
473#ifndef TPM_SUCCESS
474/** Request executed successfully. */
475# define TPM_SUCCESS UINT32_C(0)
476#endif
477#ifndef TPM_AUTHFAIL
478/** Authentication failed. */
479# define TPM_AUTHFAIL UINT32_C(1)
480#endif
481#ifndef TPM_BADINDEX
482/** An index is malformed. */
483# define TPM_BADINDEX UINT32_C(2)
484#endif
485#ifndef TPM_BAD_PARAMETER
486/** A request parameter is invalid. */
487# define TPM_BAD_PARAMETER UINT32_C(3)
488#endif
489#ifndef TPM_FAIL
490/** The TPM failed to execute the request. */
491# define TPM_FAIL UINT32_C(9)
492#endif
493/** @todo Extend as need arises. */
494/** @} */
495
496
497/* Some inline helpers to account for the unaligned members of the request and response headers. */
498
499/**
500 * Returns the request tag of the given TPM request header.
501 *
502 * @returns TPM request tag in bytes.
503 * @param pTpmReqHdr Pointer to the TPM request header.
504 */
505DECLINLINE(uint16_t) RTTpmReqGetTag(PCTPMREQHDR pTpmReqHdr)
506{
507 return RT_BE2H_U16(pTpmReqHdr->u16Tag);
508}
509
510
511/**
512 * Returns the request size of the given TPM request header.
513 *
514 * @returns TPM request size in bytes.
515 * @param pTpmReqHdr Pointer to the TPM request header.
516 */
517DECLINLINE(size_t) RTTpmReqGetSz(PCTPMREQHDR pTpmReqHdr)
518{
519 uint32_t cbReq;
520 memcpy(&cbReq, &pTpmReqHdr->cbReq, sizeof(pTpmReqHdr->cbReq));
521 return RT_BE2H_U32(cbReq);
522}
523
524
525/**
526 * Returns the request ordinal of the given TPM request header.
527 *
528 * @returns TPM request ordinal in bytes.
529 * @param pTpmReqHdr Pointer to the TPM request header.
530 */
531DECLINLINE(uint32_t) RTTpmReqGetOrdinal(PCTPMREQHDR pTpmReqHdr)
532{
533 uint32_t u32Ordinal;
534 memcpy(&u32Ordinal, &pTpmReqHdr->u32Ordinal, sizeof(pTpmReqHdr->u32Ordinal));
535 return RT_BE2H_U32(u32Ordinal);
536}
537
538
539/**
540 * Returns the response tag of the given TPM response header.
541 *
542 * @returns TPM request tag in bytes.
543 * @param pTpmRespHdr Pointer to the TPM response header.
544 */
545DECLINLINE(uint16_t) RTTpmRespGetTag(PCTPMRESPHDR pTpmRespHdr)
546{
547 return RT_BE2H_U16(pTpmRespHdr->u16Tag);
548}
549
550
551/**
552 * Returns the response size included in the given TPM response header.
553 *
554 * @returns TPM response size in bytes.
555 * @param pTpmRespHdr Pointer to the TPM response header.
556 */
557DECLINLINE(size_t) RTTpmRespGetSz(PCTPMRESPHDR pTpmRespHdr)
558{
559 uint32_t cbResp;
560 memcpy(&cbResp, &pTpmRespHdr->cbResp, sizeof(pTpmRespHdr->cbResp));
561 return RT_BE2H_U32(cbResp);
562}
563
564
565/**
566 * Returns the error code of the given TPM response header.
567 *
568 * @returns TPM response error code.
569 * @param pTpmRespHdr Pointer to the TPM response header.
570 */
571DECLINLINE(uint32_t) RTTpmRespGetErrCode(PCTPMRESPHDR pTpmRespHdr)
572{
573 uint32_t u32ErrCode;
574 memcpy(&u32ErrCode, &pTpmRespHdr->u32ErrCode, sizeof(pTpmRespHdr->u32ErrCode));
575 return RT_BE2H_U32(u32ErrCode);
576}
577
578#endif /* !IPRT_INCLUDED_formats_tpm_h */
579
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette