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

Unified Diff: components/login/secure_module_util_chromeos.cc

Issue 2856683002: cros: Replace "TPM" with "secure module" for machines without TPM. (Closed)
Patch Set: Suffixed chromeos for chromeos compiling of secure_module_*. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/login/secure_module_util_chromeos.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/login/secure_module_util_chromeos.cc
diff --git a/components/login/secure_module_util_chromeos.cc b/components/login/secure_module_util_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b33ef168cffd7f03e59bcd0a6291c2fdbe674071
--- /dev/null
+++ b/components/login/secure_module_util_chromeos.cc
@@ -0,0 +1,48 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/login/secure_module_util_chromeos.h"
+
+#include "base/bind.h"
+#include "base/callback_helpers.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/task_scheduler/post_task.h"
+
+namespace login {
+
+namespace {
+
+// If either of these two files exist, then we are using Cr50 and not using TPM.
+constexpr char kCr50UsedIndicatorFile1[] =
+ "/opt/google/cr50/firmware/cr50.bin.prod";
+constexpr char kCr50UsedIndicatorFile2[] = "/etc/init/cr50-update.conf";
+
+SecureModuleUsed g_secure_module_used = SecureModuleUsed::UNQUERIED;
+
+SecureModuleUsed GetSecureModuleInfoFromFilesAndCacheIt() {
+ if (base::PathExists(base::FilePath(kCr50UsedIndicatorFile1)) ||
+ base::PathExists(base::FilePath(kCr50UsedIndicatorFile2))) {
+ g_secure_module_used = SecureModuleUsed::CR50;
+ } else {
+ g_secure_module_used = SecureModuleUsed::TPM;
+ }
+ return g_secure_module_used;
+}
+
+} // namespace
+
+void GetSecureModuleUsed(GetSecureModuleUsedCallback callback) {
+ if (g_secure_module_used != SecureModuleUsed::UNQUERIED) {
+ base::ResetAndReturn(&callback).Run(g_secure_module_used);
+ return;
+ }
+
+ base::PostTaskWithTraitsAndReplyWithResult(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ base::BindOnce(&GetSecureModuleInfoFromFilesAndCacheIt),
+ std::move(callback));
+}
+
+} // namespace login
« no previous file with comments | « components/login/secure_module_util_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698