blob: c29ada7bf50b44cd37dde1941b8bdd8540bcf55a [file] [log] [blame]
Kees Cook41282f12012-08-01 15:32:11 -07001/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Che-Liang Chiou8511f782011-04-22 16:01:38 +08002 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
Joel Kitching0b3ce462019-06-14 14:52:41 +08006#include "2sysincludes.h"
Che-Liang Chiou8511f782011-04-22 16:01:38 +08007#include "tlcl.h"
8#include "tlcl_internal.h"
Che-Liang Chiou8511f782011-04-22 16:01:38 +08009
Randall Spanglerfb267152016-10-11 15:28:16 -070010uint32_t TlclLibInit(void)
11{
Joel Kitching28eeded2020-07-06 13:58:11 +080012 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080013}
14
Randall Spanglerfb267152016-10-11 15:28:16 -070015uint32_t TlclLibClose(void)
16{
17 return TPM_SUCCESS;
Duncan Laurieee327512013-01-11 10:32:29 -080018}
19
Randall Spanglerfb267152016-10-11 15:28:16 -070020uint32_t TlclStartup(void)
21{
22 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080023}
24
Randall Spanglerfb267152016-10-11 15:28:16 -070025uint32_t TlclSaveState(void)
26{
27 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080028}
29
Randall Spanglerfb267152016-10-11 15:28:16 -070030uint32_t TlclResume(void)
31{
32 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080033}
34
Randall Spanglerfb267152016-10-11 15:28:16 -070035uint32_t TlclSelfTestFull(void)
36{
37 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080038}
39
Randall Spanglerfb267152016-10-11 15:28:16 -070040uint32_t TlclContinueSelfTest(void)
41{
42 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080043}
44
Randall Spanglerfb267152016-10-11 15:28:16 -070045uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size)
46{
47 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080048}
49
Joel Kitching33655b32019-08-29 14:43:34 +080050uint32_t TlclDefineSpaceEx(const uint8_t* owner_auth, uint32_t owner_auth_size,
51 uint32_t index, uint32_t perm, uint32_t size,
52 const void* auth_policy, uint32_t auth_policy_size)
53{
54 return TPM_SUCCESS;
55}
56
57#ifdef CHROMEOS_ENVIRONMENT
58
Joel Kitching595108c2019-08-23 19:12:35 +080059uint32_t TlclUndefineSpace(uint32_t index)
60{
61 return TPM_SUCCESS;
62}
63
Joel Kitching33655b32019-08-29 14:43:34 +080064#endif /* CHROMEOS_ENVIRONMENT */
65
Randall Spanglerfb267152016-10-11 15:28:16 -070066uint32_t TlclWrite(uint32_t index, const void* data, uint32_t length)
67{
68 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080069}
70
Randall Spanglerfb267152016-10-11 15:28:16 -070071uint32_t TlclRead(uint32_t index, void* data, uint32_t length)
72{
Randall Spangler664096b2016-10-13 16:16:41 -070073 memset(data, '\0', length);
Randall Spanglerfb267152016-10-11 15:28:16 -070074 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080075}
76
Randall Spanglerfb267152016-10-11 15:28:16 -070077uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length)
78{
Randall Spangler664096b2016-10-13 16:16:41 -070079 memset(data, '\0', length);
Randall Spanglerfb267152016-10-11 15:28:16 -070080 return TPM_SUCCESS;
Kees Cook41282f12012-08-01 15:32:11 -070081}
82
Randall Spanglerfb267152016-10-11 15:28:16 -070083uint32_t TlclWriteLock(uint32_t index)
84{
85 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080086}
87
Randall Spanglerfb267152016-10-11 15:28:16 -070088uint32_t TlclReadLock(uint32_t index)
89{
90 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080091}
92
Randall Spanglerfb267152016-10-11 15:28:16 -070093uint32_t TlclAssertPhysicalPresence(void)
94{
95 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +080096}
97
Randall Spanglerfb267152016-10-11 15:28:16 -070098uint32_t TlclPhysicalPresenceCMDEnable(void)
99{
100 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800101}
102
Randall Spanglerfb267152016-10-11 15:28:16 -0700103uint32_t TlclFinalizePhysicalPresence(void)
104{
105 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800106}
107
Randall Spanglerfb267152016-10-11 15:28:16 -0700108uint32_t TlclAssertPhysicalPresenceResult(void)
109{
110 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800111}
112
Randall Spanglerfb267152016-10-11 15:28:16 -0700113uint32_t TlclLockPhysicalPresence(void)
114{
115 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800116}
117
Randall Spanglerfb267152016-10-11 15:28:16 -0700118uint32_t TlclSetNvLocked(void)
119{
120 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800121}
122
Randall Spanglerfb267152016-10-11 15:28:16 -0700123int TlclIsOwned(void)
124{
125 return 0;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800126}
127
Randall Spanglerfb267152016-10-11 15:28:16 -0700128uint32_t TlclForceClear(void)
129{
130 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800131}
132
Randall Spanglerfb267152016-10-11 15:28:16 -0700133uint32_t TlclSetEnable(void)
134{
135 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800136}
137
Randall Spanglerfb267152016-10-11 15:28:16 -0700138uint32_t TlclClearEnable(void)
139{
140 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800141}
142
Randall Spanglerfb267152016-10-11 15:28:16 -0700143uint32_t TlclSetDeactivated(uint8_t flag)
144{
145 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800146}
147
Randall Spanglerfb267152016-10-11 15:28:16 -0700148uint32_t TlclGetPermanentFlags(TPM_PERMANENT_FLAGS* pflags)
149{
Randall Spangler664096b2016-10-13 16:16:41 -0700150 memset(pflags, '\0', sizeof(*pflags));
Randall Spanglerfb267152016-10-11 15:28:16 -0700151 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800152}
153
Randall Spanglerfb267152016-10-11 15:28:16 -0700154uint32_t TlclGetSTClearFlags(TPM_STCLEAR_FLAGS* vflags)
155{
Randall Spangler664096b2016-10-13 16:16:41 -0700156 memset(vflags, '\0', sizeof(*vflags));
Randall Spanglerfb267152016-10-11 15:28:16 -0700157 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800158}
159
160uint32_t TlclGetFlags(uint8_t* disable,
Joel Kitching9ad8a412018-08-02 16:21:17 +0800161 uint8_t* deactivated,
162 uint8_t *nvlocked)
Randall Spanglerfb267152016-10-11 15:28:16 -0700163{
164 *disable = 0;
165 *deactivated = 0;
166 *nvlocked = 0;
167 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800168}
169
Randall Spanglerfb267152016-10-11 15:28:16 -0700170uint32_t TlclSetGlobalLock(void)
171{
172 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800173}
174
175uint32_t TlclExtend(int pcr_num, const uint8_t* in_digest,
Joel Kitching9ad8a412018-08-02 16:21:17 +0800176 uint8_t* out_digest)
Randall Spanglerfb267152016-10-11 15:28:16 -0700177{
Randall Spangler664096b2016-10-13 16:16:41 -0700178 memcpy(out_digest, in_digest, kPcrDigestLength);
Randall Spanglerfb267152016-10-11 15:28:16 -0700179 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800180}
181
Randall Spanglerfb267152016-10-11 15:28:16 -0700182uint32_t TlclGetPermissions(uint32_t index, uint32_t* permissions)
183{
184 *permissions = 0;
185 return TPM_SUCCESS;
Che-Liang Chiou8511f782011-04-22 16:01:38 +0800186}
Kees Cook41282f12012-08-01 15:32:11 -0700187
Randall Spanglerfb267152016-10-11 15:28:16 -0700188uint32_t TlclGetOwnership(uint8_t* owned)
189{
190 *owned = 0;
191 return TPM_SUCCESS;
Kees Cook41282f12012-08-01 15:32:11 -0700192}
193
Randall Spanglerfb267152016-10-11 15:28:16 -0700194uint32_t TlclGetRandom(uint8_t* data, uint32_t length, uint32_t *size)
195{
196 *size = length;
197 /* http://dilbert.com/strips/comic/2001-10-25/ */
Randall Spangler664096b2016-10-13 16:16:41 -0700198 memset(data, '\x9', *size);
Randall Spanglerfb267152016-10-11 15:28:16 -0700199 return TPM_SUCCESS;
Kees Cook41282f12012-08-01 15:32:11 -0700200}
Duncan Laurie416bdc62013-05-06 15:13:10 -0700201
Andrey Pronin3b805722017-10-06 20:01:53 -0700202uint32_t TlclGetVersion(uint32_t* vendor, uint64_t* firmware_version,
Joel Kitching9ad8a412018-08-02 16:21:17 +0800203 uint8_t* vendor_specific_buf,
204 size_t* vendor_specific_buf_size)
Mattias Nissler2a7e9b82017-07-10 13:46:20 +0200205{
206 *vendor = 0x4e4f4e45;
207 *firmware_version = 0x1;
Andrey Pronin3b805722017-10-06 20:01:53 -0700208 if (vendor_specific_buf_size) {
209 *vendor_specific_buf_size = 0;
210 }
Mattias Nissler2a7e9b82017-07-10 13:46:20 +0200211 return TPM_SUCCESS;
212}
213
Duncan Laurie416bdc62013-05-06 15:13:10 -0700214int TlclPacketSize(const uint8_t* packet)
215{
Randall Spanglerfb267152016-10-11 15:28:16 -0700216 uint32_t size;
217 FromTpmUint32(packet + sizeof(uint16_t), &size);
218 return (int) size;
Duncan Laurie416bdc62013-05-06 15:13:10 -0700219}
220
221uint32_t TlclSendReceive(const uint8_t* request, uint8_t* response,
Joel Kitching9ad8a412018-08-02 16:21:17 +0800222 int max_length)
Duncan Laurie416bdc62013-05-06 15:13:10 -0700223{
Randall Spanglerfb267152016-10-11 15:28:16 -0700224 return TPM_SUCCESS;
Duncan Laurie416bdc62013-05-06 15:13:10 -0700225}
Mattias Nisslerb2b39702017-07-07 10:26:43 +0200226
227uint32_t TlclIFXFieldUpgradeInfo(TPM_IFX_FIELDUPGRADEINFO* info)
228{
229 memset(info, 0, sizeof(*info));
230 return TPM_SUCCESS;
231}