OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 public: | 70 public: |
71 DtlsTestClient(const std::string& name) : name_(name) {} | 71 DtlsTestClient(const std::string& name) : name_(name) {} |
72 void CreateCertificate(rtc::KeyType key_type) { | 72 void CreateCertificate(rtc::KeyType key_type) { |
73 certificate_ = | 73 certificate_ = |
74 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( | 74 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( |
75 rtc::SSLIdentity::Generate(name_, key_type))); | 75 rtc::SSLIdentity::Generate(name_, key_type))); |
76 } | 76 } |
77 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() { | 77 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() { |
78 return certificate_; | 78 return certificate_; |
79 } | 79 } |
80 void SetupSrtp() { | |
81 EXPECT_TRUE(certificate_ != nullptr); | |
82 use_dtls_srtp_ = true; | |
83 } | |
84 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) { | 80 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) { |
85 ssl_max_version_ = version; | 81 ssl_max_version_ = version; |
86 } | 82 } |
87 void SetupChannels(int count, cricket::IceRole role, int async_delay_ms = 0) { | 83 void SetupChannels(int count, cricket::IceRole role, int async_delay_ms = 0) { |
88 transport_.reset( | 84 transport_.reset( |
89 new cricket::JsepTransport("dtls content name", certificate_)); | 85 new cricket::JsepTransport("dtls content name", certificate_)); |
90 for (int i = 0; i < count; ++i) { | 86 for (int i = 0; i < count; ++i) { |
91 cricket::FakeIceTransport* fake_ice_channel = | 87 cricket::FakeIceTransport* fake_ice_channel = |
92 new cricket::FakeIceTransport(transport_->mid(), i); | 88 new cricket::FakeIceTransport(transport_->mid(), i); |
93 fake_ice_channel->SetAsync(true); | 89 fake_ice_channel->SetAsync(true); |
94 fake_ice_channel->SetAsyncDelay(async_delay_ms); | 90 fake_ice_channel->SetAsyncDelay(async_delay_ms); |
95 // Hook the raw packets so that we can verify they are encrypted. | 91 // Hook the raw packets so that we can verify they are encrypted. |
96 fake_ice_channel->SignalReadPacket.connect( | 92 fake_ice_channel->SignalReadPacket.connect( |
97 this, &DtlsTestClient::OnFakeTransportChannelReadPacket); | 93 this, &DtlsTestClient::OnFakeTransportChannelReadPacket); |
98 | 94 |
99 cricket::DtlsTransport* dtls = | 95 cricket::DtlsTransport* dtls = |
100 new cricket::DtlsTransport(fake_ice_channel); | 96 new cricket::DtlsTransport(fake_ice_channel, rtc::CryptoOptions()); |
101 dtls->SetLocalCertificate(certificate_); | 97 dtls->SetLocalCertificate(certificate_); |
102 dtls->ice_transport()->SetIceRole(role); | 98 dtls->ice_transport()->SetIceRole(role); |
103 dtls->ice_transport()->SetIceTiebreaker( | 99 dtls->ice_transport()->SetIceTiebreaker( |
104 (role == cricket::ICEROLE_CONTROLLING) ? 1 : 2); | 100 (role == cricket::ICEROLE_CONTROLLING) ? 1 : 2); |
105 dtls->SetSslMaxProtocolVersion(ssl_max_version_); | 101 dtls->SetSslMaxProtocolVersion(ssl_max_version_); |
106 dtls->SignalWritableState.connect( | 102 dtls->SignalWritableState.connect( |
107 this, &DtlsTestClient::OnTransportChannelWritableState); | 103 this, &DtlsTestClient::OnTransportChannelWritableState); |
108 dtls->SignalReadPacket.connect( | 104 dtls->SignalReadPacket.connect( |
109 this, &DtlsTestClient::OnTransportChannelReadPacket); | 105 this, &DtlsTestClient::OnTransportChannelReadPacket); |
110 dtls->SignalSentPacket.connect( | 106 dtls->SignalSentPacket.connect( |
111 this, &DtlsTestClient::OnTransportChannelSentPacket); | 107 this, &DtlsTestClient::OnTransportChannelSentPacket); |
112 fake_dtls_transports_.push_back( | 108 dtls_transports_.push_back(std::unique_ptr<cricket::DtlsTransport>(dtls)); |
113 std::unique_ptr<cricket::DtlsTransport>(dtls)); | |
114 fake_ice_transports_.push_back( | 109 fake_ice_transports_.push_back( |
115 std::unique_ptr<cricket::FakeIceTransport>(fake_ice_channel)); | 110 std::unique_ptr<cricket::FakeIceTransport>(fake_ice_channel)); |
116 transport_->AddChannel(dtls, i); | 111 transport_->AddChannel(dtls, i); |
117 } | 112 } |
118 } | 113 } |
119 | 114 |
120 cricket::JsepTransport* transport() { return transport_.get(); } | 115 cricket::JsepTransport* transport() { return transport_.get(); } |
121 | 116 |
122 cricket::FakeIceTransport* GetFakeIceTransort(int component) { | 117 cricket::FakeIceTransport* GetFakeIceTransort(int component) { |
123 for (const auto& ch : fake_ice_transports_) { | 118 for (const auto& ch : fake_ice_transports_) { |
124 if (ch->component() == component) { | 119 if (ch->component() == component) { |
125 return ch.get(); | 120 return ch.get(); |
126 } | 121 } |
127 } | 122 } |
128 return nullptr; | 123 return nullptr; |
129 } | 124 } |
130 | 125 |
131 cricket::DtlsTransport* GetDtlsTransport(int component) { | 126 cricket::DtlsTransport* GetDtlsTransport(int component) { |
132 for (const auto& dtls : fake_dtls_transports_) { | 127 for (const auto& dtls : dtls_transports_) { |
133 if (dtls->component() == component) { | 128 if (dtls->component() == component) { |
134 return dtls.get(); | 129 return dtls.get(); |
135 } | 130 } |
136 } | 131 } |
137 return nullptr; | 132 return nullptr; |
138 } | 133 } |
139 | 134 |
140 // Offer DTLS if we have an identity; pass in a remote fingerprint only if | 135 // Offer DTLS if we have an identity; pass in a remote fingerprint only if |
141 // both sides support DTLS. | 136 // both sides support DTLS. |
142 void Negotiate(DtlsTestClient* peer, cricket::ContentAction action, | 137 void Negotiate(DtlsTestClient* peer, cricket::ContentAction action, |
143 ConnectionRole local_role, ConnectionRole remote_role, | 138 ConnectionRole local_role, ConnectionRole remote_role, |
144 int flags) { | 139 int flags) { |
145 Negotiate(certificate_, certificate_ ? peer->certificate_ : nullptr, action, | 140 Negotiate(certificate_, certificate_ ? peer->certificate_ : nullptr, action, |
146 local_role, remote_role, flags); | 141 local_role, remote_role, flags); |
147 } | 142 } |
148 | 143 |
149 void MaybeSetSrtpCryptoSuites() { | |
150 if (!use_dtls_srtp_) { | |
151 return; | |
152 } | |
153 std::vector<int> ciphers; | |
154 ciphers.push_back(rtc::SRTP_AES128_CM_SHA1_80); | |
155 // SRTP ciphers will be set only in the beginning. | |
156 for (const auto& dtls : fake_dtls_transports_) { | |
157 EXPECT_TRUE(dtls->SetSrtpCryptoSuites(ciphers)); | |
158 } | |
159 } | |
160 | |
161 void SetLocalTransportDescription( | 144 void SetLocalTransportDescription( |
162 const rtc::scoped_refptr<rtc::RTCCertificate>& cert, | 145 const rtc::scoped_refptr<rtc::RTCCertificate>& cert, |
163 cricket::ContentAction action, | 146 cricket::ContentAction action, |
164 ConnectionRole role, | 147 ConnectionRole role, |
165 int flags) { | 148 int flags) { |
166 // If |NF_EXPECT_FAILURE| is set, expect SRTD or SLTD to fail when | 149 // If |NF_EXPECT_FAILURE| is set, expect SRTD or SLTD to fail when |
167 // content action is CA_ANSWER. | 150 // content action is CA_ANSWER. |
168 bool expect_success = | 151 bool expect_success = |
169 !((action == cricket::CA_ANSWER) && (flags & NF_EXPECT_FAILURE)); | 152 !((action == cricket::CA_ANSWER) && (flags & NF_EXPECT_FAILURE)); |
170 EXPECT_EQ(expect_success, | 153 EXPECT_EQ(expect_success, |
(...skipping 15 matching lines...) Expand all Loading... |
186 MakeTransportDescription(cert, role), action, nullptr)); | 169 MakeTransportDescription(cert, role), action, nullptr)); |
187 } | 170 } |
188 | 171 |
189 // Allow any DTLS configuration to be specified (including invalid ones). | 172 // Allow any DTLS configuration to be specified (including invalid ones). |
190 void Negotiate(const rtc::scoped_refptr<rtc::RTCCertificate>& local_cert, | 173 void Negotiate(const rtc::scoped_refptr<rtc::RTCCertificate>& local_cert, |
191 const rtc::scoped_refptr<rtc::RTCCertificate>& remote_cert, | 174 const rtc::scoped_refptr<rtc::RTCCertificate>& remote_cert, |
192 cricket::ContentAction action, | 175 cricket::ContentAction action, |
193 ConnectionRole local_role, | 176 ConnectionRole local_role, |
194 ConnectionRole remote_role, | 177 ConnectionRole remote_role, |
195 int flags) { | 178 int flags) { |
196 if (!(flags & NF_REOFFER)) { | |
197 // SRTP ciphers will be set only in the beginning. | |
198 MaybeSetSrtpCryptoSuites(); | |
199 } | |
200 if (action == cricket::CA_OFFER) { | 179 if (action == cricket::CA_OFFER) { |
201 SetLocalTransportDescription(local_cert, cricket::CA_OFFER, local_role, | 180 SetLocalTransportDescription(local_cert, cricket::CA_OFFER, local_role, |
202 flags); | 181 flags); |
203 SetRemoteTransportDescription(remote_cert, cricket::CA_ANSWER, | 182 SetRemoteTransportDescription(remote_cert, cricket::CA_ANSWER, |
204 remote_role, flags); | 183 remote_role, flags); |
205 } else { | 184 } else { |
206 SetRemoteTransportDescription(remote_cert, cricket::CA_OFFER, remote_role, | 185 SetRemoteTransportDescription(remote_cert, cricket::CA_OFFER, remote_role, |
207 flags); | 186 flags); |
208 // If remote if the offerer and has no DTLS support, answer will be | 187 // If remote if the offerer and has no DTLS support, answer will be |
209 // without any fingerprint. | 188 // without any fingerprint. |
210 SetLocalTransportDescription(remote_cert ? local_cert : nullptr, | 189 SetLocalTransportDescription(remote_cert ? local_cert : nullptr, |
211 cricket::CA_ANSWER, local_role, flags); | 190 cricket::CA_ANSWER, local_role, flags); |
212 } | 191 } |
213 } | 192 } |
214 | 193 |
215 bool Connect(DtlsTestClient* peer, bool asymmetric) { | 194 bool Connect(DtlsTestClient* peer, bool asymmetric) { |
216 for (auto& ice : fake_ice_transports_) { | 195 for (auto& ice : fake_ice_transports_) { |
217 ice->SetDestination(peer->GetFakeIceTransort(ice->component()), | 196 ice->SetDestination(peer->GetFakeIceTransort(ice->component()), |
218 asymmetric); | 197 asymmetric); |
219 } | 198 } |
220 return true; | 199 return true; |
221 } | 200 } |
222 | 201 |
223 bool all_dtls_transports_writable() const { | 202 bool all_dtls_transports_writable() const { |
224 if (fake_dtls_transports_.empty()) { | 203 if (dtls_transports_.empty()) { |
225 return false; | 204 return false; |
226 } | 205 } |
227 for (const auto& dtls : fake_dtls_transports_) { | 206 for (const auto& dtls : dtls_transports_) { |
228 if (!dtls->writable()) { | 207 if (!dtls->writable()) { |
229 return false; | 208 return false; |
230 } | 209 } |
231 } | 210 } |
232 return true; | 211 return true; |
233 } | 212 } |
234 | 213 |
235 bool all_ice_transports_writable() const { | 214 bool all_ice_transports_writable() const { |
236 if (fake_dtls_transports_.empty()) { | 215 if (dtls_transports_.empty()) { |
237 return false; | 216 return false; |
238 } | 217 } |
239 for (const auto& dtls : fake_dtls_transports_) { | 218 for (const auto& dtls : dtls_transports_) { |
240 if (!dtls->ice_transport()->writable()) { | 219 if (!dtls->ice_transport()->writable()) { |
241 return false; | 220 return false; |
242 } | 221 } |
243 } | 222 } |
244 return true; | 223 return true; |
245 } | 224 } |
246 | 225 |
247 int received_dtls_client_hellos() const { | 226 int received_dtls_client_hellos() const { |
248 return received_dtls_client_hellos_; | 227 return received_dtls_client_hellos_; |
249 } | 228 } |
(...skipping 13 matching lines...) Expand all Loading... |
263 if (role == rtc::SSL_CLIENT) { | 242 if (role == rtc::SSL_CLIENT) { |
264 ASSERT_EQ(0, received_dtls_client_hellos_); | 243 ASSERT_EQ(0, received_dtls_client_hellos_); |
265 ASSERT_GT(received_dtls_server_hellos_, 0); | 244 ASSERT_GT(received_dtls_server_hellos_, 0); |
266 } else { | 245 } else { |
267 ASSERT_GT(received_dtls_client_hellos_, 0); | 246 ASSERT_GT(received_dtls_client_hellos_, 0); |
268 ASSERT_EQ(0, received_dtls_server_hellos_); | 247 ASSERT_EQ(0, received_dtls_server_hellos_); |
269 } | 248 } |
270 } | 249 } |
271 | 250 |
272 void CheckSrtp(int expected_crypto_suite) { | 251 void CheckSrtp(int expected_crypto_suite) { |
273 for (const auto& dtls : fake_dtls_transports_) { | 252 for (const auto& dtls : dtls_transports_) { |
274 int crypto_suite; | 253 int crypto_suite; |
275 | 254 |
276 bool rv = dtls->GetSrtpCryptoSuite(&crypto_suite); | 255 bool rv = dtls->GetSrtpCryptoSuite(&crypto_suite); |
277 if (negotiated_dtls() && expected_crypto_suite) { | 256 if (negotiated_dtls() && expected_crypto_suite) { |
278 ASSERT_TRUE(rv); | 257 ASSERT_TRUE(rv); |
279 | 258 |
280 ASSERT_EQ(crypto_suite, expected_crypto_suite); | 259 ASSERT_EQ(crypto_suite, expected_crypto_suite); |
281 } else { | 260 } else { |
282 ASSERT_FALSE(rv); | 261 ASSERT_FALSE(rv); |
283 } | 262 } |
284 } | 263 } |
285 } | 264 } |
286 | 265 |
287 void CheckSsl() { | 266 void CheckSsl() { |
288 for (const auto& dtls : fake_dtls_transports_) { | 267 for (const auto& dtls : dtls_transports_) { |
289 int cipher; | 268 int cipher; |
290 | 269 |
291 bool rv = dtls->GetSslCipherSuite(&cipher); | 270 bool rv = dtls->GetSslCipherSuite(&cipher); |
292 if (negotiated_dtls()) { | 271 if (negotiated_dtls()) { |
293 ASSERT_TRUE(rv); | 272 ASSERT_TRUE(rv); |
294 | 273 |
295 EXPECT_TRUE( | 274 EXPECT_TRUE( |
296 rtc::SSLStreamAdapter::IsAcceptableCipher(cipher, rtc::KT_DEFAULT)); | 275 rtc::SSLStreamAdapter::IsAcceptableCipher(cipher, rtc::KT_DEFAULT)); |
297 } else { | 276 } else { |
298 ASSERT_FALSE(rv); | 277 ASSERT_FALSE(rv); |
299 } | 278 } |
300 } | 279 } |
301 } | 280 } |
302 | 281 |
303 void SendPackets(size_t transport, size_t size, size_t count, bool srtp) { | 282 void SendPackets(size_t transport, size_t size, size_t count, bool srtp) { |
304 RTC_CHECK(transport < fake_dtls_transports_.size()); | 283 RTC_CHECK(transport < dtls_transports_.size()); |
305 std::unique_ptr<char[]> packet(new char[size]); | 284 std::unique_ptr<char[]> packet(new char[size]); |
306 size_t sent = 0; | 285 size_t sent = 0; |
307 do { | 286 do { |
308 // Fill the packet with a known value and a sequence number to check | 287 // Fill the packet with a known value and a sequence number to check |
309 // against, and make sure that it doesn't look like DTLS. | 288 // against, and make sure that it doesn't look like DTLS. |
310 memset(packet.get(), sent & 0xff, size); | 289 memset(packet.get(), sent & 0xff, size); |
311 packet[0] = (srtp) ? 0x80 : 0x00; | 290 packet[0] = (srtp) ? 0x80 : 0x00; |
312 rtc::SetBE32(packet.get() + kPacketNumOffset, | 291 rtc::SetBE32(packet.get() + kPacketNumOffset, |
313 static_cast<uint32_t>(sent)); | 292 static_cast<uint32_t>(sent)); |
314 | 293 |
315 // Only set the bypass flag if we've activated DTLS. | 294 // Only set the bypass flag if we've activated DTLS. |
316 int flags = (certificate_ && srtp) ? cricket::PF_SRTP_BYPASS : 0; | 295 int flags = (certificate_ && srtp) ? cricket::PF_SRTP_BYPASS : 0; |
317 rtc::PacketOptions packet_options; | 296 rtc::PacketOptions packet_options; |
318 packet_options.packet_id = kFakePacketId; | 297 packet_options.packet_id = kFakePacketId; |
319 int rv = fake_dtls_transports_[transport]->SendPacket( | 298 int rv = dtls_transports_[transport]->SendPacket(packet.get(), size, |
320 packet.get(), size, packet_options, flags); | 299 packet_options, flags); |
321 ASSERT_GT(rv, 0); | 300 ASSERT_GT(rv, 0); |
322 ASSERT_EQ(size, static_cast<size_t>(rv)); | 301 ASSERT_EQ(size, static_cast<size_t>(rv)); |
323 ++sent; | 302 ++sent; |
324 } while (sent < count); | 303 } while (sent < count); |
325 } | 304 } |
326 | 305 |
327 int SendInvalidSrtpPacket(size_t transport, size_t size) { | 306 int SendInvalidSrtpPacket(size_t transport, size_t size) { |
328 RTC_CHECK(transport < fake_dtls_transports_.size()); | 307 RTC_CHECK(transport < dtls_transports_.size()); |
329 std::unique_ptr<char[]> packet(new char[size]); | 308 std::unique_ptr<char[]> packet(new char[size]); |
330 // Fill the packet with 0 to form an invalid SRTP packet. | 309 // Fill the packet with 0 to form an invalid SRTP packet. |
331 memset(packet.get(), 0, size); | 310 memset(packet.get(), 0, size); |
332 | 311 |
333 rtc::PacketOptions packet_options; | 312 rtc::PacketOptions packet_options; |
334 return fake_dtls_transports_[transport]->SendPacket( | 313 return dtls_transports_[transport]->SendPacket( |
335 packet.get(), size, packet_options, cricket::PF_SRTP_BYPASS); | 314 packet.get(), size, packet_options, cricket::PF_SRTP_BYPASS); |
336 } | 315 } |
337 | 316 |
338 void ExpectPackets(size_t transport, size_t size) { | 317 void ExpectPackets(size_t transport, size_t size) { |
339 packet_size_ = size; | 318 packet_size_ = size; |
340 received_.clear(); | 319 received_.clear(); |
341 } | 320 } |
342 | 321 |
343 size_t NumPacketsReceived() { | 322 size_t NumPacketsReceived() { |
344 return received_.size(); | 323 return received_.size(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } else if (IsRtpLeadByte(data[0])) { | 407 } else if (IsRtpLeadByte(data[0])) { |
429 ASSERT_TRUE(VerifyPacket(data, size, NULL)); | 408 ASSERT_TRUE(VerifyPacket(data, size, NULL)); |
430 } | 409 } |
431 } | 410 } |
432 } | 411 } |
433 | 412 |
434 private: | 413 private: |
435 std::string name_; | 414 std::string name_; |
436 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 415 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
437 std::vector<std::unique_ptr<cricket::FakeIceTransport>> fake_ice_transports_; | 416 std::vector<std::unique_ptr<cricket::FakeIceTransport>> fake_ice_transports_; |
438 std::vector<std::unique_ptr<cricket::DtlsTransport>> fake_dtls_transports_; | 417 std::vector<std::unique_ptr<cricket::DtlsTransport>> dtls_transports_; |
439 std::unique_ptr<cricket::JsepTransport> transport_; | 418 std::unique_ptr<cricket::JsepTransport> transport_; |
440 size_t packet_size_ = 0u; | 419 size_t packet_size_ = 0u; |
441 std::set<int> received_; | 420 std::set<int> received_; |
442 bool use_dtls_srtp_ = false; | |
443 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; | 421 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; |
444 int received_dtls_client_hellos_ = 0; | 422 int received_dtls_client_hellos_ = 0; |
445 int received_dtls_server_hellos_ = 0; | 423 int received_dtls_server_hellos_ = 0; |
446 rtc::SentPacket sent_packet_; | 424 rtc::SentPacket sent_packet_; |
447 }; | 425 }; |
448 | 426 |
449 // Base class for DtlsTransportChannelTest and DtlsEventOrderingTest, which | 427 // Base class for DtlsTransportChannelTest and DtlsEventOrderingTest, which |
450 // inherit from different variants of testing::Test. | 428 // inherit from different variants of testing::Test. |
451 // | 429 // |
452 // Note that this test always uses a FakeClock, due to the |fake_clock_| member | 430 // Note that this test always uses a FakeClock, due to the |fake_clock_| member |
453 // variable. | 431 // variable. |
454 class DtlsTransportChannelTestBase { | 432 class DtlsTransportChannelTestBase { |
455 public: | 433 public: |
456 DtlsTransportChannelTestBase() | 434 DtlsTransportChannelTestBase() |
457 : client1_("P1"), | 435 : client1_("P1"), |
458 client2_("P2"), | 436 client2_("P2"), |
459 channel_ct_(1), | 437 channel_ct_(1), |
460 use_dtls_(false), | 438 use_dtls_(false), |
461 use_dtls_srtp_(false), | |
462 ssl_expected_version_(rtc::SSL_PROTOCOL_DTLS_12) {} | 439 ssl_expected_version_(rtc::SSL_PROTOCOL_DTLS_12) {} |
463 | 440 |
464 void SetChannelCount(size_t channel_ct) { | 441 void SetChannelCount(size_t channel_ct) { |
465 channel_ct_ = static_cast<int>(channel_ct); | 442 channel_ct_ = static_cast<int>(channel_ct); |
466 } | 443 } |
467 void SetMaxProtocolVersions(rtc::SSLProtocolVersion c1, | 444 void SetMaxProtocolVersions(rtc::SSLProtocolVersion c1, |
468 rtc::SSLProtocolVersion c2) { | 445 rtc::SSLProtocolVersion c2) { |
469 client1_.SetupMaxProtocolVersion(c1); | 446 client1_.SetupMaxProtocolVersion(c1); |
470 client2_.SetupMaxProtocolVersion(c2); | 447 client2_.SetupMaxProtocolVersion(c2); |
471 ssl_expected_version_ = std::min(c1, c2); | 448 ssl_expected_version_ = std::min(c1, c2); |
472 } | 449 } |
473 void PrepareDtls(bool c1, bool c2, rtc::KeyType key_type) { | 450 void PrepareDtls(bool c1, bool c2, rtc::KeyType key_type) { |
474 if (c1) { | 451 if (c1) { |
475 client1_.CreateCertificate(key_type); | 452 client1_.CreateCertificate(key_type); |
476 } | 453 } |
477 if (c2) { | 454 if (c2) { |
478 client2_.CreateCertificate(key_type); | 455 client2_.CreateCertificate(key_type); |
479 } | 456 } |
480 if (c1 && c2) | 457 if (c1 && c2) |
481 use_dtls_ = true; | 458 use_dtls_ = true; |
482 } | 459 } |
483 void PrepareDtlsSrtp(bool c1, bool c2) { | |
484 if (!use_dtls_) | |
485 return; | |
486 | |
487 if (c1) | |
488 client1_.SetupSrtp(); | |
489 if (c2) | |
490 client2_.SetupSrtp(); | |
491 | |
492 if (c1 && c2) | |
493 use_dtls_srtp_ = true; | |
494 } | |
495 | 460 |
496 // Negotiate local/remote fingerprint before or after the underlying | 461 // Negotiate local/remote fingerprint before or after the underlying |
497 // tranpsort is connected? | 462 // tranpsort is connected? |
498 enum NegotiateOrdering { NEGOTIATE_BEFORE_CONNECT, CONNECT_BEFORE_NEGOTIATE }; | 463 enum NegotiateOrdering { NEGOTIATE_BEFORE_CONNECT, CONNECT_BEFORE_NEGOTIATE }; |
499 bool Connect(ConnectionRole client1_role, | 464 bool Connect(ConnectionRole client1_role, |
500 ConnectionRole client2_role, | 465 ConnectionRole client2_role, |
501 NegotiateOrdering ordering = NEGOTIATE_BEFORE_CONNECT) { | 466 NegotiateOrdering ordering = NEGOTIATE_BEFORE_CONNECT) { |
502 bool rv; | 467 bool rv; |
503 if (ordering == NEGOTIATE_BEFORE_CONNECT) { | 468 if (ordering == NEGOTIATE_BEFORE_CONNECT) { |
504 Negotiate(client1_role, client2_role); | 469 Negotiate(client1_role, client2_role); |
505 rv = client1_.Connect(&client2_, false); | 470 rv = client1_.Connect(&client2_, false); |
506 } else { | 471 } else { |
507 client1_.SetupChannels(channel_ct_, cricket::ICEROLE_CONTROLLING); | 472 client1_.SetupChannels(channel_ct_, cricket::ICEROLE_CONTROLLING); |
508 client2_.SetupChannels(channel_ct_, cricket::ICEROLE_CONTROLLED); | 473 client2_.SetupChannels(channel_ct_, cricket::ICEROLE_CONTROLLED); |
509 client1_.MaybeSetSrtpCryptoSuites(); | |
510 client2_.MaybeSetSrtpCryptoSuites(); | |
511 // This is equivalent to an offer being processed on both sides, but an | 474 // This is equivalent to an offer being processed on both sides, but an |
512 // answer not yet being received on the initiating side. So the | 475 // answer not yet being received on the initiating side. So the |
513 // connection will be made before negotiation has finished on both sides. | 476 // connection will be made before negotiation has finished on both sides. |
514 client1_.SetLocalTransportDescription(client1_.certificate(), | 477 client1_.SetLocalTransportDescription(client1_.certificate(), |
515 cricket::CA_OFFER, client1_role, 0); | 478 cricket::CA_OFFER, client1_role, 0); |
516 client2_.SetRemoteTransportDescription( | 479 client2_.SetRemoteTransportDescription( |
517 client1_.certificate(), cricket::CA_OFFER, client1_role, 0); | 480 client1_.certificate(), cricket::CA_OFFER, client1_role, 0); |
518 client2_.SetLocalTransportDescription( | 481 client2_.SetLocalTransportDescription( |
519 client2_.certificate(), cricket::CA_ANSWER, client2_role, 0); | 482 client2_.certificate(), cricket::CA_ANSWER, client2_role, 0); |
520 rv = client1_.Connect(&client2_, false); | 483 rv = client1_.Connect(&client2_, false); |
(...skipping 23 matching lines...) Expand all Loading... |
544 rtc::SSLRole client2_ssl_role = | 507 rtc::SSLRole client2_ssl_role = |
545 (client2_role == cricket::CONNECTIONROLE_ACTIVE || | 508 (client2_role == cricket::CONNECTIONROLE_ACTIVE || |
546 (client1_role == cricket::CONNECTIONROLE_PASSIVE && | 509 (client1_role == cricket::CONNECTIONROLE_PASSIVE && |
547 client2_role == cricket::CONNECTIONROLE_ACTPASS)) ? | 510 client2_role == cricket::CONNECTIONROLE_ACTPASS)) ? |
548 rtc::SSL_CLIENT : rtc::SSL_SERVER; | 511 rtc::SSL_CLIENT : rtc::SSL_SERVER; |
549 | 512 |
550 client1_.CheckRole(client1_ssl_role); | 513 client1_.CheckRole(client1_ssl_role); |
551 client2_.CheckRole(client2_ssl_role); | 514 client2_.CheckRole(client2_ssl_role); |
552 } | 515 } |
553 | 516 |
554 // Check that we negotiated the right ciphers. | 517 if (use_dtls_) { |
555 if (use_dtls_srtp_) { | 518 // Check that we negotiated the right ciphers. Since GCM ciphers are not |
556 client1_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_80); | 519 // negotiated by default, we should end up with SRTP_AES128_CM_SHA1_32. |
557 client2_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_80); | 520 client1_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_32); |
| 521 client2_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_32); |
558 } else { | 522 } else { |
| 523 // If DTLS isn't actually being used, GetSrtpCryptoSuite should return |
| 524 // false. |
559 client1_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE); | 525 client1_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE); |
560 client2_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE); | 526 client2_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE); |
561 } | 527 } |
562 | 528 |
563 client1_.CheckSsl(); | 529 client1_.CheckSsl(); |
564 client2_.CheckSsl(); | 530 client2_.CheckSsl(); |
565 | 531 |
566 return true; | 532 return true; |
567 } | 533 } |
568 | 534 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 EXPECT_EQ_SIMULATED_WAIT(count, client2_.NumPacketsReceived(), kTimeout, | 589 EXPECT_EQ_SIMULATED_WAIT(count, client2_.NumPacketsReceived(), kTimeout, |
624 fake_clock_); | 590 fake_clock_); |
625 } | 591 } |
626 | 592 |
627 protected: | 593 protected: |
628 rtc::ScopedFakeClock fake_clock_; | 594 rtc::ScopedFakeClock fake_clock_; |
629 DtlsTestClient client1_; | 595 DtlsTestClient client1_; |
630 DtlsTestClient client2_; | 596 DtlsTestClient client2_; |
631 int channel_ct_; | 597 int channel_ct_; |
632 bool use_dtls_; | 598 bool use_dtls_; |
633 bool use_dtls_srtp_; | |
634 rtc::SSLProtocolVersion ssl_expected_version_; | 599 rtc::SSLProtocolVersion ssl_expected_version_; |
635 }; | 600 }; |
636 | 601 |
637 class DtlsTransportChannelTest : public DtlsTransportChannelTestBase, | 602 class DtlsTransportChannelTest : public DtlsTransportChannelTestBase, |
638 public ::testing::Test {}; | 603 public ::testing::Test {}; |
639 | 604 |
640 // Test that transport negotiation of ICE, no DTLS works properly. | 605 // Test that transport negotiation of ICE, no DTLS works properly. |
641 TEST_F(DtlsTransportChannelTest, TestChannelSetupIce) { | 606 TEST_F(DtlsTransportChannelTest, TestChannelSetupIce) { |
642 Negotiate(); | 607 Negotiate(); |
643 cricket::FakeIceTransport* channel1 = client1_.GetFakeIceTransort(0); | 608 cricket::FakeIceTransport* channel1 = client1_.GetFakeIceTransort(0); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 709 } |
745 | 710 |
746 // Create two channels with DTLS 1.2 / DTLS 1.0 and check ciphers. | 711 // Create two channels with DTLS 1.2 / DTLS 1.0 and check ciphers. |
747 TEST_F(DtlsTransportChannelTest, TestDtls12Client2) { | 712 TEST_F(DtlsTransportChannelTest, TestDtls12Client2) { |
748 SetChannelCount(2); | 713 SetChannelCount(2); |
749 PrepareDtls(true, true, rtc::KT_DEFAULT); | 714 PrepareDtls(true, true, rtc::KT_DEFAULT); |
750 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); | 715 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); |
751 ASSERT_TRUE(Connect()); | 716 ASSERT_TRUE(Connect()); |
752 } | 717 } |
753 | 718 |
754 // Connect with DTLS, negotiate DTLS-SRTP, and transfer SRTP using bypass. | 719 // Connect with DTLS, negotiating DTLS-SRTP, and transfer SRTP using bypass. |
755 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtp) { | 720 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtp) { |
756 PrepareDtls(true, true, rtc::KT_DEFAULT); | 721 PrepareDtls(true, true, rtc::KT_DEFAULT); |
757 PrepareDtlsSrtp(true, true); | |
758 ASSERT_TRUE(Connect()); | 722 ASSERT_TRUE(Connect()); |
759 TestTransfer(0, 1000, 100, true); | 723 TestTransfer(0, 1000, 100, true); |
760 } | 724 } |
761 | 725 |
762 // Connect with DTLS-SRTP, transfer an invalid SRTP packet, and expects -1 | 726 // Connect with DTLS-SRTP, transfer an invalid SRTP packet, and expects -1 |
763 // returned. | 727 // returned. |
764 TEST_F(DtlsTransportChannelTest, TestTransferDtlsInvalidSrtpPacket) { | 728 TEST_F(DtlsTransportChannelTest, TestTransferDtlsInvalidSrtpPacket) { |
765 PrepareDtls(true, true, rtc::KT_DEFAULT); | 729 PrepareDtls(true, true, rtc::KT_DEFAULT); |
766 PrepareDtlsSrtp(true, true); | |
767 ASSERT_TRUE(Connect()); | 730 ASSERT_TRUE(Connect()); |
768 int result = client1_.SendInvalidSrtpPacket(0, 100); | 731 int result = client1_.SendInvalidSrtpPacket(0, 100); |
769 ASSERT_EQ(-1, result); | 732 ASSERT_EQ(-1, result); |
770 } | 733 } |
771 | 734 |
772 // Connect with DTLS. A does DTLS-SRTP but B does not. | 735 // Connect with DTLS. A does DTLS-SRTP but B does not. |
773 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpRejected) { | 736 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpRejected) { |
774 PrepareDtls(true, true, rtc::KT_DEFAULT); | 737 PrepareDtls(true, true, rtc::KT_DEFAULT); |
775 PrepareDtlsSrtp(true, false); | |
776 ASSERT_TRUE(Connect()); | 738 ASSERT_TRUE(Connect()); |
777 } | 739 } |
778 | 740 |
779 // Connect with DTLS. B does DTLS-SRTP but A does not. | 741 // Connect with DTLS. B does DTLS-SRTP but A does not. |
780 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpNotOffered) { | 742 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpNotOffered) { |
781 PrepareDtls(true, true, rtc::KT_DEFAULT); | 743 PrepareDtls(true, true, rtc::KT_DEFAULT); |
782 PrepareDtlsSrtp(false, true); | |
783 ASSERT_TRUE(Connect()); | 744 ASSERT_TRUE(Connect()); |
784 } | 745 } |
785 | 746 |
786 // Create two channels with DTLS, negotiate DTLS-SRTP, and transfer bypass SRTP. | 747 // Create two channels with DTLS, negotiate DTLS-SRTP, and transfer bypass SRTP. |
787 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpTwoChannels) { | 748 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpTwoChannels) { |
788 SetChannelCount(2); | 749 SetChannelCount(2); |
789 PrepareDtls(true, true, rtc::KT_DEFAULT); | 750 PrepareDtls(true, true, rtc::KT_DEFAULT); |
790 PrepareDtlsSrtp(true, true); | |
791 ASSERT_TRUE(Connect()); | 751 ASSERT_TRUE(Connect()); |
792 TestTransfer(0, 1000, 100, true); | 752 TestTransfer(0, 1000, 100, true); |
793 TestTransfer(1, 1000, 100, true); | 753 TestTransfer(1, 1000, 100, true); |
794 } | 754 } |
795 | 755 |
796 // Create a single channel with DTLS, and send normal data and SRTP data on it. | 756 // Create a single channel with DTLS, and send normal data and SRTP data on it. |
797 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpDemux) { | 757 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpDemux) { |
798 PrepareDtls(true, true, rtc::KT_DEFAULT); | 758 PrepareDtls(true, true, rtc::KT_DEFAULT); |
799 PrepareDtlsSrtp(true, true); | |
800 ASSERT_TRUE(Connect()); | 759 ASSERT_TRUE(Connect()); |
801 TestTransfer(0, 1000, 100, false); | 760 TestTransfer(0, 1000, 100, false); |
802 TestTransfer(0, 1000, 100, true); | 761 TestTransfer(0, 1000, 100, true); |
803 } | 762 } |
804 | 763 |
805 // Testing when the remote is passive. | 764 // Testing when the remote is passive. |
806 TEST_F(DtlsTransportChannelTest, TestTransferDtlsAnswererIsPassive) { | 765 TEST_F(DtlsTransportChannelTest, TestTransferDtlsAnswererIsPassive) { |
807 SetChannelCount(2); | 766 SetChannelCount(2); |
808 PrepareDtls(true, true, rtc::KT_DEFAULT); | 767 PrepareDtls(true, true, rtc::KT_DEFAULT); |
809 PrepareDtlsSrtp(true, true); | |
810 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 768 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
811 cricket::CONNECTIONROLE_PASSIVE)); | 769 cricket::CONNECTIONROLE_PASSIVE)); |
812 TestTransfer(0, 1000, 100, true); | 770 TestTransfer(0, 1000, 100, true); |
813 TestTransfer(1, 1000, 100, true); | 771 TestTransfer(1, 1000, 100, true); |
814 } | 772 } |
815 | 773 |
816 // Testing with the legacy DTLS client which doesn't use setup attribute. | 774 // Testing with the legacy DTLS client which doesn't use setup attribute. |
817 // In this case legacy is the answerer. | 775 // In this case legacy is the answerer. |
818 TEST_F(DtlsTransportChannelTest, TestDtlsSetupWithLegacyAsAnswerer) { | 776 TEST_F(DtlsTransportChannelTest, TestDtlsSetupWithLegacyAsAnswerer) { |
819 PrepareDtls(true, true, rtc::KT_DEFAULT); | 777 PrepareDtls(true, true, rtc::KT_DEFAULT); |
820 NegotiateWithLegacy(); | 778 NegotiateWithLegacy(); |
821 EXPECT_EQ(rtc::SSL_SERVER, *client1_.transport()->GetSslRole()); | 779 EXPECT_EQ(rtc::SSL_SERVER, *client1_.transport()->GetSslRole()); |
822 EXPECT_EQ(rtc::SSL_CLIENT, *client2_.transport()->GetSslRole()); | 780 EXPECT_EQ(rtc::SSL_CLIENT, *client2_.transport()->GetSslRole()); |
823 } | 781 } |
824 | 782 |
825 // Testing re offer/answer after the session is estbalished. Roles will be | 783 // Testing re offer/answer after the session is estbalished. Roles will be |
826 // kept same as of the previous negotiation. | 784 // kept same as of the previous negotiation. |
827 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromOfferer) { | 785 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromOfferer) { |
828 SetChannelCount(2); | 786 SetChannelCount(2); |
829 PrepareDtls(true, true, rtc::KT_DEFAULT); | 787 PrepareDtls(true, true, rtc::KT_DEFAULT); |
830 PrepareDtlsSrtp(true, true); | |
831 // Initial role for client1 is ACTPASS and client2 is ACTIVE. | 788 // Initial role for client1 is ACTPASS and client2 is ACTIVE. |
832 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 789 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
833 cricket::CONNECTIONROLE_ACTIVE)); | 790 cricket::CONNECTIONROLE_ACTIVE)); |
834 TestTransfer(0, 1000, 100, true); | 791 TestTransfer(0, 1000, 100, true); |
835 TestTransfer(1, 1000, 100, true); | 792 TestTransfer(1, 1000, 100, true); |
836 // Using input roles for the re-offer. | 793 // Using input roles for the re-offer. |
837 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, | 794 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, |
838 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); | 795 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); |
839 TestTransfer(0, 1000, 100, true); | 796 TestTransfer(0, 1000, 100, true); |
840 TestTransfer(1, 1000, 100, true); | 797 TestTransfer(1, 1000, 100, true); |
841 } | 798 } |
842 | 799 |
843 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromAnswerer) { | 800 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromAnswerer) { |
844 SetChannelCount(2); | 801 SetChannelCount(2); |
845 PrepareDtls(true, true, rtc::KT_DEFAULT); | 802 PrepareDtls(true, true, rtc::KT_DEFAULT); |
846 PrepareDtlsSrtp(true, true); | |
847 // Initial role for client1 is ACTPASS and client2 is ACTIVE. | 803 // Initial role for client1 is ACTPASS and client2 is ACTIVE. |
848 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 804 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
849 cricket::CONNECTIONROLE_ACTIVE)); | 805 cricket::CONNECTIONROLE_ACTIVE)); |
850 TestTransfer(0, 1000, 100, true); | 806 TestTransfer(0, 1000, 100, true); |
851 TestTransfer(1, 1000, 100, true); | 807 TestTransfer(1, 1000, 100, true); |
852 // Using input roles for the re-offer. | 808 // Using input roles for the re-offer. |
853 Renegotiate(&client2_, cricket::CONNECTIONROLE_PASSIVE, | 809 Renegotiate(&client2_, cricket::CONNECTIONROLE_PASSIVE, |
854 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); | 810 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); |
855 TestTransfer(0, 1000, 100, true); | 811 TestTransfer(0, 1000, 100, true); |
856 TestTransfer(1, 1000, 100, true); | 812 TestTransfer(1, 1000, 100, true); |
857 } | 813 } |
858 | 814 |
859 // Test that any change in role after the intial setup will result in failure. | 815 // Test that any change in role after the intial setup will result in failure. |
860 TEST_F(DtlsTransportChannelTest, TestDtlsRoleReversal) { | 816 TEST_F(DtlsTransportChannelTest, TestDtlsRoleReversal) { |
861 SetChannelCount(2); | 817 SetChannelCount(2); |
862 PrepareDtls(true, true, rtc::KT_DEFAULT); | 818 PrepareDtls(true, true, rtc::KT_DEFAULT); |
863 PrepareDtlsSrtp(true, true); | |
864 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 819 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
865 cricket::CONNECTIONROLE_PASSIVE)); | 820 cricket::CONNECTIONROLE_PASSIVE)); |
866 | 821 |
867 // Renegotiate from client2 with actpass and client1 as active. | 822 // Renegotiate from client2 with actpass and client1 as active. |
868 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTPASS, | 823 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTPASS, |
869 cricket::CONNECTIONROLE_ACTIVE, | 824 cricket::CONNECTIONROLE_ACTIVE, |
870 NF_REOFFER | NF_EXPECT_FAILURE); | 825 NF_REOFFER | NF_EXPECT_FAILURE); |
871 } | 826 } |
872 | 827 |
873 // Test that using different setup attributes which results in similar ssl | 828 // Test that using different setup attributes which results in similar ssl |
874 // role as the initial negotiation will result in success. | 829 // role as the initial negotiation will result in success. |
875 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferWithDifferentSetupAttr) { | 830 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferWithDifferentSetupAttr) { |
876 SetChannelCount(2); | 831 SetChannelCount(2); |
877 PrepareDtls(true, true, rtc::KT_DEFAULT); | 832 PrepareDtls(true, true, rtc::KT_DEFAULT); |
878 PrepareDtlsSrtp(true, true); | |
879 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, | 833 ASSERT_TRUE(Connect(cricket::CONNECTIONROLE_ACTPASS, |
880 cricket::CONNECTIONROLE_PASSIVE)); | 834 cricket::CONNECTIONROLE_PASSIVE)); |
881 // Renegotiate from client2 with actpass and client1 as active. | 835 // Renegotiate from client2 with actpass and client1 as active. |
882 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTIVE, | 836 Renegotiate(&client2_, cricket::CONNECTIONROLE_ACTIVE, |
883 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); | 837 cricket::CONNECTIONROLE_ACTPASS, NF_REOFFER); |
884 TestTransfer(0, 1000, 100, true); | 838 TestTransfer(0, 1000, 100, true); |
885 TestTransfer(1, 1000, 100, true); | 839 TestTransfer(1, 1000, 100, true); |
886 } | 840 } |
887 | 841 |
888 // Test that re-negotiation can be started before the clients become connected | 842 // Test that re-negotiation can be started before the clients become connected |
889 // in the first negotiation. | 843 // in the first negotiation. |
890 TEST_F(DtlsTransportChannelTest, TestRenegotiateBeforeConnect) { | 844 TEST_F(DtlsTransportChannelTest, TestRenegotiateBeforeConnect) { |
891 SetChannelCount(2); | 845 SetChannelCount(2); |
892 PrepareDtls(true, true, rtc::KT_DEFAULT); | 846 PrepareDtls(true, true, rtc::KT_DEFAULT); |
893 PrepareDtlsSrtp(true, true); | |
894 Negotiate(); | 847 Negotiate(); |
895 | 848 |
896 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, | 849 Renegotiate(&client1_, cricket::CONNECTIONROLE_ACTPASS, |
897 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); | 850 cricket::CONNECTIONROLE_ACTIVE, NF_REOFFER); |
898 bool rv = client1_.Connect(&client2_, false); | 851 bool rv = client1_.Connect(&client2_, false); |
899 EXPECT_TRUE(rv); | 852 EXPECT_TRUE(rv); |
900 EXPECT_TRUE_SIMULATED_WAIT(client1_.all_dtls_transports_writable() && | 853 EXPECT_TRUE_SIMULATED_WAIT(client1_.all_dtls_transports_writable() && |
901 client2_.all_dtls_transports_writable(), | 854 client2_.all_dtls_transports_writable(), |
902 kTimeout, fake_clock_); | 855 kTimeout, fake_clock_); |
903 | 856 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 std::vector<DtlsTransportEvent>{ | 1109 std::vector<DtlsTransportEvent>{ |
1157 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, | 1110 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, |
1158 CALLER_WRITABLE, HANDSHAKE_FINISHES}, | 1111 CALLER_WRITABLE, HANDSHAKE_FINISHES}, |
1159 std::vector<DtlsTransportEvent>{ | 1112 std::vector<DtlsTransportEvent>{ |
1160 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, | 1113 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, |
1161 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, | 1114 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, |
1162 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, | 1115 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, |
1163 CALLER_WRITABLE, HANDSHAKE_FINISHES, | 1116 CALLER_WRITABLE, HANDSHAKE_FINISHES, |
1164 CALLER_RECEIVES_FINGERPRINT}), | 1117 CALLER_RECEIVES_FINGERPRINT}), |
1165 ::testing::Bool())); | 1118 ::testing::Bool())); |
OLD | NEW |