diff -r b5e99d8877c7 -r 0dcb073356a5 rtp/srtpstack/tsrc/ut_srtpstack/src/UT_CSRTPCryptoContext.cpp --- a/rtp/srtpstack/tsrc/ut_srtpstack/src/UT_CSRTPCryptoContext.cpp Tue Aug 31 15:32:57 2010 +0300 +++ b/rtp/srtpstack/tsrc/ut_srtpstack/src/UT_CSRTPCryptoContext.cpp Wed Sep 01 12:27:36 2010 +0100 @@ -228,12 +228,6 @@ delete iSRTPSession; delete iContext2; - - iStreamIn = NULL; - iStreamOut = NULL; - iSRTPSession = NULL; - - iContext2 = NULL; } @@ -256,22 +250,22 @@ TSrtpCryptoParams params; //test constructL - iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3, + iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3, KSRTPDefSessionEncryptionKeyLength, KSRTPDefSessionAuthenticationKeyLength ); iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); - + CleanupStack::Pop( iMasterKey3 ); CleanupStack::PopAndDestroy( mki3 ); CleanupStack::PopAndDestroy( masterSalt3 ); CleanupStack::PopAndDestroy( masterKey3 ); - - + CleanupStack::PushL( iMasterKey3 ); + CleanupStack::PushL( iMasterSalt3 ); params.iSrtcpAuthTagLen=80; RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), KErrArgument ); - - + CleanupStack::Pop( iMasterSalt3 ); + CleanupStack::Pop( iMasterKey3 ); delete iContext3; } @@ -294,20 +288,25 @@ TSrtpCryptoParams params; - iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3, + iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3, KSRTPDefSessionEncryptionKeyLength, KSRTPDefSessionAuthenticationKeyLength ); iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); - + CleanupStack::Pop( iMasterKey3 ); CleanupStack::PopAndDestroy( mki3 ); CleanupStack::PopAndDestroy( masterSalt3 ); CleanupStack::PopAndDestroy( masterKey3 ); params.iSrtcpAuthTagLen=80; - RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), + + CleanupStack::PushL( iMasterKey3 ); + CleanupStack::PushL( iMasterSalt3 ); + RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), KErrArgument ); - delete iContext3; + CleanupStack::Pop( iMasterSalt3 ); + CleanupStack::Pop( iMasterKey3 ); + delete iContext3; } @@ -325,18 +324,18 @@ *mki = K128bitMKITest1; Hex(*mki); - iMasterKey4 = CSRTPMasterKey::NewL( *masterKey, *mki, + iMasterKey4 = CSRTPMasterKey::NewLC( *masterKey, *mki, KSRTPDefSessionEncryptionKeyLength, KSRTPDefSessionAuthenticationKeyLength ); iMasterSalt4 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); - + CleanupStack::Pop( iMasterKey4 ); CleanupStack::PopAndDestroy( mki ); CleanupStack::PopAndDestroy( masterSalt ); CleanupStack::PopAndDestroy( masterKey ); - - + CleanupStack::PushL( iMasterKey4 ); + CleanupStack::PushL( iMasterSalt4 ); //invalid authalg TSrtpCryptoParams params; @@ -344,8 +343,8 @@ RTP_EUNIT_ASSERT_SPECIFIC_LEAVE(iContext4=CSRTPCryptoContext::NewL(iMasterKey4,iMasterSalt4, params), KErrArgument ); - - + CleanupStack::Pop( iMasterSalt4 ); + CleanupStack::Pop( iMasterKey4 ); } void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test4L( ) @@ -362,17 +361,17 @@ *mki = K128bitMKITest1; Hex(*mki); - iMasterKey5 = CSRTPMasterKey::NewL( *masterKey, *mki, + iMasterKey5 = CSRTPMasterKey::NewLC( *masterKey, *mki, KSRTPDefSessionEncryptionKeyLength, KSRTPDefSessionAuthenticationKeyLength); iMasterSalt5 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); - + CleanupStack::Pop( iMasterKey5 ); CleanupStack::PopAndDestroy( mki ); CleanupStack::PopAndDestroy( masterSalt ); CleanupStack::PopAndDestroy( masterKey ); - - + CleanupStack::PushL( iMasterKey5 ); + CleanupStack::PushL( iMasterSalt5 ); TSrtpCryptoParams params; //invalid auth tag length in context5 @@ -380,7 +379,8 @@ RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext5=CSRTPCryptoContext::NewL(iMasterKey5,iMasterSalt5,params ), KErrArgument ); - + CleanupStack::Pop( iMasterSalt5 ); + CleanupStack::Pop( iMasterKey5 ); } void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test5L( ) @@ -396,24 +396,26 @@ CleanupStack::PushL( mki); *mki = K128bitMKITest1; Hex(*mki); - iMasterKey6 = CSRTPMasterKey::NewL( *masterKey, *mki, + iMasterKey6 = CSRTPMasterKey::NewLC( *masterKey, *mki, KSRTPDefSessionEncryptionKeyLength, KSRTPDefSessionAuthenticationKeyLength ); iMasterSalt6 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); - + CleanupStack::Pop( iMasterKey6 ); TSrtpCryptoParams params; CleanupStack::PopAndDestroy( mki ); CleanupStack::PopAndDestroy( masterSalt ); CleanupStack::PopAndDestroy( masterKey ); - + CleanupStack::PushL( iMasterKey6 ); + CleanupStack::PushL( iMasterSalt6 ); //invalid prefix length in context6 params.iPrefixLen=10; RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext6=CSRTPCryptoContext::NewL(iMasterKey6,iMasterSalt6, params ) , KErrArgument ); - + CleanupStack::Pop( iMasterSalt6 ); + CleanupStack::Pop( iMasterKey6 ); } void UT_CSRTPCryptoContext::UT_MasterKey_Test1L( ) @@ -534,26 +536,26 @@ TSrtpCryptoParams params; //test constructL - iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3 ); + iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3 ); iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3); - + CleanupStack::Pop( iMasterKey3 ); CleanupStack::PopAndDestroy( mki3 ); CleanupStack::PopAndDestroy( masterSalt3 ); CleanupStack::PopAndDestroy( masterKey3 ); - + CleanupStack::PushL( iMasterKey3 ); + CleanupStack::PushL( iMasterSalt3 ); iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ); - - + CleanupStack::Pop( iMasterSalt3 ); + CleanupStack::Pop( iMasterKey3 ); params.iSrtpAuthTagLen=112; iContext3->UpdateCryptoParams(params ); EUNIT_ASSERT(iContext->IsEqual(*iContext3)==EFalse); - delete iContext3; - iContext3 = NULL; + delete iContext3; //test only param is different HBufC8* masterKey1 = HBufC8::NewL(K128bitMasterKey1().Length()); CleanupStack::PushL( masterKey1 ); @@ -569,22 +571,22 @@ *mki = K128bitMKITest1; Hex(*mki); - iMasterKey = CSRTPMasterKey::NewL( *masterKey1, *mki, + iMasterKey = CSRTPMasterKey::NewLC( *masterKey1, *mki, KSRTPDefSessionEncryptionKeyLength, KSRTPDefSessionAuthenticationKeyLength ); iMasterSalt = CSRTPMasterSalt::NewL( *masterSalt1,KSRTPDefSessionSaltingKeyLength ); - + CleanupStack::Pop( iMasterKey ); CleanupStack::PopAndDestroy( mki ); CleanupStack::PopAndDestroy( masterSalt1 ); CleanupStack::PopAndDestroy( masterKey1 ); TSrtpCryptoParams params2; params2.iSrtpAuthTagLen=32; - - + CleanupStack::PushL( iMasterKey ); + CleanupStack::PushL( iMasterSalt ); CSRTPCryptoContext* context = CSRTPCryptoContext::NewL(iMasterKey, iMasterSalt,params2 ); EUNIT_ASSERT(!iContext->IsEqual(*context)); - - + CleanupStack::Pop( iMasterSalt ); + CleanupStack::Pop( iMasterKey ); params2.iSrtpAuthTagLen=80; params2.iMasterKeysLifeTime = 0; context->UpdateCryptoParams(params2 ); @@ -600,7 +602,7 @@ EUNIT_ASSERT(iContext->CryptoParams().iIsRCCm3Sync); } -void UT_CSRTPCryptoContext::TestIsValidL() +void UT_CSRTPCryptoContext::TestIsValid() { TSrtpCryptoParams params; //TEst cases 1 about Encryption method @@ -663,20 +665,23 @@ *mki3 = K128bitMKITest3; Hex(*mki3); - iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3, + iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3, KSRTPDefSessionAuthenticationKeyLength, KSRTPDefSessionEncryptionKeyLength ); iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); - + CleanupStack::Pop( iMasterKey3 ); CleanupStack::PopAndDestroy( mki3 ); CleanupStack::PopAndDestroy( masterSalt3 ); CleanupStack::PopAndDestroy( masterKey3 ); - + CleanupStack::PushL( iMasterKey3 ); + CleanupStack::PushL( iMasterSalt3 ); RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), KErrArgument ); + CleanupStack::Pop( iMasterSalt3 ); + CleanupStack::Pop( iMasterKey3 ); } void UT_CSRTPCryptoContext::SRTPMasterKeyStaleEvent(const CSRTPStream& /*aStream*/) @@ -823,7 +828,7 @@ "CSRTPCryptoContext", "TestIsValid", "FUNCTIONALITY", - SetupL, TestIsValidL, Teardown) + SetupL, TestIsValid, Teardown) EUNIT_END_TEST_TABLE