Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: tpm.cc

Issue 3236009: Add additional status APIs for the TPM. (Closed) Base URL: http://git.chromium.org/git/tpm_init.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tpm.h ('k') | tpm_init.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tpm.cc
diff --git a/tpm.cc b/tpm.cc
index 66cb57f980b74c81f76860757b509391d1a757b8..7815309e0ec6ce9afbe7d7b267ca5be6d1486702 100644
--- a/tpm.cc
+++ b/tpm.cc
@@ -34,7 +34,8 @@ Tpm::Tpm()
password_sync_lock_(),
is_disabled_(true),
is_owned_(false),
- is_srk_available_(false) {
+ is_srk_available_(false),
+ is_being_owned_(false) {
}
Tpm::~Tpm() {
@@ -515,24 +516,28 @@ bool Tpm::InitializeTpm() {
bool took_ownership = false;
if (!is_owned_) {
+ is_being_owned_ = true;
file_util::Delete(FilePath(kOpenCryptokiPath), true);
file_util::Delete(FilePath(kTpmOwnedFile), false);
if (!IsEndorsementKeyAvailable(context_handle_)) {
if (!CreateEndorsementKey(context_handle_)) {
LOG(ERROR) << "Failed to create endorsement key";
+ is_being_owned_ = false;
return false;
}
}
if (!IsEndorsementKeyAvailable(context_handle_)) {
LOG(ERROR) << "Endorsement key is not available";
+ is_being_owned_ = false;
return false;
}
if (!TakeOwnership(context_handle_, kMaxTimeoutRetries,
default_owner_password)) {
LOG(ERROR) << "Take Ownership failed";
+ is_being_owned_ = false;
return false;
}
@@ -559,11 +564,13 @@ bool Tpm::InitializeTpm() {
TestTpmAuth(tpm_handle)) {
if (!ZeroSrkPassword(context_handle_, default_owner_password)) {
LOG(ERROR) << "Couldn't zero SRK password";
+ is_being_owned_ = false;
return false;
}
if (!UnrestrictSrk(context_handle_, default_owner_password)) {
LOG(ERROR) << "Couldn't unrestrict the SRK";
+ is_being_owned_ = false;
return false;
}
SecureBlob owner_password;
@@ -572,6 +579,7 @@ bool Tpm::InitializeTpm() {
if (!ChangeOwnerPassword(context_handle_, default_owner_password,
owner_password)) {
LOG(ERROR) << "Couldn't set the owner password";
+ is_being_owned_ = false;
return false;
}
@@ -582,7 +590,9 @@ bool Tpm::InitializeTpm() {
file_util::WriteFile(FilePath(kTpmOwnedFile), NULL, 0);
}
- return took_ownership;
+ is_being_owned_ = false;
+
+ return took_ownership;
}
bool Tpm::GetRandomData(size_t length, chromeos::Blob* data) {
« no previous file with comments | « tpm.h ('k') | tpm_init.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698