diff --git a/pc/dtls_srtp_transport.h b/pc/dtls_srtp_transport.h index 0f8338ca0d..995809ed4b 100644 --- a/pc/dtls_srtp_transport.h +++ b/pc/dtls_srtp_transport.h @@ -49,15 +49,6 @@ class DtlsSrtpTransport : public SrtpTransport { void SetOnDtlsStateChange(std::function callback); - RTCError SetSrtpSendKey(const cricket::CryptoParams& params) override { - return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, - "Set SRTP keys for DTLS-SRTP is not supported."); - } - RTCError SetSrtpReceiveKey(const cricket::CryptoParams& params) override { - return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, - "Set SRTP keys for DTLS-SRTP is not supported."); - } - // If `active_reset_srtp_params_` is set to be true, the SRTP parameters will // be reset whenever the DtlsTransports are reset. void SetActiveResetSrtpParams(bool active_reset_srtp_params) { diff --git a/pc/srtp_transport.cc b/pc/srtp_transport.cc index 033cca75bb..c82839ca82 100644 --- a/pc/srtp_transport.cc +++ b/pc/srtp_transport.cc @@ -37,86 +37,6 @@ SrtpTransport::SrtpTransport(bool rtcp_mux_enabled, const FieldTrialsView& field_trials) : RtpTransport(rtcp_mux_enabled), field_trials_(field_trials) {} -RTCError SrtpTransport::SetSrtpSendKey(const cricket::CryptoParams& params) { - if (send_params_) { - LOG_AND_RETURN_ERROR( - webrtc::RTCErrorType::UNSUPPORTED_OPERATION, - "Setting the SRTP send key twice is currently unsupported."); - } - if (recv_params_ && recv_params_->crypto_suite != params.crypto_suite) { - LOG_AND_RETURN_ERROR( - webrtc::RTCErrorType::UNSUPPORTED_OPERATION, - "The send key and receive key must have the same cipher suite."); - } - - send_crypto_suite_ = rtc::SrtpCryptoSuiteFromName(params.crypto_suite); - if (*send_crypto_suite_ == rtc::kSrtpInvalidCryptoSuite) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Invalid SRTP crypto suite"); - } - - int send_key_len, send_salt_len; - if (!rtc::GetSrtpKeyAndSaltLengths(*send_crypto_suite_, &send_key_len, - &send_salt_len)) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Could not get lengths for crypto suite(s):" - " send crypto_suite "); - } - - send_key_ = rtc::ZeroOnFreeBuffer(send_key_len + send_salt_len); - if (!ParseKeyParams(params.key_params, send_key_.data(), send_key_.size())) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Failed to parse the crypto key params"); - } - - if (!MaybeSetKeyParams()) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Failed to set the crypto key params"); - } - send_params_ = params; - return RTCError::OK(); -} - -RTCError SrtpTransport::SetSrtpReceiveKey(const cricket::CryptoParams& params) { - if (recv_params_) { - LOG_AND_RETURN_ERROR( - webrtc::RTCErrorType::UNSUPPORTED_OPERATION, - "Setting the SRTP send key twice is currently unsupported."); - } - if (send_params_ && send_params_->crypto_suite != params.crypto_suite) { - LOG_AND_RETURN_ERROR( - webrtc::RTCErrorType::UNSUPPORTED_OPERATION, - "The send key and receive key must have the same cipher suite."); - } - - recv_crypto_suite_ = rtc::SrtpCryptoSuiteFromName(params.crypto_suite); - if (*recv_crypto_suite_ == rtc::kSrtpInvalidCryptoSuite) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Invalid SRTP crypto suite"); - } - - int recv_key_len, recv_salt_len; - if (!rtc::GetSrtpKeyAndSaltLengths(*recv_crypto_suite_, &recv_key_len, - &recv_salt_len)) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Could not get lengths for crypto suite(s):" - " recv crypto_suite "); - } - - recv_key_ = rtc::ZeroOnFreeBuffer(recv_key_len + recv_salt_len); - if (!ParseKeyParams(params.key_params, recv_key_.data(), recv_key_.size())) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Failed to parse the crypto key params"); - } - - if (!MaybeSetKeyParams()) { - return RTCError(RTCErrorType::INVALID_PARAMETER, - "Failed to set the crypto key params"); - } - recv_params_ = params; - return RTCError::OK(); -} - bool SrtpTransport::SendRtpPacket(rtc::CopyOnWriteBuffer* packet, const rtc::PacketOptions& options, int flags) { diff --git a/pc/srtp_transport.h b/pc/srtp_transport.h index cb443d5f1c..29721f3b68 100644 --- a/pc/srtp_transport.h +++ b/pc/srtp_transport.h @@ -41,9 +41,6 @@ class SrtpTransport : public RtpTransport { virtual ~SrtpTransport() = default; - virtual RTCError SetSrtpSendKey(const cricket::CryptoParams& params); - virtual RTCError SetSrtpReceiveKey(const cricket::CryptoParams& params); - bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet, const rtc::PacketOptions& options, int flags) override;