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

Unified Diff: components/proximity_auth/remote_device_loader.h

Issue 1356943004: Add RemoteDeviceLoader to create RemoteDevice from CryptAuth data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webui
Patch Set: move RemoteDevice creation in tests to util function Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/proximity_auth/remote_device_loader.h
diff --git a/components/proximity_auth/remote_device_loader.h b/components/proximity_auth/remote_device_loader.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf2e7c7020dca73d9ea0f876b91979e309af1c33
--- /dev/null
+++ b/components/proximity_auth/remote_device_loader.h
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H
+#define COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H
+
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h"
+#include "components/proximity_auth/remote_device.h"
+
+namespace proximity_auth {
+
+class SecureMessageDelegate;
+
+// Loads a collection of RemoteDevice objects from the given ExternalDeviceInfo
+// protos that were synced from CryptAuth. We need to derive the PSK, which is
+// a symmetric key used to authenticate each remote device.
+class RemoteDeviceLoader {
+ public:
+ // Creates the instance:
+ // |unlock_keys|: The unlock keys previously synced from CryptAuth.
+ // |user_private_key|: The private key of the user's local device. Used to
+ // derive the PSK.
+ // |secure_message_delegate|: Used to derive each persistent symmetric key.
+ RemoteDeviceLoader(
+ const std::vector<cryptauth::ExternalDeviceInfo>& unlock_keys,
+ const std::string& user_id,
+ const std::string& user_private_key,
+ scoped_ptr<SecureMessageDelegate> secure_message_delegate);
+
+ ~RemoteDeviceLoader();
+
+ // Loads the RemoteDevice objects. |callback| will be invoked upon completion.
+ typedef base::Callback<void(const std::vector<RemoteDevice>&)>
+ RemoteDeviceCallback;
+ void Load(const RemoteDeviceCallback& callback);
+
+ private:
+ // Called when the PSK is derived for each unlock key. If the PSK for all
+ // unlock have been derived, then we can invoke |callback_|.
+ void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key,
+ const std::string& psk);
+
+ // The remaining unlock keys whose PSK we're waiting on.
+ std::vector<cryptauth::ExternalDeviceInfo> remaining_unlock_keys_;
+
+ // The id of the user who the remote devices belong to.
+ const std::string user_id_;
+
+ // The private key of the user's local device.
+ const std::string user_private_key_;
+
+ // Performs the PSK key derivation.
+ scoped_ptr<SecureMessageDelegate> secure_message_delegate_;
+
+ // Invoked when the RemoteDevices are loaded.
+ RemoteDeviceCallback callback_;
+
+ // The collection of RemoteDevices to return.
+ std::vector<RemoteDevice> remote_devices_;
+
+ base::WeakPtrFactory<RemoteDeviceLoader> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLoader);
+};
+
+} // namespace proximity_auth
+
+#endif // COMPONENTS_PROXIMITY_REMOTE_DEVICE_LOADER_H
« no previous file with comments | « components/proximity_auth/remote_device_life_cycle_impl_unittest.cc ('k') | components/proximity_auth/remote_device_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698