OLD | NEW |
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_DEVICE_TO_DEVICE_AUTHENTICATOR_H | 5 #ifndef COMPONENTS_PROXIMITY_DEVICE_TO_DEVICE_AUTHENTICATOR_H |
6 #define COMPONENTS_PROXIMITY_DEVICE_TO_DEVICE_AUTHENTICATOR_H | 6 #define COMPONENTS_PROXIMITY_DEVICE_TO_DEVICE_AUTHENTICATOR_H |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 public: | 43 public: |
44 // Creates the instance: | 44 // Creates the instance: |
45 // |connection|: The connection to the remote device, which must be in a | 45 // |connection|: The connection to the remote device, which must be in a |
46 // connected state. Not owned. | 46 // connected state. Not owned. |
47 // |account_id|: The canonical account id of the user who is the owner of both | 47 // |account_id|: The canonical account id of the user who is the owner of both |
48 // the local and remote devices. | 48 // the local and remote devices. |
49 // |secure_message_delegate|: Handles the SecureMessage crypto operations. | 49 // |secure_message_delegate|: Handles the SecureMessage crypto operations. |
50 DeviceToDeviceAuthenticator( | 50 DeviceToDeviceAuthenticator( |
51 Connection* connection, | 51 Connection* connection, |
52 const std::string& account_id, | 52 const std::string& account_id, |
53 scoped_ptr<SecureMessageDelegate> secure_message_delegate); | 53 std::unique_ptr<SecureMessageDelegate> secure_message_delegate); |
54 | 54 |
55 ~DeviceToDeviceAuthenticator() override; | 55 ~DeviceToDeviceAuthenticator() override; |
56 | 56 |
57 // Authenticator: | 57 // Authenticator: |
58 void Authenticate(const AuthenticationCallback& callback) override; | 58 void Authenticate(const AuthenticationCallback& callback) override; |
59 | 59 |
60 protected: | 60 protected: |
61 // Creates a base::Timer instance. Exposed for testing. | 61 // Creates a base::Timer instance. Exposed for testing. |
62 virtual scoped_ptr<base::Timer> CreateTimer(); | 62 virtual std::unique_ptr<base::Timer> CreateTimer(); |
63 | 63 |
64 private: | 64 private: |
65 // The current state of the authentication flow. | 65 // The current state of the authentication flow. |
66 enum class State { | 66 enum class State { |
67 NOT_STARTED, | 67 NOT_STARTED, |
68 GENERATING_SESSION_KEYS, | 68 GENERATING_SESSION_KEYS, |
69 SENDING_HELLO, | 69 SENDING_HELLO, |
70 SENT_HELLO, | 70 SENT_HELLO, |
71 RECEIVED_RESPONDER_AUTH, | 71 RECEIVED_RESPONDER_AUTH, |
72 VALIDATED_RESPONDER_AUTH, | 72 VALIDATED_RESPONDER_AUTH, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // The connection to the remote device. It is expected to be in the CONNECTED | 117 // The connection to the remote device. It is expected to be in the CONNECTED |
118 // state at all times during authentication. | 118 // state at all times during authentication. |
119 // Not owned, and must outlive this instance. | 119 // Not owned, and must outlive this instance. |
120 Connection* const connection_; | 120 Connection* const connection_; |
121 | 121 |
122 // The account id of the user who owns the local and remote devices. This is | 122 // The account id of the user who owns the local and remote devices. This is |
123 // normally an email address, and should be canonicalized. | 123 // normally an email address, and should be canonicalized. |
124 const std::string account_id_; | 124 const std::string account_id_; |
125 | 125 |
126 // Handles SecureMessage crypto operations. | 126 // Handles SecureMessage crypto operations. |
127 scoped_ptr<SecureMessageDelegate> secure_message_delegate_; | 127 std::unique_ptr<SecureMessageDelegate> secure_message_delegate_; |
128 | 128 |
129 // The current state in the authentication flow. | 129 // The current state in the authentication flow. |
130 State state_; | 130 State state_; |
131 | 131 |
132 // Callback to invoke when authentication completes. | 132 // Callback to invoke when authentication completes. |
133 AuthenticationCallback callback_; | 133 AuthenticationCallback callback_; |
134 | 134 |
135 // Used for timing out when waiting for [Remote Auth] from the remote device. | 135 // Used for timing out when waiting for [Remote Auth] from the remote device. |
136 scoped_ptr<base::Timer> timer_; | 136 std::unique_ptr<base::Timer> timer_; |
137 | 137 |
138 // The bytes of the [Hello] message sent to the remote device. | 138 // The bytes of the [Hello] message sent to the remote device. |
139 std::string hello_message_; | 139 std::string hello_message_; |
140 | 140 |
141 // The bytes of the [Responder Auth] message received from the remote device. | 141 // The bytes of the [Responder Auth] message received from the remote device. |
142 std::string responder_auth_message_; | 142 std::string responder_auth_message_; |
143 | 143 |
144 // The private key generated for the session. | 144 // The private key generated for the session. |
145 std::string local_session_private_key_; | 145 std::string local_session_private_key_; |
146 | 146 |
147 // The derived symmetric key for the session. | 147 // The derived symmetric key for the session. |
148 std::string session_symmetric_key_; | 148 std::string session_symmetric_key_; |
149 | 149 |
150 base::WeakPtrFactory<DeviceToDeviceAuthenticator> weak_ptr_factory_; | 150 base::WeakPtrFactory<DeviceToDeviceAuthenticator> weak_ptr_factory_; |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticator); | 152 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticator); |
153 }; | 153 }; |
154 | 154 |
155 } // namespace proximity_auth | 155 } // namespace proximity_auth |
156 | 156 |
157 #endif // COMPONENTS_PROXIMITY_DEVICE_TO_DEVICE_AUTHENTICATOR_H | 157 #endif // COMPONENTS_PROXIMITY_DEVICE_TO_DEVICE_AUTHENTICATOR_H |
OLD | NEW |