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

Unified Diff: webrtc/base/sslstreamadapter_unittest.cc

Issue 1455233005: Revert of Convert internal representation of Srtp cryptos from string to int. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 1 month 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/sslstreamadapter.cc ('k') | webrtc/p2p/base/dtlstransportchannel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/sslstreamadapter_unittest.cc
diff --git a/webrtc/base/sslstreamadapter_unittest.cc b/webrtc/base/sslstreamadapter_unittest.cc
index 0344bd057ab2fec3ad77fc156076ba691d26bb2a..a3e8d9c637980f6ca4d1453283c9915874d40e0e 100644
--- a/webrtc/base/sslstreamadapter_unittest.cc
+++ b/webrtc/base/sslstreamadapter_unittest.cc
@@ -29,6 +29,8 @@
using ::testing::tuple;
static const int kBlockSize = 4096;
+static const char kAES_CM_HMAC_SHA1_80[] = "AES_CM_128_HMAC_SHA1_80";
+static const char kAES_CM_HMAC_SHA1_32[] = "AES_CM_128_HMAC_SHA1_32";
static const char kExporterLabel[] = "label";
static const unsigned char kExporterContext[] = "context";
static int kExporterContextLen = sizeof(kExporterContext);
@@ -387,18 +389,19 @@
handshake_wait_ = wait;
}
- void SetDtlsSrtpCryptoSuites(const std::vector<int>& ciphers, bool client) {
+ void SetDtlsSrtpCiphers(const std::vector<std::string> &ciphers,
+ bool client) {
if (client)
- client_ssl_->SetDtlsSrtpCryptoSuites(ciphers);
+ client_ssl_->SetDtlsSrtpCiphers(ciphers);
else
- server_ssl_->SetDtlsSrtpCryptoSuites(ciphers);
- }
-
- bool GetDtlsSrtpCryptoSuite(bool client, int* retval) {
+ server_ssl_->SetDtlsSrtpCiphers(ciphers);
+ }
+
+ bool GetDtlsSrtpCipher(bool client, std::string *retval) {
if (client)
- return client_ssl_->GetDtlsSrtpCryptoSuite(retval);
+ return client_ssl_->GetDtlsSrtpCipher(retval);
else
- return server_ssl_->GetDtlsSrtpCryptoSuite(retval);
+ return server_ssl_->GetDtlsSrtpCipher(retval);
}
bool GetPeerCertificate(bool client, rtc::SSLCertificate** cert) {
@@ -806,74 +809,74 @@
// Test DTLS-SRTP with all high ciphers
TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpHigh) {
MAYBE_SKIP_TEST(HaveDtlsSrtp);
- std::vector<int> high;
- high.push_back(rtc::SRTP_AES128_CM_SHA1_80);
- SetDtlsSrtpCryptoSuites(high, true);
- SetDtlsSrtpCryptoSuites(high, false);
- TestHandshake();
-
- int client_cipher;
- ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher));
- int server_cipher;
- ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher));
+ std::vector<std::string> high;
+ high.push_back(kAES_CM_HMAC_SHA1_80);
+ SetDtlsSrtpCiphers(high, true);
+ SetDtlsSrtpCiphers(high, false);
+ TestHandshake();
+
+ std::string client_cipher;
+ ASSERT_TRUE(GetDtlsSrtpCipher(true, &client_cipher));
+ std::string server_cipher;
+ ASSERT_TRUE(GetDtlsSrtpCipher(false, &server_cipher));
ASSERT_EQ(client_cipher, server_cipher);
- ASSERT_EQ(client_cipher, rtc::SRTP_AES128_CM_SHA1_80);
+ ASSERT_EQ(client_cipher, kAES_CM_HMAC_SHA1_80);
};
// Test DTLS-SRTP with all low ciphers
TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpLow) {
MAYBE_SKIP_TEST(HaveDtlsSrtp);
- std::vector<int> low;
- low.push_back(rtc::SRTP_AES128_CM_SHA1_32);
- SetDtlsSrtpCryptoSuites(low, true);
- SetDtlsSrtpCryptoSuites(low, false);
- TestHandshake();
-
- int client_cipher;
- ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher));
- int server_cipher;
- ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher));
+ std::vector<std::string> low;
+ low.push_back(kAES_CM_HMAC_SHA1_32);
+ SetDtlsSrtpCiphers(low, true);
+ SetDtlsSrtpCiphers(low, false);
+ TestHandshake();
+
+ std::string client_cipher;
+ ASSERT_TRUE(GetDtlsSrtpCipher(true, &client_cipher));
+ std::string server_cipher;
+ ASSERT_TRUE(GetDtlsSrtpCipher(false, &server_cipher));
ASSERT_EQ(client_cipher, server_cipher);
- ASSERT_EQ(client_cipher, rtc::SRTP_AES128_CM_SHA1_32);
+ ASSERT_EQ(client_cipher, kAES_CM_HMAC_SHA1_32);
};
// Test DTLS-SRTP with a mismatch -- should not converge
TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpHighLow) {
MAYBE_SKIP_TEST(HaveDtlsSrtp);
- std::vector<int> high;
- high.push_back(rtc::SRTP_AES128_CM_SHA1_80);
- std::vector<int> low;
- low.push_back(rtc::SRTP_AES128_CM_SHA1_32);
- SetDtlsSrtpCryptoSuites(high, true);
- SetDtlsSrtpCryptoSuites(low, false);
- TestHandshake();
-
- int client_cipher;
- ASSERT_FALSE(GetDtlsSrtpCryptoSuite(true, &client_cipher));
- int server_cipher;
- ASSERT_FALSE(GetDtlsSrtpCryptoSuite(false, &server_cipher));
+ std::vector<std::string> high;
+ high.push_back(kAES_CM_HMAC_SHA1_80);
+ std::vector<std::string> low;
+ low.push_back(kAES_CM_HMAC_SHA1_32);
+ SetDtlsSrtpCiphers(high, true);
+ SetDtlsSrtpCiphers(low, false);
+ TestHandshake();
+
+ std::string client_cipher;
+ ASSERT_FALSE(GetDtlsSrtpCipher(true, &client_cipher));
+ std::string server_cipher;
+ ASSERT_FALSE(GetDtlsSrtpCipher(false, &server_cipher));
};
// Test DTLS-SRTP with each side being mixed -- should select high
TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpMixed) {
MAYBE_SKIP_TEST(HaveDtlsSrtp);
- std::vector<int> mixed;
- mixed.push_back(rtc::SRTP_AES128_CM_SHA1_80);
- mixed.push_back(rtc::SRTP_AES128_CM_SHA1_32);
- SetDtlsSrtpCryptoSuites(mixed, true);
- SetDtlsSrtpCryptoSuites(mixed, false);
- TestHandshake();
-
- int client_cipher;
- ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher));
- int server_cipher;
- ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher));
+ std::vector<std::string> mixed;
+ mixed.push_back(kAES_CM_HMAC_SHA1_80);
+ mixed.push_back(kAES_CM_HMAC_SHA1_32);
+ SetDtlsSrtpCiphers(mixed, true);
+ SetDtlsSrtpCiphers(mixed, false);
+ TestHandshake();
+
+ std::string client_cipher;
+ ASSERT_TRUE(GetDtlsSrtpCipher(true, &client_cipher));
+ std::string server_cipher;
+ ASSERT_TRUE(GetDtlsSrtpCipher(false, &server_cipher));
ASSERT_EQ(client_cipher, server_cipher);
- ASSERT_EQ(client_cipher, rtc::SRTP_AES128_CM_SHA1_80);
+ ASSERT_EQ(client_cipher, kAES_CM_HMAC_SHA1_80);
};
// Test an exporter
« no previous file with comments | « webrtc/base/sslstreamadapter.cc ('k') | webrtc/p2p/base/dtlstransportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698