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

Side by Side Diff: tpm_init.cc

Issue 3116014: Add method to get random bytes from the TPM. (Closed) Base URL: http://src.chromium.org/git/tpm_init.git
Patch Set: Change int to size_t. 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 unified diff | Download patch
« no previous file with comments | « tpm_init.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 10 matching lines...) Expand all
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 GetTpmPassword(chromeos::Blob* password); 29 bool GetTpmPassword(chromeos::Blob* password);
30 long GetInitializationMillis(); 30 long GetInitializationMillis();
31 bool GetRandomData(int length, chromeos::Blob* data);
31 32
32 private: 33 private:
33 scoped_ptr<tpm_init::Tpm> default_tpm_; 34 scoped_ptr<tpm_init::Tpm> default_tpm_;
34 tpm_init::Tpm* tpm_; 35 tpm_init::Tpm* tpm_;
35 bool initialize_status_; 36 bool initialize_status_;
36 bool task_done_; 37 bool task_done_;
37 long initialization_time_; 38 long initialization_time_;
38 }; 39 };
39 40
40 TpmInit::TpmInit() 41 TpmInit::TpmInit()
41 : tpm_init_(new TpmInitTask()) { 42 : tpm_init_(new TpmInitTask()) {
42 } 43 }
43 44
44 TpmInit::~TpmInit() { 45 TpmInit::~TpmInit() {
45 } 46 }
46 47
48 bool TpmInit::GetRandomData(int length, chromeos::Blob* data) {
49 return tpm_init_->GetRandomData(length, data);
50 }
51
47 bool TpmInit::StartInitializeTpm() { 52 bool TpmInit::StartInitializeTpm() {
48 tpm_init_->Init(); 53 tpm_init_->Init();
49 if (!PlatformThread::CreateNonJoinable(0, tpm_init_.get())) { 54 if (!PlatformThread::CreateNonJoinable(0, tpm_init_.get())) {
50 LOG(ERROR) << "Unable to create TPM initialization background thread."; 55 LOG(ERROR) << "Unable to create TPM initialization background thread.";
51 return false; 56 return false;
52 } 57 }
53 return true; 58 return true;
54 } 59 }
55 60
56 bool TpmInit::IsTpmReady() { 61 bool TpmInit::IsTpmReady() {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 123 }
119 124
120 bool TpmInitTask::GetTpmPassword(chromeos::Blob* password) { 125 bool TpmInitTask::GetTpmPassword(chromeos::Blob* password) {
121 return tpm_->GetOwnerPassword(password); 126 return tpm_->GetOwnerPassword(password);
122 } 127 }
123 128
124 long TpmInitTask::GetInitializationMillis() { 129 long TpmInitTask::GetInitializationMillis() {
125 return initialization_time_; 130 return initialization_time_;
126 } 131 }
127 132
133 bool TpmInitTask::GetRandomData(int length, chromeos::Blob* data) {
134 return tpm_->GetRandomData(length, data);
135 }
136
128 } // namespace tpm_init 137 } // namespace tpm_init
OLDNEW
« no previous file with comments | « tpm_init.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698