Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: extensions/browser/api/cast_channel/cast_socket.cc

Issue 2709523008: [Cast Channel] Add support for nonce challenge to Cast channel authentication. (Closed)
Patch Set: Rebase-only Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" 5 #include "extensions/browser/api/cast_channel/cast_socket.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id, 108 CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id,
109 const net::IPEndPoint& ip_endpoint, 109 const net::IPEndPoint& ip_endpoint,
110 ChannelAuthType channel_auth, 110 ChannelAuthType channel_auth,
111 net::NetLog* net_log, 111 net::NetLog* net_log,
112 const base::TimeDelta& timeout, 112 const base::TimeDelta& timeout,
113 bool keep_alive, 113 bool keep_alive,
114 const scoped_refptr<Logger>& logger, 114 const scoped_refptr<Logger>& logger,
115 uint64_t device_capabilities) 115 uint64_t device_capabilities)
116 : CastSocketImpl(owner_extension_id,
117 ip_endpoint,
118 channel_auth,
119 net_log,
120 timeout,
121 keep_alive,
122 logger,
123 device_capabilities,
124 AuthContext::Create()) {}
125
126 CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id,
127 const net::IPEndPoint& ip_endpoint,
128 ChannelAuthType channel_auth,
129 net::NetLog* net_log,
130 const base::TimeDelta& timeout,
131 bool keep_alive,
132 const scoped_refptr<Logger>& logger,
133 uint64_t device_capabilities,
134 const AuthContext& auth_context)
116 : CastSocket(owner_extension_id), 135 : CastSocket(owner_extension_id),
117 owner_extension_id_(owner_extension_id), 136 owner_extension_id_(owner_extension_id),
118 channel_id_(0), 137 channel_id_(0),
119 ip_endpoint_(ip_endpoint), 138 ip_endpoint_(ip_endpoint),
120 channel_auth_(channel_auth), 139 channel_auth_(channel_auth),
121 net_log_(net_log), 140 net_log_(net_log),
122 keep_alive_(keep_alive), 141 keep_alive_(keep_alive),
123 logger_(logger), 142 logger_(logger),
143 auth_context_(auth_context),
124 connect_timeout_(timeout), 144 connect_timeout_(timeout),
125 connect_timeout_timer_(new base::OneShotTimer), 145 connect_timeout_timer_(new base::OneShotTimer),
126 is_canceled_(false), 146 is_canceled_(false),
127 device_capabilities_(device_capabilities), 147 device_capabilities_(device_capabilities),
128 audio_only_(false), 148 audio_only_(false),
129 connect_state_(proto::CONN_STATE_START_CONNECT), 149 connect_state_(proto::CONN_STATE_START_CONNECT),
130 error_state_(CHANNEL_ERROR_NONE), 150 error_state_(CHANNEL_ERROR_NONE),
131 ready_state_(READY_STATE_NONE), 151 ready_state_(READY_STATE_NONE),
132 auth_delegate_(nullptr) { 152 auth_delegate_(nullptr) {
133 DCHECK(net_log_); 153 DCHECK(net_log_);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 LOG_WITH_CONNECTION(ERROR) 245 LOG_WITH_CONNECTION(ERROR)
226 << "Audio only channel policy enforced for video out capable device"; 246 << "Audio only channel policy enforced for video out capable device";
227 return false; 247 return false;
228 } 248 }
229 return true; 249 return true;
230 } 250 }
231 251
232 bool CastSocketImpl::VerifyChallengeReply() { 252 bool CastSocketImpl::VerifyChallengeReply() {
233 DCHECK(peer_cert_); 253 DCHECK(peer_cert_);
234 AuthResult result = 254 AuthResult result =
235 AuthenticateChallengeReply(*challenge_reply_, *peer_cert_); 255 AuthenticateChallengeReply(*challenge_reply_, *peer_cert_, auth_context_);
236 logger_->LogSocketChallengeReplyEvent(channel_id_, result); 256 logger_->LogSocketChallengeReplyEvent(channel_id_, result);
237 if (result.success()) { 257 if (result.success()) {
238 VLOG(1) << result.error_message; 258 VLOG(1) << result.error_message;
239 if (!VerifyChannelPolicy(result)) { 259 if (!VerifyChannelPolicy(result)) {
240 return false; 260 return false;
241 } 261 }
242 } 262 }
243 return result.success(); 263 return result.success();
244 } 264 }
245 265
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 SetErrorState(CHANNEL_ERROR_AUTHENTICATION_ERROR); 456 SetErrorState(CHANNEL_ERROR_AUTHENTICATION_ERROR);
437 } 457 }
438 return result; 458 return result;
439 } 459 }
440 460
441 int CastSocketImpl::DoAuthChallengeSend() { 461 int CastSocketImpl::DoAuthChallengeSend() {
442 VLOG_WITH_CONNECTION(1) << "DoAuthChallengeSend"; 462 VLOG_WITH_CONNECTION(1) << "DoAuthChallengeSend";
443 SetConnectState(proto::CONN_STATE_AUTH_CHALLENGE_SEND_COMPLETE); 463 SetConnectState(proto::CONN_STATE_AUTH_CHALLENGE_SEND_COMPLETE);
444 464
445 CastMessage challenge_message; 465 CastMessage challenge_message;
446 CreateAuthChallengeMessage(&challenge_message); 466 CreateAuthChallengeMessage(&challenge_message, auth_context_);
447 VLOG_WITH_CONNECTION(1) << "Sending challenge: " 467 VLOG_WITH_CONNECTION(1) << "Sending challenge: "
448 << CastMessageToString(challenge_message); 468 << CastMessageToString(challenge_message);
449 469
450 transport_->SendMessage( 470 transport_->SendMessage(
451 challenge_message, 471 challenge_message,
452 base::Bind(&CastSocketImpl::DoConnectLoop, base::Unretained(this))); 472 base::Bind(&CastSocketImpl::DoConnectLoop, base::Unretained(this)));
453 473
454 // Always return IO_PENDING since the result is always asynchronous. 474 // Always return IO_PENDING since the result is always asynchronous.
455 return net::ERR_IO_PENDING; 475 return net::ERR_IO_PENDING;
456 } 476 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 if (ready_state_ != ready_state) 615 if (ready_state_ != ready_state)
596 ready_state_ = ready_state; 616 ready_state_ = ready_state;
597 } 617 }
598 618
599 void CastSocketImpl::SetErrorState(ChannelError error_state) { 619 void CastSocketImpl::SetErrorState(ChannelError error_state) {
600 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state; 620 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state;
601 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_); 621 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_);
602 error_state_ = error_state; 622 error_state_ = error_state;
603 delegate_->OnError(error_state_); 623 delegate_->OnError(error_state_);
604 } 624 }
625
605 } // namespace cast_channel 626 } // namespace cast_channel
606 } // namespace api 627 } // namespace api
607 } // namespace extensions 628 } // namespace extensions
608 #undef VLOG_WITH_CONNECTION 629 #undef VLOG_WITH_CONNECTION
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_socket.h ('k') | extensions/browser/api/cast_channel/cast_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698