| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dbus/cryptohome_client.h" | 5 #include "chromeos/dbus/cryptohome_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 | 882 |
| 883 proxy_->CallMethod(&method_call, | 883 proxy_->CallMethod(&method_call, |
| 884 kTpmDBusTimeoutMs , | 884 kTpmDBusTimeoutMs , |
| 885 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | 885 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, |
| 886 weak_ptr_factory_.GetWeakPtr(), | 886 weak_ptr_factory_.GetWeakPtr(), |
| 887 callback)); | 887 callback)); |
| 888 } | 888 } |
| 889 | 889 |
| 890 void GetBootAttribute(const cryptohome::GetBootAttributeRequest& request, | 890 void GetBootAttribute(const cryptohome::GetBootAttributeRequest& request, |
| 891 const ProtobufMethodCallback& callback) override { | 891 const ProtobufMethodCallback& callback) override { |
| 892 const char* method_name = cryptohome::kCryptohomeGetBootAttribute; | 892 CallCryptohomeMethod(cryptohome::kCryptohomeGetBootAttribute, request, |
| 893 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); | 893 callback); |
| 894 | |
| 895 dbus::MessageWriter writer(&method_call); | |
| 896 writer.AppendProtoAsArrayOfBytes(request); | |
| 897 | |
| 898 proxy_->CallMethod(&method_call, | |
| 899 kTpmDBusTimeoutMs , | |
| 900 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | |
| 901 weak_ptr_factory_.GetWeakPtr(), | |
| 902 callback)); | |
| 903 } | 894 } |
| 904 | 895 |
| 905 void SetBootAttribute(const cryptohome::SetBootAttributeRequest& request, | 896 void SetBootAttribute(const cryptohome::SetBootAttributeRequest& request, |
| 906 const ProtobufMethodCallback& callback) override { | 897 const ProtobufMethodCallback& callback) override { |
| 907 const char* method_name = cryptohome::kCryptohomeSetBootAttribute; | 898 CallCryptohomeMethod(cryptohome::kCryptohomeSetBootAttribute, request, |
| 908 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); | 899 callback); |
| 909 | |
| 910 dbus::MessageWriter writer(&method_call); | |
| 911 writer.AppendProtoAsArrayOfBytes(request); | |
| 912 | |
| 913 proxy_->CallMethod(&method_call, | |
| 914 kTpmDBusTimeoutMs , | |
| 915 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | |
| 916 weak_ptr_factory_.GetWeakPtr(), | |
| 917 callback)); | |
| 918 } | 900 } |
| 919 | 901 |
| 920 void FlushAndSignBootAttributes( | 902 void FlushAndSignBootAttributes( |
| 921 const cryptohome::FlushAndSignBootAttributesRequest& request, | 903 const cryptohome::FlushAndSignBootAttributesRequest& request, |
| 922 const ProtobufMethodCallback& callback) override { | 904 const ProtobufMethodCallback& callback) override { |
| 923 const char* method_name = cryptohome::kCryptohomeFlushAndSignBootAttributes; | 905 CallCryptohomeMethod(cryptohome::kCryptohomeFlushAndSignBootAttributes, |
| 924 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); | 906 request, callback); |
| 907 } |
| 925 | 908 |
| 926 dbus::MessageWriter writer(&method_call); | 909 void RemoveFirmwareManagementParametersFromTpm( |
| 927 writer.AppendProtoAsArrayOfBytes(request); | 910 const cryptohome::RemoveFirmwareManagementParametersRequest& request, |
| 911 const ProtobufMethodCallback& callback) override { |
| 912 CallCryptohomeMethod( |
| 913 cryptohome::kCryptohomeRemoveFirmwareManagementParameters, request, |
| 914 callback); |
| 915 } |
| 928 | 916 |
| 929 proxy_->CallMethod(&method_call, | 917 void SetFirmwareManagementParametersInTpm( |
| 930 kTpmDBusTimeoutMs , | 918 const cryptohome::SetFirmwareManagementParametersRequest& request, |
| 931 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | 919 const ProtobufMethodCallback& callback) override { |
| 932 weak_ptr_factory_.GetWeakPtr(), | 920 CallCryptohomeMethod(cryptohome::kCryptohomeSetFirmwareManagementParameters, |
| 933 callback)); | 921 request, callback); |
| 934 } | 922 } |
| 935 | 923 |
| 936 void MigrateToDircrypto(const cryptohome::Identification& cryptohome_id, | 924 void MigrateToDircrypto(const cryptohome::Identification& cryptohome_id, |
| 937 const cryptohome::AuthorizationRequest& auth, | 925 const cryptohome::AuthorizationRequest& auth, |
| 938 const VoidDBusMethodCallback& callback) override { | 926 const VoidDBusMethodCallback& callback) override { |
| 939 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, | 927 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, |
| 940 cryptohome::kCryptohomeMigrateToDircrypto); | 928 cryptohome::kCryptohomeMigrateToDircrypto); |
| 941 | 929 |
| 942 cryptohome::AccountIdentifier id_proto; | 930 cryptohome::AccountIdentifier id_proto; |
| 943 FillIdentificationProtobuf(cryptohome_id, &id_proto); | 931 FillIdentificationProtobuf(cryptohome_id, &id_proto); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 } | 1227 } |
| 1240 | 1228 |
| 1241 // Handles the result of signal connection setup. | 1229 // Handles the result of signal connection setup. |
| 1242 void OnSignalConnected(const std::string& interface, | 1230 void OnSignalConnected(const std::string& interface, |
| 1243 const std::string& signal, | 1231 const std::string& signal, |
| 1244 bool succeeded) { | 1232 bool succeeded) { |
| 1245 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " << | 1233 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " << |
| 1246 signal << " failed."; | 1234 signal << " failed."; |
| 1247 } | 1235 } |
| 1248 | 1236 |
| 1237 // Makes an asynchronous D-Bus call, using cryptohome interface. |
| 1238 // |method_name| - the name of the method to be called. |
| 1239 // |request| - the specific request for the method, including the data |
| 1240 // required to be sent. |
| 1241 // |callback| - the callback to be invoked when the response is received. |
| 1242 void CallCryptohomeMethod(const std::string& method_name, |
| 1243 const google::protobuf::MessageLite& request, |
| 1244 const ProtobufMethodCallback& callback) { |
| 1245 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); |
| 1246 |
| 1247 dbus::MessageWriter writer(&method_call); |
| 1248 writer.AppendProtoAsArrayOfBytes(request); |
| 1249 |
| 1250 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs, |
| 1251 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, |
| 1252 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 1253 } |
| 1254 |
| 1249 dbus::ObjectProxy* proxy_; | 1255 dbus::ObjectProxy* proxy_; |
| 1250 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; | 1256 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; |
| 1251 AsyncCallStatusHandler async_call_status_handler_; | 1257 AsyncCallStatusHandler async_call_status_handler_; |
| 1252 AsyncCallStatusWithDataHandler async_call_status_data_handler_; | 1258 AsyncCallStatusWithDataHandler async_call_status_data_handler_; |
| 1253 LowDiskSpaceHandler low_disk_space_handler_; | 1259 LowDiskSpaceHandler low_disk_space_handler_; |
| 1254 DircryptoMigrationProgessHandler dircrypto_migration_progress_handler_; | 1260 DircryptoMigrationProgessHandler dircrypto_migration_progress_handler_; |
| 1255 | 1261 |
| 1256 // Note: This should remain the last member so it'll be destroyed and | 1262 // Note: This should remain the last member so it'll be destroyed and |
| 1257 // invalidate its weak pointers before any other members are destroyed. | 1263 // invalidate its weak pointers before any other members are destroyed. |
| 1258 base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_; | 1264 base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1274 return new CryptohomeClientImpl(); | 1280 return new CryptohomeClientImpl(); |
| 1275 } | 1281 } |
| 1276 | 1282 |
| 1277 // static | 1283 // static |
| 1278 std::string CryptohomeClient::GetStubSanitizedUsername( | 1284 std::string CryptohomeClient::GetStubSanitizedUsername( |
| 1279 const cryptohome::Identification& cryptohome_id) { | 1285 const cryptohome::Identification& cryptohome_id) { |
| 1280 return cryptohome_id.id() + kUserIdStubHashSuffix; | 1286 return cryptohome_id.id() + kUserIdStubHashSuffix; |
| 1281 } | 1287 } |
| 1282 | 1288 |
| 1283 } // namespace chromeos | 1289 } // namespace chromeos |
| OLD | NEW |