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

Unified Diff: webrtc/base/ssladapter_unittest.cc

Issue 1189583002: Support generation of EC keys using P256 curve and support ECDSA certs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase, glue to hbos's changes Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/opensslstreamadapter.cc ('k') | webrtc/base/sslidentity.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/ssladapter_unittest.cc
diff --git a/webrtc/base/ssladapter_unittest.cc b/webrtc/base/ssladapter_unittest.cc
index 9a0548602e20eae23eb1550eaaf0c7b967052298..9b6945132ae4e9235dcce36609ca595db6f0ee9f 100644
--- a/webrtc/base/ssladapter_unittest.cc
+++ b/webrtc/base/ssladapter_unittest.cc
@@ -15,6 +15,7 @@
#include "webrtc/base/socketstream.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/sslstreamadapter.h"
+#include "webrtc/base/sslidentity.h"
#include "webrtc/base/stream.h"
#include "webrtc/base/virtualsocketserver.h"
@@ -129,10 +130,11 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> {
class SSLAdapterTestDummyServer : public sigslot::has_slots<> {
public:
- explicit SSLAdapterTestDummyServer(const rtc::SSLMode& ssl_mode)
+ explicit SSLAdapterTestDummyServer(const rtc::SSLMode& ssl_mode,
+ const rtc::KeyType key_type)
: ssl_mode_(ssl_mode) {
// Generate a key pair and a certificate for this host.
- ssl_identity_.reset(rtc::SSLIdentity::Generate(GetHostname()));
+ ssl_identity_.reset(rtc::SSLIdentity::Generate(GetHostname(), key_type));
server_socket_.reset(CreateSocket(ssl_mode_));
@@ -268,13 +270,13 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> {
class SSLAdapterTestBase : public testing::Test,
public sigslot::has_slots<> {
public:
- explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode)
+ explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode,
+ const rtc::KeyType key_type)
: ssl_mode_(ssl_mode),
ss_scope_(new rtc::VirtualSocketServer(NULL)),
- server_(new SSLAdapterTestDummyServer(ssl_mode_)),
+ server_(new SSLAdapterTestDummyServer(ssl_mode_, key_type)),
client_(new SSLAdapterTestDummyClient(ssl_mode_)),
- handshake_wait_(kTimeout) {
- }
+ handshake_wait_(kTimeout) {}
void SetHandshakeWait(int wait) {
handshake_wait_ = wait;
@@ -343,43 +345,78 @@ class SSLAdapterTestBase : public testing::Test,
int handshake_wait_;
};
-class SSLAdapterTestTLS : public SSLAdapterTestBase {
+class SSLAdapterTestTLS_RSA : public SSLAdapterTestBase {
+ public:
+ SSLAdapterTestTLS_RSA()
+ : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KT_RSA) {}
+};
+
+class SSLAdapterTestTLS_ECDSA : public SSLAdapterTestBase {
public:
- SSLAdapterTestTLS() : SSLAdapterTestBase(rtc::SSL_MODE_TLS) {}
+ SSLAdapterTestTLS_ECDSA()
+ : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KT_ECDSA) {}
};
-class SSLAdapterTestDTLS : public SSLAdapterTestBase {
+class SSLAdapterTestDTLS_RSA : public SSLAdapterTestBase {
public:
- SSLAdapterTestDTLS() : SSLAdapterTestBase(rtc::SSL_MODE_DTLS) {}
+ SSLAdapterTestDTLS_RSA()
+ : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KT_RSA) {}
+};
+
+class SSLAdapterTestDTLS_ECDSA : public SSLAdapterTestBase {
+ public:
+ SSLAdapterTestDTLS_ECDSA()
+ : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KT_ECDSA) {}
};
#if SSL_USE_OPENSSL
// Basic tests: TLS
-// Test that handshake works
-TEST_F(SSLAdapterTestTLS, TestTLSConnect) {
+// Test that handshake works, using RSA
+TEST_F(SSLAdapterTestTLS_RSA, TestTLSConnect) {
+ TestHandshake(true);
+}
+
+// Test that handshake works, using ECDSA
+TEST_F(SSLAdapterTestTLS_ECDSA, TestTLSConnect) {
+ TestHandshake(true);
+}
+
+// Test transfer between client and server, using RSA
+TEST_F(SSLAdapterTestTLS_RSA, TestTLSTransfer) {
TestHandshake(true);
+ TestTransfer("Hello, world!");
}
-// Test transfer between client and server
-TEST_F(SSLAdapterTestTLS, TestTLSTransfer) {
+// Test transfer between client and server, using ECDSA
+TEST_F(SSLAdapterTestTLS_ECDSA, TestTLSTransfer) {
TestHandshake(true);
TestTransfer("Hello, world!");
}
// Basic tests: DTLS
-// Test that handshake works
-TEST_F(SSLAdapterTestDTLS, TestDTLSConnect) {
+// Test that handshake works, using RSA
+TEST_F(SSLAdapterTestDTLS_RSA, TestDTLSConnect) {
+ TestHandshake(true);
+}
+
+// Test that handshake works, using ECDSA
+TEST_F(SSLAdapterTestDTLS_ECDSA, TestDTLSConnect) {
TestHandshake(true);
}
-// Test transfer between client and server
-TEST_F(SSLAdapterTestDTLS, TestDTLSTransfer) {
+// Test transfer between client and server, using RSA
+TEST_F(SSLAdapterTestDTLS_RSA, TestDTLSTransfer) {
TestHandshake(true);
TestTransfer("Hello, world!");
}
-#endif // SSL_USE_OPENSSL
+// Test transfer between client and server, using ECDSA
+TEST_F(SSLAdapterTestDTLS_ECDSA, TestDTLSTransfer) {
+ TestHandshake(true);
+ TestTransfer("Hello, world!");
+}
+#endif // SSL_USE_OPENSSL
« no previous file with comments | « webrtc/base/opensslstreamadapter.cc ('k') | webrtc/base/sslidentity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698