summaryrefslogtreecommitdiff
path: root/server/tpm_status_impl.h
diff options
context:
space:
mode:
authorUtkarsh Sanghi <usanghi@chromium.org>2015-08-13 14:25:18 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-08-26 20:22:02 -0700
commitc8573194d35f6b6c5033aedbef1ef5b07771792b (patch)
treeed70e4169e4fbefb3462ad0534d4df78157ce97d /server/tpm_status_impl.h
parente6419641bfebd76cbe5fffe3877c068af6b1c396 (diff)
downloadtpm_manager-c8573194d35f6b6c5033aedbef1ef5b07771792b.tar.gz
tpm_manager: Implement GetStatus
BUG=brillo:1040 TEST=tpm_manager_client --status Change-Id: I67322b6f2bd63743812c2b6edb7156471978f6d2 Reviewed-on: https://chromium-review.googlesource.com/292781 Commit-Ready: Utkarsh Sanghi <usanghi@chromium.org> Tested-by: Utkarsh Sanghi <usanghi@chromium.org> Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Diffstat (limited to 'server/tpm_status_impl.h')
-rw-r--r--server/tpm_status_impl.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/server/tpm_status_impl.h b/server/tpm_status_impl.h
new file mode 100644
index 0000000..ca38342
--- /dev/null
+++ b/server/tpm_status_impl.h
@@ -0,0 +1,58 @@
+// Copyright 2015 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TPM_MANAGER_SERVER_TPM_STATUS_IMPL_H_
+#define TPM_MANAGER_SERVER_TPM_STATUS_IMPL_H_
+
+#include "tpm_manager/server/tpm_status.h"
+
+#include <string>
+
+#include <base/macros.h>
+#include <trousers/scoped_tss_type.h>
+#include <trousers/tss.h>
+#include <trousers/trousers.h> // NOLINT(build/include_alpha)
+
+namespace tpm_manager {
+
+class TpmStatusImpl : public TpmStatus {
+ public:
+ TpmStatusImpl() = default;
+ ~TpmStatusImpl() override = default;
+
+ // TpmState methods.
+ bool IsTpmEnabled() override;
+ bool IsTpmOwned() override;
+ bool GetDictionaryAttackInfo(int* counter,
+ int* threshold,
+ bool* lockout,
+ int* seconds_remaining) override;
+
+ private:
+ // This method refreshes the |is_owned_| and |is_enabled_| status of the
+ // Tpm. It can be called multiple times.
+ void RefreshOwnedEnabledInfo();
+ // This method wraps calls to Tspi_TPM_GetCapability. |data| is set to
+ // the raw capability data. If the optional out argument |tpm_result| is
+ // provided, it is set to the result of the |Tspi_TPM_GetCapability| call.
+ bool GetCapability(uint32_t capability,
+ uint32_t sub_capability,
+ std::string* data,
+ TSS_RESULT* tpm_result);
+ // This method tries to get a handle to the TPM. Returns 0 on failure.
+ TSS_HTPM GetTpm();
+ // This method connects to the Tpm. Returns true on success.
+ bool ConnectContext();
+
+ trousers::ScopedTssContext context_;
+ bool is_enabled_{false};
+ bool is_owned_{false};
+ bool is_enable_initialized_{false};
+
+ DISALLOW_COPY_AND_ASSIGN(TpmStatusImpl);
+};
+
+} // namespace tpm_manager
+
+#endif // TPM_MANAGER_SERVER_TPM_STATUS_IMPL_H_