| 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 TpmInit | 5 // Contains the implementation of class TpmInit |
| 6 | 6 |
| 7 #include "tpm_init.h" | 7 #include "tpm_init.h" |
| 8 | 8 |
| 9 #include <base/logging.h> | 9 #include <base/logging.h> |
| 10 #include <base/time.h> | 10 #include <base/time.h> |
| 11 | 11 |
| 12 #include "tpm.h" | 12 #include "tpm.h" |
| 13 | 13 |
| 14 namespace tpm_init { | 14 namespace tpm_init { |
| 15 | 15 |
| 16 // TpmInitTask is a private class used to handle asynchronous initialization of | 16 // TpmInitTask is a private class used to handle asynchronous initialization of |
| 17 // the TPM. | 17 // the TPM. |
| 18 class TpmInitTask : public PlatformThread::Delegate { | 18 class TpmInitTask : public PlatformThread::Delegate { |
| 19 public: | 19 public: |
| 20 TpmInitTask(); | 20 TpmInitTask(); |
| 21 virtual ~TpmInitTask(); | 21 virtual ~TpmInitTask(); |
| 22 | 22 |
| 23 void Init(); | 23 void Init(); |
| 24 | 24 |
| 25 virtual void ThreadMain(); | 25 virtual void ThreadMain(); |
| 26 | 26 |
| 27 bool IsTpmReady(); | 27 bool IsTpmReady(); |
| 28 bool IsTpmEnabled(); | 28 bool IsTpmEnabled(); |
| 29 bool IsTpmOwned(); |
| 30 bool IsTpmBeingOwned(); |
| 29 bool GetTpmPassword(chromeos::Blob* password); | 31 bool GetTpmPassword(chromeos::Blob* password); |
| 30 long GetInitializationMillis(); | 32 long GetInitializationMillis(); |
| 31 bool GetRandomData(int length, chromeos::Blob* data); | 33 bool GetRandomData(int length, chromeos::Blob* data); |
| 32 | 34 |
| 33 private: | 35 private: |
| 34 scoped_ptr<tpm_init::Tpm> default_tpm_; | 36 scoped_ptr<tpm_init::Tpm> default_tpm_; |
| 35 tpm_init::Tpm* tpm_; | 37 tpm_init::Tpm* tpm_; |
| 36 bool initialize_status_; | 38 bool initialize_status_; |
| 37 bool task_done_; | 39 bool task_done_; |
| 38 long initialization_time_; | 40 long initialization_time_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 } | 61 } |
| 60 | 62 |
| 61 bool TpmInit::IsTpmReady() { | 63 bool TpmInit::IsTpmReady() { |
| 62 return tpm_init_->IsTpmReady(); | 64 return tpm_init_->IsTpmReady(); |
| 63 } | 65 } |
| 64 | 66 |
| 65 bool TpmInit::IsTpmEnabled() { | 67 bool TpmInit::IsTpmEnabled() { |
| 66 return tpm_init_->IsTpmEnabled(); | 68 return tpm_init_->IsTpmEnabled(); |
| 67 } | 69 } |
| 68 | 70 |
| 71 bool TpmInit::IsTpmOwned() { |
| 72 return tpm_init_->IsTpmOwned(); |
| 73 } |
| 74 |
| 75 bool TpmInit::IsTpmBeingOwned() { |
| 76 return tpm_init_->IsTpmBeingOwned(); |
| 77 } |
| 78 |
| 69 bool TpmInit::GetTpmPassword(chromeos::Blob* password) { | 79 bool TpmInit::GetTpmPassword(chromeos::Blob* password) { |
| 70 return tpm_init_->GetTpmPassword(password); | 80 return tpm_init_->GetTpmPassword(password); |
| 71 } | 81 } |
| 72 | 82 |
| 73 long TpmInit::GetInitializationMillis() { | 83 long TpmInit::GetInitializationMillis() { |
| 74 return tpm_init_->GetInitializationMillis(); | 84 return tpm_init_->GetInitializationMillis(); |
| 75 } | 85 } |
| 76 | 86 |
| 77 TpmInitTask::TpmInitTask() | 87 TpmInitTask::TpmInitTask() |
| 78 : default_tpm_(new tpm_init::Tpm()), | 88 : default_tpm_(new tpm_init::Tpm()), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // returned false. That merely means that it did not successfully take | 125 // returned false. That merely means that it did not successfully take |
| 116 // ownership, which is the common case after ownership is established on OOBE. | 126 // ownership, which is the common case after ownership is established on OOBE. |
| 117 // In that case, the TPM is ready if it is enabled and owned. | 127 // In that case, the TPM is ready if it is enabled and owned. |
| 118 return (tpm_->IsEnabled() && tpm_->IsOwned()); | 128 return (tpm_->IsEnabled() && tpm_->IsOwned()); |
| 119 } | 129 } |
| 120 | 130 |
| 121 bool TpmInitTask::IsTpmEnabled() { | 131 bool TpmInitTask::IsTpmEnabled() { |
| 122 return tpm_->IsEnabled(); | 132 return tpm_->IsEnabled(); |
| 123 } | 133 } |
| 124 | 134 |
| 135 bool TpmInitTask::IsTpmOwned() { |
| 136 return tpm_->IsOwned(); |
| 137 } |
| 138 |
| 139 bool TpmInitTask::IsTpmBeingOwned() { |
| 140 return tpm_->IsBeingOwned(); |
| 141 } |
| 142 |
| 125 bool TpmInitTask::GetTpmPassword(chromeos::Blob* password) { | 143 bool TpmInitTask::GetTpmPassword(chromeos::Blob* password) { |
| 126 return tpm_->GetOwnerPassword(password); | 144 return tpm_->GetOwnerPassword(password); |
| 127 } | 145 } |
| 128 | 146 |
| 129 long TpmInitTask::GetInitializationMillis() { | 147 long TpmInitTask::GetInitializationMillis() { |
| 130 return initialization_time_; | 148 return initialization_time_; |
| 131 } | 149 } |
| 132 | 150 |
| 133 bool TpmInitTask::GetRandomData(int length, chromeos::Blob* data) { | 151 bool TpmInitTask::GetRandomData(int length, chromeos::Blob* data) { |
| 134 return tpm_->GetRandomData(length, data); | 152 return tpm_->GetRandomData(length, data); |
| 135 } | 153 } |
| 136 | 154 |
| 137 } // namespace tpm_init | 155 } // namespace tpm_init |
| OLD | NEW |