|
@@ -45,6 +45,17 @@ void DtlsSrtpTransport::Init() { srtp_init(); }
|
|
|
|
|
|
void DtlsSrtpTransport::Cleanup() { srtp_shutdown(); }
|
|
|
|
|
|
+bool DtlsSrtpTransport::IsGcmSupported() {
|
|
|
+#if RTC_SYSTEM_SRTP
|
|
|
+ // system libSRTP may not have GCM support
|
|
|
+ srtp_policy_t policy = {};
|
|
|
+ return srtp_crypto_policy_set_from_profile_for_rtp(
|
|
|
+ &policy.rtp, srtp_profile_aead_aes_256_gcm) == srtp_err_status_ok;
|
|
|
+#else
|
|
|
+ return true;
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
DtlsSrtpTransport::DtlsSrtpTransport(shared_ptr<IceTransport> lower,
|
|
|
shared_ptr<Certificate> certificate, optional<size_t> mtu,
|
|
|
verifier_callback verifierCallback,
|
|
@@ -326,11 +337,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;
|
|
@@ -340,8 +353,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;
|
|
@@ -356,7 +372,7 @@ void DtlsSrtpTransport::postHandshake() {
|
|
|
}
|
|
|
|
|
|
#if !USE_GNUTLS && !USE_MBEDTLS
|
|
|
-ProfileParams DtlsSrtpTransport::getProfileParamsFromName(string_view name) {
|
|
|
+DtlsSrtpTransport::ProfileParams DtlsSrtpTransport::getProfileParamsFromName(string_view name) {
|
|
|
if (name == "SRTP_AES128_CM_SHA1_80")
|
|
|
return {srtp_profile_aes128_cm_sha1_80, SRTP_AES_128_KEY_LEN, SRTP_SALT_LEN};
|
|
|
if (name == "SRTP_AES128_CM_SHA1_32")
|