| OLD | NEW |
| 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/proximity_auth/remote_device_loader.h" | 5 #include "components/proximity_auth/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return unlock_key.public_key() == public_key; | 62 return unlock_key.public_key() == public_key; |
| 63 }); | 63 }); |
| 64 | 64 |
| 65 DCHECK(iterator != remaining_unlock_keys_.end()); | 65 DCHECK(iterator != remaining_unlock_keys_.end()); |
| 66 remaining_unlock_keys_.erase(iterator); | 66 remaining_unlock_keys_.erase(iterator); |
| 67 PA_LOG(INFO) << "Derived PSK for " << unlock_key.friendly_device_name() | 67 PA_LOG(INFO) << "Derived PSK for " << unlock_key.friendly_device_name() |
| 68 << ", " << remaining_unlock_keys_.size() << " keys remaining."; | 68 << ", " << remaining_unlock_keys_.size() << " keys remaining."; |
| 69 | 69 |
| 70 // TODO(tengs): We assume that devices without a |bluetooth_address| field are | 70 // TODO(tengs): We assume that devices without a |bluetooth_address| field are |
| 71 // BLE devices. Ideally, we should have a separate field for this information. | 71 // BLE devices. Ideally, we should have a separate field for this information. |
| 72 RemoteDevice::BluetoothType bluetooth_type = | 72 cryptauth::RemoteDevice::BluetoothType bluetooth_type = |
| 73 unlock_key.bluetooth_address().empty() ? RemoteDevice::BLUETOOTH_LE | 73 unlock_key.bluetooth_address().empty() |
| 74 : RemoteDevice::BLUETOOTH_CLASSIC; | 74 ? cryptauth::RemoteDevice::BLUETOOTH_LE |
| 75 : cryptauth::RemoteDevice::BLUETOOTH_CLASSIC; |
| 75 | 76 |
| 76 std::string bluetooth_address = unlock_key.bluetooth_address(); | 77 std::string bluetooth_address = unlock_key.bluetooth_address(); |
| 77 if (bluetooth_address.empty() && pref_manager_) { | 78 if (bluetooth_address.empty() && pref_manager_) { |
| 78 std::string b64_public_key; | 79 std::string b64_public_key; |
| 79 base::Base64UrlEncode(unlock_key.public_key(), | 80 base::Base64UrlEncode(unlock_key.public_key(), |
| 80 base::Base64UrlEncodePolicy::INCLUDE_PADDING, | 81 base::Base64UrlEncodePolicy::INCLUDE_PADDING, |
| 81 &b64_public_key); | 82 &b64_public_key); |
| 82 bluetooth_address = pref_manager_->GetDeviceAddress(b64_public_key); | 83 bluetooth_address = pref_manager_->GetDeviceAddress(b64_public_key); |
| 83 PA_LOG(INFO) << "The BLE address of " << unlock_key.friendly_device_name() | 84 PA_LOG(INFO) << "The BLE address of " << unlock_key.friendly_device_name() |
| 84 << " is " << bluetooth_address; | 85 << " is " << bluetooth_address; |
| 85 } | 86 } |
| 86 | 87 |
| 87 remote_devices_.push_back(RemoteDevice( | 88 remote_devices_.push_back(cryptauth::RemoteDevice( |
| 88 user_id_, unlock_key.friendly_device_name(), unlock_key.public_key(), | 89 user_id_, unlock_key.friendly_device_name(), unlock_key.public_key(), |
| 89 bluetooth_type, bluetooth_address, psk, std::string())); | 90 bluetooth_type, bluetooth_address, psk, std::string())); |
| 90 | 91 |
| 91 if (remaining_unlock_keys_.empty()) | 92 if (remaining_unlock_keys_.empty()) |
| 92 callback_.Run(remote_devices_); | 93 callback_.Run(remote_devices_); |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace proximity_auth | 96 } // namespace proximity_auth |
| OLD | NEW |