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

Side by Side Diff: webrtc/base/ssladapter_unittest.cc

Issue 1329493005: Provide RSA2048 as per RFC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Allow full parameterization of RSA, curve id for ECDSA. Created 5 years, 2 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 /* 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
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::KeyTypeFull key_type)
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_type));
hbos 2015/09/29 13:53:18 DCHECK(ssl_identity_.get()) after this line?
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
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::KeyTypeFull key_type)
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_type)),
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
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::KeyTypeFull::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::KeyTypeFull::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::KeyTypeFull::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::KeyTypeFull::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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698