| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "third_party/libsrtp/srtp/crypto/include/err.h" | 39 #include "third_party/libsrtp/srtp/crypto/include/err.h" |
| 40 #endif | 40 #endif |
| 41 } | 41 } |
| 42 | 42 |
| 43 using rtc::CS_AES_CM_128_HMAC_SHA1_80; | 43 using rtc::CS_AES_CM_128_HMAC_SHA1_80; |
| 44 using rtc::CS_AES_CM_128_HMAC_SHA1_32; | 44 using rtc::CS_AES_CM_128_HMAC_SHA1_32; |
| 45 using cricket::CryptoParams; | 45 using cricket::CryptoParams; |
| 46 using cricket::CS_LOCAL; | 46 using cricket::CS_LOCAL; |
| 47 using cricket::CS_REMOTE; | 47 using cricket::CS_REMOTE; |
| 48 | 48 |
| 49 static const uint8 kTestKey1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234"; | 49 static const uint8_t kTestKey1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234"; |
| 50 static const uint8 kTestKey2[] = "4321ZYXWVUTSRQPONMLKJIHGFEDCBA"; | 50 static const uint8_t kTestKey2[] = "4321ZYXWVUTSRQPONMLKJIHGFEDCBA"; |
| 51 static const int kTestKeyLen = 30; | 51 static const int kTestKeyLen = 30; |
| 52 static const std::string kTestKeyParams1 = | 52 static const std::string kTestKeyParams1 = |
| 53 "inline:WVNfX19zZW1jdGwgKCkgewkyMjA7fQp9CnVubGVz"; | 53 "inline:WVNfX19zZW1jdGwgKCkgewkyMjA7fQp9CnVubGVz"; |
| 54 static const std::string kTestKeyParams2 = | 54 static const std::string kTestKeyParams2 = |
| 55 "inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR"; | 55 "inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR"; |
| 56 static const std::string kTestKeyParams3 = | 56 static const std::string kTestKeyParams3 = |
| 57 "inline:1234X19zZW1jdGwgKCkgewkyMjA7fQp9CnVubGVz"; | 57 "inline:1234X19zZW1jdGwgKCkgewkyMjA7fQp9CnVubGVz"; |
| 58 static const std::string kTestKeyParams4 = | 58 static const std::string kTestKeyParams4 = |
| 59 "inline:4567QCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR"; | 59 "inline:4567QCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR"; |
| 60 static const cricket::CryptoParams kTestCryptoParams1( | 60 static const cricket::CryptoParams kTestCryptoParams1( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 EXPECT_TRUE(f2_.IsActive()); | 92 EXPECT_TRUE(f2_.IsActive()); |
| 93 } | 93 } |
| 94 void TestProtectUnprotect(const std::string& cs1, const std::string& cs2) { | 94 void TestProtectUnprotect(const std::string& cs1, const std::string& cs2) { |
| 95 char rtp_packet[sizeof(kPcmuFrame) + 10]; | 95 char rtp_packet[sizeof(kPcmuFrame) + 10]; |
| 96 char original_rtp_packet[sizeof(kPcmuFrame)]; | 96 char original_rtp_packet[sizeof(kPcmuFrame)]; |
| 97 char rtcp_packet[sizeof(kRtcpReport) + 4 + 10]; | 97 char rtcp_packet[sizeof(kRtcpReport) + 4 + 10]; |
| 98 int rtp_len = sizeof(kPcmuFrame), rtcp_len = sizeof(kRtcpReport), out_len; | 98 int rtp_len = sizeof(kPcmuFrame), rtcp_len = sizeof(kRtcpReport), out_len; |
| 99 memcpy(rtp_packet, kPcmuFrame, rtp_len); | 99 memcpy(rtp_packet, kPcmuFrame, rtp_len); |
| 100 // In order to be able to run this test function multiple times we can not | 100 // In order to be able to run this test function multiple times we can not |
| 101 // use the same sequence number twice. Increase the sequence number by one. | 101 // use the same sequence number twice. Increase the sequence number by one. |
| 102 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet) + 2, | 102 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet) + 2, |
| 103 ++sequence_number_); | 103 ++sequence_number_); |
| 104 memcpy(original_rtp_packet, rtp_packet, rtp_len); | 104 memcpy(original_rtp_packet, rtp_packet, rtp_len); |
| 105 memcpy(rtcp_packet, kRtcpReport, rtcp_len); | 105 memcpy(rtcp_packet, kRtcpReport, rtcp_len); |
| 106 | 106 |
| 107 EXPECT_TRUE(f1_.ProtectRtp(rtp_packet, rtp_len, | 107 EXPECT_TRUE(f1_.ProtectRtp(rtp_packet, rtp_len, |
| 108 sizeof(rtp_packet), &out_len)); | 108 sizeof(rtp_packet), &out_len)); |
| 109 EXPECT_EQ(out_len, rtp_len + rtp_auth_tag_len(cs1)); | 109 EXPECT_EQ(out_len, rtp_len + rtp_auth_tag_len(cs1)); |
| 110 EXPECT_NE(0, memcmp(rtp_packet, original_rtp_packet, rtp_len)); | 110 EXPECT_NE(0, memcmp(rtp_packet, original_rtp_packet, rtp_len)); |
| 111 EXPECT_TRUE(f2_.UnprotectRtp(rtp_packet, out_len, &out_len)); | 111 EXPECT_TRUE(f2_.UnprotectRtp(rtp_packet, out_len, &out_len)); |
| 112 EXPECT_EQ(rtp_len, out_len); | 112 EXPECT_EQ(rtp_len, out_len); |
| 113 EXPECT_EQ(0, memcmp(rtp_packet, original_rtp_packet, rtp_len)); | 113 EXPECT_EQ(0, memcmp(rtp_packet, original_rtp_packet, rtp_len)); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 #if defined(ENABLE_EXTERNAL_AUTH) | 567 #if defined(ENABLE_EXTERNAL_AUTH) |
| 568 TEST_F(SrtpFilterTest, TestGetSendAuthParams) { | 568 TEST_F(SrtpFilterTest, TestGetSendAuthParams) { |
| 569 EXPECT_TRUE(f1_.SetRtpParams(CS_AES_CM_128_HMAC_SHA1_32, | 569 EXPECT_TRUE(f1_.SetRtpParams(CS_AES_CM_128_HMAC_SHA1_32, |
| 570 kTestKey1, kTestKeyLen, | 570 kTestKey1, kTestKeyLen, |
| 571 CS_AES_CM_128_HMAC_SHA1_32, | 571 CS_AES_CM_128_HMAC_SHA1_32, |
| 572 kTestKey2, kTestKeyLen)); | 572 kTestKey2, kTestKeyLen)); |
| 573 EXPECT_TRUE(f1_.SetRtcpParams(CS_AES_CM_128_HMAC_SHA1_32, | 573 EXPECT_TRUE(f1_.SetRtcpParams(CS_AES_CM_128_HMAC_SHA1_32, |
| 574 kTestKey1, kTestKeyLen, | 574 kTestKey1, kTestKeyLen, |
| 575 CS_AES_CM_128_HMAC_SHA1_32, | 575 CS_AES_CM_128_HMAC_SHA1_32, |
| 576 kTestKey2, kTestKeyLen)); | 576 kTestKey2, kTestKeyLen)); |
| 577 uint8* auth_key = NULL; | 577 uint8_t* auth_key = NULL; |
| 578 int auth_key_len = 0, auth_tag_len = 0; | 578 int auth_key_len = 0, auth_tag_len = 0; |
| 579 EXPECT_TRUE(f1_.GetRtpAuthParams(&auth_key, &auth_key_len, &auth_tag_len)); | 579 EXPECT_TRUE(f1_.GetRtpAuthParams(&auth_key, &auth_key_len, &auth_tag_len)); |
| 580 EXPECT_TRUE(auth_key != NULL); | 580 EXPECT_TRUE(auth_key != NULL); |
| 581 EXPECT_EQ(20, auth_key_len); | 581 EXPECT_EQ(20, auth_key_len); |
| 582 EXPECT_EQ(4, auth_tag_len); | 582 EXPECT_EQ(4, auth_tag_len); |
| 583 } | 583 } |
| 584 #endif | 584 #endif |
| 585 | 585 |
| 586 class SrtpSessionTest : public testing::Test { | 586 class SrtpSessionTest : public testing::Test { |
| 587 protected: | 587 protected: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_32, kTestKey1, kTestKeyLen)); | 662 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_32, kTestKey1, kTestKeyLen)); |
| 663 EXPECT_TRUE(s2_.SetRecv(CS_AES_CM_128_HMAC_SHA1_32, kTestKey1, kTestKeyLen)); | 663 EXPECT_TRUE(s2_.SetRecv(CS_AES_CM_128_HMAC_SHA1_32, kTestKey1, kTestKeyLen)); |
| 664 TestProtectRtp(CS_AES_CM_128_HMAC_SHA1_32); | 664 TestProtectRtp(CS_AES_CM_128_HMAC_SHA1_32); |
| 665 TestProtectRtcp(CS_AES_CM_128_HMAC_SHA1_32); | 665 TestProtectRtcp(CS_AES_CM_128_HMAC_SHA1_32); |
| 666 TestUnprotectRtp(CS_AES_CM_128_HMAC_SHA1_32); | 666 TestUnprotectRtp(CS_AES_CM_128_HMAC_SHA1_32); |
| 667 TestUnprotectRtcp(CS_AES_CM_128_HMAC_SHA1_32); | 667 TestUnprotectRtcp(CS_AES_CM_128_HMAC_SHA1_32); |
| 668 } | 668 } |
| 669 | 669 |
| 670 TEST_F(SrtpSessionTest, TestGetSendStreamPacketIndex) { | 670 TEST_F(SrtpSessionTest, TestGetSendStreamPacketIndex) { |
| 671 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_32, kTestKey1, kTestKeyLen)); | 671 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_32, kTestKey1, kTestKeyLen)); |
| 672 int64 index; | 672 int64_t index; |
| 673 int out_len = 0; | 673 int out_len = 0; |
| 674 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, | 674 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, |
| 675 sizeof(rtp_packet_), &out_len, &index)); | 675 sizeof(rtp_packet_), &out_len, &index)); |
| 676 // |index| will be shifted by 16. | 676 // |index| will be shifted by 16. |
| 677 int64 be64_index = static_cast<int64>(rtc::NetworkToHost64(1 << 16)); | 677 int64_t be64_index = static_cast<int64_t>(rtc::NetworkToHost64(1 << 16)); |
| 678 EXPECT_EQ(be64_index, index); | 678 EXPECT_EQ(be64_index, index); |
| 679 } | 679 } |
| 680 | 680 |
| 681 // Test that we fail to unprotect if someone tampers with the RTP/RTCP paylaods. | 681 // Test that we fail to unprotect if someone tampers with the RTP/RTCP paylaods. |
| 682 TEST_F(SrtpSessionTest, TestTamperReject) { | 682 TEST_F(SrtpSessionTest, TestTamperReject) { |
| 683 int out_len; | 683 int out_len; |
| 684 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); | 684 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); |
| 685 EXPECT_TRUE(s2_.SetRecv(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); | 685 EXPECT_TRUE(s2_.SetRecv(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); |
| 686 TestProtectRtp(CS_AES_CM_128_HMAC_SHA1_80); | 686 TestProtectRtp(CS_AES_CM_128_HMAC_SHA1_80); |
| 687 TestProtectRtcp(CS_AES_CM_128_HMAC_SHA1_80); | 687 TestProtectRtcp(CS_AES_CM_128_HMAC_SHA1_80); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 704 TEST_F(SrtpSessionTest, TestBuffersTooSmall) { | 704 TEST_F(SrtpSessionTest, TestBuffersTooSmall) { |
| 705 int out_len; | 705 int out_len; |
| 706 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); | 706 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); |
| 707 EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, | 707 EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, |
| 708 sizeof(rtp_packet_) - 10, &out_len)); | 708 sizeof(rtp_packet_) - 10, &out_len)); |
| 709 EXPECT_FALSE(s1_.ProtectRtcp(rtcp_packet_, rtcp_len_, | 709 EXPECT_FALSE(s1_.ProtectRtcp(rtcp_packet_, rtcp_len_, |
| 710 sizeof(rtcp_packet_) - 14, &out_len)); | 710 sizeof(rtcp_packet_) - 14, &out_len)); |
| 711 } | 711 } |
| 712 | 712 |
| 713 TEST_F(SrtpSessionTest, TestReplay) { | 713 TEST_F(SrtpSessionTest, TestReplay) { |
| 714 static const uint16 kMaxSeqnum = static_cast<uint16>(-1); | 714 static const uint16_t kMaxSeqnum = static_cast<uint16_t>(-1); |
| 715 static const uint16 seqnum_big = 62275; | 715 static const uint16_t seqnum_big = 62275; |
| 716 static const uint16 seqnum_small = 10; | 716 static const uint16_t seqnum_small = 10; |
| 717 static const uint16 replay_window = 1024; | 717 static const uint16_t replay_window = 1024; |
| 718 int out_len; | 718 int out_len; |
| 719 | 719 |
| 720 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); | 720 EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); |
| 721 EXPECT_TRUE(s2_.SetRecv(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); | 721 EXPECT_TRUE(s2_.SetRecv(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); |
| 722 | 722 |
| 723 // Initial sequence number. | 723 // Initial sequence number. |
| 724 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet_) + 2, seqnum_big); | 724 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_) + 2, seqnum_big); |
| 725 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), | 725 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), |
| 726 &out_len)); | 726 &out_len)); |
| 727 | 727 |
| 728 // Replay within the 1024 window should succeed. | 728 // Replay within the 1024 window should succeed. |
| 729 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet_) + 2, | 729 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_) + 2, |
| 730 seqnum_big - replay_window + 1); | 730 seqnum_big - replay_window + 1); |
| 731 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), | 731 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), |
| 732 &out_len)); | 732 &out_len)); |
| 733 | 733 |
| 734 // Replay out side of the 1024 window should fail. | 734 // Replay out side of the 1024 window should fail. |
| 735 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet_) + 2, | 735 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_) + 2, |
| 736 seqnum_big - replay_window - 1); | 736 seqnum_big - replay_window - 1); |
| 737 EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), | 737 EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), |
| 738 &out_len)); | 738 &out_len)); |
| 739 | 739 |
| 740 // Increment sequence number to a small number. | 740 // Increment sequence number to a small number. |
| 741 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet_) + 2, seqnum_small); | 741 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_) + 2, seqnum_small); |
| 742 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), | 742 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), |
| 743 &out_len)); | 743 &out_len)); |
| 744 | 744 |
| 745 // Replay around 0 but out side of the 1024 window should fail. | 745 // Replay around 0 but out side of the 1024 window should fail. |
| 746 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet_) + 2, | 746 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_) + 2, |
| 747 kMaxSeqnum + seqnum_small - replay_window - 1); | 747 kMaxSeqnum + seqnum_small - replay_window - 1); |
| 748 EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), | 748 EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), |
| 749 &out_len)); | 749 &out_len)); |
| 750 | 750 |
| 751 // Replay around 0 but within the 1024 window should succeed. | 751 // Replay around 0 but within the 1024 window should succeed. |
| 752 for (uint16 seqnum = 65000; seqnum < 65003; ++seqnum) { | 752 for (uint16_t seqnum = 65000; seqnum < 65003; ++seqnum) { |
| 753 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet_) + 2, seqnum); | 753 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_) + 2, seqnum); |
| 754 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), | 754 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), |
| 755 &out_len)); | 755 &out_len)); |
| 756 } | 756 } |
| 757 | 757 |
| 758 // Go back to normal sequence nubmer. | 758 // Go back to normal sequence nubmer. |
| 759 // NOTE: without the fix in libsrtp, this would fail. This is because | 759 // NOTE: without the fix in libsrtp, this would fail. This is because |
| 760 // without the fix, the loop above would keep incrementing local sequence | 760 // without the fix, the loop above would keep incrementing local sequence |
| 761 // number in libsrtp, eventually the new sequence number would go out side | 761 // number in libsrtp, eventually the new sequence number would go out side |
| 762 // of the window. | 762 // of the window. |
| 763 rtc::SetBE16(reinterpret_cast<uint8*>(rtp_packet_) + 2, | 763 rtc::SetBE16(reinterpret_cast<uint8_t*>(rtp_packet_) + 2, seqnum_small + 1); |
| 764 seqnum_small + 1); | |
| 765 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), | 764 EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), |
| 766 &out_len)); | 765 &out_len)); |
| 767 } | 766 } |
| 768 | 767 |
| 769 class SrtpStatTest | 768 class SrtpStatTest |
| 770 : public testing::Test, | 769 : public testing::Test, |
| 771 public sigslot::has_slots<> { | 770 public sigslot::has_slots<> { |
| 772 public: | 771 public: |
| 773 SrtpStatTest() | 772 SrtpStatTest() |
| 774 : ssrc_(0U), | 773 : ssrc_(0U), |
| 775 mode_(-1), | 774 mode_(-1), |
| 776 error_(cricket::SrtpFilter::ERROR_NONE) { | 775 error_(cricket::SrtpFilter::ERROR_NONE) { |
| 777 srtp_stat_.SignalSrtpError.connect(this, &SrtpStatTest::OnSrtpError); | 776 srtp_stat_.SignalSrtpError.connect(this, &SrtpStatTest::OnSrtpError); |
| 778 srtp_stat_.set_signal_silent_time(200); | 777 srtp_stat_.set_signal_silent_time(200); |
| 779 } | 778 } |
| 780 | 779 |
| 781 protected: | 780 protected: |
| 782 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode, | 781 void OnSrtpError(uint32_t ssrc, |
| 782 cricket::SrtpFilter::Mode mode, |
| 783 cricket::SrtpFilter::Error error) { | 783 cricket::SrtpFilter::Error error) { |
| 784 ssrc_ = ssrc; | 784 ssrc_ = ssrc; |
| 785 mode_ = mode; | 785 mode_ = mode; |
| 786 error_ = error; | 786 error_ = error; |
| 787 } | 787 } |
| 788 void Reset() { | 788 void Reset() { |
| 789 ssrc_ = 0U; | 789 ssrc_ = 0U; |
| 790 mode_ = -1; | 790 mode_ = -1; |
| 791 error_ = cricket::SrtpFilter::ERROR_NONE; | 791 error_ = cricket::SrtpFilter::ERROR_NONE; |
| 792 } | 792 } |
| 793 | 793 |
| 794 cricket::SrtpStat srtp_stat_; | 794 cricket::SrtpStat srtp_stat_; |
| 795 uint32 ssrc_; | 795 uint32_t ssrc_; |
| 796 int mode_; | 796 int mode_; |
| 797 cricket::SrtpFilter::Error error_; | 797 cricket::SrtpFilter::Error error_; |
| 798 | 798 |
| 799 private: | 799 private: |
| 800 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStatTest); | 800 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStatTest); |
| 801 }; | 801 }; |
| 802 | 802 |
| 803 TEST_F(SrtpStatTest, TestProtectRtpError) { | 803 TEST_F(SrtpStatTest, TestProtectRtpError) { |
| 804 Reset(); | 804 Reset(); |
| 805 srtp_stat_.AddProtectRtpResult(1, err_status_ok); | 805 srtp_stat_.AddProtectRtpResult(1, err_status_ok); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 srtp_stat_.AddUnprotectRtcpResult(err_status_fail); | 926 srtp_stat_.AddUnprotectRtcpResult(err_status_fail); |
| 927 EXPECT_EQ(-1, mode_); | 927 EXPECT_EQ(-1, mode_); |
| 928 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_); | 928 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_); |
| 929 // Now the error will be triggered again. | 929 // Now the error will be triggered again. |
| 930 Reset(); | 930 Reset(); |
| 931 rtc::Thread::Current()->SleepMs(210); | 931 rtc::Thread::Current()->SleepMs(210); |
| 932 srtp_stat_.AddUnprotectRtcpResult(err_status_fail); | 932 srtp_stat_.AddUnprotectRtcpResult(err_status_fail); |
| 933 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, mode_); | 933 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, mode_); |
| 934 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_); | 934 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_); |
| 935 } | 935 } |
| OLD | NEW |