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

Side by Side Diff: chromeos/tpm/tpm_token_info_getter.cc

Issue 2856683002: cros: Replace "TPM" with "secure module" for machines without TPM. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium 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 "chromeos/tpm/tpm_token_info_getter.h" 5 #include "chromeos/tpm/tpm_token_info_getter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h"
10 #include "base/location.h" 12 #include "base/location.h"
11 #include "base/task_runner.h" 13 #include "base/task_runner.h"
12 #include "chromeos/cryptohome/cryptohome_parameters.h" 14 #include "chromeos/cryptohome/cryptohome_parameters.h"
13 #include "chromeos/dbus/cryptohome_client.h" 15 #include "chromeos/dbus/cryptohome_client.h"
14 16
15 namespace { 17 namespace {
16 18
17 const int64_t kInitialRequestDelayMs = 100; 19 const int64_t kInitialRequestDelayMs = 100;
18 const int64_t kMaxRequestDelayMs = 300000; // 5 minutes 20 const int64_t kMaxRequestDelayMs = 300000; // 5 minutes
19 21
22 // If either of these two files exist, then we are not using TPM.
23 constexpr char kNoTPMIndicatorFile1[] =
apronin 2017/05/02 16:43:38 I'd go with 'NoTPMIndicator' -> 'Cr50UsedIndicator
sammiequon 2017/05/02 17:27:23 Done.
24 "/opt/google/cr50/firmware/cr50.bin.prod";
25 constexpr char kNoTPMIndicatorFile2[] = "/etc/init/cr50-update.conf";
26
20 // Calculates the delay before running next attempt to initiatialize the TPM 27 // Calculates the delay before running next attempt to initiatialize the TPM
21 // token, if |last_delay| was the last or initial delay. 28 // token, if |last_delay| was the last or initial delay.
22 base::TimeDelta GetNextRequestDelayMs(base::TimeDelta last_delay) { 29 base::TimeDelta GetNextRequestDelayMs(base::TimeDelta last_delay) {
23 // This implements an exponential backoff, as we don't know in which order of 30 // This implements an exponential backoff, as we don't know in which order of
24 // magnitude the TPM token changes it's state. 31 // magnitude the TPM token changes it's state.
25 base::TimeDelta next_delay = last_delay * 2; 32 base::TimeDelta next_delay = last_delay * 2;
26 33
27 // Cap the delay to prevent an overflow. This threshold is arbitrarily chosen. 34 // Cap the delay to prevent an overflow. This threshold is arbitrarily chosen.
28 const base::TimeDelta max_delay = 35 const base::TimeDelta max_delay =
29 base::TimeDelta::FromMilliseconds(kMaxRequestDelayMs); 36 base::TimeDelta::FromMilliseconds(kMaxRequestDelayMs);
(...skipping 24 matching lines...) Expand all
54 } 61 }
55 62
56 // static 63 // static
57 std::unique_ptr<TPMTokenInfoGetter> TPMTokenInfoGetter::CreateForSystemToken( 64 std::unique_ptr<TPMTokenInfoGetter> TPMTokenInfoGetter::CreateForSystemToken(
58 CryptohomeClient* cryptohome_client, 65 CryptohomeClient* cryptohome_client,
59 const scoped_refptr<base::TaskRunner>& delayed_task_runner) { 66 const scoped_refptr<base::TaskRunner>& delayed_task_runner) {
60 return std::unique_ptr<TPMTokenInfoGetter>(new TPMTokenInfoGetter( 67 return std::unique_ptr<TPMTokenInfoGetter>(new TPMTokenInfoGetter(
61 TYPE_SYSTEM, EmptyAccountId(), cryptohome_client, delayed_task_runner)); 68 TYPE_SYSTEM, EmptyAccountId(), cryptohome_client, delayed_task_runner));
62 } 69 }
63 70
71 bool TPMTokenInfoGetter::DoesTPMExist() {
apronin 2017/05/02 16:43:38 Does what is supposed to do for the purposes of th
sammiequon 2017/05/02 17:27:23 Done.
72 return !base::PathExists(base::FilePath(kNoTPMIndicatorFile1)) &&
73 !base::PathExists(base::FilePath(kNoTPMIndicatorFile2));
74 }
75
64 TPMTokenInfoGetter::~TPMTokenInfoGetter() {} 76 TPMTokenInfoGetter::~TPMTokenInfoGetter() {}
65 77
66 void TPMTokenInfoGetter::Start(const TPMTokenInfoCallback& callback) { 78 void TPMTokenInfoGetter::Start(const TPMTokenInfoCallback& callback) {
67 CHECK(state_ == STATE_INITIAL); 79 CHECK(state_ == STATE_INITIAL);
68 CHECK(!callback.is_null()); 80 CHECK(!callback.is_null());
69 81
70 callback_ = callback; 82 callback_ = callback;
71 83
72 state_ = STATE_STARTED; 84 state_ = STATE_STARTED;
73 Continue(); 85 Continue();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 TPMTokenInfo token_info; 166 TPMTokenInfo token_info;
155 token_info.tpm_is_enabled = true; 167 token_info.tpm_is_enabled = true;
156 token_info.token_name = token_name; 168 token_info.token_name = token_name;
157 token_info.user_pin = user_pin; 169 token_info.user_pin = user_pin;
158 token_info.token_slot_id = token_slot_id; 170 token_info.token_slot_id = token_slot_id;
159 171
160 callback_.Run(token_info); 172 callback_.Run(token_info);
161 } 173 }
162 174
163 } // namespace chromeos 175 } // namespace chromeos
OLDNEW
« chrome/app/chromeos_strings.grdp ('K') | « chromeos/tpm/tpm_token_info_getter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698