| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-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 // Contains the implementation of class Tpm | 5 // Contains the implementation of class Tpm |
| 6 | 6 |
| 7 #include "tpm.h" | 7 #include "tpm.h" |
| 8 | 8 |
| 9 #include <base/file_util.h> | 9 #include <base/file_util.h> |
| 10 #include <base/platform_thread.h> | 10 #include <base/platform_thread.h> |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 if (TPM_ERROR(result = Tspi_TPM_GetCapability(tpm_handle, | 623 if (TPM_ERROR(result = Tspi_TPM_GetCapability(tpm_handle, |
| 624 TSS_TPMCAP_PROPERTY, | 624 TSS_TPMCAP_PROPERTY, |
| 625 sizeof(subcap), | 625 sizeof(subcap), |
| 626 reinterpret_cast<BYTE*>( | 626 reinterpret_cast<BYTE*>( |
| 627 &subcap), | 627 &subcap), |
| 628 &cap_length, cap.ptr()))) { | 628 &cap_length, cap.ptr()))) { |
| 629 TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_GetCapability"; | 629 TPM_LOG(ERROR, result) << "Error calling Tspi_TPM_GetCapability"; |
| 630 return count; | 630 return count; |
| 631 } | 631 } |
| 632 if (cap_length == sizeof(unsigned int)) { | 632 if (cap_length == sizeof(unsigned int)) { |
| 633 count = *(reinterpret_cast<unsigned int*>(*cap)); | 633 count = *(reinterpret_cast<unsigned int*>(*cap.ptr())); |
| 634 } | 634 } |
| 635 return count; | 635 return count; |
| 636 } | 636 } |
| 637 | 637 |
| 638 bool Tpm::OpenAndConnectTpm(TSS_HCONTEXT* context_handle, TSS_RESULT* result) { | 638 bool Tpm::OpenAndConnectTpm(TSS_HCONTEXT* context_handle, TSS_RESULT* result) { |
| 639 TSS_RESULT local_result; | 639 TSS_RESULT local_result; |
| 640 ScopedTssContext local_context_handle; | 640 ScopedTssContext local_context_handle; |
| 641 if (TPM_ERROR(local_result = Tspi_Context_Create( | 641 if (TPM_ERROR(local_result = Tspi_Context_Create( |
| 642 local_context_handle.ptr()))) { | 642 local_context_handle.ptr()))) { |
| 643 TPM_LOG(ERROR, local_result) << "Error calling Tspi_Context_Create"; | 643 TPM_LOG(ERROR, local_result) << "Error calling Tspi_Context_Create"; |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 | 1078 |
| 1079 UINT32 sub_cap = TSS_TPMCAP_PROP_OWNER; | 1079 UINT32 sub_cap = TSS_TPMCAP_PROP_OWNER; |
| 1080 UINT32 cap_length = 0; | 1080 UINT32 cap_length = 0; |
| 1081 ScopedTssMemory cap(context_handle); | 1081 ScopedTssMemory cap(context_handle); |
| 1082 if (TPM_ERROR(result = Tspi_TPM_GetCapability(tpm_handle, TSS_TPMCAP_PROPERTY, | 1082 if (TPM_ERROR(result = Tspi_TPM_GetCapability(tpm_handle, TSS_TPMCAP_PROPERTY, |
| 1083 sizeof(sub_cap), | 1083 sizeof(sub_cap), |
| 1084 reinterpret_cast<BYTE*>(&sub_cap), | 1084 reinterpret_cast<BYTE*>(&sub_cap), |
| 1085 &cap_length, cap.ptr())) == 0) { | 1085 &cap_length, cap.ptr())) == 0) { |
| 1086 if (cap_length >= (sizeof(TSS_BOOL))) { | 1086 if (cap_length >= (sizeof(TSS_BOOL))) { |
| 1087 *enabled = true; | 1087 *enabled = true; |
| 1088 *owned = ((*(reinterpret_cast<TSS_BOOL*>(*cap))) != 0); | 1088 *owned = ((*(reinterpret_cast<TSS_BOOL*>(*cap.ptr()))) != 0); |
| 1089 } | 1089 } |
| 1090 } else if(ERROR_CODE(result) == TPM_E_DISABLED) { | 1090 } else if(ERROR_CODE(result) == TPM_E_DISABLED) { |
| 1091 *enabled = false; | 1091 *enabled = false; |
| 1092 } | 1092 } |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 bool Tpm::CreateEndorsementKey(TSS_HCONTEXT context_handle) { | 1095 bool Tpm::CreateEndorsementKey(TSS_HCONTEXT context_handle) { |
| 1096 TSS_RESULT result; | 1096 TSS_RESULT result; |
| 1097 TSS_HTPM tpm_handle; | 1097 TSS_HTPM tpm_handle; |
| 1098 if (!GetTpm(context_handle, &tpm_handle)) { | 1098 if (!GetTpm(context_handle, &tpm_handle)) { |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 | 1752 |
| 1753 if (data_written != final_blob.size()) { | 1753 if (data_written != final_blob.size()) { |
| 1754 platform.SetMask(old_mask); | 1754 platform.SetMask(old_mask); |
| 1755 return false; | 1755 return false; |
| 1756 } | 1756 } |
| 1757 platform.SetMask(old_mask); | 1757 platform.SetMask(old_mask); |
| 1758 return true; | 1758 return true; |
| 1759 } | 1759 } |
| 1760 | 1760 |
| 1761 } // namespace cryptohome | 1761 } // namespace cryptohome |
| OLD | NEW |