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_CRYPTAUTH_DEVICE_TO_DEVICE_AUTHENTICATOR_H_ | 5 #ifndef COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_AUTHENTICATOR_H_ |
6 #define COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_AUTHENTICATOR_H_ | 6 #define COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_AUTHENTICATOR_H_ |
7 | 7 |
8 #include <memory> | |
9 | |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
11 #include "components/cryptauth/authenticator.h" | 13 #include "components/cryptauth/authenticator.h" |
12 #include "components/cryptauth/connection.h" | 14 #include "components/cryptauth/connection.h" |
13 #include "components/cryptauth/connection_observer.h" | 15 #include "components/cryptauth/connection_observer.h" |
14 | 16 |
15 namespace base { | 17 namespace base { |
16 class Timer; | 18 class Timer; |
17 }; | 19 }; |
18 | 20 |
19 namespace cryptauth { | 21 namespace cryptauth { |
20 class SecureMessageDelegate; | 22 class SecureMessageDelegate; |
23 class SessionKeys; | |
21 } | 24 } |
22 | 25 |
23 namespace cryptauth { | 26 namespace cryptauth { |
24 | 27 |
25 // Authenticator implementation using the "device to device" protocol, which is | 28 // Authenticator implementation using the "device to device" protocol, which is |
26 // in turn built on top of the SecureMessage library. | 29 // in turn built on top of the SecureMessage library. |
27 // This protocol contains the following steps (local device is the initiator): | 30 // This protocol contains the following steps (local device is the initiator): |
28 // 1. Both initiator and responder devices generate a temporary key pair for | 31 // 1. Both initiator and responder devices generate a temporary key pair for |
29 // the session. | 32 // the session. |
30 // 2. Initiator sends [Hello] message to responder device, which contains the | 33 // 2. Initiator sends [Hello] message to responder device, which contains the |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 const std::string& private_key); | 106 const std::string& private_key); |
104 | 107 |
105 // Callback when [Hello] is created. | 108 // Callback when [Hello] is created. |
106 void OnHelloMessageCreated(const std::string& message); | 109 void OnHelloMessageCreated(const std::string& message); |
107 | 110 |
108 // Callback when waiting for [Remote Auth] times out. | 111 // Callback when waiting for [Remote Auth] times out. |
109 void OnResponderAuthTimedOut(); | 112 void OnResponderAuthTimedOut(); |
110 | 113 |
111 // Callback for validating the received [Remote Auth]. | 114 // Callback for validating the received [Remote Auth]. |
112 void OnResponderAuthValidated(bool validated, | 115 void OnResponderAuthValidated(bool validated, |
113 const std::string& session_symmetric_key); | 116 std::unique_ptr<SessionKeys> session_keys); |
114 | 117 |
115 // Callback when [Initiator Auth] is created. | 118 // Callback when [Initiator Auth] is created. |
116 void OnInitiatorAuthCreated(const std::string& message); | 119 void OnInitiatorAuthCreated(const std::string& message); |
117 | 120 |
118 // Callback when the session symmetric key is derived. | 121 // Callback when the session symmetric key is derived. |
119 void OnKeyDerived(const std::string& session_symmetric_key); | 122 void OnKeyDerived(const std::string& session_symmetric_key); |
120 | 123 |
121 // Called when the authentication flow fails, and logs |error_message|. The | 124 // Called when the authentication flow fails, and logs |error_message|. The |
122 // overloaded version specifies the Result to be reported; | 125 // overloaded version specifies the Result to be reported; |
123 // otherwise, a FAILURE result will be reported. | 126 // otherwise, a FAILURE result will be reported. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 | 164 |
162 // The bytes of the [Hello] message sent to the remote device. | 165 // The bytes of the [Hello] message sent to the remote device. |
163 std::string hello_message_; | 166 std::string hello_message_; |
164 | 167 |
165 // The bytes of the [Responder Auth] message received from the remote device. | 168 // The bytes of the [Responder Auth] message received from the remote device. |
166 std::string responder_auth_message_; | 169 std::string responder_auth_message_; |
167 | 170 |
168 // The private key generated for the session. | 171 // The private key generated for the session. |
169 std::string local_session_private_key_; | 172 std::string local_session_private_key_; |
170 | 173 |
171 // The derived symmetric key for the session. | 174 // The derived symmetric key for the session. |
Tim Song
2017/05/22 23:18:24
nit: s/key/keys
sacomoto
2017/05/23 09:50:13
Done.
| |
172 std::string session_symmetric_key_; | 175 std::unique_ptr<SessionKeys> session_keys_; |
173 | 176 |
174 base::WeakPtrFactory<DeviceToDeviceAuthenticator> weak_ptr_factory_; | 177 base::WeakPtrFactory<DeviceToDeviceAuthenticator> weak_ptr_factory_; |
175 | 178 |
176 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticator); | 179 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticator); |
177 }; | 180 }; |
178 | 181 |
179 } // namespace cryptauth | 182 } // namespace cryptauth |
180 | 183 |
181 #endif // COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_AUTHENTICATOR_H_ | 184 #endif // COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_AUTHENTICATOR_H_ |
OLD | NEW |