Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: firmware/lib/tpm_lite/tlcl.c

Issue 3116025: Added new commands and reactivated full rebuild after fixing for ARM ebuild. (Closed) Base URL: ssh://git@chromiumos-git/vboot_reference.git
Patch Set: move to new build flow (no changes expected) Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « firmware/lib/tpm_lite/include/tss_constants.h ('k') | firmware/stub/include/tpmextras.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* A lightweight TPM command library. 6 /* A lightweight TPM command library.
7 * 7 *
8 * The general idea is that TPM commands are array of bytes whose 8 * The general idea is that TPM commands are array of bytes whose
9 * fields are mostly compile-time constant. The goal is to build much 9 * fields are mostly compile-time constant. The goal is to build much
10 * of the commands at compile time (or build time) and change some of 10 * of the commands at compile time (or build time) and change some of
11 * the fields at run time as needed. The code in 11 * the fields at run time as needed. The code in
12 * utility/tlcl_generator.c builds structures containing the commands, 12 * utility/tlcl_generator.c builds structures containing the commands,
13 * as well as the offsets of the fields that need to be set at run 13 * as well as the offsets of the fields that need to be set at run
14 * time. 14 * time.
15 */ 15 */
16 16
17 #include "sysincludes.h" 17 #include "sysincludes.h"
18 #include "tlcl.h" 18 #include "tlcl.h"
19 #include "tlcl_internal.h" 19 #include "tlcl_internal.h"
20 #include "tlcl_structures.h" 20 #include "tlcl_structures.h"
21 #include "tss_constants.h" 21 #include "tpmextras.h"
22 #include "utility.h" 22 #include "utility.h"
23 23
24 /* Sets the size field of a TPM command. */ 24 /* Sets the size field of a TPM command. */
25 static INLINE void SetTpmCommandSize(uint8_t* buffer, uint32_t size) { 25 static INLINE void SetTpmCommandSize(uint8_t* buffer, uint32_t size) {
26 ToTpmUint32(buffer + sizeof(uint16_t), size); 26 ToTpmUint32(buffer + sizeof(uint16_t), size);
27 } 27 }
28 28
29 /* Gets the size field of a TPM command. */ 29 /* Gets the size field of a TPM command. */
30 POSSIBLY_UNUSED static INLINE int TpmCommandSize(const uint8_t* buffer) { 30 POSSIBLY_UNUSED static INLINE int TpmCommandSize(const uint8_t* buffer) {
31 uint32_t size; 31 uint32_t size;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 215
216 uint32_t TlclSetDeactivated(uint8_t flag) { 216 uint32_t TlclSetDeactivated(uint8_t flag) {
217 struct s_tpm_physicalsetdeactivated_cmd cmd; 217 struct s_tpm_physicalsetdeactivated_cmd cmd;
218 VBDEBUG(("TPM: SetDeactivated(%d)\n", flag)); 218 VBDEBUG(("TPM: SetDeactivated(%d)\n", flag));
219 Memcpy(&cmd, &tpm_physicalsetdeactivated_cmd, sizeof(cmd)); 219 Memcpy(&cmd, &tpm_physicalsetdeactivated_cmd, sizeof(cmd));
220 *(cmd.buffer + cmd.deactivated) = flag; 220 *(cmd.buffer + cmd.deactivated) = flag;
221 return Send(cmd.buffer); 221 return Send(cmd.buffer);
222 } 222 }
223 223
224 uint32_t TlclGetFlags(uint8_t* disable, uint8_t* deactivated, uint8_t *nvlocked) { 224 uint32_t TlclGetPermanentFlags(TPM_PERMANENT_FLAGS* pflags) {
225 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; 225 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
226 TPM_PERMANENT_FLAGS* pflags;
227 uint32_t result;
228 uint32_t size; 226 uint32_t size;
229 VBDEBUG(("TPM: Get flags\n")); 227 uint32_t result =
230 228 TlclSendReceive(tpm_getflags_cmd.buffer, response, sizeof(response));
231 result = TlclSendReceive(tpm_getflags_cmd.buffer, response, sizeof(response));
232 if (result != TPM_SUCCESS) 229 if (result != TPM_SUCCESS)
233 return result; 230 return result;
234
235 FromTpmUint32(response + kTpmResponseHeaderLength, &size); 231 FromTpmUint32(response + kTpmResponseHeaderLength, &size);
236 assert(size == sizeof(TPM_PERMANENT_FLAGS)); 232 assert(size == sizeof(TPM_PERMANENT_FLAGS));
237 pflags = 233 Memcpy(pflags,
238 (TPM_PERMANENT_FLAGS*) (response + kTpmResponseHeaderLength + sizeof(size)); 234 response + kTpmResponseHeaderLength + sizeof(size),
239 VBDEBUG(("TPM: Got flags disable=%d, deactivated=%d, nvlocked=%d\n", 235 sizeof(TPM_PERMANENT_FLAGS));
240 pflags->disable, pflags->deactivated, pflags->nvLocked));
241 if (disable)
242 *disable = pflags->disable;
243 if (deactivated)
244 *deactivated = pflags->deactivated;
245 if (nvlocked)
246 *nvlocked = pflags->nvLocked;
247 return result; 236 return result;
248 } 237 }
249 238
239 uint32_t TlclGetSTClearFlags(TPM_STCLEAR_FLAGS* vflags) {
240 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
241 uint32_t size;
242 uint32_t result =
243 TlclSendReceive(tpm_getstclearflags_cmd.buffer, response, sizeof(response));
244 if (result != TPM_SUCCESS)
245 return result;
246 FromTpmUint32(response + kTpmResponseHeaderLength, &size);
247 /* Ugly assertion, but the struct is padded up by one byte. */
248 assert(size == 7 && sizeof(TPM_STCLEAR_FLAGS) - 1 == 7);
249 Memcpy(vflags,
250 response + kTpmResponseHeaderLength + sizeof(size),
251 sizeof(TPM_STCLEAR_FLAGS));
252 return result;
253 }
254
255 uint32_t TlclGetFlags(uint8_t* disable,
256 uint8_t* deactivated,
257 uint8_t *nvlocked) {
258 TPM_PERMANENT_FLAGS pflags;
259 uint32_t result = TlclGetPermanentFlags(&pflags);
260 if (result == TPM_SUCCESS) {
261 if (disable)
262 *disable = pflags.disable;
263 if (deactivated)
264 *deactivated = pflags.deactivated;
265 if (nvlocked)
266 *nvlocked = pflags.nvLocked;
267 VBDEBUG(("TPM: Got flags disable=%d, deactivated=%d, nvlocked=%d\n",
268 pflags.disable, pflags.deactivated, pflags.nvLocked));
269 }
270 return result;
271 }
272
250 uint32_t TlclSetGlobalLock(void) { 273 uint32_t TlclSetGlobalLock(void) {
251 uint32_t x; 274 uint32_t x;
252 VBDEBUG(("TPM: Set global lock\n")); 275 VBDEBUG(("TPM: Set global lock\n"));
253 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0); 276 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0);
254 } 277 }
255 278
256 uint32_t TlclExtend(int pcr_num, uint8_t* in_digest, uint8_t* out_digest) { 279 uint32_t TlclExtend(int pcr_num, uint8_t* in_digest, uint8_t* out_digest) {
257 struct s_tpm_extend_cmd cmd; 280 struct s_tpm_extend_cmd cmd;
258 uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength]; 281 uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
259 uint32_t result; 282 uint32_t result;
(...skipping 20 matching lines...) Expand all
280 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); 303 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd));
281 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); 304 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index);
282 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); 305 result = TlclSendReceive(cmd.buffer, response, sizeof(response));
283 if (result != TPM_SUCCESS) 306 if (result != TPM_SUCCESS)
284 return result; 307 return result;
285 308
286 nvdata = response + kTpmResponseHeaderLength + sizeof(size); 309 nvdata = response + kTpmResponseHeaderLength + sizeof(size);
287 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); 310 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions);
288 return result; 311 return result;
289 } 312 }
OLDNEW
« no previous file with comments | « firmware/lib/tpm_lite/include/tss_constants.h ('k') | firmware/stub/include/tpmextras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698