xref: /aosp_15_r20/external/webrtc/pc/srtp_transport_unittest.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2017 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "pc/srtp_transport.h"
12 
13 #include <string.h>
14 
15 #include <vector>
16 
17 #include "call/rtp_demuxer.h"
18 #include "media/base/fake_rtp.h"
19 #include "p2p/base/dtls_transport_internal.h"
20 #include "p2p/base/fake_packet_transport.h"
21 #include "pc/test/rtp_transport_test_util.h"
22 #include "pc/test/srtp_test_util.h"
23 #include "rtc_base/async_packet_socket.h"
24 #include "rtc_base/byte_order.h"
25 #include "rtc_base/checks.h"
26 #include "rtc_base/containers/flat_set.h"
27 #include "rtc_base/ssl_stream_adapter.h"
28 #include "rtc_base/third_party/sigslot/sigslot.h"
29 #include "test/gtest.h"
30 #include "test/scoped_key_value_config.h"
31 
32 using rtc::kSrtpAeadAes128Gcm;
33 using rtc::kTestKey1;
34 using rtc::kTestKey2;
35 using rtc::kTestKeyLen;
36 
37 namespace webrtc {
38 static const uint8_t kTestKeyGcm128_1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ12";
39 static const uint8_t kTestKeyGcm128_2[] = "21ZYXWVUTSRQPONMLKJIHGFEDCBA";
40 static const int kTestKeyGcm128Len = 28;  // 128 bits key + 96 bits salt.
41 static const uint8_t kTestKeyGcm256_1[] =
42     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr";
43 static const uint8_t kTestKeyGcm256_2[] =
44     "rqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA";
45 static const int kTestKeyGcm256Len = 44;  // 256 bits key + 96 bits salt.
46 
47 class SrtpTransportTest : public ::testing::Test, public sigslot::has_slots<> {
48  protected:
SrtpTransportTest()49   SrtpTransportTest() {
50     bool rtcp_mux_enabled = true;
51 
52     rtp_packet_transport1_ =
53         std::make_unique<rtc::FakePacketTransport>("fake_packet_transport1");
54     rtp_packet_transport2_ =
55         std::make_unique<rtc::FakePacketTransport>("fake_packet_transport2");
56 
57     bool asymmetric = false;
58     rtp_packet_transport1_->SetDestination(rtp_packet_transport2_.get(),
59                                            asymmetric);
60 
61     srtp_transport1_ =
62         std::make_unique<SrtpTransport>(rtcp_mux_enabled, field_trials_);
63     srtp_transport2_ =
64         std::make_unique<SrtpTransport>(rtcp_mux_enabled, field_trials_);
65 
66     srtp_transport1_->SetRtpPacketTransport(rtp_packet_transport1_.get());
67     srtp_transport2_->SetRtpPacketTransport(rtp_packet_transport2_.get());
68 
69     srtp_transport1_->SignalRtcpPacketReceived.connect(
70         &rtp_sink1_, &TransportObserver::OnRtcpPacketReceived);
71     srtp_transport2_->SignalRtcpPacketReceived.connect(
72         &rtp_sink2_, &TransportObserver::OnRtcpPacketReceived);
73 
74     RtpDemuxerCriteria demuxer_criteria;
75     // 0x00 is the payload type used in kPcmuFrame.
76     demuxer_criteria.payload_types().insert(0x00);
77 
78     srtp_transport1_->RegisterRtpDemuxerSink(demuxer_criteria, &rtp_sink1_);
79     srtp_transport2_->RegisterRtpDemuxerSink(demuxer_criteria, &rtp_sink2_);
80   }
81 
~SrtpTransportTest()82   ~SrtpTransportTest() {
83     if (srtp_transport1_) {
84       srtp_transport1_->UnregisterRtpDemuxerSink(&rtp_sink1_);
85     }
86     if (srtp_transport2_) {
87       srtp_transport2_->UnregisterRtpDemuxerSink(&rtp_sink2_);
88     }
89   }
90 
91   // With external auth enabled, SRTP doesn't write the auth tag and
92   // unprotect would fail. Check accessing the information about the
93   // tag instead, similar to what the actual code would do that relies
94   // on external auth.
TestRtpAuthParams(SrtpTransport * transport,const std::string & cs)95   void TestRtpAuthParams(SrtpTransport* transport, const std::string& cs) {
96     int overhead;
97     EXPECT_TRUE(transport->GetSrtpOverhead(&overhead));
98     switch (rtc::SrtpCryptoSuiteFromName(cs)) {
99       case rtc::kSrtpAes128CmSha1_32:
100         EXPECT_EQ(32 / 8, overhead);  // 32-bit tag.
101         break;
102       case rtc::kSrtpAes128CmSha1_80:
103         EXPECT_EQ(80 / 8, overhead);  // 80-bit tag.
104         break;
105       default:
106         RTC_DCHECK_NOTREACHED();
107         break;
108     }
109 
110     uint8_t* auth_key = nullptr;
111     int key_len = 0;
112     int tag_len = 0;
113     EXPECT_TRUE(transport->GetRtpAuthParams(&auth_key, &key_len, &tag_len));
114     EXPECT_NE(nullptr, auth_key);
115     EXPECT_EQ(160 / 8, key_len);  // Length of SHA-1 is 160 bits.
116     EXPECT_EQ(overhead, tag_len);
117   }
118 
TestSendRecvRtpPacket(const std::string & cipher_suite_name)119   void TestSendRecvRtpPacket(const std::string& cipher_suite_name) {
120     size_t rtp_len = sizeof(kPcmuFrame);
121     size_t packet_size = rtp_len + rtc::rtp_auth_tag_len(cipher_suite_name);
122     rtc::Buffer rtp_packet_buffer(packet_size);
123     char* rtp_packet_data = rtp_packet_buffer.data<char>();
124     memcpy(rtp_packet_data, kPcmuFrame, rtp_len);
125     // In order to be able to run this test function multiple times we can not
126     // use the same sequence number twice. Increase the sequence number by one.
127     rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_data) + 2,
128                  ++sequence_number_);
129     rtc::CopyOnWriteBuffer rtp_packet1to2(rtp_packet_data, rtp_len,
130                                           packet_size);
131     rtc::CopyOnWriteBuffer rtp_packet2to1(rtp_packet_data, rtp_len,
132                                           packet_size);
133 
134     char original_rtp_data[sizeof(kPcmuFrame)];
135     memcpy(original_rtp_data, rtp_packet_data, rtp_len);
136 
137     rtc::PacketOptions options;
138     // Send a packet from `srtp_transport1_` to `srtp_transport2_` and verify
139     // that the packet can be successfully received and decrypted.
140     ASSERT_TRUE(srtp_transport1_->SendRtpPacket(&rtp_packet1to2, options,
141                                                 cricket::PF_SRTP_BYPASS));
142     if (srtp_transport1_->IsExternalAuthActive()) {
143       TestRtpAuthParams(srtp_transport1_.get(), cipher_suite_name);
144     } else {
145       ASSERT_TRUE(rtp_sink2_.last_recv_rtp_packet().data());
146       EXPECT_EQ(0, memcmp(rtp_sink2_.last_recv_rtp_packet().data(),
147                           original_rtp_data, rtp_len));
148       // Get the encrypted packet from underneath packet transport and verify
149       // the data is actually encrypted.
150       auto fake_rtp_packet_transport = static_cast<rtc::FakePacketTransport*>(
151           srtp_transport1_->rtp_packet_transport());
152       EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(),
153                           original_rtp_data, rtp_len));
154     }
155 
156     // Do the same thing in the opposite direction;
157     ASSERT_TRUE(srtp_transport2_->SendRtpPacket(&rtp_packet2to1, options,
158                                                 cricket::PF_SRTP_BYPASS));
159     if (srtp_transport2_->IsExternalAuthActive()) {
160       TestRtpAuthParams(srtp_transport2_.get(), cipher_suite_name);
161     } else {
162       ASSERT_TRUE(rtp_sink1_.last_recv_rtp_packet().data());
163       EXPECT_EQ(0, memcmp(rtp_sink1_.last_recv_rtp_packet().data(),
164                           original_rtp_data, rtp_len));
165       auto fake_rtp_packet_transport = static_cast<rtc::FakePacketTransport*>(
166           srtp_transport2_->rtp_packet_transport());
167       EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(),
168                           original_rtp_data, rtp_len));
169     }
170   }
171 
TestSendRecvRtcpPacket(const std::string & cipher_suite_name)172   void TestSendRecvRtcpPacket(const std::string& cipher_suite_name) {
173     size_t rtcp_len = sizeof(::kRtcpReport);
174     size_t packet_size =
175         rtcp_len + 4 + rtc::rtcp_auth_tag_len(cipher_suite_name);
176     rtc::Buffer rtcp_packet_buffer(packet_size);
177     char* rtcp_packet_data = rtcp_packet_buffer.data<char>();
178     memcpy(rtcp_packet_data, ::kRtcpReport, rtcp_len);
179 
180     rtc::CopyOnWriteBuffer rtcp_packet1to2(rtcp_packet_data, rtcp_len,
181                                            packet_size);
182     rtc::CopyOnWriteBuffer rtcp_packet2to1(rtcp_packet_data, rtcp_len,
183                                            packet_size);
184 
185     rtc::PacketOptions options;
186     // Send a packet from `srtp_transport1_` to `srtp_transport2_` and verify
187     // that the packet can be successfully received and decrypted.
188     ASSERT_TRUE(srtp_transport1_->SendRtcpPacket(&rtcp_packet1to2, options,
189                                                  cricket::PF_SRTP_BYPASS));
190     ASSERT_TRUE(rtp_sink2_.last_recv_rtcp_packet().data());
191     EXPECT_EQ(0, memcmp(rtp_sink2_.last_recv_rtcp_packet().data(),
192                         rtcp_packet_data, rtcp_len));
193     // Get the encrypted packet from underneath packet transport and verify the
194     // data is actually encrypted.
195     auto fake_rtp_packet_transport = static_cast<rtc::FakePacketTransport*>(
196         srtp_transport1_->rtp_packet_transport());
197     EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(),
198                         rtcp_packet_data, rtcp_len));
199 
200     // Do the same thing in the opposite direction;
201     ASSERT_TRUE(srtp_transport2_->SendRtcpPacket(&rtcp_packet2to1, options,
202                                                  cricket::PF_SRTP_BYPASS));
203     ASSERT_TRUE(rtp_sink1_.last_recv_rtcp_packet().data());
204     EXPECT_EQ(0, memcmp(rtp_sink1_.last_recv_rtcp_packet().data(),
205                         rtcp_packet_data, rtcp_len));
206     fake_rtp_packet_transport = static_cast<rtc::FakePacketTransport*>(
207         srtp_transport2_->rtp_packet_transport());
208     EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(),
209                         rtcp_packet_data, rtcp_len));
210   }
211 
TestSendRecvPacket(bool enable_external_auth,int cs,const uint8_t * key1,int key1_len,const uint8_t * key2,int key2_len,const std::string & cipher_suite_name)212   void TestSendRecvPacket(bool enable_external_auth,
213                           int cs,
214                           const uint8_t* key1,
215                           int key1_len,
216                           const uint8_t* key2,
217                           int key2_len,
218                           const std::string& cipher_suite_name) {
219     EXPECT_EQ(key1_len, key2_len);
220     EXPECT_EQ(cipher_suite_name, rtc::SrtpCryptoSuiteToName(cs));
221     if (enable_external_auth) {
222       srtp_transport1_->EnableExternalAuth();
223       srtp_transport2_->EnableExternalAuth();
224     }
225     std::vector<int> extension_ids;
226     EXPECT_TRUE(srtp_transport1_->SetRtpParams(
227         cs, key1, key1_len, extension_ids, cs, key2, key2_len, extension_ids));
228     EXPECT_TRUE(srtp_transport2_->SetRtpParams(
229         cs, key2, key2_len, extension_ids, cs, key1, key1_len, extension_ids));
230     EXPECT_TRUE(srtp_transport1_->SetRtcpParams(
231         cs, key1, key1_len, extension_ids, cs, key2, key2_len, extension_ids));
232     EXPECT_TRUE(srtp_transport2_->SetRtcpParams(
233         cs, key2, key2_len, extension_ids, cs, key1, key1_len, extension_ids));
234     EXPECT_TRUE(srtp_transport1_->IsSrtpActive());
235     EXPECT_TRUE(srtp_transport2_->IsSrtpActive());
236     if (rtc::IsGcmCryptoSuite(cs)) {
237       EXPECT_FALSE(srtp_transport1_->IsExternalAuthActive());
238       EXPECT_FALSE(srtp_transport2_->IsExternalAuthActive());
239     } else if (enable_external_auth) {
240       EXPECT_TRUE(srtp_transport1_->IsExternalAuthActive());
241       EXPECT_TRUE(srtp_transport2_->IsExternalAuthActive());
242     }
243     TestSendRecvRtpPacket(cipher_suite_name);
244     TestSendRecvRtcpPacket(cipher_suite_name);
245   }
246 
TestSendRecvPacketWithEncryptedHeaderExtension(const std::string & cs,const std::vector<int> & encrypted_header_ids)247   void TestSendRecvPacketWithEncryptedHeaderExtension(
248       const std::string& cs,
249       const std::vector<int>& encrypted_header_ids) {
250     size_t rtp_len = sizeof(kPcmuFrameWithExtensions);
251     size_t packet_size = rtp_len + rtc::rtp_auth_tag_len(cs);
252     rtc::Buffer rtp_packet_buffer(packet_size);
253     char* rtp_packet_data = rtp_packet_buffer.data<char>();
254     memcpy(rtp_packet_data, kPcmuFrameWithExtensions, rtp_len);
255     // In order to be able to run this test function multiple times we can not
256     // use the same sequence number twice. Increase the sequence number by one.
257     rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_data) + 2,
258                  ++sequence_number_);
259     rtc::CopyOnWriteBuffer rtp_packet1to2(rtp_packet_data, rtp_len,
260                                           packet_size);
261     rtc::CopyOnWriteBuffer rtp_packet2to1(rtp_packet_data, rtp_len,
262                                           packet_size);
263 
264     char original_rtp_data[sizeof(kPcmuFrameWithExtensions)];
265     memcpy(original_rtp_data, rtp_packet_data, rtp_len);
266 
267     rtc::PacketOptions options;
268     // Send a packet from `srtp_transport1_` to `srtp_transport2_` and verify
269     // that the packet can be successfully received and decrypted.
270     ASSERT_TRUE(srtp_transport1_->SendRtpPacket(&rtp_packet1to2, options,
271                                                 cricket::PF_SRTP_BYPASS));
272     ASSERT_TRUE(rtp_sink2_.last_recv_rtp_packet().data());
273     EXPECT_EQ(0, memcmp(rtp_sink2_.last_recv_rtp_packet().data(),
274                         original_rtp_data, rtp_len));
275     // Get the encrypted packet from underneath packet transport and verify the
276     // data and header extension are actually encrypted.
277     auto fake_rtp_packet_transport = static_cast<rtc::FakePacketTransport*>(
278         srtp_transport1_->rtp_packet_transport());
279     EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(),
280                         original_rtp_data, rtp_len));
281     CompareHeaderExtensions(
282         reinterpret_cast<const char*>(
283             fake_rtp_packet_transport->last_sent_packet()->data()),
284         fake_rtp_packet_transport->last_sent_packet()->size(),
285         original_rtp_data, rtp_len, encrypted_header_ids, false);
286 
287     // Do the same thing in the opposite direction;
288     ASSERT_TRUE(srtp_transport2_->SendRtpPacket(&rtp_packet2to1, options,
289                                                 cricket::PF_SRTP_BYPASS));
290     ASSERT_TRUE(rtp_sink1_.last_recv_rtp_packet().data());
291     EXPECT_EQ(0, memcmp(rtp_sink1_.last_recv_rtp_packet().data(),
292                         original_rtp_data, rtp_len));
293     fake_rtp_packet_transport = static_cast<rtc::FakePacketTransport*>(
294         srtp_transport2_->rtp_packet_transport());
295     EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(),
296                         original_rtp_data, rtp_len));
297     CompareHeaderExtensions(
298         reinterpret_cast<const char*>(
299             fake_rtp_packet_transport->last_sent_packet()->data()),
300         fake_rtp_packet_transport->last_sent_packet()->size(),
301         original_rtp_data, rtp_len, encrypted_header_ids, false);
302   }
303 
TestSendRecvEncryptedHeaderExtension(int cs,const uint8_t * key1,int key1_len,const uint8_t * key2,int key2_len,const std::string & cs_name)304   void TestSendRecvEncryptedHeaderExtension(int cs,
305                                             const uint8_t* key1,
306                                             int key1_len,
307                                             const uint8_t* key2,
308                                             int key2_len,
309                                             const std::string& cs_name) {
310     std::vector<int> encrypted_headers;
311     encrypted_headers.push_back(kHeaderExtensionIDs[0]);
312     // Don't encrypt header ids 2 and 3.
313     encrypted_headers.push_back(kHeaderExtensionIDs[1]);
314     EXPECT_EQ(key1_len, key2_len);
315     EXPECT_EQ(cs_name, rtc::SrtpCryptoSuiteToName(cs));
316     EXPECT_TRUE(srtp_transport1_->SetRtpParams(cs, key1, key1_len,
317                                                encrypted_headers, cs, key2,
318                                                key2_len, encrypted_headers));
319     EXPECT_TRUE(srtp_transport2_->SetRtpParams(cs, key2, key2_len,
320                                                encrypted_headers, cs, key1,
321                                                key1_len, encrypted_headers));
322     EXPECT_TRUE(srtp_transport1_->IsSrtpActive());
323     EXPECT_TRUE(srtp_transport2_->IsSrtpActive());
324     EXPECT_FALSE(srtp_transport1_->IsExternalAuthActive());
325     EXPECT_FALSE(srtp_transport2_->IsExternalAuthActive());
326     TestSendRecvPacketWithEncryptedHeaderExtension(cs_name, encrypted_headers);
327   }
328 
329   std::unique_ptr<SrtpTransport> srtp_transport1_;
330   std::unique_ptr<SrtpTransport> srtp_transport2_;
331 
332   std::unique_ptr<rtc::FakePacketTransport> rtp_packet_transport1_;
333   std::unique_ptr<rtc::FakePacketTransport> rtp_packet_transport2_;
334 
335   TransportObserver rtp_sink1_;
336   TransportObserver rtp_sink2_;
337 
338   int sequence_number_ = 0;
339   webrtc::test::ScopedKeyValueConfig field_trials_;
340 };
341 
342 class SrtpTransportTestWithExternalAuth
343     : public SrtpTransportTest,
344       public ::testing::WithParamInterface<bool> {};
345 
TEST_P(SrtpTransportTestWithExternalAuth,SendAndRecvPacket_AES_CM_128_HMAC_SHA1_80)346 TEST_P(SrtpTransportTestWithExternalAuth,
347        SendAndRecvPacket_AES_CM_128_HMAC_SHA1_80) {
348   bool enable_external_auth = GetParam();
349   TestSendRecvPacket(enable_external_auth, rtc::kSrtpAes128CmSha1_80, kTestKey1,
350                      kTestKeyLen, kTestKey2, kTestKeyLen,
351                      rtc::kCsAesCm128HmacSha1_80);
352 }
353 
TEST_F(SrtpTransportTest,SendAndRecvPacketWithHeaderExtension_AES_CM_128_HMAC_SHA1_80)354 TEST_F(SrtpTransportTest,
355        SendAndRecvPacketWithHeaderExtension_AES_CM_128_HMAC_SHA1_80) {
356   TestSendRecvEncryptedHeaderExtension(rtc::kSrtpAes128CmSha1_80, kTestKey1,
357                                        kTestKeyLen, kTestKey2, kTestKeyLen,
358                                        rtc::kCsAesCm128HmacSha1_80);
359 }
360 
TEST_P(SrtpTransportTestWithExternalAuth,SendAndRecvPacket_AES_CM_128_HMAC_SHA1_32)361 TEST_P(SrtpTransportTestWithExternalAuth,
362        SendAndRecvPacket_AES_CM_128_HMAC_SHA1_32) {
363   bool enable_external_auth = GetParam();
364   TestSendRecvPacket(enable_external_auth, rtc::kSrtpAes128CmSha1_32, kTestKey1,
365                      kTestKeyLen, kTestKey2, kTestKeyLen,
366                      rtc::kCsAesCm128HmacSha1_32);
367 }
368 
TEST_F(SrtpTransportTest,SendAndRecvPacketWithHeaderExtension_AES_CM_128_HMAC_SHA1_32)369 TEST_F(SrtpTransportTest,
370        SendAndRecvPacketWithHeaderExtension_AES_CM_128_HMAC_SHA1_32) {
371   TestSendRecvEncryptedHeaderExtension(rtc::kSrtpAes128CmSha1_32, kTestKey1,
372                                        kTestKeyLen, kTestKey2, kTestKeyLen,
373                                        rtc::kCsAesCm128HmacSha1_32);
374 }
375 
TEST_P(SrtpTransportTestWithExternalAuth,SendAndRecvPacket_kSrtpAeadAes128Gcm)376 TEST_P(SrtpTransportTestWithExternalAuth,
377        SendAndRecvPacket_kSrtpAeadAes128Gcm) {
378   bool enable_external_auth = GetParam();
379   TestSendRecvPacket(enable_external_auth, rtc::kSrtpAeadAes128Gcm,
380                      kTestKeyGcm128_1, kTestKeyGcm128Len, kTestKeyGcm128_2,
381                      kTestKeyGcm128Len, rtc::kCsAeadAes128Gcm);
382 }
383 
TEST_F(SrtpTransportTest,SendAndRecvPacketWithHeaderExtension_kSrtpAeadAes128Gcm)384 TEST_F(SrtpTransportTest,
385        SendAndRecvPacketWithHeaderExtension_kSrtpAeadAes128Gcm) {
386   TestSendRecvEncryptedHeaderExtension(
387       rtc::kSrtpAeadAes128Gcm, kTestKeyGcm128_1, kTestKeyGcm128Len,
388       kTestKeyGcm128_2, kTestKeyGcm128Len, rtc::kCsAeadAes128Gcm);
389 }
390 
TEST_P(SrtpTransportTestWithExternalAuth,SendAndRecvPacket_kSrtpAeadAes256Gcm)391 TEST_P(SrtpTransportTestWithExternalAuth,
392        SendAndRecvPacket_kSrtpAeadAes256Gcm) {
393   bool enable_external_auth = GetParam();
394   TestSendRecvPacket(enable_external_auth, rtc::kSrtpAeadAes256Gcm,
395                      kTestKeyGcm256_1, kTestKeyGcm256Len, kTestKeyGcm256_2,
396                      kTestKeyGcm256Len, rtc::kCsAeadAes256Gcm);
397 }
398 
TEST_F(SrtpTransportTest,SendAndRecvPacketWithHeaderExtension_kSrtpAeadAes256Gcm)399 TEST_F(SrtpTransportTest,
400        SendAndRecvPacketWithHeaderExtension_kSrtpAeadAes256Gcm) {
401   TestSendRecvEncryptedHeaderExtension(
402       rtc::kSrtpAeadAes256Gcm, kTestKeyGcm256_1, kTestKeyGcm256Len,
403       kTestKeyGcm256_2, kTestKeyGcm256Len, rtc::kCsAeadAes256Gcm);
404 }
405 
406 // Run all tests both with and without external auth enabled.
407 INSTANTIATE_TEST_SUITE_P(ExternalAuth,
408                          SrtpTransportTestWithExternalAuth,
409                          ::testing::Values(true, false));
410 
411 // Test directly setting the params with bogus keys.
TEST_F(SrtpTransportTest,TestSetParamsKeyTooShort)412 TEST_F(SrtpTransportTest, TestSetParamsKeyTooShort) {
413   std::vector<int> extension_ids;
414   EXPECT_FALSE(srtp_transport1_->SetRtpParams(
415       rtc::kSrtpAes128CmSha1_80, kTestKey1, kTestKeyLen - 1, extension_ids,
416       rtc::kSrtpAes128CmSha1_80, kTestKey1, kTestKeyLen - 1, extension_ids));
417   EXPECT_FALSE(srtp_transport1_->SetRtcpParams(
418       rtc::kSrtpAes128CmSha1_80, kTestKey1, kTestKeyLen - 1, extension_ids,
419       rtc::kSrtpAes128CmSha1_80, kTestKey1, kTestKeyLen - 1, extension_ids));
420 }
421 
422 }  // namespace webrtc
423