| 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 #include "components/proximity_auth/device_to_device_authenticator.h" | 5 #include "components/proximity_auth/device_to_device_authenticator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
| 12 #include "components/cryptauth/secure_message_delegate.h" |
| 12 #include "components/proximity_auth/connection.h" | 13 #include "components/proximity_auth/connection.h" |
| 13 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | |
| 14 #include "components/proximity_auth/device_to_device_initiator_operations.h" | 14 #include "components/proximity_auth/device_to_device_initiator_operations.h" |
| 15 #include "components/proximity_auth/device_to_device_secure_context.h" | 15 #include "components/proximity_auth/device_to_device_secure_context.h" |
| 16 #include "components/proximity_auth/logging/logging.h" | 16 #include "components/proximity_auth/logging/logging.h" |
| 17 #include "components/proximity_auth/secure_context.h" | 17 #include "components/proximity_auth/secure_context.h" |
| 18 #include "components/proximity_auth/wire_message.h" | 18 #include "components/proximity_auth/wire_message.h" |
| 19 | 19 |
| 20 namespace proximity_auth { | 20 namespace proximity_auth { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // The time to wait in seconds for the remote device to send its | 24 // The time to wait in seconds for the remote device to send its |
| 25 // [Responder Auth] message. If we do not get the message in this time, then | 25 // [Responder Auth] message. If we do not get the message in this time, then |
| 26 // authentication will fail. | 26 // authentication will fail. |
| 27 const int kResponderAuthTimeoutSeconds = 5; | 27 const int kResponderAuthTimeoutSeconds = 5; |
| 28 | 28 |
| 29 // The prefix of the permit id sent to the remote device. The permit id | 29 // The prefix of the permit id sent to the remote device. The permit id |
| 30 // is used by the remote device to find the credentials of the local device. | 30 // is used by the remote device to find the credentials of the local device. |
| 31 const char kPermitIdPrefix[] = "permit://google.com/easyunlock/v1/"; | 31 const char kPermitIdPrefix[] = "permit://google.com/easyunlock/v1/"; |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 DeviceToDeviceAuthenticator::DeviceToDeviceAuthenticator( | 35 DeviceToDeviceAuthenticator::DeviceToDeviceAuthenticator( |
| 36 Connection* connection, | 36 Connection* connection, |
| 37 const std::string& account_id, | 37 const std::string& account_id, |
| 38 std::unique_ptr<SecureMessageDelegate> secure_message_delegate) | 38 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate) |
| 39 : connection_(connection), | 39 : connection_(connection), |
| 40 account_id_(account_id), | 40 account_id_(account_id), |
| 41 secure_message_delegate_(std::move(secure_message_delegate)), | 41 secure_message_delegate_(std::move(secure_message_delegate)), |
| 42 state_(State::NOT_STARTED), | 42 state_(State::NOT_STARTED), |
| 43 weak_ptr_factory_(this) { | 43 weak_ptr_factory_(this) { |
| 44 DCHECK(connection_); | 44 DCHECK(connection_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 DeviceToDeviceAuthenticator::~DeviceToDeviceAuthenticator() { | 47 DeviceToDeviceAuthenticator::~DeviceToDeviceAuthenticator() { |
| 48 connection_->RemoveObserver(this); | 48 connection_->RemoveObserver(this); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 Succeed(); | 230 Succeed(); |
| 231 else | 231 else |
| 232 Fail("Failed to send [Initiator Auth]"); | 232 Fail("Failed to send [Initiator Auth]"); |
| 233 } else if (!success && state_ == State::SENT_HELLO) { | 233 } else if (!success && state_ == State::SENT_HELLO) { |
| 234 DCHECK(message.payload() == hello_message_); | 234 DCHECK(message.payload() == hello_message_); |
| 235 Fail("Failed to send [Hello]"); | 235 Fail("Failed to send [Hello]"); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace proximity_auth | 239 } // namespace proximity_auth |
| OLD | NEW |