| OLD | NEW |
| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 uint32_t TlclAssertPhysicalPresence(void) { | 174 uint32_t TlclAssertPhysicalPresence(void) { |
| 175 VBDEBUG(("TPM: Asserting physical presence\n")); | 175 VBDEBUG(("TPM: Asserting physical presence\n")); |
| 176 return Send(tpm_ppassert_cmd.buffer); | 176 return Send(tpm_ppassert_cmd.buffer); |
| 177 } | 177 } |
| 178 | 178 |
| 179 uint32_t TlclPhysicalPresenceCMDEnable(void) { | 179 uint32_t TlclPhysicalPresenceCMDEnable(void) { |
| 180 VBDEBUG(("TPM: Enable the physical presence command\n")); | 180 VBDEBUG(("TPM: Enable the physical presence command\n")); |
| 181 return Send(tpm_ppenable_cmd.buffer); | 181 return Send(tpm_ppenable_cmd.buffer); |
| 182 } | 182 } |
| 183 | 183 |
| 184 uint32_t TlclFinalizePhysicalPresence(void) { |
| 185 VBDEBUG(("TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n")); |
| 186 return Send(tpm_finalizepp_cmd.buffer); |
| 187 } |
| 188 |
| 184 uint32_t TlclAssertPhysicalPresenceResult(void) { | 189 uint32_t TlclAssertPhysicalPresenceResult(void) { |
| 185 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; | 190 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; |
| 186 return TlclSendReceive(tpm_ppassert_cmd.buffer, response, sizeof(response)); | 191 return TlclSendReceive(tpm_ppassert_cmd.buffer, response, sizeof(response)); |
| 187 } | 192 } |
| 188 | 193 |
| 189 uint32_t TlclLockPhysicalPresence(void) { | 194 uint32_t TlclLockPhysicalPresence(void) { |
| 190 VBDEBUG(("TPM: Lock physical presence\n")); | 195 VBDEBUG(("TPM: Lock physical presence\n")); |
| 191 return Send(tpm_pplock_cmd.buffer); | 196 return Send(tpm_pplock_cmd.buffer); |
| 192 } | 197 } |
| 193 | 198 |
| 194 uint32_t TlclSetNvLocked(void) { | 199 uint32_t TlclSetNvLocked(void) { |
| 195 VBDEBUG(("TPM: Set NV locked\n")); | 200 VBDEBUG(("TPM: Set NV locked\n")); |
| 196 return TlclDefineSpace(TPM_NV_INDEX_LOCK, 0, 0); | 201 return TlclDefineSpace(TPM_NV_INDEX_LOCK, 0, 0); |
| 197 } | 202 } |
| 198 | 203 |
| 199 int TlclIsOwned(void) { | 204 int TlclIsOwned(void) { |
| 200 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE + TPM_PUBEK_SIZE]; | 205 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE + TPM_PUBEK_SIZE]; |
| 201 uint32_t result; | 206 uint32_t result; |
| 202 result = TlclSendReceive(tpm_readpubek_cmd.buffer, response, sizeof(response))
; | 207 result = TlclSendReceive(tpm_readpubek_cmd.buffer, |
| 208 response, sizeof(response)); |
| 203 return (result != TPM_SUCCESS); | 209 return (result != TPM_SUCCESS); |
| 204 } | 210 } |
| 205 | 211 |
| 206 uint32_t TlclForceClear(void) { | 212 uint32_t TlclForceClear(void) { |
| 207 VBDEBUG(("TPM: Force clear\n")); | 213 VBDEBUG(("TPM: Force clear\n")); |
| 208 return Send(tpm_forceclear_cmd.buffer); | 214 return Send(tpm_forceclear_cmd.buffer); |
| 209 } | 215 } |
| 210 | 216 |
| 211 uint32_t TlclSetEnable(void) { | 217 uint32_t TlclSetEnable(void) { |
| 212 VBDEBUG(("TPM: Enabling TPM\n")); | 218 VBDEBUG(("TPM: Enabling TPM\n")); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); | 314 Memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); |
| 309 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); | 315 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); |
| 310 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); | 316 result = TlclSendReceive(cmd.buffer, response, sizeof(response)); |
| 311 if (result != TPM_SUCCESS) | 317 if (result != TPM_SUCCESS) |
| 312 return result; | 318 return result; |
| 313 | 319 |
| 314 nvdata = response + kTpmResponseHeaderLength + sizeof(size); | 320 nvdata = response + kTpmResponseHeaderLength + sizeof(size); |
| 315 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); | 321 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); |
| 316 return result; | 322 return result; |
| 317 } | 323 } |
| OLD | NEW |