| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/login/secure_module_util_chromeos.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" |
| 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" |
| 11 #include "base/task_scheduler/post_task.h" |
| 12 |
| 13 namespace login { |
| 14 |
| 15 namespace { |
| 16 |
| 17 // If either of these two files exist, then we are using Cr50 and not using TPM. |
| 18 constexpr char kCr50UsedIndicatorFile1[] = |
| 19 "/opt/google/cr50/firmware/cr50.bin.prod"; |
| 20 constexpr char kCr50UsedIndicatorFile2[] = "/etc/init/cr50-update.conf"; |
| 21 |
| 22 SecureModuleUsed g_secure_module_used = SecureModuleUsed::UNQUERIED; |
| 23 |
| 24 SecureModuleUsed GetSecureModuleInfoFromFilesAndCacheIt() { |
| 25 if (base::PathExists(base::FilePath(kCr50UsedIndicatorFile1)) || |
| 26 base::PathExists(base::FilePath(kCr50UsedIndicatorFile2))) { |
| 27 g_secure_module_used = SecureModuleUsed::CR50; |
| 28 } else { |
| 29 g_secure_module_used = SecureModuleUsed::TPM; |
| 30 } |
| 31 return g_secure_module_used; |
| 32 } |
| 33 |
| 34 } // namespace |
| 35 |
| 36 void GetSecureModuleUsed(GetSecureModuleUsedCallback callback) { |
| 37 if (g_secure_module_used != SecureModuleUsed::UNQUERIED) { |
| 38 base::ResetAndReturn(&callback).Run(g_secure_module_used); |
| 39 return; |
| 40 } |
| 41 |
| 42 base::PostTaskWithTraitsAndReplyWithResult( |
| 43 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 44 base::BindOnce(&GetSecureModuleInfoFromFilesAndCacheIt), |
| 45 std::move(callback)); |
| 46 } |
| 47 |
| 48 } // namespace login |
| OLD | NEW |