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

Side by Side Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.cc

Issue 2863533003: [EasyUnlock] Serialize and store BeaconSeeds along as cryptohome key metadata. (Closed)
Patch Set: comments 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 5 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 11 matching lines...) Expand all
22 namespace { 22 namespace {
23 23
24 const char kKeyBluetoothAddress[] = "bluetoothAddress"; 24 const char kKeyBluetoothAddress[] = "bluetoothAddress";
25 const char kKeyBluetoothType[] = "bluetoothType"; 25 const char kKeyBluetoothType[] = "bluetoothType";
26 const char kKeyPermitRecord[] = "permitRecord"; 26 const char kKeyPermitRecord[] = "permitRecord";
27 const char kKeyPermitId[] = "permitRecord.id"; 27 const char kKeyPermitId[] = "permitRecord.id";
28 const char kKeyPermitPermitId[] = "permitRecord.permitId"; 28 const char kKeyPermitPermitId[] = "permitRecord.permitId";
29 const char kKeyPermitData[] = "permitRecord.data"; 29 const char kKeyPermitData[] = "permitRecord.data";
30 const char kKeyPermitType[] = "permitRecord.type"; 30 const char kKeyPermitType[] = "permitRecord.type";
31 const char kKeyPsk[] = "psk"; 31 const char kKeyPsk[] = "psk";
32 const char kKeySerializedBeaconSeeds[] = "serializedBeaconSeeds";
32 33
33 const char kKeyLabelPrefix[] = "easy-unlock-"; 34 const char kKeyLabelPrefix[] = "easy-unlock-";
34 35
35 const char kPermitPermitIdFormat[] = "permit://google.com/easyunlock/v1/%s"; 36 const char kPermitPermitIdFormat[] = "permit://google.com/easyunlock/v1/%s";
36 const char kPermitTypeLicence[] = "licence"; 37 const char kPermitTypeLicence[] = "licence";
37 38
38 } // namespace 39 } // namespace
39 40
40 EasyUnlockKeyManager::EasyUnlockKeyManager() : weak_ptr_factory_(this) {} 41 EasyUnlockKeyManager::EasyUnlockKeyManager() : weak_ptr_factory_(this) {}
41 42
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 dict->SetString(kKeyPsk, data.psk); 119 dict->SetString(kKeyPsk, data.psk);
119 std::unique_ptr<base::DictionaryValue> permit_record( 120 std::unique_ptr<base::DictionaryValue> permit_record(
120 new base::DictionaryValue); 121 new base::DictionaryValue);
121 dict->Set(kKeyPermitRecord, std::move(permit_record)); 122 dict->Set(kKeyPermitRecord, std::move(permit_record));
122 dict->SetString(kKeyPermitId, data.public_key); 123 dict->SetString(kKeyPermitId, data.public_key);
123 dict->SetString(kKeyPermitData, data.public_key); 124 dict->SetString(kKeyPermitData, data.public_key);
124 dict->SetString(kKeyPermitType, kPermitTypeLicence); 125 dict->SetString(kKeyPermitType, kPermitTypeLicence);
125 dict->SetString(kKeyPermitPermitId, 126 dict->SetString(kKeyPermitPermitId,
126 base::StringPrintf(kPermitPermitIdFormat, 127 base::StringPrintf(kPermitPermitIdFormat,
127 account_id.GetUserEmail().c_str())); 128 account_id.GetUserEmail().c_str()));
129 dict->SetString(kKeySerializedBeaconSeeds, data.serialized_beacon_seeds);
128 } 130 }
129 131
130 // static 132 // static
131 bool EasyUnlockKeyManager::RemoteDeviceDictionaryToDeviceData( 133 bool EasyUnlockKeyManager::RemoteDeviceDictionaryToDeviceData(
132 const base::DictionaryValue& dict, 134 const base::DictionaryValue& dict,
133 EasyUnlockDeviceKeyData* data) { 135 EasyUnlockDeviceKeyData* data) {
134 std::string bluetooth_address; 136 std::string bluetooth_address;
135 std::string public_key; 137 std::string public_key;
136 std::string psk; 138 std::string psk;
137 139
138 if (!dict.GetString(kKeyBluetoothAddress, &bluetooth_address) || 140 if (!dict.GetString(kKeyBluetoothAddress, &bluetooth_address) ||
139 !dict.GetString(kKeyPermitId, &public_key) || 141 !dict.GetString(kKeyPermitId, &public_key) ||
140 !dict.GetString(kKeyPsk, &psk)) { 142 !dict.GetString(kKeyPsk, &psk)) {
141 return false; 143 return false;
142 } 144 }
143 145
144 // TODO(tengs): Move this conditional up once we can be certain that the 146 // TODO(tengs): Move this conditional up once we can be certain that the
145 // dictionary will contain the Bluetooth type key. 147 // dictionary will contain the Bluetooth type key.
146 int bluetooth_type_as_int; 148 int bluetooth_type_as_int;
147 if (dict.GetInteger(kKeyBluetoothType, &bluetooth_type_as_int)) { 149 if (dict.GetInteger(kKeyBluetoothType, &bluetooth_type_as_int)) {
148 if (bluetooth_type_as_int >= EasyUnlockDeviceKeyData::NUM_BLUETOOTH_TYPES) { 150 if (bluetooth_type_as_int >= EasyUnlockDeviceKeyData::NUM_BLUETOOTH_TYPES) {
149 PA_LOG(ERROR) << "Invalid Bluetooth type: " << bluetooth_type_as_int; 151 PA_LOG(ERROR) << "Invalid Bluetooth type: " << bluetooth_type_as_int;
150 } else { 152 } else {
151 data->bluetooth_type = 153 data->bluetooth_type =
152 static_cast<EasyUnlockDeviceKeyData::BluetoothType>( 154 static_cast<EasyUnlockDeviceKeyData::BluetoothType>(
153 bluetooth_type_as_int); 155 bluetooth_type_as_int);
154 } 156 }
155 } 157 }
156 158
159 std::string serialized_beacon_seeds;
160 if (dict.GetString(kKeySerializedBeaconSeeds, &serialized_beacon_seeds)) {
161 data->serialized_beacon_seeds = serialized_beacon_seeds;
162 } else {
163 PA_LOG(ERROR) << "Failed to parse key data: "
164 << "expected serialized_beacon_seeds.";
165 }
166
157 data->bluetooth_address.swap(bluetooth_address); 167 data->bluetooth_address.swap(bluetooth_address);
158 data->public_key.swap(public_key); 168 data->public_key.swap(public_key);
159 data->psk.swap(psk); 169 data->psk.swap(psk);
160 return true; 170 return true;
161 } 171 }
162 172
163 // static 173 // static
164 void EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList( 174 void EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList(
165 const AccountId& account_id, 175 const AccountId& account_id,
166 const EasyUnlockDeviceKeyDataList& data_list, 176 const EasyUnlockDeviceKeyDataList& data_list,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const EasyUnlockDeviceKeyDataList& fetched_data) { 244 const EasyUnlockDeviceKeyDataList& fetched_data) {
235 if (!callback.is_null()) 245 if (!callback.is_null())
236 callback.Run(fetch_success, fetched_data); 246 callback.Run(fetch_success, fetched_data);
237 247
238 DCHECK(pending_read_operation_); 248 DCHECK(pending_read_operation_);
239 pending_read_operation_.reset(); 249 pending_read_operation_.reset();
240 RunNextOperation(); 250 RunNextOperation();
241 } 251 }
242 252
243 } // namespace chromeos 253 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698