blob: ed8ff9b5b465d353ec050e8616288eef8cec24a0 [file] [log] [blame]
Randall Spanglera2db67d2013-01-24 16:15:35 -08001/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Gaurav Shah887e3d42010-04-27 16:26:48 -07002 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
Randall Spanglera2db67d2013-01-24 16:15:35 -08005 * Some TPM constants and type definitions for standalone compilation for use
6 * in the firmware
Gaurav Shah887e3d42010-04-27 16:26:48 -07007 */
Che-Liang Chiou89678602010-11-09 08:33:36 +08008#ifndef VBOOT_REFERENCE_TSS_CONSTANTS_H_
9#define VBOOT_REFERENCE_TSS_CONSTANTS_H_
Bill Richardson0c3ba242013-03-29 11:09:30 -070010#include <stdint.h>
Gaurav Shah887e3d42010-04-27 16:26:48 -070011
12#define TPM_MAX_COMMAND_SIZE 4096
13#define TPM_LARGE_ENOUGH_COMMAND_SIZE 256 /* saves space in the firmware */
Randall Spangler1fe16072010-09-02 11:37:51 -070014#define TPM_PUBEK_SIZE 256
Kees Cook946370d2012-01-09 14:17:40 -080015#define TPM_PCR_DIGEST 20
Gaurav Shah887e3d42010-04-27 16:26:48 -070016
Luigi Semenzato5896b962010-08-25 07:16:03 -070017#define TPM_E_NON_FATAL 0x800
18
Luigi Semenzatob472d9c2015-04-28 11:12:18 -070019#define TPM_SUCCESS ((uint32_t) 0x00000000)
Luigi Semenzato5896b962010-08-25 07:16:03 -070020
Luigi Semenzatob472d9c2015-04-28 11:12:18 -070021#define TPM_E_AREA_LOCKED ((uint32_t) 0x0000003c)
22#define TPM_E_BADINDEX ((uint32_t) 0x00000002)
23#define TPM_E_BAD_PRESENCE ((uint32_t) 0x0000002d)
24#define TPM_E_IOERROR ((uint32_t) 0x0000001f)
25#define TPM_E_INVALID_POSTINIT ((uint32_t) 0x00000026)
26#define TPM_E_MAXNVWRITES ((uint32_t) 0x00000048)
27#define TPM_E_OWNER_SET ((uint32_t) 0x00000014)
Luigi Semenzato416f6812010-07-08 12:12:12 -070028
Luigi Semenzatob472d9c2015-04-28 11:12:18 -070029#define TPM_E_NEEDS_SELFTEST ((uint32_t) (TPM_E_NON_FATAL + 1))
30#define TPM_E_DOING_SELFTEST ((uint32_t) (TPM_E_NON_FATAL + 2))
Luigi Semenzato5896b962010-08-25 07:16:03 -070031
Luigi Semenzatob472d9c2015-04-28 11:12:18 -070032#define TPM_E_ALREADY_INITIALIZED ((uint32_t) 0x00005000) /* vboot local */
33#define TPM_E_INTERNAL_INCONSISTENCY ((uint32_t) 0x00005001) /* vboot local */
34#define TPM_E_MUST_REBOOT ((uint32_t) 0x00005002) /* vboot local */
35#define TPM_E_CORRUPTED_STATE ((uint32_t) 0x00005003) /* vboot local */
36#define TPM_E_COMMUNICATION_ERROR ((uint32_t) 0x00005004) /* vboot local */
37#define TPM_E_RESPONSE_TOO_LARGE ((uint32_t) 0x00005005) /* vboot local */
38#define TPM_E_NO_DEVICE ((uint32_t) 0x00005006) /* vboot local */
39#define TPM_E_INPUT_TOO_SMALL ((uint32_t) 0x00005007) /* vboot local */
40#define TPM_E_WRITE_FAILURE ((uint32_t) 0x00005008) /* vboot local */
41#define TPM_E_READ_EMPTY ((uint32_t) 0x00005009) /* vboot local */
42#define TPM_E_READ_FAILURE ((uint32_t) 0x0000500a) /* vboot local */
Luigi Semenzato52a8d2d2010-05-28 10:34:31 -070043
Luigi Semenzatob472d9c2015-04-28 11:12:18 -070044#define TPM_NV_INDEX0 ((uint32_t) 0x00000000)
45#define TPM_NV_INDEX_LOCK ((uint32_t) 0xffffffff)
46#define TPM_NV_PER_GLOBALLOCK (((uint32_t) 1) << 15)
47#define TPM_NV_PER_PPWRITE (((uint32_t) 1) << 0)
48#define TPM_NV_PER_READ_STCLEAR (((uint32_t)1) << 31)
49#define TPM_NV_PER_WRITE_STCLEAR (((uint32_t)1) << 14)
50
51#define TPM_TAG_NV_ATTRIBUTES ((uint16_t) 0x0017)
52#define TPM_TAG_NV_DATA_PUBLIC ((uint16_t) 0x0018)
Luigi Semenzato5896b962010-08-25 07:16:03 -070053
54#define TPM_TAG_RQU_COMMAND ((uint16_t) 0xc1)
55#define TPM_TAG_RQU_AUTH1_COMMAND ((uint16_t) 0xc2)
56#define TPM_TAG_RQU_AUTH2_COMMAND ((uint16_t) 0xc3)
57
58#define TPM_TAG_RSP_COMMAND ((uint16_t) 0xc4)
59#define TPM_TAG_RSP_AUTH1_COMMAND ((uint16_t) 0xc5)
60#define TPM_TAG_RSP_AUTH2_COMMAND ((uint16_t) 0xc6)
Gaurav Shah887e3d42010-04-27 16:26:48 -070061
62typedef uint8_t TSS_BOOL;
Luigi Semenzatob472d9c2015-04-28 11:12:18 -070063typedef uint8_t TPM_BOOL;
64typedef uint16_t TPM_TAG;
Gaurav Shah887e3d42010-04-27 16:26:48 -070065typedef uint16_t TPM_STRUCTURE_TAG;
Luigi Semenzatob472d9c2015-04-28 11:12:18 -070066typedef uint32_t TPM_NV_INDEX;
67typedef uint32_t TPM_NV_PER_ATTRIBUTES;
68typedef uint8_t TPM_LOCALITY_SELECTION;
69typedef uint32_t TPM_COMMAND_CODE;
70typedef uint16_t TPM_PHYSICAL_PRESENCE;
71typedef uint16_t TPM_STARTUP_TYPE;
72typedef uint32_t TPM_CAPABILITY_AREA;
73
74#define TPM_CAP_FLAG ((uint32_t) 0x00000004)
75#define TPM_CAP_FLAG_PERMANENT ((uint32_t) 0x00000108)
76#define TPM_CAP_FLAG_VOLATILE ((uint32_t) 0x00000109)
77
78#define TPM_CAP_PROPERTY ((uint32_t) 0x00000005)
79#define TPM_CAP_PROP_OWNER ((uint32_t) 0x00000111)
80#define TPM_CAP_NV_INDEX ((uint32_t) 0x00000011)
81
82#define TPM_ST_CLEAR ((uint16_t) 0x0001)
83#define TPM_ST_STATE ((uint16_t) 0x0002)
84#define TPM_ST_DEACTIVATED ((uint16_t) 0x0003)
85
86#define TPM_LOC_FOUR (((uint32_t)1)<<4)
87#define TPM_LOC_THREE (((uint32_t)1)<<3)
88#define TPM_LOC_TWO (((uint32_t)1)<<2)
89#define TPM_LOC_ONE (((uint32_t)1)<<1)
90#define TPM_LOC_ZERO (((uint32_t)1)<<0)
91
92#define TPM_PHYSICAL_PRESENCE_LOCK ((uint16_t) 0x0004)
93#define TPM_PHYSICAL_PRESENCE_PRESENT ((uint16_t) 0x0008)
94#define TPM_PHYSICAL_PRESENCE_NOTPRESENT ((uint16_t) 0x0010)
95#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE ((uint16_t) 0x0020)
96#define TPM_PHYSICAL_PRESENCE_HW_ENABLE ((uint16_t) 0x0040)
97#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((uint16_t) 0x0080)
98#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE ((uint16_t) 0x0100)
99#define TPM_PHYSICAL_PRESENCE_HW_DISABLE ((uint16_t) 0x0200)
100
101#define TPM_SHA1_160_HASH_LEN 0x14
102#define TPM_SHA1BASED_NONCE_LEN TPM_SHA1_160_HASH_LEN
103
104typedef struct tdTPM_DIGEST
105{
106 uint8_t digest[TPM_SHA1_160_HASH_LEN];
107} TPM_DIGEST;
108
109typedef TPM_DIGEST TPM_COMPOSITE_HASH;
110
111typedef struct tdTPM_PCR_SELECTION
112{
113 uint16_t sizeOfSelect;
114 uint8_t *pcrSelect;
115} TPM_PCR_SELECTION;
116
117typedef struct tdTPM_NV_ATTRIBUTES
118{
119 TPM_STRUCTURE_TAG tag;
120 TPM_NV_PER_ATTRIBUTES attributes;
121} TPM_NV_ATTRIBUTES;
122
123typedef struct tdTPM_PCR_INFO_SHORT
124{
125 TPM_PCR_SELECTION pcrSelection;
126 TPM_LOCALITY_SELECTION localityAtRelease;
127 TPM_COMPOSITE_HASH digestAtRelease;
128} TPM_PCR_INFO_SHORT;
Gaurav Shah887e3d42010-04-27 16:26:48 -0700129
Gaurav Shah887e3d42010-04-27 16:26:48 -0700130typedef struct tdTPM_PERMANENT_FLAGS
131{
Randall Spanglera2db67d2013-01-24 16:15:35 -0800132 TPM_STRUCTURE_TAG tag;
133 TSS_BOOL disable;
134 TSS_BOOL ownership;
135 TSS_BOOL deactivated;
136 TSS_BOOL readPubek;
137 TSS_BOOL disableOwnerClear;
138 TSS_BOOL allowMaintenance;
139 TSS_BOOL physicalPresenceLifetimeLock;
140 TSS_BOOL physicalPresenceHWEnable;
141 TSS_BOOL physicalPresenceCMDEnable;
142 TSS_BOOL CEKPUsed;
143 TSS_BOOL TPMpost;
144 TSS_BOOL TPMpostLock;
145 TSS_BOOL FIPS;
146 TSS_BOOL Operator;
147 TSS_BOOL enableRevokeEK;
148 TSS_BOOL nvLocked;
149 TSS_BOOL readSRKPub;
150 TSS_BOOL tpmEstablished;
151 TSS_BOOL maintenanceDone;
152 TSS_BOOL disableFullDALogicInfo;
Gaurav Shah887e3d42010-04-27 16:26:48 -0700153} TPM_PERMANENT_FLAGS;
154
Luigi Semenzato5896b962010-08-25 07:16:03 -0700155typedef struct tdTPM_STCLEAR_FLAGS{
Randall Spanglera2db67d2013-01-24 16:15:35 -0800156 TPM_STRUCTURE_TAG tag;
157 TSS_BOOL deactivated;
158 TSS_BOOL disableForceClear;
159 TSS_BOOL physicalPresence;
160 TSS_BOOL physicalPresenceLock;
161 TSS_BOOL bGlobalLock;
Luigi Semenzato5896b962010-08-25 07:16:03 -0700162} TPM_STCLEAR_FLAGS;
Gaurav Shah887e3d42010-04-27 16:26:48 -0700163
Luigi Semenzatob472d9c2015-04-28 11:12:18 -0700164typedef struct tdTPM_NV_DATA_PUBLIC
165{
166 TPM_STRUCTURE_TAG tag;
167 TPM_NV_INDEX nvIndex;
168 TPM_PCR_INFO_SHORT pcrInfoRead;
169 TPM_PCR_INFO_SHORT pcrInfoWrite;
170 TPM_NV_ATTRIBUTES permission;
171 TPM_BOOL bReadSTClear;
172 TPM_BOOL bWriteSTClear;
173 TPM_BOOL bWriteDefine;
174 uint32_t dataSize;
175} TPM_NV_DATA_PUBLIC;
176
177typedef struct tdTPM_NONCE
178{
179 uint8_t nonce[TPM_SHA1BASED_NONCE_LEN];
180} TPM_NONCE;
181
182/* Ordinals */
183
184#define TPM_ORD_ContinueSelfTest ((uint32_t) 0x00000053)
185#define TPM_ORD_Extend ((uint32_t) 0x00000014)
186#define TPM_ORD_ForceClear ((uint32_t) 0x0000005D)
187#define TPM_ORD_GetCapability ((uint32_t) 0x00000065)
188#define TPM_ORD_GetRandom ((uint32_t) 0x00000046)
189#define TPM_ORD_NV_DefineSpace ((uint32_t) 0x000000CC)
190#define TPM_ORD_NV_ReadValue ((uint32_t) 0x000000CF)
191#define TPM_ORD_NV_WriteValue ((uint32_t) 0x000000CD)
192#define TPM_ORD_PcrRead ((uint32_t) 0x00000015)
193#define TPM_ORD_PhysicalEnable ((uint32_t) 0x0000006F)
194#define TPM_ORD_PhysicalDisable ((uint32_t) 0x00000070)
195#define TSC_ORD_PhysicalPresence ((uint32_t) 0x4000000A)
196#define TPM_ORD_PhysicalSetDeactivated ((uint32_t) 0x00000072)
197#define TPM_ORD_ReadPubek ((uint32_t) 0x0000007C)
198#define TPM_ORD_SaveState ((uint32_t) 0x00000098)
199#define TPM_ORD_SelfTestFull ((uint32_t) 0x00000050)
200#define TPM_ORD_Startup ((uint32_t) 0x00000099)
201
202
Che-Liang Chiou89678602010-11-09 08:33:36 +0800203#endif /* VBOOT_REFERENCE_TSS_CONSTANTS_H_ */