| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/cryptohome/cryptohome_util.h" | 5 #include "chromeos/cryptohome/cryptohome_util.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "chromeos/dbus/cryptohome_client.h" | 10 #include "chromeos/dbus/cryptohome_client.h" |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
| 10 | 12 |
| 11 namespace chromeos { | 13 namespace chromeos { |
| 12 namespace cryptohome_util { | 14 namespace cryptohome_util { |
| 13 | 15 |
| 14 bool TpmIsEnabled() { | 16 bool TpmIsEnabled() { |
| 15 bool result = false; | 17 bool result = false; |
| 16 DBusThreadManager::Get()->GetCryptohomeClient()->CallTpmIsEnabledAndBlock( | 18 DBusThreadManager::Get()->GetCryptohomeClient()->CallTpmIsEnabledAndBlock( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 27 | 29 |
| 28 bool TpmIsBeingOwned() { | 30 bool TpmIsBeingOwned() { |
| 29 bool result = false; | 31 bool result = false; |
| 30 DBusThreadManager::Get()->GetCryptohomeClient()-> | 32 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 31 CallTpmIsBeingOwnedAndBlock(&result); | 33 CallTpmIsBeingOwnedAndBlock(&result); |
| 32 return result; | 34 return result; |
| 33 } | 35 } |
| 34 | 36 |
| 35 bool InstallAttributesGet( | 37 bool InstallAttributesGet( |
| 36 const std::string& name, std::string* value) { | 38 const std::string& name, std::string* value) { |
| 37 std::vector<uint8> buf; | 39 std::vector<uint8_t> buf; |
| 38 bool success = false; | 40 bool success = false; |
| 39 DBusThreadManager::Get()->GetCryptohomeClient()-> | 41 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 40 InstallAttributesGet(name, &buf, &success); | 42 InstallAttributesGet(name, &buf, &success); |
| 41 if (success) { | 43 if (success) { |
| 42 // Cryptohome returns 'buf' with a terminating '\0' character. | 44 // Cryptohome returns 'buf' with a terminating '\0' character. |
| 43 DCHECK(!buf.empty()); | 45 DCHECK(!buf.empty()); |
| 44 DCHECK_EQ(buf.back(), 0); | 46 DCHECK_EQ(buf.back(), 0); |
| 45 value->assign(reinterpret_cast<char*>(buf.data()), buf.size() - 1); | 47 value->assign(reinterpret_cast<char*>(buf.data()), buf.size() - 1); |
| 46 } | 48 } |
| 47 return success; | 49 return success; |
| 48 } | 50 } |
| 49 | 51 |
| 50 bool InstallAttributesSet( | 52 bool InstallAttributesSet( |
| 51 const std::string& name, const std::string& value) { | 53 const std::string& name, const std::string& value) { |
| 52 std::vector<uint8> buf(value.c_str(), value.c_str() + value.size() + 1); | 54 std::vector<uint8_t> buf(value.c_str(), value.c_str() + value.size() + 1); |
| 53 bool success = false; | 55 bool success = false; |
| 54 DBusThreadManager::Get()->GetCryptohomeClient()-> | 56 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 55 InstallAttributesSet(name, buf, &success); | 57 InstallAttributesSet(name, buf, &success); |
| 56 return success; | 58 return success; |
| 57 } | 59 } |
| 58 | 60 |
| 59 bool InstallAttributesFinalize() { | 61 bool InstallAttributesFinalize() { |
| 60 bool success = false; | 62 bool success = false; |
| 61 DBusThreadManager::Get()->GetCryptohomeClient()-> | 63 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 62 InstallAttributesFinalize(&success); | 64 InstallAttributesFinalize(&success); |
| 63 return success; | 65 return success; |
| 64 } | 66 } |
| 65 | 67 |
| 66 bool InstallAttributesIsInvalid() { | 68 bool InstallAttributesIsInvalid() { |
| 67 bool result = false; | 69 bool result = false; |
| 68 DBusThreadManager::Get()->GetCryptohomeClient()-> | 70 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 69 InstallAttributesIsInvalid(&result); | 71 InstallAttributesIsInvalid(&result); |
| 70 return result; | 72 return result; |
| 71 } | 73 } |
| 72 | 74 |
| 73 bool InstallAttributesIsFirstInstall() { | 75 bool InstallAttributesIsFirstInstall() { |
| 74 bool result = false; | 76 bool result = false; |
| 75 DBusThreadManager::Get()->GetCryptohomeClient()-> | 77 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 76 InstallAttributesIsFirstInstall(&result); | 78 InstallAttributesIsFirstInstall(&result); |
| 77 return result; | 79 return result; |
| 78 } | 80 } |
| 79 | 81 |
| 80 } // namespace cryptohome_util | 82 } // namespace cryptohome_util |
| 81 } // namespace chromeos | 83 } // namespace chromeos |
| OLD | NEW |