OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ssl_hmac_channel_authenticator.h" | 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 result->local_key_pair_ = key_pair; | 216 result->local_key_pair_ = key_pair; |
217 return result; | 217 return result; |
218 } | 218 } |
219 | 219 |
220 SslHmacChannelAuthenticator::SslHmacChannelAuthenticator( | 220 SslHmacChannelAuthenticator::SslHmacChannelAuthenticator( |
221 const std::string& auth_key) | 221 const std::string& auth_key) |
222 : auth_key_(auth_key) { | 222 : auth_key_(auth_key) { |
223 } | 223 } |
224 | 224 |
225 SslHmacChannelAuthenticator::~SslHmacChannelAuthenticator() { | 225 SslHmacChannelAuthenticator::~SslHmacChannelAuthenticator() { |
| 226 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
226 } | 227 } |
227 | 228 |
228 void SslHmacChannelAuthenticator::SecureAndAuthenticate( | 229 void SslHmacChannelAuthenticator::SecureAndAuthenticate( |
229 std::unique_ptr<P2PStreamSocket> socket, | 230 std::unique_ptr<P2PStreamSocket> socket, |
230 const DoneCallback& done_callback) { | 231 const DoneCallback& done_callback) { |
231 DCHECK(CalledOnValidThread()); | 232 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
232 | 233 |
233 done_callback_ = done_callback; | 234 done_callback_ = done_callback; |
234 | 235 |
235 int result; | 236 int result; |
236 if (is_ssl_server()) { | 237 if (is_ssl_server()) { |
237 #if defined(OS_NACL) | 238 #if defined(OS_NACL) |
238 // Client plugin doesn't use server SSL sockets, and so SSLServerSocket | 239 // Client plugin doesn't use server SSL sockets, and so SSLServerSocket |
239 // implementation is not compiled for NaCl as part of net_nacl. | 240 // implementation is not compiled for NaCl as part of net_nacl. |
240 NOTREACHED(); | 241 NOTREACHED(); |
241 result = net::ERR_FAILED; | 242 result = net::ERR_FAILED; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 base::Bind(&SslHmacChannelAuthenticator::OnAuthBytesWritten, | 371 base::Bind(&SslHmacChannelAuthenticator::OnAuthBytesWritten, |
371 base::Unretained(this))); | 372 base::Unretained(this))); |
372 if (result == net::ERR_IO_PENDING) | 373 if (result == net::ERR_IO_PENDING) |
373 break; | 374 break; |
374 if (!HandleAuthBytesWritten(result, callback_called)) | 375 if (!HandleAuthBytesWritten(result, callback_called)) |
375 break; | 376 break; |
376 } | 377 } |
377 } | 378 } |
378 | 379 |
379 void SslHmacChannelAuthenticator::OnAuthBytesWritten(int result) { | 380 void SslHmacChannelAuthenticator::OnAuthBytesWritten(int result) { |
380 DCHECK(CalledOnValidThread()); | 381 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
381 | 382 |
382 if (HandleAuthBytesWritten(result, nullptr)) | 383 if (HandleAuthBytesWritten(result, nullptr)) |
383 WriteAuthenticationBytes(nullptr); | 384 WriteAuthenticationBytes(nullptr); |
384 } | 385 } |
385 | 386 |
386 bool SslHmacChannelAuthenticator::HandleAuthBytesWritten( | 387 bool SslHmacChannelAuthenticator::HandleAuthBytesWritten( |
387 int result, bool* callback_called) { | 388 int result, bool* callback_called) { |
388 if (result <= 0) { | 389 if (result <= 0) { |
389 LOG(ERROR) << "Error writing authentication: " << result; | 390 LOG(ERROR) << "Error writing authentication: " << result; |
390 if (callback_called) | 391 if (callback_called) |
(...skipping 19 matching lines...) Expand all Loading... |
410 base::Bind(&SslHmacChannelAuthenticator::OnAuthBytesRead, | 411 base::Bind(&SslHmacChannelAuthenticator::OnAuthBytesRead, |
411 base::Unretained(this))); | 412 base::Unretained(this))); |
412 if (result == net::ERR_IO_PENDING) | 413 if (result == net::ERR_IO_PENDING) |
413 break; | 414 break; |
414 if (!HandleAuthBytesRead(result)) | 415 if (!HandleAuthBytesRead(result)) |
415 break; | 416 break; |
416 } | 417 } |
417 } | 418 } |
418 | 419 |
419 void SslHmacChannelAuthenticator::OnAuthBytesRead(int result) { | 420 void SslHmacChannelAuthenticator::OnAuthBytesRead(int result) { |
420 DCHECK(CalledOnValidThread()); | 421 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
421 | 422 |
422 if (HandleAuthBytesRead(result)) | 423 if (HandleAuthBytesRead(result)) |
423 ReadAuthenticationBytes(); | 424 ReadAuthenticationBytes(); |
424 } | 425 } |
425 | 426 |
426 bool SslHmacChannelAuthenticator::HandleAuthBytesRead(int read_result) { | 427 bool SslHmacChannelAuthenticator::HandleAuthBytesRead(int read_result) { |
427 if (read_result <= 0) { | 428 if (read_result <= 0) { |
428 NotifyError(read_result); | 429 NotifyError(read_result); |
429 return false; | 430 return false; |
430 } | 431 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 std::move(socket_), std::move(server_context_))); | 473 std::move(socket_), std::move(server_context_))); |
473 } | 474 } |
474 } | 475 } |
475 | 476 |
476 void SslHmacChannelAuthenticator::NotifyError(int error) { | 477 void SslHmacChannelAuthenticator::NotifyError(int error) { |
477 base::ResetAndReturn(&done_callback_).Run(error, nullptr); | 478 base::ResetAndReturn(&done_callback_).Run(error, nullptr); |
478 } | 479 } |
479 | 480 |
480 } // namespace protocol | 481 } // namespace protocol |
481 } // namespace remoting | 482 } // namespace remoting |
OLD | NEW |