| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/protocol/negotiating_host_authenticator.h" | 5 #include "remoting/protocol/negotiating_host_authenticator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 Authenticator::State preferred_initial_state, | 168 Authenticator::State preferred_initial_state, |
| 169 const base::Closure& resume_callback) { | 169 const base::Closure& resume_callback) { |
| 170 DCHECK(current_method_ != AuthenticationMethod::INVALID); | 170 DCHECK(current_method_ != AuthenticationMethod::INVALID); |
| 171 | 171 |
| 172 if (current_method_ == AuthenticationMethod::THIRD_PARTY) { | 172 if (current_method_ == AuthenticationMethod::THIRD_PARTY) { |
| 173 // |ThirdPartyHostAuthenticator| takes ownership of |token_validator_|. | 173 // |ThirdPartyHostAuthenticator| takes ownership of |token_validator_|. |
| 174 // The authentication method negotiation logic should guarantee that only | 174 // The authentication method negotiation logic should guarantee that only |
| 175 // one |ThirdPartyHostAuthenticator| will need to be created per session. | 175 // one |ThirdPartyHostAuthenticator| will need to be created per session. |
| 176 DCHECK(token_validator_); | 176 DCHECK(token_validator_); |
| 177 current_authenticator_.reset(new ThirdPartyHostAuthenticator( | 177 current_authenticator_.reset(new ThirdPartyHostAuthenticator( |
| 178 local_cert_, local_key_pair_, std::move(token_validator_))); | 178 base::Bind(&V2Authenticator::CreateForHost, local_cert_, |
| 179 local_key_pair_), |
| 180 std::move(token_validator_))); |
| 179 } else if (current_method_ == AuthenticationMethod::SPAKE2_PAIR && | 181 } else if (current_method_ == AuthenticationMethod::SPAKE2_PAIR && |
| 180 preferred_initial_state == WAITING_MESSAGE) { | 182 preferred_initial_state == WAITING_MESSAGE) { |
| 181 // If the client requested Spake2Pair and sent an initial message, attempt | 183 // If the client requested Spake2Pair and sent an initial message, attempt |
| 182 // the paired connection protocol. | 184 // the paired connection protocol. |
| 183 current_authenticator_.reset(new PairingHostAuthenticator( | 185 current_authenticator_.reset(new PairingHostAuthenticator( |
| 184 pairing_registry_, local_cert_, local_key_pair_, shared_secret_hash_)); | 186 pairing_registry_, base::Bind(&V2Authenticator::CreateForHost, |
| 187 local_cert_, local_key_pair_), |
| 188 shared_secret_hash_)); |
| 185 } else { | 189 } else { |
| 186 // In all other cases, use the V2 protocol. Note that this includes the | 190 // In all other cases, use the V2 protocol. Note that this includes the |
| 187 // case where the protocol is Spake2Pair but the client is not yet paired. | 191 // case where the protocol is Spake2Pair but the client is not yet paired. |
| 188 // In this case, the on-the-wire protocol is plain Spake2, advertised as | 192 // In this case, the on-the-wire protocol is plain Spake2, advertised as |
| 189 // Spake2Pair so that the client knows that the host supports pairing and | 193 // Spake2Pair so that the client knows that the host supports pairing and |
| 190 // that it can therefore present the option to the user when they enter | 194 // that it can therefore present the option to the user when they enter |
| 191 // the PIN. | 195 // the PIN. |
| 192 DCHECK(current_method_ == | 196 DCHECK(current_method_ == |
| 193 AuthenticationMethod::SPAKE2_SHARED_SECRET_PLAIN || | 197 AuthenticationMethod::SPAKE2_SHARED_SECRET_PLAIN || |
| 194 current_method_ == AuthenticationMethod::SPAKE2_SHARED_SECRET_HMAC || | 198 current_method_ == AuthenticationMethod::SPAKE2_SHARED_SECRET_HMAC || |
| 195 current_method_ == AuthenticationMethod::SPAKE2_PAIR); | 199 current_method_ == AuthenticationMethod::SPAKE2_PAIR); |
| 196 current_authenticator_ = V2Authenticator::CreateForHost( | 200 current_authenticator_ = V2Authenticator::CreateForHost( |
| 197 local_cert_, local_key_pair_, shared_secret_hash_, | 201 local_cert_, local_key_pair_, shared_secret_hash_, |
| 198 preferred_initial_state); | 202 preferred_initial_state); |
| 199 } | 203 } |
| 200 resume_callback.Run(); | 204 resume_callback.Run(); |
| 201 } | 205 } |
| 202 | 206 |
| 203 } // namespace protocol | 207 } // namespace protocol |
| 204 } // namespace remoting | 208 } // namespace remoting |
| OLD | NEW |