Removed all code enclosed in WEBRTC_SRTP #ifdefs, and the unsupported VoE SRTP APIs. Test stubs are left in place as we still have the (De)RegisterExternalEncryption() APIs, although they are currently untested.

Today I had to figure out this code was legacy. Now next person doesn't have to.

BUG=

Review URL: https://webrtc-codereview.appspot.com/1247004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3738 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
solenberg@webrtc.org 2013-03-28 09:14:36 +00:00
parent 80fccc29de
commit a442d4d983
14 changed files with 32 additions and 1405 deletions

View File

@ -136,27 +136,6 @@ enum ProcessingTypes
kRecordingPreprocessing
};
// Encryption enums
enum CipherTypes
{
kCipherNull = 0,
kCipherAes128CounterMode = 1
};
enum AuthenticationTypes
{
kAuthNull = 0,
kAuthHmacSha1 = 3
};
enum SecurityLevels
{
kNoProtection = 0,
kEncryption = 1,
kAuthentication = 2,
kEncryptionAndAuthentication = 3
};
// Interface for encrypting and decrypting regular data and rtp/rtcp packets.
// Implement this interface if you wish to provide an encryption scheme to
// the voice or video engines.

View File

@ -152,7 +152,5 @@
// #define WEBRTC_CODEC_G729
// #define WEBRTC_DTMF_DETECTION
// #define WEBRTC_SRTP
// #define WEBRTC_SRTP_ALLOW_ROC_ITERATION
#endif // WEBRTC_ENGINE_CONFIGURATIONS_H_

View File

@ -102,8 +102,8 @@ enum ViEErrors {
// ViEEncryption.
kViEEncryptionInvalidChannelId = 12700, // Channel id does not exist.
kViEEncryptionInvalidSrtpParameter, // EnableSRTPSend, EnableSRTPReceive- Check the SRTP parameters.
kViEEncryptionSrtpNotSupported, // This build does not support SRTP.
kViEEncryptionInvalidSrtpParameter, // DEPRECATED
kViEEncryptionSrtpNotSupported, // DEPRECATED
kViEEncryptionUnknownError, // An unknown error has occurred. Check the log file.
// ViEImageProcess.

View File

@ -103,59 +103,6 @@ void ViEAutoTest::ViEEncryptionStandardTest()
RenderCaptureDeviceAndOutputStream(&ViE, &tbChannel, &tbCapture);
#ifdef WEBRTC_SRTP
//***************************************************************
// Engine ready. Begin testing class
//***************************************************************
//
// SRTP
//
unsigned char srtpKey1[30] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9};
// Encryption only
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1));
ViETest::Log("SRTP encryption only");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Authentication only
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
20, 4, webrtc::kAuthentication, srtpKey1));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
20, 4, webrtc::kAuthentication, srtpKey1));
ViETest::Log("SRTP authentication only");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Full protection
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey1));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey1));
ViETest::Log("SRTP full protection");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
#endif // WEBRTC_SRTP
//
// External encryption
//
@ -199,104 +146,6 @@ void ViEAutoTest::ViEEncryptionExtendedTest()
// Engine ready. Begin testing class
//***************************************************************
#ifdef WEBRTC_SRTP
//
// SRTP
//
unsigned char srtpKey1[30] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9};
unsigned char srtpKey2[30] =
{ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6,
5, 4, 3, 2, 1, 0};
// NULL
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0,
webrtc::kNoProtection, srtpKey1));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0,
webrtc::kNoProtection, srtpKey1));
ViETest::Log("SRTP NULL encryption/authentication");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Encryption only
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1));
ViETest::Log("SRTP encryption only");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Authentication only
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
20, 4, webrtc::kAuthentication, srtpKey1));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
20, 4, webrtc::kAuthentication, srtpKey1));
ViETest::Log("SRTP authentication only");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Full protection
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey1));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey1));
ViETest::Log("SRTP full protection");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Change receive key, but not send key...
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey2));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey1));
ViETest::Log(
"\nSRTP receive key changed, you should not see any remote images");
AutoTestSleep(kAutoTestSleepTimeMs);
// Change send key too
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey2));
ViETest::Log("\nSRTP send key changed too, you should see remote video "
"again with some decoding artefacts at start");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
// Disable receive, keep send
ViETest::Log("SRTP receive disabled , you shouldn't see any video");
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
#endif //WEBRTC_SRTP
//
// External encryption
//
@ -334,227 +183,6 @@ void ViEAutoTest::ViEEncryptionAPITest()
// Connect to channel
tbCapture.ConnectTo(tbChannel.videoChannel);
#ifdef WEBRTC_SRTP
unsigned char srtpKey[30] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9};
//
// EnableSRTPSend and DisableSRTPSend
//
// Incorrect input argument, complete protection not enabled
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kNoProtection, srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryption, srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kAuthentication, srtpKey));
// Incorrect cipher key length
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 15,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 257,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 15, webrtc::kAuthHmacSha1,
20, 4, webrtc::kEncryptionAndAuthentication, srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 257, webrtc::kAuthHmacSha1,
20, 4, webrtc::kEncryptionAndAuthentication, srtpKey));
// Incorrect auth key length
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode,
30, webrtc::kAuthHmacSha1, 21, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 257, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 21, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 20, 13, webrtc::kEncryptionAndAuthentication,
srtpKey));
// NULL input
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
NULL));
// Double enable and disable
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
// Note(qhogpat): the second check is likely incorrect.
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// No protection
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0,
webrtc::kNoProtection, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Authentication only
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
20, 4, webrtc::kAuthentication, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
1, 4, webrtc::kAuthentication, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
20, 20, webrtc::kAuthentication, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
1, 1, webrtc::kAuthentication, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Encryption only
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 16,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// Full protection
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
//
// EnableSRTPReceive and DisableSRTPReceive
//
// Incorrect input argument, complete protection not enabled
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kNoProtection, srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryption, srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kAuthentication, srtpKey));
// Incorrect cipher key length
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 15,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 257,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 15, webrtc::kAuthHmacSha1,
20, 4, webrtc::kEncryptionAndAuthentication, srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 257, webrtc::kAuthHmacSha1,
20, 4, webrtc::kEncryptionAndAuthentication, srtpKey));
// Incorrect auth key length
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 21, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 257, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 21, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 20, 13, webrtc::kEncryptionAndAuthentication,
srtpKey));
// NULL input
EXPECT_NE(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
NULL));
// Double enable and disable
EXPECT_EQ(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_NE(0, ViE.encryption->EnableSRTPSend(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel));
// No protection
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0,
webrtc::kNoProtection, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
// Authentication only
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
1, 4, webrtc::kAuthentication, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 0,
webrtc::kAuthHmacSha1, 20, 20, webrtc::kAuthentication, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1,
1, 1, webrtc::kAuthentication, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
// Encryption only
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 16,
webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
// Full protection
EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive(
tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30,
webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication,
srtpKey));
EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel));
#endif //WEBRTC_SRTP
//
// External encryption
//

View File

@ -1032,10 +1032,6 @@ Channel::Channel(const WebRtc_Word32 channelId,
_numSocketThreads(KNumSocketThreads),
_socketTransportModule(*UdpTransport::Create(
VoEModuleId(instanceId, channelId), _numSocketThreads)),
#endif
#ifdef WEBRTC_SRTP
_srtpModule(*SrtpModule::CreateSrtpModule(VoEModuleId(instanceId,
channelId))),
#endif
_rtpDumpIn(*RtpDump::CreateRtpDump()),
_rtpDumpOut(*RtpDump::CreateRtpDump()),
@ -1241,9 +1237,6 @@ Channel::~Channel()
&_socketTransportModule);
#endif
AudioCodingModule::Destroy(&_audioCodingModule);
#ifdef WEBRTC_SRTP
SrtpModule::DestroySrtpModule(&_srtpModule);
#endif
if (_rxAudioProcessingModulePtr != NULL)
{
AudioProcessing::Destroy(_rxAudioProcessingModulePtr); // far end APM
@ -4018,236 +4011,6 @@ Channel::GetChannelOutputVolumeScaling(float& scaling) const
return 0;
}
#ifdef WEBRTC_SRTP
int
Channel::EnableSRTPSend(
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP)
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::EnableSRTPSend()");
CriticalSectionScoped cs(&_callbackCritSect);
if (_encrypting)
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_OPERATION, kTraceWarning,
"EnableSRTPSend() encryption already enabled");
return -1;
}
if (key == NULL)
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_ARGUMENT, kTraceWarning,
"EnableSRTPSend() invalid key string");
return -1;
}
if (((kEncryption == level ||
kEncryptionAndAuthentication == level) &&
(cipherKeyLength < kVoiceEngineMinSrtpEncryptLength ||
cipherKeyLength > kVoiceEngineMaxSrtpEncryptLength)) ||
((kAuthentication == level ||
kEncryptionAndAuthentication == level) &&
kAuthHmacSha1 == authType &&
(authKeyLength > kVoiceEngineMaxSrtpAuthSha1Length ||
authTagLength > kVoiceEngineMaxSrtpAuthSha1Length)) ||
((kAuthentication == level ||
kEncryptionAndAuthentication == level) &&
kAuthNull == authType &&
(authKeyLength > kVoiceEngineMaxSrtpKeyAuthNullLength ||
authTagLength > kVoiceEngineMaxSrtpTagAuthNullLength)))
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
"EnableSRTPSend() invalid key length(s)");
return -1;
}
if (_srtpModule.EnableSRTPEncrypt(
!useForRTCP,
(SrtpModule::CipherTypes)cipherType,
cipherKeyLength,
(SrtpModule::AuthenticationTypes)authType,
authKeyLength, authTagLength,
(SrtpModule::SecurityLevels)level,
key) == -1)
{
_engineStatisticsPtr->SetLastError(
VE_SRTP_ERROR, kTraceError,
"EnableSRTPSend() failed to enable SRTP encryption");
return -1;
}
if (_encryptionPtr == NULL)
{
_encryptionPtr = &_srtpModule;
}
_encrypting = true;
return 0;
}
int
Channel::DisableSRTPSend()
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::DisableSRTPSend()");
CriticalSectionScoped cs(&_callbackCritSect);
if (!_encrypting)
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_OPERATION, kTraceWarning,
"DisableSRTPSend() SRTP encryption already disabled");
return 0;
}
_encrypting = false;
if (_srtpModule.DisableSRTPEncrypt() == -1)
{
_engineStatisticsPtr->SetLastError(
VE_SRTP_ERROR, kTraceError,
"DisableSRTPSend() failed to disable SRTP encryption");
return -1;
}
if (!_srtpModule.SRTPDecrypt() && !_srtpModule.SRTPEncrypt())
{
// Both directions are disabled
_encryptionPtr = NULL;
}
return 0;
}
int
Channel::EnableSRTPReceive(
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP)
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::EnableSRTPReceive()");
CriticalSectionScoped cs(&_callbackCritSect);
if (_decrypting)
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_OPERATION, kTraceWarning,
"EnableSRTPReceive() SRTP decryption already enabled");
return -1;
}
if (key == NULL)
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_ARGUMENT, kTraceWarning,
"EnableSRTPReceive() invalid key string");
return -1;
}
if ((((kEncryption == level) ||
(kEncryptionAndAuthentication == level)) &&
((cipherKeyLength < kVoiceEngineMinSrtpEncryptLength) ||
(cipherKeyLength > kVoiceEngineMaxSrtpEncryptLength))) ||
(((kAuthentication == level) ||
(kEncryptionAndAuthentication == level)) &&
(kAuthHmacSha1 == authType) &&
((authKeyLength > kVoiceEngineMaxSrtpAuthSha1Length) ||
(authTagLength > kVoiceEngineMaxSrtpAuthSha1Length))) ||
(((kAuthentication == level) ||
(kEncryptionAndAuthentication == level)) &&
(kAuthNull == authType) &&
((authKeyLength > kVoiceEngineMaxSrtpKeyAuthNullLength) ||
(authTagLength > kVoiceEngineMaxSrtpTagAuthNullLength))))
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
"EnableSRTPReceive() invalid key length(s)");
return -1;
}
if (_srtpModule.EnableSRTPDecrypt(
!useForRTCP,
(SrtpModule::CipherTypes)cipherType,
cipherKeyLength,
(SrtpModule::AuthenticationTypes)authType,
authKeyLength,
authTagLength,
(SrtpModule::SecurityLevels)level,
key) == -1)
{
_engineStatisticsPtr->SetLastError(
VE_SRTP_ERROR, kTraceError,
"EnableSRTPReceive() failed to enable SRTP decryption");
return -1;
}
if (_encryptionPtr == NULL)
{
_encryptionPtr = &_srtpModule;
}
_decrypting = true;
return 0;
}
int
Channel::DisableSRTPReceive()
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::DisableSRTPReceive()");
CriticalSectionScoped cs(&_callbackCritSect);
if (!_decrypting)
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_OPERATION, kTraceWarning,
"DisableSRTPReceive() SRTP decryption already disabled");
return 0;
}
_decrypting = false;
if (_srtpModule.DisableSRTPDecrypt() == -1)
{
_engineStatisticsPtr->SetLastError(
VE_SRTP_ERROR, kTraceError,
"DisableSRTPReceive() failed to disable SRTP decryption");
return -1;
}
if (!_srtpModule.SRTPDecrypt() && !_srtpModule.SRTPEncrypt())
{
_encryptionPtr = NULL;
}
return 0;
}
#endif
int
Channel::RegisterExternalEncryption(Encryption& encryption)
{

View File

@ -30,9 +30,6 @@
#ifndef WEBRTC_EXTERNAL_TRANSPORT
#include "webrtc/modules/udp_transport/interface/udp_transport.h"
#endif
#ifdef WEBRTC_SRTP
#include "SrtpModule.h"
#endif
#ifdef WEBRTC_DTMF_DETECTION
#include "voe_dtmf.h" // TelephoneEventDetectionMethods, TelephoneEventObserver
#endif
@ -259,28 +256,6 @@ public:
int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
// VoEEncryption
#ifdef WEBRTC_SRTP
int EnableSRTPSend(
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP);
int DisableSRTPSend();
int EnableSRTPReceive(
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP);
int DisableSRTPReceive();
#endif
int RegisterExternalEncryption(Encryption& encryption);
int DeRegisterExternalEncryption();
@ -538,9 +513,6 @@ private:
#ifndef WEBRTC_EXTERNAL_TRANSPORT
WebRtc_UWord8 _numSocketThreads;
UdpTransport& _socketTransportModule;
#endif
#ifdef WEBRTC_SRTP
SrtpModule& _srtpModule;
#endif
RtpDump& _rtpDumpIn;
RtpDump& _rtpDumpOut;

View File

@ -53,24 +53,6 @@ public:
// for the selected |channel|.
virtual int DeRegisterExternalEncryption(int channel) = 0;
// Not supported
virtual int EnableSRTPSend(int channel, CipherTypes cipherType,
int cipherKeyLength, AuthenticationTypes authType, int authKeyLength,
int authTagLength, SecurityLevels level, const unsigned char key[30],
bool useForRTCP = false) = 0;
// Not supported
virtual int DisableSRTPSend(int channel) = 0;
// Not supported
virtual int EnableSRTPReceive(int channel, CipherTypes cipherType,
int cipherKeyLength, AuthenticationTypes authType, int authKeyLength,
int authTagLength, SecurityLevels level, const unsigned char key[30],
bool useForRTCP = false) = 0;
// Not supported
virtual int DisableSRTPReceive(int channel) = 0;
protected:
VoEEncryption() {}
virtual ~VoEEncryption() {}

View File

@ -29,7 +29,6 @@
#include "voe_test_interface.h"
//#define USE_SRTP
//#define INIT_FROM_THREAD
//#define START_CALL_FROM_THREAD
@ -767,20 +766,6 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartListen(
jobject,
jint channel)
{
#ifdef USE_SRTP
VALIDATE_ENCRYPT_POINTER;
bool useForRTCP = false;
if (veData1.encrypt->EnableSRTPReceive(
channel,CIPHER_AES_128_COUNTER_MODE,30,AUTH_HMAC_SHA1,
16,4, ENCRYPTION_AND_AUTHENTICATION,
(unsigned char*)nikkey, useForRTCP) != 0)
{
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
"Failed to enable SRTP receive");
return -1;
}
#endif
VALIDATE_BASE_POINTER;
int retVal = veData1.base->StartReceive(channel);
@ -834,19 +819,6 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StartSend(
"Failed to enable FEC");
return -1;
} */
#ifdef USE_SRTP
VALIDATE_ENCRYPT_POINTER;
bool useForRTCP = false;
if (veData1.encrypt->EnableSRTPSend(
channel,CIPHER_AES_128_COUNTER_MODE,30,AUTH_HMAC_SHA1,
16,4, ENCRYPTION_AND_AUTHENTICATION,
(unsigned char*)nikkey, useForRTCP) != 0)
{
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
"Failed to enable SRTP send");
return -1;
}
#endif
VALIDATE_BASE_POINTER;
int retVal = veData1.base->StartSend(channel);
@ -862,16 +834,6 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopListen(
jobject,
jint channel)
{
#ifdef USE_SRTP
VALIDATE_ENCRYPT_POINTER;
if (veData1.encrypt->DisableSRTPReceive(channel) != 0)
{
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
"Failed to disable SRTP receive");
return -1;
}
#endif
VALIDATE_BASE_POINTER;
return veData1.base->StopReceive(channel);
}
@ -903,16 +865,6 @@ JNIEXPORT jint JNICALL Java_org_webrtc_voiceengine_test_AndroidTest_StopSend(
return -1;
} */
#ifdef USE_SRTP
VALIDATE_ENCRYPT_POINTER;
if (veData1.encrypt->DisableSRTPSend(channel) != 0)
{
__android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
"Failed to disable SRTP send");
return -1;
}
#endif
VALIDATE_BASE_POINTER;
return veData1.base->StopSend(channel);
}

View File

@ -2902,7 +2902,6 @@ int VoEExtendedTest::TestEncryption() {
VoEBase* voe_base_ = _mgr.BasePtr();
VoEFile* file = _mgr.FilePtr();
VoEEncryption* encrypt = _mgr.EncryptionPtr();
VoENetwork* voe_network = _mgr.NetworkPtr();
#ifdef _USE_EXTENDED_TRACE_
@ -2929,474 +2928,17 @@ int VoEExtendedTest::TestEncryption() {
TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(),
true, true));
///////////////////////////
///////////////////////////
// Actual test starts here
unsigned char key1[30] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
#ifdef WEBRTC_SRTP
unsigned char key2[30]; // Different than key1 in first position
memcpy(key2, key1, 30);
key2[0] = 99;
unsigned char key3[30]; // Different than key1 in last position
memcpy(key3, key1, 30);
key3[29] = 99;
unsigned char key4[29]; // Same as key1 but shorter
memcpy(key4, key1, 29);
TEST(SRTP - Fail tests); ANL();
// Send
// Incorrect parameters when not all protection is enabled
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kNoProtection, key1));
TEST_MUSTPASS(VE_SRTP_ERROR != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kEncryption key1));
TEST_MUSTPASS(VE_SRTP_ERROR != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kAuthentication, key1));
TEST_MUSTPASS(VE_SRTP_ERROR != voe_base_->LastError());
MARK();
// Incorrect cipher key length
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 15,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 257,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 15, kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 257, kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// Incorrect auth key length
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 21, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthNull, 257, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// Incorrect auth tag length
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 21,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthNull, 20, 13,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// key NULL pointer
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, NULL));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// Same for receive
// Incorrect parameters when not all protection is enabled
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kNoProtection, key1));
TEST_MUSTPASS(VE_SRTP_ERROR != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kEncryption key1));
TEST_MUSTPASS(VE_SRTP_ERROR != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kAuthentication, key1));
TEST_MUSTPASS(VE_SRTP_ERROR != voe_base_->LastError());
MARK();
// Incorrect cipher key length
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 15,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 257,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 15,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 257,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// Incorrect auth key length
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode,
30, kAuthHmacSha1, 21, 4,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// it crashed the application
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthNull, 257, 4,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// Incorrect auth tag length
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 21,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// it crashed the application
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthNull, 20, 13,
kEncryptionAndAuthentication,
key1));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
// key NULL pointer
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
NULL));
TEST_MUSTPASS(VE_INVALID_ARGUMENT != voe_base_->LastError());
MARK();
ANL();
TEST(SRTP - Should hear audio at all time); ANL();
// Authentication only
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20,
4, kAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1,
20, 4, kAuthentication, key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
MARK(); SleepMs(2000);
ANL();
// No protection
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthNull, 0, 0,
kNoProtection, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthNull, 0, 0,
kNoProtection, key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
MARK(); SleepMs(2000);
// Encryption only
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0, kEncryption key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0,
kEncryption key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
MARK(); SleepMs(2000);
// Authentication only
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20,
4, kAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1,
20, 4, kAuthentication, key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
MARK(); SleepMs(2000);
ANL();
// Switching between keys
TEST(SRTP - Different keys - should hear audio at all time); ANL();
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key2));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key2));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(voe_base_->StopPlayout(0));
TEST_MUSTPASS(voe_base_->StopSend(0));
TEST_MUSTPASS(voe_base_->StopReceive(0));
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key2));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key2));
TEST_MUSTPASS(voe_base_->SetLocalReceiver(0, 8000));
TEST_MUSTPASS(voe_base_->SetSendDestination(0, 8000, "127.0.0.1"));
TEST_MUSTPASS(voe_base_->StartReceive(0));
TEST_MUSTPASS(voe_base_->StartPlayout(0));
TEST_MUSTPASS(voe_base_->StartSend(0));
TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(),
true, true));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
MARK(); SleepMs(2000);
ANL();
// Testing different keys that should be silent
TEST(SRTP - Should be silent or garbage); ANL();
// key1 and key2
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key2));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key2));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0, kEncryption key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0,
kEncryption key2));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1,
20, 4, kAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1,
20, 4, kAuthentication, key2));
MARK(); SleepMs(2000);
// key1 and key3
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key3));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key3));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0, kEncryption key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0,
kEncryption key3));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20,
4, kAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1,
20, 4, kAuthentication, key3));
MARK(); SleepMs(2000);
// key1 and key4
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key4));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication, key4));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1, 20, 4,
kEncryptionAndAuthentication,
key1));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0, kEncryption key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthNull, 0, 0,
kEncryption key4));
MARK(); SleepMs(2000);
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20,
4, kAuthentication, key1));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1,
20, 4, kAuthentication, key4));
MARK(); SleepMs(2000);
ANL();
// Back to normal
TEST(SRTP - Back to normal - should hear audio); ANL();
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
MARK(); SleepMs(2000);
ANL();
// SRTCP tests
TEST(SRTCP - Ignore voice or not); ANL();
VoERTP_RTCP* rtp_rtcp = _mgr.RTP_RTCPPtr();
char tmpStr[32];
// First test that RTCP packet is received and OK without encryption
TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik1"));
MARK(); SleepMs(8000);
TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr));
TEST_MUSTPASS(_stricmp("Henrik1", tmpStr));
// Enable SRTP and SRTCP send and receive
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication, key1, true));
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication, key1, true));
TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik2"));
MARK(); SleepMs(8000);
TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr));
TEST_MUSTPASS(_stricmp("Henrik2", tmpStr));
// Disable SRTP and SRTCP send
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik3"));
MARK(); SleepMs(8000);
TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr));
TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed
// Enable SRTP send, but disable SRTCP send
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik4"));
MARK(); SleepMs(8000);
TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr));
TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed
// Enable SRTP and SRTCP send, disable SRTP and SRTCP receive
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication, key1, true));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik5"));
MARK(); SleepMs(8000);
TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr));
TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed
// Enable SRTP receive, but disable SRTCP receive
TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30,
kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik6"));
MARK(); SleepMs(8000);
TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr));
TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed
// Disable all
TEST_MUSTPASS(encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik7"));
MARK(); SleepMs(8000);
TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr));
TEST_MUSTPASS(_stricmp("Henrik7", tmpStr));
ANL();
#else
TEST(SRTP disabled - Fail tests);
ANL();
TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != voe_base_->LastError());
TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1,
20, 4, kEncryptionAndAuthentication, key1));
TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != voe_base_->LastError());
TEST_MUSTPASS(!encrypt->DisableSRTPSend(0));
TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != voe_base_->LastError());
TEST_MUSTPASS(!encrypt->DisableSRTPReceive(0));
TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != voe_base_->LastError());
ANL();
#endif
AOK();
// TODO(solenberg): Test should verify that external encryption policy
// registration works, i.e.:
// VoEEncryption* encrypt = _mgr.EncryptionPtr();
// encrypt->RegisterExternalEncryption() and
// encrypt->DeRegisterExternalEncryption().
TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0));
TEST_MUSTPASS(voe_base_->StopSend(0));

View File

@ -103,7 +103,6 @@
// Some parts can cause problems while running Insure
#ifdef __INSURE__
#define _INSTRUMENTATION_TESTING_
#undef WEBRTC_SRTP
#endif
// Time in ms to test each packet size for each codec

View File

@ -2684,14 +2684,15 @@ void CWinTestDlg::OnBnClickedCheckSrtpTx1()
if (enable)
{
(_checkSrtpTx1++ %2 == 0) ? useForRTCP = false : useForRTCP = true;
TEST((ret = _veEncryptionPtr->EnableSRTPSend(channel,
kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP)) == 0,
_T("EnableSRTPSend(channel=%d, kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP=%d)"),
channel, useForRTCP);
// TODO(solenberg): Install SRTP encryption policy.
TEST(true, "Built-in SRTP support is deprecated. Enable it again by "
"setting an external encryption policy, i.e.:\n\r"
"_veEncryptionPtr->RegisterExternalEncryption(channel, myPolicy)");
}
else
{
TEST((ret = _veEncryptionPtr->DisableSRTPSend(channel) == 0), _T("DisableSRTPSend(channel=%d)"), channel);
// TODO(solenberg): Uninstall SRTP encryption policy, i.e.:
// _veEncryptionPtr->DeRegisterExternalEncryption(channel);
}
if (ret == -1)
{
@ -2711,14 +2712,15 @@ void CWinTestDlg::OnBnClickedCheckSrtpTx2()
if (enable)
{
(_checkSrtpTx2++ %2 == 0) ? useForRTCP = false : useForRTCP = true;
TEST((ret = _veEncryptionPtr->EnableSRTPSend(channel,
kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP)) == 0,
_T("EnableSRTPSend(channel=%d, kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP=%d)"),
channel, useForRTCP);
// TODO(solenberg): Install SRTP encryption policy.
TEST(true, "Built-in SRTP support is deprecated. Enable it again by "
"setting an external encryption policy, i.e.:\n\r"
"_veEncryptionPtr->RegisterExternalEncryption(channel, myPolicy)");
}
else
{
TEST((ret = _veEncryptionPtr->DisableSRTPSend(channel) == 0), _T("DisableSRTPSend(channel=%d)"), channel);
// TODO(solenberg): Uninstall SRTP encryption policy, i.e.:
// _veEncryptionPtr->DeRegisterExternalEncryption(channel);
}
if (ret == -1)
{
@ -2738,14 +2740,15 @@ void CWinTestDlg::OnBnClickedCheckSrtpRx1()
if (enable)
{
(_checkSrtpRx1++ %2 == 0) ? useForRTCP = false : useForRTCP = true;
TEST((ret = _veEncryptionPtr->EnableSRTPReceive(channel,
kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP)) == 0,
_T("EnableSRTPReceive(channel=%d, kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP=%d)"),
channel, useForRTCP);
// TODO(solenberg): Install SRTP encryption policy.
TEST(true, "Built-in SRTP support is deprecated. Enable it again by "
"setting an external encryption policy, i.e.:\n\r"
"_veEncryptionPtr->RegisterExternalEncryption(channel, myPolicy)");
}
else
{
TEST((ret = _veEncryptionPtr->DisableSRTPReceive(channel) == 0), _T("DisableSRTPReceive(channel=%d)"), channel);
// TODO(solenberg): Uninstall SRTP encryption policy, i.e.:
// _veEncryptionPtr->DeRegisterExternalEncryption(channel);
}
if (ret == -1)
{
@ -2765,14 +2768,15 @@ void CWinTestDlg::OnBnClickedCheckSrtpRx2()
if (enable)
{
(_checkSrtpRx2++ %2 == 0) ? useForRTCP = false : useForRTCP = true;
TEST((ret = _veEncryptionPtr->EnableSRTPReceive(channel,
kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP)) == 0,
_T("EnableSRTPReceive(channel=%d, kCipherAes128CounterMode, 30, kAuthHmacSha1, 20, 4, kEncryptionAndAuthentication, key, useForRTCP=%d)"),
channel, useForRTCP);
// TODO(solenberg): Install SRTP encryption policy.
TEST(true, "Built-in SRTP support is deprecated. Enable it again by "
"setting an external encryption policy, i.e.:\n\r"
"_veEncryptionPtr->RegisterExternalEncryption(channel, myPolicy)");
}
else
{
TEST((ret = _veEncryptionPtr->DisableSRTPReceive(channel)) == 0, _T("DisableSRTPReceive(channel=%d)"), channel);
// TODO(solenberg): Uninstall SRTP encryption policy, i.e.:
// _veEncryptionPtr->DeRegisterExternalEncryption(channel);
}
if (ret == -1)
{

View File

@ -48,154 +48,6 @@ VoEEncryptionImpl::~VoEEncryptionImpl()
"VoEEncryptionImpl::~VoEEncryptionImpl() - dtor");
}
int VoEEncryptionImpl::EnableSRTPSend(
int channel,
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"EnableSRTPSend(channel=%i, cipherType=%i, cipherKeyLength=%i,"
" authType=%i, authKeyLength=%i, authTagLength=%i, level=%i, "
"key=?, useForRTCP=%d)",
channel, cipherType, cipherKeyLength, authType,
authKeyLength, authTagLength, level, useForRTCP);
#ifdef WEBRTC_SRTP
if (!_shared->statistics().Initialized())
{
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"EnableSRTPSend() failed to locate channel");
return -1;
}
return channelPtr->EnableSRTPSend(cipherType,
cipherKeyLength,
authType,
authKeyLength,
authTagLength,
level,
key,
useForRTCP);
#else
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"EnableSRTPSend() SRTP is not supported");
return -1;
#endif
}
int VoEEncryptionImpl::DisableSRTPSend(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DisableSRTPSend(channel=%i)",channel);
#ifdef WEBRTC_SRTP
if (!_shared->statistics().Initialized())
{
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DisableSRTPSend() failed to locate channel");
return -1;
}
return channelPtr->DisableSRTPSend();
#else
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"DisableSRTPSend() SRTP is not supported");
return -1;
#endif
}
int VoEEncryptionImpl::EnableSRTPReceive(
int channel,
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"EnableSRTPReceive(channel=%i, cipherType=%i, "
"cipherKeyLength=%i, authType=%i, authKeyLength=%i, "
"authTagLength=%i, level=%i, key=?, useForRTCP=%d)",
channel, cipherType, cipherKeyLength, authType,
authKeyLength, authTagLength, level, useForRTCP);
#ifdef WEBRTC_SRTP
if (!_shared->statistics().Initialized())
{
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"EnableSRTPReceive() failed to locate channel");
return -1;
}
return channelPtr->EnableSRTPReceive(cipherType,
cipherKeyLength,
authType,
authKeyLength,
authTagLength,
level,
key,
useForRTCP);
#else
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"EnableSRTPReceive() SRTP is not supported");
return -1;
#endif
}
int VoEEncryptionImpl::DisableSRTPReceive(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DisableSRTPReceive(channel=%i)", channel);
#ifdef WEBRTC_SRTP
if (!_shared->statistics().Initialized())
{
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DisableSRTPReceive() failed to locate channel");
return -1;
}
return channelPtr->DisableSRTPReceive();
#else
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"DisableSRTPReceive() SRTP is not supported");
return -1;
#endif
}
int VoEEncryptionImpl::RegisterExternalEncryption(int channel,
Encryption& encryption)
{

View File

@ -20,33 +20,6 @@ namespace webrtc {
class VoEEncryptionImpl : public VoEEncryption
{
public:
// SRTP
virtual int EnableSRTPSend(
int channel,
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP = false);
virtual int DisableSRTPSend(int channel);
virtual int EnableSRTPReceive(
int channel,
CipherTypes cipherType,
int cipherKeyLength,
AuthenticationTypes authType,
int authKeyLength,
int authTagLength,
SecurityLevels level,
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP = false);
virtual int DisableSRTPReceive(int channel);
// External encryption
virtual int RegisterExternalEncryption(
int channel,

View File

@ -60,23 +60,6 @@ enum { kVoiceEngineMaxModuleVersionSize = 960 };
// Base
enum { kVoiceEngineVersionMaxMessageSize = 1024 };
// Encryption
// SRTP uses 30 bytes key length
enum { kVoiceEngineMaxSrtpKeyLength = 30 };
// SRTP minimum key/tag length for encryption level
enum { kVoiceEngineMinSrtpEncryptLength = 16 };
// SRTP maximum key/tag length for encryption level
enum { kVoiceEngineMaxSrtpEncryptLength = 256 };
// SRTP maximum key/tag length for authentication level,
// HMAC SHA1 authentication type
enum { kVoiceEngineMaxSrtpAuthSha1Length = 20 };
// SRTP maximum tag length for authentication level,
// null authentication type
enum { kVoiceEngineMaxSrtpTagAuthNullLength = 12 };
// SRTP maximum key length for authentication level,
// null authentication type
enum { kVoiceEngineMaxSrtpKeyAuthNullLength = 256 };
// Audio processing
const NoiseSuppression::Level kDefaultNsMode = NoiseSuppression::kModerate;
const GainControl::Mode kDefaultAgcMode =