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

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

Issue 3010019: TPM cleanup (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: this e-mail Created 10 years, 5 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/rollback_index.c ('k') | firmware/version.c » ('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
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 uint32_t TlclSetGlobalLock(void) { 249 uint32_t TlclSetGlobalLock(void) {
250 uint32_t x; 250 uint32_t x;
251 VBDEBUG(("TPM: Set Set global lock\n")); 251 VBDEBUG(("TPM: Set Set global lock\n"));
252 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0); 252 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0);
253 } 253 }
254 254
255 uint32_t TlclExtend(int pcr_num, uint8_t* in_digest, uint8_t* out_digest) { 255 uint32_t TlclExtend(int pcr_num, uint8_t* in_digest, uint8_t* out_digest) {
256 struct s_tpm_extend_cmd cmd; 256 struct s_tpm_extend_cmd cmd;
257 uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
258
257 Memcpy(&cmd, &tpm_extend_cmd, sizeof(cmd)); 259 Memcpy(&cmd, &tpm_extend_cmd, sizeof(cmd));
258 uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
259 ToTpmUint32(cmd.buffer + tpm_extend_cmd.pcrNum, pcr_num); 260 ToTpmUint32(cmd.buffer + tpm_extend_cmd.pcrNum, pcr_num);
260 Memcpy(cmd.buffer + cmd.inDigest, in_digest, kPcrDigestLength); 261 Memcpy(cmd.buffer + cmd.inDigest, in_digest, kPcrDigestLength);
261 TlclSendReceive(cmd.buffer, response, sizeof(response)); 262 TlclSendReceive(cmd.buffer, response, sizeof(response));
262 Memcpy(out_digest, response + kTpmResponseHeaderLength, kPcrDigestLength); 263 Memcpy(out_digest, response + kTpmResponseHeaderLength, kPcrDigestLength);
263 return TpmReturnCode(response); 264 return TpmReturnCode(response);
264 } 265 }
265 266
266 uint32_t TlclGetPermissions(uint32_t index, uint32_t* permissions) { 267 uint32_t TlclGetPermissions(uint32_t index, uint32_t* permissions) {
267 struct s_tpm_getpermissions_cmd cmd; 268 struct s_tpm_getpermissions_cmd cmd;
268 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; 269 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
269 uint8_t* nvdata; 270 uint8_t* nvdata;
270 uint32_t result; 271 uint32_t result;
271 uint32_t size; 272 uint32_t size;
272 273
273 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); 274 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd));
274 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); 275 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index);
275 TlclSendReceive(tpm_getpermissions_cmd.buffer, response, sizeof(response)); 276 TlclSendReceive(tpm_getpermissions_cmd.buffer, response, sizeof(response));
276 result = TpmReturnCode(response); 277 result = TpmReturnCode(response);
277 if (result != TPM_SUCCESS) { 278 if (result != TPM_SUCCESS) {
278 return result; 279 return result;
279 } 280 }
280 nvdata = response + kTpmResponseHeaderLength + sizeof(size); 281 nvdata = response + kTpmResponseHeaderLength + sizeof(size);
281 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); 282 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions);
282 return result; 283 return result;
283 } 284 }
OLDNEW
« no previous file with comments | « firmware/lib/rollback_index.c ('k') | firmware/version.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698