Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chromeos/dbus/cryptohome_client.cc

Issue 2727713003: Update FWMP in TPM (Closed)
Patch Set: Fixed review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 876
877 proxy_->CallMethod(&method_call, 877 proxy_->CallMethod(&method_call,
878 kTpmDBusTimeoutMs , 878 kTpmDBusTimeoutMs ,
879 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, 879 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod,
880 weak_ptr_factory_.GetWeakPtr(), 880 weak_ptr_factory_.GetWeakPtr(),
881 callback)); 881 callback));
882 } 882 }
883 883
884 void GetBootAttribute(const cryptohome::GetBootAttributeRequest& request, 884 void GetBootAttribute(const cryptohome::GetBootAttributeRequest& request,
885 const ProtobufMethodCallback& callback) override { 885 const ProtobufMethodCallback& callback) override {
886 const char* method_name = cryptohome::kCryptohomeGetBootAttribute; 886 CallCryptohomeMethod(cryptohome::kCryptohomeGetBootAttribute, request,
887 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); 887 callback);
888
889 dbus::MessageWriter writer(&method_call);
890 writer.AppendProtoAsArrayOfBytes(request);
891
892 proxy_->CallMethod(&method_call,
893 kTpmDBusTimeoutMs ,
894 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod,
895 weak_ptr_factory_.GetWeakPtr(),
896 callback));
897 } 888 }
898 889
899 void SetBootAttribute(const cryptohome::SetBootAttributeRequest& request, 890 void SetBootAttribute(const cryptohome::SetBootAttributeRequest& request,
900 const ProtobufMethodCallback& callback) override { 891 const ProtobufMethodCallback& callback) override {
901 const char* method_name = cryptohome::kCryptohomeSetBootAttribute; 892 CallCryptohomeMethod(cryptohome::kCryptohomeSetBootAttribute, request,
902 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); 893 callback);
903
904 dbus::MessageWriter writer(&method_call);
905 writer.AppendProtoAsArrayOfBytes(request);
906
907 proxy_->CallMethod(&method_call,
908 kTpmDBusTimeoutMs ,
909 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod,
910 weak_ptr_factory_.GetWeakPtr(),
911 callback));
912 } 894 }
913 895
914 void FlushAndSignBootAttributes( 896 void FlushAndSignBootAttributes(
915 const cryptohome::FlushAndSignBootAttributesRequest& request, 897 const cryptohome::FlushAndSignBootAttributesRequest& request,
916 const ProtobufMethodCallback& callback) override { 898 const ProtobufMethodCallback& callback) override {
917 const char* method_name = cryptohome::kCryptohomeFlushAndSignBootAttributes; 899 CallCryptohomeMethod(cryptohome::kCryptohomeFlushAndSignBootAttributes,
918 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); 900 request, callback);
901 }
919 902
920 dbus::MessageWriter writer(&method_call); 903 void RemoveFirmwareManagementParametersInTpm(
921 writer.AppendProtoAsArrayOfBytes(request); 904 const cryptohome::RemoveFirmwareManagementParametersRequest& request,
905 const ProtobufMethodCallback& callback) override {
906 CallCryptohomeMethod(
907 cryptohome::kCryptohomeRemoveFirmwareManagementParameters, request,
908 callback);
909 }
922 910
923 proxy_->CallMethod(&method_call, 911 void SetFirmwareManagementParametersInTpm(
924 kTpmDBusTimeoutMs , 912 const cryptohome::SetFirmwareManagementParametersRequest& request,
925 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, 913 const ProtobufMethodCallback& callback) override {
926 weak_ptr_factory_.GetWeakPtr(), 914 CallCryptohomeMethod(cryptohome::kCryptohomeSetFirmwareManagementParameters,
927 callback)); 915 request, callback);
928 } 916 }
929 917
930 protected: 918 protected:
931 void Init(dbus::Bus* bus) override { 919 void Init(dbus::Bus* bus) override {
932 proxy_ = bus->GetObjectProxy( 920 proxy_ = bus->GetObjectProxy(
933 cryptohome::kCryptohomeServiceName, 921 cryptohome::kCryptohomeServiceName,
934 dbus::ObjectPath(cryptohome::kCryptohomeServicePath)); 922 dbus::ObjectPath(cryptohome::kCryptohomeServicePath));
935 923
936 blocking_method_caller_.reset(new BlockingMethodCaller(bus, proxy_)); 924 blocking_method_caller_.reset(new BlockingMethodCaller(bus, proxy_));
937 925
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 } 1176 }
1189 1177
1190 // Handles the result of signal connection setup. 1178 // Handles the result of signal connection setup.
1191 void OnSignalConnected(const std::string& interface, 1179 void OnSignalConnected(const std::string& interface,
1192 const std::string& signal, 1180 const std::string& signal,
1193 bool succeeded) { 1181 bool succeeded) {
1194 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " << 1182 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " <<
1195 signal << " failed."; 1183 signal << " failed.";
1196 } 1184 }
1197 1185
1186 // Makes an asynchronous D-Bus call, using cryptohome interface.
Thiemo Nagel 2017/03/23 17:23:52 Nit: Please wrap comments at 80 characters.
igorcov 2017/03/24 13:29:15 This is formatted with arguments to the function e
Thiemo Nagel 2017/03/27 17:21:47 True, but this does not match the prevalent style
igorcov 2017/03/28 16:39:09 Done.
1187 // |method_name| is the name of the method to be called.
1188 // |request| is the specific request for the method, including the data
1189 // required to be sent.
1190 // |callback| is run when the response is received.
1191 void CallCryptohomeMethod(const std::string& method_name,
1192 const google::protobuf::MessageLite& request,
1193 const ProtobufMethodCallback& callback) {
1194 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name);
1195
1196 dbus::MessageWriter writer(&method_call);
1197 writer.AppendProtoAsArrayOfBytes(request);
1198
1199 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs,
1200 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod,
1201 weak_ptr_factory_.GetWeakPtr(), callback));
1202 }
1203
1198 dbus::ObjectProxy* proxy_; 1204 dbus::ObjectProxy* proxy_;
1199 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; 1205 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_;
1200 AsyncCallStatusHandler async_call_status_handler_; 1206 AsyncCallStatusHandler async_call_status_handler_;
1201 AsyncCallStatusWithDataHandler async_call_status_data_handler_; 1207 AsyncCallStatusWithDataHandler async_call_status_data_handler_;
1202 LowDiskSpaceHandler low_disk_space_handler_; 1208 LowDiskSpaceHandler low_disk_space_handler_;
1203 1209
1204 // Note: This should remain the last member so it'll be destroyed and 1210 // Note: This should remain the last member so it'll be destroyed and
1205 // invalidate its weak pointers before any other members are destroyed. 1211 // invalidate its weak pointers before any other members are destroyed.
1206 base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_; 1212 base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_;
1207 1213
(...skipping 14 matching lines...) Expand all
1222 return new CryptohomeClientImpl(); 1228 return new CryptohomeClientImpl();
1223 } 1229 }
1224 1230
1225 // static 1231 // static
1226 std::string CryptohomeClient::GetStubSanitizedUsername( 1232 std::string CryptohomeClient::GetStubSanitizedUsername(
1227 const cryptohome::Identification& cryptohome_id) { 1233 const cryptohome::Identification& cryptohome_id) {
1228 return cryptohome_id.id() + kUserIdStubHashSuffix; 1234 return cryptohome_id.id() + kUserIdStubHashSuffix;
1229 } 1235 }
1230 1236
1231 } // namespace chromeos 1237 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698