]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - include/tpm-v2.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2018 Bootlin
4 * Author: Miquel Raynal <miquel.raynal@bootlin.com>
10 #include <tpm-common.h>
12 #define TPM2_DIGEST_LEN 32
15 * TPM2 Structure Tags for command/response buffers.
17 * @TPM2_ST_NO_SESSIONS: the command does not need an authentication.
18 * @TPM2_ST_SESSIONS: the command needs an authentication.
20 enum tpm2_structures
{
21 TPM2_ST_NO_SESSIONS
= 0x8001,
22 TPM2_ST_SESSIONS
= 0x8002,
26 * TPM2 type of boolean.
34 * TPM2 startup values.
36 * @TPM2_SU_CLEAR: reset the internal state.
37 * @TPM2_SU_STATE: restore saved state (if any).
39 enum tpm2_startup_types
{
40 TPM2_SU_CLEAR
= 0x0000,
41 TPM2_SU_STATE
= 0x0001,
45 * TPM2 permanent handles.
47 * @TPM2_RH_OWNER: refers to the 'owner' hierarchy.
48 * @TPM2_RS_PW: indicates a password.
49 * @TPM2_RH_LOCKOUT: refers to the 'lockout' hierarchy.
50 * @TPM2_RH_ENDORSEMENT: refers to the 'endorsement' hierarchy.
51 * @TPM2_RH_PLATFORM: refers to the 'platform' hierarchy.
54 TPM2_RH_OWNER
= 0x40000001,
55 TPM2_RS_PW
= 0x40000009,
56 TPM2_RH_LOCKOUT
= 0x4000000A,
57 TPM2_RH_ENDORSEMENT
= 0x4000000B,
58 TPM2_RH_PLATFORM
= 0x4000000C,
62 * TPM2 command codes used at the beginning of a buffer, gives the command.
64 * @TPM2_CC_STARTUP: TPM2_Startup().
65 * @TPM2_CC_SELF_TEST: TPM2_SelfTest().
66 * @TPM2_CC_CLEAR: TPM2_Clear().
67 * @TPM2_CC_CLEARCONTROL: TPM2_ClearControl().
68 * @TPM2_CC_HIERCHANGEAUTH: TPM2_HierarchyChangeAuth().
69 * @TPM2_CC_PCR_SETAUTHPOL: TPM2_PCR_SetAuthPolicy().
70 * @TPM2_CC_DAM_RESET: TPM2_DictionaryAttackLockReset().
71 * @TPM2_CC_DAM_PARAMETERS: TPM2_DictionaryAttackParameters().
72 * @TPM2_CC_GET_CAPABILITY: TPM2_GetCapibility().
73 * @TPM2_CC_PCR_READ: TPM2_PCR_Read().
74 * @TPM2_CC_PCR_EXTEND: TPM2_PCR_Extend().
75 * @TPM2_CC_PCR_SETAUTHVAL: TPM2_PCR_SetAuthValue().
77 enum tpm2_command_codes
{
78 TPM2_CC_STARTUP
= 0x0144,
79 TPM2_CC_SELF_TEST
= 0x0143,
80 TPM2_CC_CLEAR
= 0x0126,
81 TPM2_CC_CLEARCONTROL
= 0x0127,
82 TPM2_CC_HIERCHANGEAUTH
= 0x0129,
83 TPM2_CC_DAM_RESET
= 0x0139,
84 TPM2_CC_DAM_PARAMETERS
= 0x013A,
85 TPM2_CC_GET_CAPABILITY
= 0x017A,
86 TPM2_CC_PCR_READ
= 0x017E,
87 TPM2_CC_PCR_EXTEND
= 0x0182,
93 enum tpm2_return_codes
{
94 TPM2_RC_SUCCESS
= 0x0000,
95 TPM2_RC_BAD_TAG
= 0x001E,
96 TPM2_RC_FMT1
= 0x0080,
97 TPM2_RC_HASH
= TPM2_RC_FMT1
+ 0x0003,
98 TPM2_RC_VALUE
= TPM2_RC_FMT1
+ 0x0004,
99 TPM2_RC_SIZE
= TPM2_RC_FMT1
+ 0x0015,
100 TPM2_RC_BAD_AUTH
= TPM2_RC_FMT1
+ 0x0022,
101 TPM2_RC_HANDLE
= TPM2_RC_FMT1
+ 0x000B,
102 TPM2_RC_VER1
= 0x0100,
103 TPM2_RC_INITIALIZE
= TPM2_RC_VER1
+ 0x0000,
104 TPM2_RC_FAILURE
= TPM2_RC_VER1
+ 0x0001,
105 TPM2_RC_DISABLED
= TPM2_RC_VER1
+ 0x0020,
106 TPM2_RC_AUTH_MISSING
= TPM2_RC_VER1
+ 0x0025,
107 TPM2_RC_COMMAND_CODE
= TPM2_RC_VER1
+ 0x0043,
108 TPM2_RC_AUTHSIZE
= TPM2_RC_VER1
+ 0x0044,
109 TPM2_RC_AUTH_CONTEXT
= TPM2_RC_VER1
+ 0x0045,
110 TPM2_RC_NEEDS_TEST
= TPM2_RC_VER1
+ 0x0053,
111 TPM2_RC_WARN
= 0x0900,
112 TPM2_RC_TESTING
= TPM2_RC_WARN
+ 0x000A,
113 TPM2_RC_REFERENCE_H0
= TPM2_RC_WARN
+ 0x0010,
114 TPM2_RC_LOCKOUT
= TPM2_RC_WARN
+ 0x0021,
120 enum tpm2_algorithms
{
122 TPM2_ALG_SHA256
= 0x0B,
123 TPM2_ALG_SHA384
= 0x0C,
124 TPM2_ALG_SHA512
= 0x0D,
125 TPM2_ALG_NULL
= 0x10,
129 * Issue a TPM2_Startup command.
131 * @mode TPM startup mode
133 * @return code of the operation
135 u32
tpm2_startup(enum tpm2_startup_types mode
);
137 #endif /* __TPM_V2_H */