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

Unified Diff: chrome/browser/local_discovery/privetv3_session.h

Issue 877613002: Added pairing with Spake SHA224 key exchange. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@brillo1
Patch Set: Sun 01/25/2015 23:51:07.99 Created 5 years, 11 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: chrome/browser/local_discovery/privetv3_session.h
diff --git a/chrome/browser/local_discovery/privetv3_session.h b/chrome/browser/local_discovery/privetv3_session.h
index 82c44402276a42b233948f34cbd53dcaa14da11b..57b0753a092ed3be501c14fff909842a9de14a5d 100644
--- a/chrome/browser/local_discovery/privetv3_session.h
+++ b/chrome/browser/local_discovery/privetv3_session.h
@@ -12,14 +12,21 @@
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "chrome/common/extensions/api/gcd_private.h"
+#include "net/url_request/url_fetcher.h"
namespace base {
class DictionaryValue;
}
+namespace crypto {
+class P224EncryptedKeyExchange;
+}
+
namespace local_discovery {
class PrivetHTTPClient;
+class PrivetJSONOperation;
+class PrivetURLFetcher;
// Manages secure communication between browser and local Privet device.
class PrivetV3Session {
@@ -41,27 +48,63 @@ class PrivetV3Session {
explicit PrivetV3Session(scoped_ptr<PrivetHTTPClient> client);
~PrivetV3Session();
- // Initialized session.
+ // Initializes session. Queries /privet/info and returns supported pairing
+ // types in callback.
void Init(const InitCallback& callback);
+ // Starts pairing by calling /privet/v3/pairing/start.
void StartPairing(PairingType pairing_type, const ResultCallback& callback);
+ // Confirms pairing code by calling /privet/v3/pairing/confirm.
+ // TODO(vitalybuka): Call /privet/v3/pairing/auth after pairing.
void ConfirmCode(const std::string& code, const ResultCallback& callback);
- // Create a single /privet/v3/session/call request.
+ // TODO(vitalybuka): Make HTTPS request to device with certificate validation.
void SendMessage(const std::string& api,
const base::DictionaryValue& input,
const MessageCallback& callback);
private:
+ void OnInfoDone(const InitCallback& callback,
+ Result result,
+ const base::DictionaryValue& response);
+ void OnPairingStartDone(const ResultCallback& callback,
+ Result result,
+ const base::DictionaryValue& response);
+ void OnPairingConfirmDone(const ResultCallback& callback,
+ Result result,
+ const base::DictionaryValue& response);
void RunCallback(const base::Closure& callback);
+ void StartGetRequest(const std::string& api, const MessageCallback& callback);
+ void StartPostRequest(const std::string& api,
+ const base::DictionaryValue& input,
+ const MessageCallback& callback);
+ PrivetURLFetcher* CreateFetcher(const std::string& api,
+ net::URLFetcher::RequestType request_type,
+ const MessageCallback& callback);
void DeleteFetcher(const FetcherDelegate* fetcher);
+ // Creates instances of PrivetURLFetcher.
scoped_ptr<PrivetHTTPClient> client_;
- bool code_confirmed_;
+
+ // Current authentication token.
+ std::string privet_auth_token_;
+
+ // ID of the session received from pairing/start.
+ std::string session_id_;
+
+ // Device commitment received from pairing/start.
+ std::string commitment_;
+
+ // Key exchange algorithm for pairing.
+ scoped_ptr<crypto::P224EncryptedKeyExchange> spake_;
+
+ // HTTPS certificate fingerprint received during pairing.
+ std::string fingerprint_;
+
+ // List of fetches to cancel when session is destroyed.
ScopedVector<FetcherDelegate> fetchers_;
base::WeakPtrFactory<PrivetV3Session> weak_ptr_factory_;
- std::string privet_auth_token_;
DISALLOW_COPY_AND_ASSIGN(PrivetV3Session);
};
« no previous file with comments | « no previous file | chrome/browser/local_discovery/privetv3_session.cc » ('j') | chrome/browser/local_discovery/privetv3_session.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698