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

Side by Side Diff: components/cryptauth/remote_device_loader.cc

Issue 2859053003: [EasyUnlock] Add beacon_seeds to RemoteDevice. (Closed)
Patch Set: load beacon seed in RemoteDevice Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/cryptauth/remote_device_loader.h" 5 #include "components/cryptauth/remote_device_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64url.h" 10 #include "base/base64url.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 user_id, 49 user_id,
50 user_private_key, 50 user_private_key,
51 std::move(secure_message_delegate))); 51 std::move(secure_message_delegate)));
52 } 52 }
53 53
54 RemoteDeviceLoader::RemoteDeviceLoader( 54 RemoteDeviceLoader::RemoteDeviceLoader(
55 const std::vector<cryptauth::ExternalDeviceInfo>& device_info_list, 55 const std::vector<cryptauth::ExternalDeviceInfo>& device_info_list,
56 const std::string& user_id, 56 const std::string& user_id,
57 const std::string& user_private_key, 57 const std::string& user_private_key,
58 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate) 58 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate)
59 : remaining_devices_(device_info_list), 59 : should_load_beacon_seeds_(false),
60 remaining_devices_(device_info_list),
60 user_id_(user_id), 61 user_id_(user_id),
61 user_private_key_(user_private_key), 62 user_private_key_(user_private_key),
62 secure_message_delegate_(std::move(secure_message_delegate)), 63 secure_message_delegate_(std::move(secure_message_delegate)),
63 weak_ptr_factory_(this) {} 64 weak_ptr_factory_(this) {}
64 65
65 RemoteDeviceLoader::~RemoteDeviceLoader() {} 66 RemoteDeviceLoader::~RemoteDeviceLoader() {}
66 67
67 void RemoteDeviceLoader::Load(const RemoteDeviceCallback& callback) { 68 void RemoteDeviceLoader::Load(bool should_load_beacon_seeds,
69 const RemoteDeviceCallback& callback) {
68 DCHECK(callback_.is_null()); 70 DCHECK(callback_.is_null());
71 should_load_beacon_seeds_ = should_load_beacon_seeds;
69 callback_ = callback; 72 callback_ = callback;
70 PA_LOG(INFO) << "Loading " << remaining_devices_.size() 73 PA_LOG(INFO) << "Loading " << remaining_devices_.size()
71 << " remote devices"; 74 << " remote devices";
72 75
73 if (remaining_devices_.empty()) { 76 if (remaining_devices_.empty()) {
74 callback_.Run(remote_devices_); 77 callback_.Run(remote_devices_);
75 return; 78 return;
76 } 79 }
77 80
78 std::vector<cryptauth::ExternalDeviceInfo> all_devices_to_convert = 81 std::vector<cryptauth::ExternalDeviceInfo> all_devices_to_convert =
(...skipping 15 matching lines...) Expand all
94 remaining_devices_.begin(), remaining_devices_.end(), 97 remaining_devices_.begin(), remaining_devices_.end(),
95 [&public_key](const cryptauth::ExternalDeviceInfo& device) { 98 [&public_key](const cryptauth::ExternalDeviceInfo& device) {
96 return device.public_key() == public_key; 99 return device.public_key() == public_key;
97 }); 100 });
98 101
99 DCHECK(iterator != remaining_devices_.end()); 102 DCHECK(iterator != remaining_devices_.end());
100 remaining_devices_.erase(iterator); 103 remaining_devices_.erase(iterator);
101 PA_LOG(INFO) << "Derived PSK for " << device.friendly_device_name() 104 PA_LOG(INFO) << "Derived PSK for " << device.friendly_device_name()
102 << ", " << remaining_devices_.size() << " keys remaining."; 105 << ", " << remaining_devices_.size() << " keys remaining.";
103 106
104 remote_devices_.push_back(cryptauth::RemoteDevice( 107 cryptauth::RemoteDevice remote_device(
105 user_id_, device.friendly_device_name(), device.public_key(), 108 user_id_, device.friendly_device_name(), device.public_key(),
106 device.bluetooth_address(), psk, std::string())); 109 device.bluetooth_address(), psk, std::string());
110
111 if (should_load_beacon_seeds_) {
112 std::vector<BeaconSeed> beacon_seeds;
113 for (const BeaconSeed& beacon_seed : device.beacon_seeds()) {
114 beacon_seeds.push_back(beacon_seed);
115 }
116 remote_device.LoadBeaconSeeds(beacon_seeds);
117 }
118 remote_devices_.push_back(remote_device);
107 119
108 if (remaining_devices_.empty()) 120 if (remaining_devices_.empty())
109 callback_.Run(remote_devices_); 121 callback_.Run(remote_devices_);
110 } 122 }
111 123
112 } // namespace cryptauth 124 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698