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

Side by Side Diff: components/proximity_auth/remote_device_loader.h

Issue 2502343003: Moved //components/proximity_auth/cryptauth to //components/cryptauth. (Closed)
Patch Set: Fixed proto #includes. Created 4 years, 1 month 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 #ifndef COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H 5 #ifndef COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H
6 #define COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H 6 #define COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" 14 #include "components/cryptauth/proto/cryptauth_api.pb.h"
15 #include "components/proximity_auth/remote_device.h" 15 #include "components/proximity_auth/remote_device.h"
16 16
17 namespace cryptauth {
18 class SecureMessageDelegate;
19 }
20
17 namespace proximity_auth { 21 namespace proximity_auth {
18 22
19 class ProximityAuthPrefManager; 23 class ProximityAuthPrefManager;
20 class SecureMessageDelegate;
21 24
22 // Loads a collection of RemoteDevice objects from the given ExternalDeviceInfo 25 // Loads a collection of RemoteDevice objects from the given ExternalDeviceInfo
23 // protos that were synced from CryptAuth. We need to derive the PSK, which is 26 // protos that were synced from CryptAuth. We need to derive the PSK, which is
24 // a symmetric key used to authenticate each remote device. 27 // a symmetric key used to authenticate each remote device.
25 class RemoteDeviceLoader { 28 class RemoteDeviceLoader {
26 public: 29 public:
27 // Creates the instance: 30 // Creates the instance:
28 // |unlock_keys|: The unlock keys previously synced from CryptAuth. 31 // |unlock_keys|: The unlock keys previously synced from CryptAuth.
29 // |user_private_key|: The private key of the user's local device. Used to 32 // |user_private_key|: The private key of the user's local device. Used to
30 // derive the PSK. 33 // derive the PSK.
31 // |secure_message_delegate|: Used to derive each persistent symmetric key. 34 // |secure_message_delegate|: Used to derive each persistent symmetric key.
32 // |pref_manager|: Used to retrieve the Bluetooth address of BLE devices. 35 // |pref_manager|: Used to retrieve the Bluetooth address of BLE devices.
33 RemoteDeviceLoader( 36 RemoteDeviceLoader(
34 const std::vector<cryptauth::ExternalDeviceInfo>& unlock_keys, 37 const std::vector<cryptauth::ExternalDeviceInfo>& unlock_keys,
35 const std::string& user_id, 38 const std::string& user_id,
36 const std::string& user_private_key, 39 const std::string& user_private_key,
37 std::unique_ptr<SecureMessageDelegate> secure_message_delegate, 40 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate,
38 ProximityAuthPrefManager* pref_manager); 41 ProximityAuthPrefManager* pref_manager);
39 42
40 ~RemoteDeviceLoader(); 43 ~RemoteDeviceLoader();
41 44
42 // Loads the RemoteDevice objects. |callback| will be invoked upon completion. 45 // Loads the RemoteDevice objects. |callback| will be invoked upon completion.
43 typedef base::Callback<void(const RemoteDeviceList&)> RemoteDeviceCallback; 46 typedef base::Callback<void(const RemoteDeviceList&)> RemoteDeviceCallback;
44 void Load(const RemoteDeviceCallback& callback); 47 void Load(const RemoteDeviceCallback& callback);
45 48
46 private: 49 private:
47 // Called when the PSK is derived for each unlock key. If the PSK for all 50 // Called when the PSK is derived for each unlock key. If the PSK for all
48 // unlock have been derived, then we can invoke |callback_|. 51 // unlock have been derived, then we can invoke |callback_|.
49 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key, 52 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key,
50 const std::string& psk); 53 const std::string& psk);
51 54
52 // The remaining unlock keys whose PSK we're waiting on. 55 // The remaining unlock keys whose PSK we're waiting on.
53 std::vector<cryptauth::ExternalDeviceInfo> remaining_unlock_keys_; 56 std::vector<cryptauth::ExternalDeviceInfo> remaining_unlock_keys_;
54 57
55 // The id of the user who the remote devices belong to. 58 // The id of the user who the remote devices belong to.
56 const std::string user_id_; 59 const std::string user_id_;
57 60
58 // The private key of the user's local device. 61 // The private key of the user's local device.
59 const std::string user_private_key_; 62 const std::string user_private_key_;
60 63
61 // Performs the PSK key derivation. 64 // Performs the PSK key derivation.
62 std::unique_ptr<SecureMessageDelegate> secure_message_delegate_; 65 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate_;
63 66
64 // Used to retrieve the address for BLE devices. Not owned. 67 // Used to retrieve the address for BLE devices. Not owned.
65 ProximityAuthPrefManager* pref_manager_; 68 ProximityAuthPrefManager* pref_manager_;
66 69
67 // Invoked when the RemoteDevices are loaded. 70 // Invoked when the RemoteDevices are loaded.
68 RemoteDeviceCallback callback_; 71 RemoteDeviceCallback callback_;
69 72
70 // The collection of RemoteDevices to return. 73 // The collection of RemoteDevices to return.
71 RemoteDeviceList remote_devices_; 74 RemoteDeviceList remote_devices_;
72 75
73 base::WeakPtrFactory<RemoteDeviceLoader> weak_ptr_factory_; 76 base::WeakPtrFactory<RemoteDeviceLoader> weak_ptr_factory_;
74 77
75 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLoader); 78 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLoader);
76 }; 79 };
77 80
78 } // namespace proximity_auth 81 } // namespace proximity_auth
79 82
80 #endif // COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H 83 #endif // COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H
OLDNEW
« no previous file with comments | « components/proximity_auth/remote_device_life_cycle_impl.cc ('k') | components/proximity_auth/remote_device_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698