summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Freed <bfreed@google.com>2016-01-06 14:45:17 -0800
committerBryan Freed <bfreed@google.com>2016-01-06 14:45:17 -0800
commit3d9de9ace6d8bf53df452787f51109c609281293 (patch)
tree8df5e74004b5f462666728f292378254b516fe3c
parentbd0dc3c259a6da35a17d5fa6962b25b6a52a1a3d (diff)
downloadtpm-3d9de9ace6d8bf53df452787f51109c609281293.tar.gz
attestation: Support a new sysfs tpm class directorybrillo-m9-releasebrillo-m9-dev
Kernel TPM patches from 4.x moved /sys/class/misc/tpm0 to /sys/class/tpm/tpm0. Support both paths in attestation. BUG=chromium:573368 Change-Id: I02b68f0c4ce7cbcc307471e203db376129a662db
-rw-r--r--attestation/common/tpm_utility_v1.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/attestation/common/tpm_utility_v1.cc b/attestation/common/tpm_utility_v1.cc
index 6b7ab17..b6bc64f 100644
--- a/attestation/common/tpm_utility_v1.cc
+++ b/attestation/common/tpm_utility_v1.cc
@@ -44,8 +44,10 @@ using ScopedByteArray = scoped_ptr<BYTE, base::FreeDeleter>;
using ScopedTssEncryptedData = trousers::ScopedTssObject<TSS_HENCDATA>;
using ScopedTssHash = trousers::ScopedTssObject<TSS_HHASH>;
-const char* kTpmEnabledFile = "/sys/class/misc/tpm0/device/enabled";
-const char* kTpmOwnedFile = "/sys/class/misc/tpm0/device/owned";
+const char* kTpmTpmEnabledFile = "/sys/class/tpm/tpm0/device/enabled";
+const char* kMscTpmEnabledFile = "/sys/class/misc/tpm0/device/enabled";
+const char* kTpmTpmOwnedFile = "/sys/class/tpm/tpm0/device/owned";
+const char* kMscTpmOwnedFile = "/sys/class/misc/tpm0/device/owned";
const unsigned int kWellKnownExponent = 65537;
const unsigned char kSha256DigestInfo[] = {
0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04,
@@ -89,8 +91,13 @@ bool TpmUtilityV1::Initialize() {
bool TpmUtilityV1::IsTpmReady() {
if (!is_ready_) {
- is_ready_ = (GetFirstByte(kTpmEnabledFile) == "1" &&
- GetFirstByte(kTpmOwnedFile) == "1");
+ if (base::PathExists(base::FilePath(kMscTpmEnabledFile))) {
+ is_ready_ = (GetFirstByte(kMscTpmEnabledFile) == "1" &&
+ GetFirstByte(kMscTpmOwnedFile) == "1");
+ } else {
+ is_ready_ = (GetFirstByte(kTpmTpmEnabledFile) == "1" &&
+ GetFirstByte(kTpmTpmOwnedFile) == "1");
+ }
}
return is_ready_;
}