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 * Functions for querying, manipulating and locking rollback indices | 5 * Functions for querying, manipulating and locking rollback indices |
6 * stored in the TPM NVRAM. | 6 * stored in the TPM NVRAM. |
7 */ | 7 */ |
8 | 8 |
9 #include "rollback_index.h" | 9 #include "rollback_index.h" |
10 | 10 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 * previous boot.) In recovery mode, we ignore the failure and continue, thus | 238 * previous boot.) In recovery mode, we ignore the failure and continue, thus |
239 * giving the recovery kernel a chance to fix things (that's why we don't set | 239 * giving the recovery kernel a chance to fix things (that's why we don't set |
240 * bGlobalLock). The choice is between a knowingly insecure device and a | 240 * bGlobalLock). The choice is between a knowingly insecure device and a |
241 * bricked device. | 241 * bricked device. |
242 * | 242 * |
243 * As a side note, observe that we go through considerable hoops to avoid using | 243 * As a side note, observe that we go through considerable hoops to avoid using |
244 * the STCLEAR permissions for the index spaces. We do this to avoid writing | 244 * the STCLEAR permissions for the index spaces. We do this to avoid writing |
245 * to the TPM flashram at every reboot or wake-up, because of concerns about | 245 * to the TPM flashram at every reboot or wake-up, because of concerns about |
246 * the durability of the NVRAM. | 246 * the durability of the NVRAM. |
247 */ | 247 */ |
248 static uint32_t SetupTPM(int recovery_mode, | 248 uint32_t SetupTPM(int recovery_mode, int developer_mode) { |
249 int developer_mode) { | |
250 uint8_t disable; | 249 uint8_t disable; |
251 uint8_t deactivated; | 250 uint8_t deactivated; |
252 uint32_t result; | 251 uint32_t result; |
253 | 252 |
254 TlclLibInit(); | 253 TlclLibInit(); |
255 RETURN_ON_FAILURE(TlclStartup()); | 254 RETURN_ON_FAILURE(TlclStartup()); |
256 RETURN_ON_FAILURE(TlclContinueSelfTest()); | 255 RETURN_ON_FAILURE(TlclContinueSelfTest()); |
257 RETURN_ON_FAILURE(TlclAssertPhysicalPresence()); | 256 RETURN_ON_FAILURE(TlclAssertPhysicalPresence()); |
258 /* Checks that the TPM is enabled and activated. */ | 257 /* Checks that the TPM is enabled and activated. */ |
259 RETURN_ON_FAILURE(TlclGetFlags(&disable, &deactivated)); | 258 RETURN_ON_FAILURE(TlclGetFlags(&disable, &deactivated)); |
(...skipping 23 matching lines...) Expand all Loading... |
283 if (recovery_mode) { | 282 if (recovery_mode) { |
284 /* In recovery mode global variables are usable. */ | 283 /* In recovery mode global variables are usable. */ |
285 g_rollback_recovery_mode = 1; | 284 g_rollback_recovery_mode = 1; |
286 } | 285 } |
287 return TPM_SUCCESS; | 286 return TPM_SUCCESS; |
288 } | 287 } |
289 | 288 |
290 /* disable MSVC warnings on unused arguments */ | 289 /* disable MSVC warnings on unused arguments */ |
291 __pragma(warning (disable: 4100)) | 290 __pragma(warning (disable: 4100)) |
292 | 291 |
| 292 |
| 293 #ifdef DISABLE_ROLLBACK_TPM |
| 294 |
| 295 /* Dummy implementations which don't call into the tpm_lite library */ |
| 296 |
| 297 uint32_t RollbackFirmwareSetup(int developer_mode) { |
| 298 return TPM_SUCCESS; |
| 299 } |
| 300 |
| 301 uint32_t RollbackFirmwareRead(uint16_t* key_version, uint16_t* version) { |
| 302 *key_version = *version = 0; |
| 303 return TPM_SUCCESS; |
| 304 } |
| 305 |
| 306 uint32_t RollbackFirmwareWrite(uint16_t key_version, uint16_t version) { |
| 307 return TPM_SUCCESS; |
| 308 } |
| 309 |
| 310 uint32_t RollbackFirmwareLock(void) { |
| 311 return TPM_SUCCESS; |
| 312 } |
| 313 |
| 314 uint32_t RollbackKernelRecovery(int developer_mode) { |
| 315 return TPM_SUCCESS; |
| 316 } |
| 317 |
| 318 uint32_t RollbackKernelRead(uint16_t* key_version, uint16_t* version) { |
| 319 *key_version = *version = 0; |
| 320 return TPM_SUCCESS; |
| 321 } |
| 322 |
| 323 uint32_t RollbackKernelWrite(uint16_t key_version, uint16_t version) { |
| 324 return TPM_SUCCESS; |
| 325 } |
| 326 |
| 327 uint32_t RollbackKernelLock(void) { |
| 328 return TPM_SUCCESS; |
| 329 } |
| 330 |
| 331 #else |
| 332 |
293 uint32_t RollbackFirmwareSetup(int developer_mode) { | 333 uint32_t RollbackFirmwareSetup(int developer_mode) { |
294 return SetupTPM(0, developer_mode); | 334 return SetupTPM(0, developer_mode); |
295 } | 335 } |
296 | 336 |
297 uint32_t RollbackFirmwareRead(uint16_t* key_version, uint16_t* version) { | 337 uint32_t RollbackFirmwareRead(uint16_t* key_version, uint16_t* version) { |
298 uint32_t firmware_versions; | 338 uint32_t firmware_versions; |
299 /* Gets firmware versions. */ | 339 /* Gets firmware versions. */ |
300 RETURN_ON_FAILURE(TlclRead(FIRMWARE_VERSIONS_NV_INDEX, | 340 RETURN_ON_FAILURE(TlclRead(FIRMWARE_VERSIONS_NV_INDEX, |
301 (uint8_t*) &firmware_versions, | 341 (uint8_t*) &firmware_versions, |
302 sizeof(firmware_versions))); | 342 sizeof(firmware_versions))); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return TPM_SUCCESS; | 398 return TPM_SUCCESS; |
359 } | 399 } |
360 | 400 |
361 uint32_t RollbackKernelLock(void) { | 401 uint32_t RollbackKernelLock(void) { |
362 if (!g_rollback_recovery_mode) { | 402 if (!g_rollback_recovery_mode) { |
363 return TlclLockPhysicalPresence(); | 403 return TlclLockPhysicalPresence(); |
364 } else { | 404 } else { |
365 return TPM_SUCCESS; | 405 return TPM_SUCCESS; |
366 } | 406 } |
367 } | 407 } |
| 408 |
| 409 #endif // DISABLE_ROLLBACK_TPM |
OLD | NEW |