Promotoing webrtc::CryptoOptions to RTCConfiguration.
With the expanding use cases for webrtc::CryptoOptions it makes more sense for
it to be be available per peer connection instead of only as a factory option.
To support backwards compatability for now this code will support the factory
method of setting crypto options by default. However it will completely
overwrite these settings if an RTCConfiguration.crypto_options is provided.
Got LGTM offline from Sami, adding him to TBR if he has any further comments.
TBR=sakal@webrtc.org
Bug: webrtc:9891
Change-Id: I86914cab69284ad82afd7285fd84ec5f4f2c4986
Reviewed-on: https://webrtc-review.googlesource.com/c/107029
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25375}
diff --git a/sdk/objc/unittests/RTCConfigurationTest.mm b/sdk/objc/unittests/RTCConfigurationTest.mm
index 1ef718a..67a303e 100644
--- a/sdk/objc/unittests/RTCConfigurationTest.mm
+++ b/sdk/objc/unittests/RTCConfigurationTest.mm
@@ -50,6 +50,10 @@
RTCContinualGatheringPolicyGatherContinually;
config.shouldPruneTurnPorts = YES;
config.iceRegatherIntervalRange = range;
+ config.cryptoOptions = [[RTCCryptoOptions alloc] initWithSrtpEnableGcmCryptoSuites:YES
+ srtpEnableAes128Sha1_32CryptoCipher:YES
+ srtpEnableEncryptedRtpHeaderExtensions:YES
+ sframeRequireFrameEncryption:YES];
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
nativeConfig([config createNativeConfiguration]);
@@ -78,6 +82,10 @@
EXPECT_EQ(true, nativeConfig->prune_turn_ports);
EXPECT_EQ(range.min, nativeConfig->ice_regather_interval_range->min());
EXPECT_EQ(range.max, nativeConfig->ice_regather_interval_range->max());
+ EXPECT_EQ(true, nativeConfig->crypto_options->srtp.enable_gcm_crypto_suites);
+ EXPECT_EQ(true, nativeConfig->crypto_options->srtp.enable_aes128_sha1_32_crypto_cipher);
+ EXPECT_EQ(true, nativeConfig->crypto_options->srtp.enable_encrypted_rtp_header_extensions);
+ EXPECT_EQ(true, nativeConfig->crypto_options->sframe.require_frame_encryption);
}
- (void)testNativeConversionToConfiguration {
@@ -103,6 +111,10 @@
RTCContinualGatheringPolicyGatherContinually;
config.shouldPruneTurnPorts = YES;
config.iceRegatherIntervalRange = range;
+ config.cryptoOptions = [[RTCCryptoOptions alloc] initWithSrtpEnableGcmCryptoSuites:YES
+ srtpEnableAes128Sha1_32CryptoCipher:NO
+ srtpEnableEncryptedRtpHeaderExtensions:NO
+ sframeRequireFrameEncryption:NO];
webrtc::PeerConnectionInterface::RTCConfiguration *nativeConfig =
[config createNativeConfiguration];
@@ -130,6 +142,19 @@
EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts);
EXPECT_EQ(config.iceRegatherIntervalRange.min, newConfig.iceRegatherIntervalRange.min);
EXPECT_EQ(config.iceRegatherIntervalRange.max, newConfig.iceRegatherIntervalRange.max);
+ EXPECT_EQ(config.cryptoOptions.srtpEnableGcmCryptoSuites,
+ newConfig.cryptoOptions.srtpEnableGcmCryptoSuites);
+ EXPECT_EQ(config.cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher,
+ newConfig.cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher);
+ EXPECT_EQ(config.cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions,
+ newConfig.cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions);
+ EXPECT_EQ(config.cryptoOptions.sframeRequireFrameEncryption,
+ newConfig.cryptoOptions.sframeRequireFrameEncryption);
+}
+
+- (void)testDefaultValues {
+ RTCConfiguration *config = [[RTCConfiguration alloc] init];
+ EXPECT_EQ(config.cryptoOptions, nil);
}
@end
@@ -139,5 +164,6 @@
RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init];
[test testConversionToNativeConfiguration];
[test testNativeConversionToConfiguration];
+ [test testDefaultValues];
}
}