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