OLD | NEW |
1 /* Copyright (c) 2010-2011 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010-2011 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 return result; | 285 return result; |
286 } | 286 } |
287 | 287 |
288 uint32_t TlclSetGlobalLock(void) { | 288 uint32_t TlclSetGlobalLock(void) { |
289 uint32_t x; | 289 uint32_t x; |
290 VBDEBUG(("TPM: Set global lock\n")); | 290 VBDEBUG(("TPM: Set global lock\n")); |
291 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0); | 291 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0); |
292 } | 292 } |
293 | 293 |
294 uint32_t TlclExtend(int pcr_num, uint8_t* in_digest, uint8_t* out_digest) { | 294 uint32_t TlclExtend(int pcr_num, const uint8_t* in_digest, |
| 295 uint8_t* out_digest) { |
295 struct s_tpm_extend_cmd cmd; | 296 struct s_tpm_extend_cmd cmd; |
296 uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength]; | 297 uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength]; |
297 uint32_t result; | 298 uint32_t result; |
298 | 299 |
299 Memcpy(&cmd, &tpm_extend_cmd, sizeof(cmd)); | 300 Memcpy(&cmd, &tpm_extend_cmd, sizeof(cmd)); |
300 ToTpmUint32(cmd.buffer + tpm_extend_cmd.pcrNum, pcr_num); | 301 ToTpmUint32(cmd.buffer + tpm_extend_cmd.pcrNum, pcr_num); |
301 Memcpy(cmd.buffer + cmd.inDigest, in_digest, kPcrDigestLength); | 302 Memcpy(cmd.buffer + cmd.inDigest, in_digest, kPcrDigestLength); |
302 | 303 |
303 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); | 304 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); |
304 if (result != TPM_SUCCESS) | 305 if (result != TPM_SUCCESS) |
(...skipping 13 matching lines...) Expand all Loading... |
318 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); | 319 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); |
319 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); | 320 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); |
320 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); | 321 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); |
321 if (result != TPM_SUCCESS) | 322 if (result != TPM_SUCCESS) |
322 return result; | 323 return result; |
323 | 324 |
324 nvdata = response + kTpmResponseHeaderLength + sizeof(size); | 325 nvdata = response + kTpmResponseHeaderLength + sizeof(size); |
325 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); | 326 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); |
326 return result; | 327 return result; |
327 } | 328 } |
OLD | NEW |