From eaa9c1db73133d771ea7a9b7ceb39b4286df0e78 Mon Sep 17 00:00:00 2001 From: jbauch Date: Mon, 6 Mar 2017 11:32:22 -0800 Subject: [PATCH] Remove HAVE_SRTP define and unmaintained code. It was defined unconditionally and the code for non-HAVE_SRTP was unmaintained and failed to compile. BUG=webrtc:7294 Review-Url: https://codereview.webrtc.org/2729373002 Cr-Commit-Position: refs/heads/master@{#17074} --- webrtc/BUILD.gn | 1 - webrtc/pc/BUILD.gn | 2 +- webrtc/pc/externalhmac.cc | 6 -- webrtc/pc/externalhmac.h | 5 -- webrtc/pc/mediasession.cc | 10 ---- webrtc/pc/mediasession_unittest.cc | 4 -- webrtc/pc/srtpfilter.cc | 93 ------------------------------ 7 files changed, 1 insertion(+), 120 deletions(-) diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index c0c41eb10f..b2062aabdb 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -131,7 +131,6 @@ config("common_config") { # targets, there's no point including the defines in that config here. # TODO(kjellander): Cleanup unused ones and move defines closer to the # source when webrtc:4256 is completed. - "HAVE_SRTP", "HAVE_WEBRTC_VIDEO", "HAVE_WEBRTC_VOICE", "LOGGING_INSIDE_WEBRTC", diff --git a/webrtc/pc/BUILD.gn b/webrtc/pc/BUILD.gn index f84622b231..5e38c6b9dd 100644 --- a/webrtc/pc/BUILD.gn +++ b/webrtc/pc/BUILD.gn @@ -19,7 +19,7 @@ group("pc") { } config("rtc_pc_config") { - defines = [ "HAVE_SRTP" ] + defines = [] if (rtc_enable_sctp) { defines += [ "HAVE_SCTP" ] } diff --git a/webrtc/pc/externalhmac.cc b/webrtc/pc/externalhmac.cc index 2d3ff5f873..94e39d30b7 100644 --- a/webrtc/pc/externalhmac.cc +++ b/webrtc/pc/externalhmac.cc @@ -14,12 +14,8 @@ #include "webrtc/base/logging.h" -#ifdef HAVE_SRTP #include "third_party/libsrtp/crypto/include/crypto_kernel.h" #include "third_party/libsrtp/include/srtp.h" -#endif // HAVE_SRTP - -#if defined(HAVE_SRTP) // Begin test case 0 */ static const uint8_t kExternalHmacTestCase0Key[20] = { @@ -150,5 +146,3 @@ srtp_err_status_t external_crypto_init() { } return srtp_err_status_ok; } - -#endif // defined(HAVE_SRTP) diff --git a/webrtc/pc/externalhmac.h b/webrtc/pc/externalhmac.h index c0f2ce1ff6..4a6e817aff 100644 --- a/webrtc/pc/externalhmac.h +++ b/webrtc/pc/externalhmac.h @@ -30,11 +30,7 @@ #include -#ifdef HAVE_SRTP #include "third_party/libsrtp/crypto/include/auth.h" -#endif // HAVE_SRTP - -#if defined(HAVE_SRTP) #define EXTERNAL_HMAC_SHA1 SRTP_HMAC_SHA1 + 1 #define HMAC_KEY_LENGTH 20 @@ -71,5 +67,4 @@ srtp_err_status_t external_hmac_compute(ExternalHmacContext* state, srtp_err_status_t external_crypto_init(); -#endif // defined(HAVE_SRTP) #endif // WEBRTC_PC_EXTERNALHMAC_H_ diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc index 05e6ccbd5c..dbd32566d5 100644 --- a/webrtc/pc/mediasession.cc +++ b/webrtc/pc/mediasession.cc @@ -39,13 +39,11 @@ void GetSupportedCryptoSuiteNames(void (*func)(const rtc::CryptoOptions&, std::vector*), const rtc::CryptoOptions& crypto_options, std::vector* names) { -#ifdef HAVE_SRTP std::vector crypto_suites; func(crypto_options, &crypto_suites); for (const auto crypto : crypto_suites) { names->push_back(rtc::SrtpCryptoSuiteToName(crypto)); } -#endif } } // namespace @@ -131,7 +129,6 @@ static bool CreateCryptoParams(int tag, const std::string& cipher, return true; } -#ifdef HAVE_SRTP static bool AddCryptoParams(const std::string& cipher_suite, CryptoParamsVec *out) { int size = static_cast(out->size()); @@ -160,7 +157,6 @@ bool CreateMediaCryptos(const std::vector& crypto_suites, AddMediaCryptos(cryptos, media); return true; } -#endif const CryptoParamsVec* GetCryptos(const MediaContentDescription* media) { if (!media) { @@ -185,14 +181,12 @@ bool FindMatchingCrypto(const CryptoParamsVec& cryptos, // For audio, HMAC 32 is prefered over HMAC 80 because of the low overhead. void GetSupportedAudioCryptoSuites(const rtc::CryptoOptions& crypto_options, std::vector* crypto_suites) { -#ifdef HAVE_SRTP if (crypto_options.enable_gcm_crypto_suites) { crypto_suites->push_back(rtc::SRTP_AEAD_AES_256_GCM); crypto_suites->push_back(rtc::SRTP_AEAD_AES_128_GCM); } crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_32); crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_80); -#endif } void GetSupportedAudioCryptoSuiteNames(const rtc::CryptoOptions& crypto_options, @@ -225,13 +219,11 @@ void GetSupportedDataCryptoSuiteNames(const rtc::CryptoOptions& crypto_options, void GetDefaultSrtpCryptoSuites(const rtc::CryptoOptions& crypto_options, std::vector* crypto_suites) { -#ifdef HAVE_SRTP if (crypto_options.enable_gcm_crypto_suites) { crypto_suites->push_back(rtc::SRTP_AEAD_AES_256_GCM); crypto_suites->push_back(rtc::SRTP_AEAD_AES_128_GCM); } crypto_suites->push_back(rtc::SRTP_AES128_CM_SHA1_80); -#endif } void GetDefaultSrtpCryptoSuiteNames(const rtc::CryptoOptions& crypto_options, @@ -762,7 +754,6 @@ static bool CreateMediaContentOffer( return false; } -#ifdef HAVE_SRTP if (secure_policy != SEC_DISABLED) { if (current_cryptos) { AddMediaCryptos(*current_cryptos, offer); @@ -773,7 +764,6 @@ static bool CreateMediaContentOffer( } } } -#endif if (secure_policy == SEC_REQUIRED && offer->cryptos().empty()) { return false; diff --git a/webrtc/pc/mediasession_unittest.cc b/webrtc/pc/mediasession_unittest.cc index 6837e50fa6..7fe4b51fa8 100644 --- a/webrtc/pc/mediasession_unittest.cc +++ b/webrtc/pc/mediasession_unittest.cc @@ -25,13 +25,9 @@ #include "webrtc/pc/mediasession.h" #include "webrtc/pc/srtpfilter.h" -#ifdef HAVE_SRTP #define ASSERT_CRYPTO(cd, s, cs) \ ASSERT_EQ(s, cd->cryptos().size()); \ ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) -#else -#define ASSERT_CRYPTO(cd, s, cs) ASSERT_EQ(0, cd->cryptos().size()); -#endif typedef std::vector Candidates; diff --git a/webrtc/pc/srtpfilter.cc b/webrtc/pc/srtpfilter.cc index 82ab4e1432..f8537f3dd6 100644 --- a/webrtc/pc/srtpfilter.cc +++ b/webrtc/pc/srtpfilter.cc @@ -29,26 +29,11 @@ namespace cricket { -#ifndef HAVE_SRTP - -// This helper function is used on systems that don't (yet) have SRTP, -// to log that the functions that require it won't do anything. -namespace { -bool SrtpNotAvailable(const char *func) { - LOG(LS_ERROR) << func << ": SRTP is not available on your system."; - return false; -} -} // anonymous namespace - -#endif // !HAVE_SRTP - // NOTE: This is called from ChannelManager D'tor. void ShutdownSrtp() { -#ifdef HAVE_SRTP // If srtp_dealloc is not executed then this will clear all existing sessions. // This should be called when application is shutting down. SrtpSession::Terminate(); -#endif } SrtpFilter::SrtpFilter() { @@ -476,8 +461,6 @@ bool SrtpFilter::ParseKeyParams(const std::string& key_params, /////////////////////////////////////////////////////////////////////////////// // SrtpSession -#ifdef HAVE_SRTP - bool SrtpSession::inited_ = false; // This lock protects SrtpSession::inited_. @@ -824,54 +807,9 @@ void SrtpSession::HandleEventThunk(srtp_event_data_t* ev) { } } -#else // !HAVE_SRTP - -// On some systems, SRTP is not (yet) available. - -SrtpSession::SrtpSession() { - LOG(WARNING) << "SRTP implementation is missing."; -} - -SrtpSession::~SrtpSession() { -} - -bool SrtpSession::SetSend(const std::string& cs, const uint8_t* key, int len) { - return SrtpNotAvailable(__FUNCTION__); -} - -bool SrtpSession::SetRecv(const std::string& cs, const uint8_t* key, int len) { - return SrtpNotAvailable(__FUNCTION__); -} - -bool SrtpSession::ProtectRtp(void* data, int in_len, int max_len, - int* out_len) { - return SrtpNotAvailable(__FUNCTION__); -} - -bool SrtpSession::ProtectRtcp(void* data, int in_len, int max_len, - int* out_len) { - return SrtpNotAvailable(__FUNCTION__); -} - -bool SrtpSession::UnprotectRtp(void* data, int in_len, int* out_len) { - return SrtpNotAvailable(__FUNCTION__); -} - -bool SrtpSession::UnprotectRtcp(void* data, int in_len, int* out_len) { - return SrtpNotAvailable(__FUNCTION__); -} - -void SrtpSession::set_signal_silent_time(uint32_t signal_silent_time) { - // Do nothing. -} - -#endif // HAVE_SRTP - /////////////////////////////////////////////////////////////////////////////// // SrtpStat -#ifdef HAVE_SRTP - SrtpStat::SrtpStat() : signal_silent_time_(1000) { } @@ -939,35 +877,4 @@ void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) { } } -#else // !HAVE_SRTP - -// On some systems, SRTP is not (yet) available. - -SrtpStat::SrtpStat() - : signal_silent_time_(1000) { - LOG(WARNING) << "SRTP implementation is missing."; -} - -void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) { - SrtpNotAvailable(__FUNCTION__); -} - -void SrtpStat::AddUnprotectRtpResult(uint32_t ssrc, int result) { - SrtpNotAvailable(__FUNCTION__); -} - -void SrtpStat::AddProtectRtcpResult(int result) { - SrtpNotAvailable(__FUNCTION__); -} - -void SrtpStat::AddUnprotectRtcpResult(int result) { - SrtpNotAvailable(__FUNCTION__); -} - -void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) { - SrtpNotAvailable(__FUNCTION__); -} - -#endif // HAVE_SRTP - } // namespace cricket