diff options
author | solenberg@webrtc.org <solenberg@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-03-28 09:14:36 +0000 |
---|---|---|
committer | solenberg@webrtc.org <solenberg@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-03-28 09:14:36 +0000 |
commit | fa2dd2236203bca19390976e39e4442270064504 (patch) | |
tree | 324488dff97917647afe4531d1f714db04903e3c /voice_engine | |
parent | 2ffc8bf69efc5cfcaae1027a78df72e7dfeb5e0b (diff) | |
download | webrtc-fa2dd2236203bca19390976e39e4442270064504.tar.gz |
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/webrtc@3738 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'voice_engine')
-rw-r--r-- | voice_engine/channel.cc | 237 | ||||
-rw-r--r-- | voice_engine/channel.h | 28 | ||||
-rw-r--r-- | voice_engine/include/voe_encryption.h | 18 | ||||
-rw-r--r-- | voice_engine/test/android/android_test/jni/android_test.cc | 48 | ||||
-rw-r--r-- | voice_engine/test/auto_test/voe_extended_test.cc | 470 | ||||
-rw-r--r-- | voice_engine/test/auto_test/voe_test_defines.h | 1 | ||||
-rw-r--r-- | voice_engine/test/win_test/WinTestDlg.cc | 44 | ||||
-rw-r--r-- | voice_engine/voe_encryption_impl.cc | 148 | ||||
-rw-r--r-- | voice_engine/voe_encryption_impl.h | 27 | ||||
-rw-r--r-- | voice_engine/voice_engine_defines.h | 17 |
10 files changed, 30 insertions, 1008 deletions
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc index 1eabee84..e26cf7f9 100644 --- a/voice_engine/channel.cc +++ b/voice_engine/channel.cc @@ -1033,10 +1033,6 @@ Channel::Channel(const WebRtc_Word32 channelId, _socketTransportModule(*UdpTransport::Create( VoEModuleId(instanceId, channelId), _numSocketThreads)), #endif -#ifdef WEBRTC_SRTP - _srtpModule(*SrtpModule::CreateSrtpModule(VoEModuleId(instanceId, - channelId))), -#endif _rtpDumpIn(*RtpDump::CreateRtpDump()), _rtpDumpOut(*RtpDump::CreateRtpDump()), _outputAudioLevel(), @@ -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) { diff --git a/voice_engine/channel.h b/voice_engine/channel.h index f1c5809b..53306196 100644 --- a/voice_engine/channel.h +++ b/voice_engine/channel.h @@ -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(); @@ -539,9 +514,6 @@ private: WebRtc_UWord8 _numSocketThreads; UdpTransport& _socketTransportModule; #endif -#ifdef WEBRTC_SRTP - SrtpModule& _srtpModule; -#endif RtpDump& _rtpDumpIn; RtpDump& _rtpDumpOut; private: diff --git a/voice_engine/include/voe_encryption.h b/voice_engine/include/voe_encryption.h index ae3f3730..bd28ae1f 100644 --- a/voice_engine/include/voe_encryption.h +++ b/voice_engine/include/voe_encryption.h @@ -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() {} diff --git a/voice_engine/test/android/android_test/jni/android_test.cc b/voice_engine/test/android/android_test/jni/android_test.cc index 8c5fdff5..146216a9 100644 --- a/voice_engine/test/android/android_test/jni/android_test.cc +++ b/voice_engine/test/android/android_test/jni/android_test.cc @@ -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); } diff --git a/voice_engine/test/auto_test/voe_extended_test.cc b/voice_engine/test/auto_test/voe_extended_test.cc index 0d5d5a61..84d7c2b3 100644 --- a/voice_engine/test/auto_test/voe_extended_test.cc +++ b/voice_engine/test/auto_test/voe_extended_test.cc @@ -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)); diff --git a/voice_engine/test/auto_test/voe_test_defines.h b/voice_engine/test/auto_test/voe_test_defines.h index 9fff35b1..2954fe6f 100644 --- a/voice_engine/test/auto_test/voe_test_defines.h +++ b/voice_engine/test/auto_test/voe_test_defines.h @@ -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 diff --git a/voice_engine/test/win_test/WinTestDlg.cc b/voice_engine/test/win_test/WinTestDlg.cc index b11c09f0..0aaeb51a 100644 --- a/voice_engine/test/win_test/WinTestDlg.cc +++ b/voice_engine/test/win_test/WinTestDlg.cc @@ -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) { diff --git a/voice_engine/voe_encryption_impl.cc b/voice_engine/voe_encryption_impl.cc index 4dbed0a6..cad762aa 100644 --- a/voice_engine/voe_encryption_impl.cc +++ b/voice_engine/voe_encryption_impl.cc @@ -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) { diff --git a/voice_engine/voe_encryption_impl.h b/voice_engine/voe_encryption_impl.h index 76124d41..1a2bf913 100644 --- a/voice_engine/voe_encryption_impl.h +++ b/voice_engine/voe_encryption_impl.h @@ -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, diff --git a/voice_engine/voice_engine_defines.h b/voice_engine/voice_engine_defines.h index ba9f8ce1..18600e11 100644 --- a/voice_engine/voice_engine_defines.h +++ b/voice_engine/voice_engine_defines.h @@ -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 = |