Skip to content

Commit

Permalink
Added earlier checks when setting SRTP policy from profile
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Sep 15, 2023
1 parent b1d4e3c commit fb533df
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/impl/dtlssrtptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,13 @@ void DtlsSrtpTransport::postHandshake() {
std::memcpy(mServerSessionKey.data() + keySize, serverSalt, saltSize);

srtp_policy_t inbound = {};
srtp_crypto_policy_set_from_profile_for_rtp(&inbound.rtp, srtpProfile);
srtp_crypto_policy_set_from_profile_for_rtcp(&inbound.rtcp, srtpProfile);
if(srtp_crypto_policy_set_from_profile_for_rtp(&inbound.rtp, srtpProfile))
throw std::runtime_error("SRTP profile is not supported");
if(srtp_crypto_policy_set_from_profile_for_rtcp(&inbound.rtcp, srtpProfile))
throw std::runtime_error("SRTP profile is not supported");

inbound.ssrc.type = ssrc_any_inbound;
inbound.key = mIsClient ? mServerSessionKey.data() : mClientSessionKey.data();

inbound.window_size = 1024;
inbound.allow_repeat_tx = true;
inbound.next = nullptr;
Expand All @@ -340,8 +342,11 @@ void DtlsSrtpTransport::postHandshake() {
to_string(static_cast<int>(err)));

srtp_policy_t outbound = {};
srtp_crypto_policy_set_from_profile_for_rtp(&outbound.rtp, srtpProfile);
srtp_crypto_policy_set_from_profile_for_rtcp(&outbound.rtcp, srtpProfile);
if(srtp_crypto_policy_set_from_profile_for_rtp(&outbound.rtp, srtpProfile))
throw std::runtime_error("SRTP profile is not supported");
if(srtp_crypto_policy_set_from_profile_for_rtcp(&outbound.rtcp, srtpProfile))
throw std::runtime_error("SRTP profile is not supported");

outbound.ssrc.type = ssrc_any_outbound;
outbound.key = mIsClient ? mClientSessionKey.data() : mServerSessionKey.data();
outbound.window_size = 1024;
Expand Down

0 comments on commit fb533df

Please sign in to comment.