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 #include "entd/tpm.h" | 5 #include "entd/tpm.h" |
6 | 6 |
7 #include "cros/chromeos_cryptohome.h" | 7 #include "cros/chromeos_cryptohome.h" |
8 #include "entd/entd.h" | 8 #include "entd/entd.h" |
9 | 9 |
10 namespace entd { | 10 namespace entd { |
11 | 11 |
| 12 bool Tpm::cryptohome_init_pkcs11 = false; |
| 13 |
12 bool Tpm::Initialize() { | 14 bool Tpm::Initialize() { |
13 return true; | 15 return true; |
14 } | 16 } |
15 | 17 |
16 // static | 18 // static |
17 bool Tpm::InitializeTemplate( | 19 bool Tpm::InitializeTemplate( |
18 v8::Handle<v8::FunctionTemplate> ctor_t) { | 20 v8::Handle<v8::FunctionTemplate> ctor_t) { |
19 v8::Handle<v8::ObjectTemplate> instance_t = ctor_t->InstanceTemplate(); | 21 v8::Handle<v8::ObjectTemplate> instance_t = ctor_t->InstanceTemplate(); |
20 | 22 |
21 instance_t->SetAccessor(v8::String::New("isEnabled"), | 23 instance_t->SetAccessor(v8::String::New("isEnabled"), |
(...skipping 23 matching lines...) Expand all Loading... |
45 v8::Handle<v8::Value>(), // Don't need any data. | 47 v8::Handle<v8::Value>(), // Don't need any data. |
46 v8::DEFAULT, // DEFAULT AccessControl | 48 v8::DEFAULT, // DEFAULT AccessControl |
47 v8::DontDelete); | 49 v8::DontDelete); |
48 | 50 |
49 instance_t->SetAccessor(v8::String::New("statusString"), | 51 instance_t->SetAccessor(v8::String::New("statusString"), |
50 Tpm::GetStatusString, | 52 Tpm::GetStatusString, |
51 0, // readonly, so setter is NULL | 53 0, // readonly, so setter is NULL |
52 v8::Handle<v8::Value>(), // Don't need any data. | 54 v8::Handle<v8::Value>(), // Don't need any data. |
53 v8::DEFAULT, // DEFAULT AccessControl | 55 v8::DEFAULT, // DEFAULT AccessControl |
54 v8::DontDelete); | 56 v8::DontDelete); |
| 57 if (cryptohome_init_pkcs11) { |
| 58 instance_t->SetAccessor(v8::String::New("isTokenReady"), |
| 59 Tpm::IsTokenReady, |
| 60 0, // readonly, so setter is NULL |
| 61 v8::Handle<v8::Value>(), // Don't need any data. |
| 62 v8::DEFAULT, // DEFAULT AccessControl |
| 63 v8::DontDelete); |
| 64 } |
55 | 65 |
56 return true; | 66 return true; |
57 } | 67 } |
58 | 68 |
59 // static | 69 // static |
60 v8::Handle<v8::Value> Tpm::IsEnabled(v8::Local<v8::String> property, | 70 v8::Handle<v8::Value> Tpm::IsEnabled(v8::Local<v8::String> property, |
61 const v8::AccessorInfo& info) { | 71 const v8::AccessorInfo& info) { |
62 if (!Entd::LibcrosLoadedOrThrow()) | 72 if (!Entd::LibcrosLoadedOrThrow()) |
63 return v8::False(); | 73 return v8::False(); |
64 | 74 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 v8::Handle<v8::Value> Tpm::GetStatusString(v8::Local<v8::String> property, | 106 v8::Handle<v8::Value> Tpm::GetStatusString(v8::Local<v8::String> property, |
97 const v8::AccessorInfo& info) { | 107 const v8::AccessorInfo& info) { |
98 if (!Entd::LibcrosLoadedOrThrow()) | 108 if (!Entd::LibcrosLoadedOrThrow()) |
99 return v8::Undefined(); | 109 return v8::Undefined(); |
100 | 110 |
101 std::string status; | 111 std::string status; |
102 chromeos::CryptohomeGetStatusString(&status); | 112 chromeos::CryptohomeGetStatusString(&status); |
103 return v8::String::New(status.c_str()); | 113 return v8::String::New(status.c_str()); |
104 } | 114 } |
105 | 115 |
| 116 // static |
| 117 v8::Handle<v8::Value> Tpm::IsTokenReady(v8::Local<v8::String> property, |
| 118 const v8::AccessorInfo& info) { |
| 119 return v8::Boolean::New(chromeos::CryptohomePkcs11IsTpmTokenReady()); |
| 120 } |
| 121 |
106 } // namespace entd | 122 } // namespace entd |
OLD | NEW |