Skip to content

Commit

Permalink
Revert "Add a flag to actively reset the SRTP parameters"
Browse files Browse the repository at this point in the history
This reverts commit bae1031.

Reason for revert: Merge native code change with Android and Objc wrapper.

Original change's description:
> Add a flag to actively reset the SRTP parameters
> 
> Add a new flag to RtcConfiguration. By setting that flag to true, the
> SRTP parameters will be reset whenever the DTLS transports are reset
> after every offer/answer negotiation.
> 
> This should only be used as a workaround for the linked bug, if the
> application knows that the other party is affected (for instance,
> using a version number).
> 
> Bug: chromium:835958
> Change-Id: Ifb4b99f68dc272507728ab59c07627f0d1b9c605
> Reviewed-on: https://webrtc-review.googlesource.com/81642
> Commit-Queue: Zhi Huang <[email protected]>
> Reviewed-by: Taylor Brandstetter <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#23570}

[email protected],[email protected]

Change-Id: Ibd7a3b8f45ff8df4af33d758f8fd3e2d5158e8e2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:835958
Reviewed-on: https://webrtc-review.googlesource.com/83080
Reviewed-by: Zhi Huang <[email protected]>
Commit-Queue: Zhi Huang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#23571}
  • Loading branch information
zhihuang0718 authored and Commit Bot committed Jun 12, 2018
1 parent bae1031 commit 6c789e0
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 74 deletions.
7 changes: 0 additions & 7 deletions api/peerconnectioninterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,6 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
// For all other users, specify kUnifiedPlan.
SdpSemantics sdp_semantics = SdpSemantics::kPlanB;

// Actively reset the SRTP parameters whenever the DTLS transports
// underneath are reset for every offer/answer negotiation.
// This is only intended to be a workaround for crbug.com/835958
// WARNING: This would cause RTP/RTCP packets decryption failure if not used
// correctly. This flag will be deprecated soon. Do not rely on it.
bool active_reset_srtp_params = false;

//
// Don't forget to update operator== if adding something.
//
Expand Down
5 changes: 1 addition & 4 deletions pc/dtlssrtptransport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ void DtlsSrtpTransport::SetDtlsTransports(
// When using DTLS-SRTP, we must reset the SrtpTransport every time the
// DtlsTransport changes and wait until the DTLS handshake is complete to set
// the newly negotiated parameters.
// If |active_reset_srtp_params_| is true, intentionally reset the SRTP
// parameter even though the DtlsTransport may not change.
if (IsSrtpActive() && (rtp_dtls_transport != rtp_dtls_transport_ ||
active_reset_srtp_params_)) {
if (IsSrtpActive() && rtp_dtls_transport != rtp_dtls_transport_) {
ResetParams();
}

Expand Down
8 changes: 0 additions & 8 deletions pc/dtlssrtptransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ class DtlsSrtpTransport : public SrtpTransport {
"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) {
active_reset_srtp_params_ = active_reset_srtp_params;
}

private:
bool IsDtlsActive();
bool IsDtlsConnected();
Expand Down Expand Up @@ -90,8 +84,6 @@ class DtlsSrtpTransport : public SrtpTransport {
// The encrypted header extension IDs.
rtc::Optional<std::vector<int>> send_extension_ids_;
rtc::Optional<std::vector<int>> recv_extension_ids_;

bool active_reset_srtp_params_ = false;
};

} // namespace webrtc
Expand Down
48 changes: 0 additions & 48 deletions pc/dtlssrtptransport_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,51 +510,3 @@ TEST_F(DtlsSrtpTransportTest, SrtpSessionNotResetWhenRtcpTransportRemoved) {
// errors when a packet with a duplicate SRTCP index is received.
SendRecvRtcpPackets();
}

// Tests that RTCP packets can be sent and received if both sides actively reset
// the SRTP parameters with the |active_reset_srtp_params_| flag.
TEST_F(DtlsSrtpTransportTest, ActivelyResetSrtpParams) {
auto rtp_dtls1 = rtc::MakeUnique<FakeDtlsTransport>(
"audio", cricket::ICE_CANDIDATE_COMPONENT_RTP);
auto rtcp_dtls1 = rtc::MakeUnique<FakeDtlsTransport>(
"audio", cricket::ICE_CANDIDATE_COMPONENT_RTCP);
auto rtp_dtls2 = rtc::MakeUnique<FakeDtlsTransport>(
"audio", cricket::ICE_CANDIDATE_COMPONENT_RTP);
auto rtcp_dtls2 = rtc::MakeUnique<FakeDtlsTransport>(
"audio", cricket::ICE_CANDIDATE_COMPONENT_RTCP);

MakeDtlsSrtpTransports(rtp_dtls1.get(), rtcp_dtls1.get(), rtp_dtls2.get(),
rtcp_dtls2.get(), /*rtcp_mux_enabled=*/true);
CompleteDtlsHandshake(rtp_dtls1.get(), rtp_dtls2.get());
CompleteDtlsHandshake(rtcp_dtls1.get(), rtcp_dtls2.get());

// Send some RTCP packets, causing the SRTCP index to be incremented.
SendRecvRtcpPackets();

// Only set the |active_reset_srtp_params_| flag to be true one side.
dtls_srtp_transport1_->SetActiveResetSrtpParams(true);
// Set RTCP transport to null to trigger the SRTP parameters update.
dtls_srtp_transport1_->SetDtlsTransports(rtp_dtls1.get(), nullptr);
dtls_srtp_transport2_->SetDtlsTransports(rtp_dtls2.get(), nullptr);

// Sending some RTCP packets.
size_t rtcp_len = sizeof(kRtcpReport);
size_t packet_size = rtcp_len + 4 + kRtpAuthTagLen;
rtc::Buffer rtcp_packet_buffer(packet_size);
rtc::CopyOnWriteBuffer rtcp_packet(kRtcpReport, rtcp_len, packet_size);
int prev_received_packets = transport_observer2_.rtcp_count();
ASSERT_TRUE(dtls_srtp_transport1_->SendRtcpPacket(
&rtcp_packet, rtc::PacketOptions(), cricket::PF_SRTP_BYPASS));
// The RTCP packet is not exepected to be received because the SRTP parameters
// are only reset on one side and the SRTCP index is out of sync.
EXPECT_EQ(prev_received_packets, transport_observer2_.rtcp_count());

// Set the flag to be true on the other side.
dtls_srtp_transport2_->SetActiveResetSrtpParams(true);
// Set RTCP transport to null to trigger the SRTP parameters update.
dtls_srtp_transport1_->SetDtlsTransports(rtp_dtls1.get(), nullptr);
dtls_srtp_transport2_->SetDtlsTransports(rtp_dtls2.get(), nullptr);

// RTCP packets flow is expected to work just fine.
SendRecvRtcpPackets();
}
2 changes: 0 additions & 2 deletions pc/jseptransportcontroller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,6 @@ JsepTransportController::CreateDtlsSrtpTransport(

dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport,
rtcp_dtls_transport);
dtls_srtp_transport->SetActiveResetSrtpParams(
config_.active_reset_srtp_params);
return dtls_srtp_transport;
}

Expand Down
1 change: 0 additions & 1 deletion pc/jseptransportcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class JsepTransportController : public sigslot::has_slots<>,
// Used to inject the ICE/DTLS transports created externally.
cricket::TransportFactoryInterface* external_transport_factory = nullptr;
Observer* transport_observer = nullptr;
bool active_reset_srtp_params = false;
};

// The ICE related events are signaled on the |signaling_thread|.
Expand Down
5 changes: 1 addition & 4 deletions pc/peerconnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
webrtc::TurnCustomizer* turn_customizer;
SdpSemantics sdp_semantics;
rtc::Optional<rtc::AdapterType> network_preference;
bool active_reset_srtp_params;
};
static_assert(sizeof(stuff_being_tested_for_equality) == sizeof(*this),
"Did you add something to RTCConfiguration and forget to "
Expand Down Expand Up @@ -740,8 +739,7 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
ice_regather_interval_range == o.ice_regather_interval_range &&
turn_customizer == o.turn_customizer &&
sdp_semantics == o.sdp_semantics &&
network_preference == o.network_preference &&
active_reset_srtp_params == o.active_reset_srtp_params;
network_preference == o.network_preference;
}

bool PeerConnectionInterface::RTCConfiguration::operator!=(
Expand Down Expand Up @@ -939,7 +937,6 @@ bool PeerConnection::Initialize(
#if defined(ENABLE_EXTERNAL_AUTH)
config.enable_external_auth = true;
#endif
config.active_reset_srtp_params = configuration.active_reset_srtp_params;
transport_controller_.reset(new JsepTransportController(
signaling_thread(), network_thread(), port_allocator_.get(), config));
transport_controller_->SignalIceConnectionState.connect(
Expand Down

0 comments on commit 6c789e0

Please sign in to comment.