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

Unified Diff: webrtc/api/peerconnection_unittest.cc

Issue 1528843005: Add support for GCM cipher suites from RFC 7714. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Disable GCM if ENABLE_EXTERNAL_AUTH is defined. Created 4 years, 5 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/api/peerconnection.cc ('k') | webrtc/api/peerconnectionfactory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/peerconnection_unittest.cc
diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/api/peerconnection_unittest.cc
index 4b06b90d01c6c1c9dd5ed7e9aaf181c9f1fddfb2..18d360692f6cd652bf4b1453f292c74fe24b1588 100644
--- a/webrtc/api/peerconnection_unittest.cc
+++ b/webrtc/api/peerconnection_unittest.cc
@@ -100,6 +100,7 @@ static const char kDataChannelLabel[] = "data_channel";
// SRTP cipher name negotiated by the tests. This must be updated if the
// default changes.
static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32;
+static const int kDefaultSrtpCryptoSuiteGcm = rtc::SRTP_AEAD_AES_256_GCM;
#endif
static void RemoveLinesFromSdp(const std::string& line_start,
@@ -1364,6 +1365,28 @@ class P2PTestConductor : public testing::Test {
return true;
}
+ void TestGcmNegotiation(bool local_gcm_enabled, bool remote_gcm_enabled,
+ int expected_cipher_suite) {
+ PeerConnectionFactory::Options init_options;
+ init_options.crypto_options.enable_gcm_crypto_suites = local_gcm_enabled;
+ PeerConnectionFactory::Options recv_options;
+ recv_options.crypto_options.enable_gcm_crypto_suites = remote_gcm_enabled;
+ ASSERT_TRUE(
+ CreateTestClients(nullptr, &init_options, nullptr, &recv_options));
+ rtc::scoped_refptr<webrtc::FakeMetricsObserver>
+ init_observer =
+ new rtc::RefCountedObject<webrtc::FakeMetricsObserver>();
+ initializing_client()->pc()->RegisterUMAObserver(init_observer);
+ LocalP2PTest();
+
+ EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(expected_cipher_suite),
+ initializing_client()->GetSrtpCipherStats(),
+ kMaxWaitMs);
+ EXPECT_EQ(1,
+ init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher,
+ expected_cipher_suite));
+ }
+
private:
// |ss_| is used by |network_thread_| so it must be destroyed later.
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
@@ -1814,6 +1837,26 @@ TEST_F(P2PTestConductor, GetDtls12Recv) {
kDefaultSrtpCryptoSuite));
}
+// Test that a non-GCM cipher is used if both sides only support non-GCM.
+TEST_F(P2PTestConductor, GetGcmNone) {
+ TestGcmNegotiation(false, false, kDefaultSrtpCryptoSuite);
+}
+
+// Test that a GCM cipher is used if both ends support it.
+TEST_F(P2PTestConductor, GetGcmBoth) {
+ TestGcmNegotiation(true, true, kDefaultSrtpCryptoSuiteGcm);
+}
+
+// Test that GCM isn't used if only the initiator supports it.
+TEST_F(P2PTestConductor, GetGcmInit) {
+ TestGcmNegotiation(true, false, kDefaultSrtpCryptoSuite);
+}
+
+// Test that GCM isn't used if only the receiver supports it.
+TEST_F(P2PTestConductor, GetGcmRecv) {
+ TestGcmNegotiation(false, true, kDefaultSrtpCryptoSuite);
+}
+
// This test sets up a call between two parties with audio, video and an RTP
// data channel.
TEST_F(P2PTestConductor, LocalP2PTestRtpDataChannel) {
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/api/peerconnectionfactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698