OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 const rtc::SSLMode ssl_mode_; | 124 const rtc::SSLMode ssl_mode_; |
125 | 125 |
126 rtc::scoped_ptr<rtc::SSLAdapter> ssl_adapter_; | 126 rtc::scoped_ptr<rtc::SSLAdapter> ssl_adapter_; |
127 | 127 |
128 std::string data_; | 128 std::string data_; |
129 }; | 129 }; |
130 | 130 |
131 class SSLAdapterTestDummyServer : public sigslot::has_slots<> { | 131 class SSLAdapterTestDummyServer : public sigslot::has_slots<> { |
132 public: | 132 public: |
133 explicit SSLAdapterTestDummyServer(const rtc::SSLMode& ssl_mode, | 133 explicit SSLAdapterTestDummyServer(const rtc::SSLMode& ssl_mode, |
134 const rtc::KeyType key_type) | 134 const rtc::KeyParams& key_params) |
135 : ssl_mode_(ssl_mode) { | 135 : ssl_mode_(ssl_mode) { |
136 // Generate a key pair and a certificate for this host. | 136 // Generate a key pair and a certificate for this host. |
137 ssl_identity_.reset(rtc::SSLIdentity::Generate(GetHostname(), key_type)); | 137 ssl_identity_.reset(rtc::SSLIdentity::Generate(GetHostname(), key_params)); |
138 | 138 |
139 server_socket_.reset(CreateSocket(ssl_mode_)); | 139 server_socket_.reset(CreateSocket(ssl_mode_)); |
140 | 140 |
141 if (ssl_mode_ == rtc::SSL_MODE_TLS) { | 141 if (ssl_mode_ == rtc::SSL_MODE_TLS) { |
142 server_socket_->SignalReadEvent.connect(this, | 142 server_socket_->SignalReadEvent.connect(this, |
143 &SSLAdapterTestDummyServer::OnServerSocketReadEvent); | 143 &SSLAdapterTestDummyServer::OnServerSocketReadEvent); |
144 | 144 |
145 server_socket_->Listen(1); | 145 server_socket_->Listen(1); |
146 } | 146 } |
147 | 147 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 264 |
265 rtc::scoped_ptr<rtc::SSLIdentity> ssl_identity_; | 265 rtc::scoped_ptr<rtc::SSLIdentity> ssl_identity_; |
266 | 266 |
267 std::string data_; | 267 std::string data_; |
268 }; | 268 }; |
269 | 269 |
270 class SSLAdapterTestBase : public testing::Test, | 270 class SSLAdapterTestBase : public testing::Test, |
271 public sigslot::has_slots<> { | 271 public sigslot::has_slots<> { |
272 public: | 272 public: |
273 explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode, | 273 explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode, |
274 const rtc::KeyType key_type) | 274 const rtc::KeyParams& key_params) |
275 : ssl_mode_(ssl_mode), | 275 : ssl_mode_(ssl_mode), |
276 ss_scope_(new rtc::VirtualSocketServer(NULL)), | 276 ss_scope_(new rtc::VirtualSocketServer(NULL)), |
277 server_(new SSLAdapterTestDummyServer(ssl_mode_, key_type)), | 277 server_(new SSLAdapterTestDummyServer(ssl_mode_, key_params)), |
278 client_(new SSLAdapterTestDummyClient(ssl_mode_)), | 278 client_(new SSLAdapterTestDummyClient(ssl_mode_)), |
279 handshake_wait_(kTimeout) {} | 279 handshake_wait_(kTimeout) {} |
280 | 280 |
281 void SetHandshakeWait(int wait) { | 281 void SetHandshakeWait(int wait) { |
282 handshake_wait_ = wait; | 282 handshake_wait_ = wait; |
283 } | 283 } |
284 | 284 |
285 void TestHandshake(bool expect_success) { | 285 void TestHandshake(bool expect_success) { |
286 int rv; | 286 int rv; |
287 | 287 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 rtc::scoped_ptr<SSLAdapterTestDummyServer> server_; | 342 rtc::scoped_ptr<SSLAdapterTestDummyServer> server_; |
343 rtc::scoped_ptr<SSLAdapterTestDummyClient> client_; | 343 rtc::scoped_ptr<SSLAdapterTestDummyClient> client_; |
344 | 344 |
345 int handshake_wait_; | 345 int handshake_wait_; |
346 }; | 346 }; |
347 | 347 |
348 class SSLAdapterTestTLS_RSA : public SSLAdapterTestBase { | 348 class SSLAdapterTestTLS_RSA : public SSLAdapterTestBase { |
349 public: | 349 public: |
350 SSLAdapterTestTLS_RSA() | 350 SSLAdapterTestTLS_RSA() |
351 : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KT_RSA) {} | 351 : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KeyParams::RSA()) {} |
352 }; | 352 }; |
353 | 353 |
354 class SSLAdapterTestTLS_ECDSA : public SSLAdapterTestBase { | 354 class SSLAdapterTestTLS_ECDSA : public SSLAdapterTestBase { |
355 public: | 355 public: |
356 SSLAdapterTestTLS_ECDSA() | 356 SSLAdapterTestTLS_ECDSA() |
357 : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KT_ECDSA) {} | 357 : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KeyParams::ECDSA()) {} |
358 }; | 358 }; |
359 | 359 |
360 class SSLAdapterTestDTLS_RSA : public SSLAdapterTestBase { | 360 class SSLAdapterTestDTLS_RSA : public SSLAdapterTestBase { |
361 public: | 361 public: |
362 SSLAdapterTestDTLS_RSA() | 362 SSLAdapterTestDTLS_RSA() |
363 : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KT_RSA) {} | 363 : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KeyParams::RSA()) {} |
364 }; | 364 }; |
365 | 365 |
366 class SSLAdapterTestDTLS_ECDSA : public SSLAdapterTestBase { | 366 class SSLAdapterTestDTLS_ECDSA : public SSLAdapterTestBase { |
367 public: | 367 public: |
368 SSLAdapterTestDTLS_ECDSA() | 368 SSLAdapterTestDTLS_ECDSA() |
369 : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KT_ECDSA) {} | 369 : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KeyParams::ECDSA()) {} |
370 }; | 370 }; |
371 | 371 |
372 #if SSL_USE_OPENSSL | 372 #if SSL_USE_OPENSSL |
373 | 373 |
374 // Basic tests: TLS | 374 // Basic tests: TLS |
375 | 375 |
376 // Test that handshake works, using RSA | 376 // Test that handshake works, using RSA |
377 TEST_F(SSLAdapterTestTLS_RSA, TestTLSConnect) { | 377 TEST_F(SSLAdapterTestTLS_RSA, TestTLSConnect) { |
378 TestHandshake(true); | 378 TestHandshake(true); |
379 } | 379 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 TestTransfer("Hello, world!"); | 413 TestTransfer("Hello, world!"); |
414 } | 414 } |
415 | 415 |
416 // Test transfer between client and server, using ECDSA | 416 // Test transfer between client and server, using ECDSA |
417 TEST_F(SSLAdapterTestDTLS_ECDSA, TestDTLSTransfer) { | 417 TEST_F(SSLAdapterTestDTLS_ECDSA, TestDTLSTransfer) { |
418 TestHandshake(true); | 418 TestHandshake(true); |
419 TestTransfer("Hello, world!"); | 419 TestTransfer("Hello, world!"); |
420 } | 420 } |
421 | 421 |
422 #endif // SSL_USE_OPENSSL | 422 #endif // SSL_USE_OPENSSL |
OLD | NEW |