1 // Copyright 2013 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.
5 #include "chromeos/cryptohome/cryptohome_util.h"
7 #include "base/logging.h"
8 #include "chromeos/dbus/cryptohome_client.h"
9 #include "chromeos/dbus/dbus_thread_manager.h"
12 namespace cryptohome_util {
16 DBusThreadManager::Get()->GetCryptohomeClient()->CallTpmIsEnabledAndBlock(
23 DBusThreadManager::Get()->GetCryptohomeClient()->CallTpmIsOwnedAndBlock(
28 bool TpmIsBeingOwned() {
30 DBusThreadManager::Get()->GetCryptohomeClient()->
31 CallTpmIsBeingOwnedAndBlock(&result);
35 bool InstallAttributesGet(
36 const std::string& name, std::string* value) {
37 std::vector<uint8> buf;
39 DBusThreadManager::Get()->GetCryptohomeClient()->
40 InstallAttributesGet(name, &buf, &success);
42 // Cryptohome returns 'buf' with a terminating '\0' character.
44 DCHECK_EQ(buf.back(), 0);
45 value->assign(reinterpret_cast<char*>(buf.data()), buf.size() - 1);
50 bool InstallAttributesSet(
51 const std::string& name, const std::string& value) {
52 std::vector<uint8> buf(value.c_str(), value.c_str() + value.size() + 1);
54 DBusThreadManager::Get()->GetCryptohomeClient()->
55 InstallAttributesSet(name, buf, &success);
59 bool InstallAttributesFinalize() {
61 DBusThreadManager::Get()->GetCryptohomeClient()->
62 InstallAttributesFinalize(&success);
66 bool InstallAttributesIsInvalid() {
68 DBusThreadManager::Get()->GetCryptohomeClient()->
69 InstallAttributesIsInvalid(&result);
73 bool InstallAttributesIsFirstInstall() {
75 DBusThreadManager::Get()->GetCryptohomeClient()->
76 InstallAttributesIsFirstInstall(&result);
80 } // namespace cryptohome_util
81 } // namespace chromeos