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

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

Issue 2859053003: [EasyUnlock] Add beacon_seeds to RemoteDevice. (Closed)
Patch Set: [EasyUnlock] Add beacon_seeds to 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.h" 5 #include "components/cryptauth/remote_device.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 8
9 namespace cryptauth { 9 namespace cryptauth {
10 10
(...skipping 20 matching lines...) Expand all
31 std::string to_return; 31 std::string to_return;
32 base::Base64Encode(public_key, &to_return); 32 base::Base64Encode(public_key, &to_return);
33 return to_return; 33 return to_return;
34 } 34 }
35 35
36 std::string RemoteDevice::GetTruncatedDeviceIdForLogs() const { 36 std::string RemoteDevice::GetTruncatedDeviceIdForLogs() const {
37 return RemoteDevice::TruncateDeviceIdForLogs(GetDeviceId()); 37 return RemoteDevice::TruncateDeviceIdForLogs(GetDeviceId());
38 } 38 }
39 39
40 bool RemoteDevice::operator==(const RemoteDevice& other) const { 40 bool RemoteDevice::operator==(const RemoteDevice& other) const {
41 // Note: We don't compare the |beacon_seeds| for equality as they may not be
Kyle Horimoto 2017/05/04 03:52:51 If the "hast fetched" values are equal, also compa
Tim Song 2017/05/06 22:53:16 As mentioned in the header file, there are some is
42 // present.
41 return user_id == other.user_id 43 return user_id == other.user_id
42 && name == other.name 44 && name == other.name
43 && public_key == other.public_key 45 && public_key == other.public_key
44 && bluetooth_address == other.bluetooth_address 46 && bluetooth_address == other.bluetooth_address
45 && persistent_symmetric_key == other.persistent_symmetric_key 47 && persistent_symmetric_key == other.persistent_symmetric_key
46 && sign_in_challenge == other.sign_in_challenge; 48 && sign_in_challenge == other.sign_in_challenge;
47 } 49 }
48 50
49 bool RemoteDevice::operator<(const RemoteDevice& other) const { 51 bool RemoteDevice::operator<(const RemoteDevice& other) const {
50 // |public_key| is the only field guaranteed to be set and is also unique to 52 // |public_key| is the only field guaranteed to be set and is also unique to
51 // each RemoteDevice. However, since it can contain null bytes, use 53 // each RemoteDevice. However, since it can contain null bytes, use
52 // GetDeviceId(), which cannot contain null bytes, to compare devices. 54 // GetDeviceId(), which cannot contain null bytes, to compare devices.
53 return GetDeviceId().compare(other.GetDeviceId()) < 0; 55 return GetDeviceId().compare(other.GetDeviceId()) < 0;
54 } 56 }
55 57
56 // static 58 // static
57 std::string RemoteDevice::TruncateDeviceIdForLogs(const std::string& full_id) { 59 std::string RemoteDevice::TruncateDeviceIdForLogs(const std::string& full_id) {
58 if (full_id.length() <= 10) { 60 if (full_id.length() <= 10) {
59 return full_id; 61 return full_id;
60 } 62 }
61 63
62 return full_id.substr(0, 5) 64 return full_id.substr(0, 5)
63 + "..." 65 + "..."
64 + full_id.substr(full_id.length() - 5, full_id.length()); 66 + full_id.substr(full_id.length() - 5, full_id.length());
65 } 67 }
66 68
67 } // namespace cryptauth 69 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698