--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp Wed Jun 09 10:06:41 2010 +0300
@@ -88,6 +88,7 @@
iSecInf(aSecureInterface),
iMediaStream(aMediaStream),
iIsSAVP(ETrue),
+ iRemoteChangeKey(EFalse),
iCryptoContextOutId(0),
iCryptoContextInId(0),
iOldLocalMediaPort(0)
@@ -336,6 +337,11 @@
MCEMM_DEBUG(" Set Multiple Client Cryptoto")
User::LeaveIfError ( CountCryptoInOffer( aMediaField ) );
Session().iIsSecureSession = !iGnoreSdpMsg ? ETrue : EFalse;
+ if( iSecureSession.iNatBind )
+ {
+ SetCryptoContextL( ETrue );
+ iSecureSession.iNatBind = EFalse;
+ }
}
MCEMM_DEBUG("CMceSecureDesStream::DecodeSecureSdpL(), Exit")
MSG_IGNORE_RETURN()
@@ -376,7 +382,8 @@
}
if ( iSecureSession.iLSReadyToBind )
{
- SetCryptoContextL();
+ SetCryptoContextL( EFalse );
+ iRemoteChangeKey = EFalse;
}
MSG_IGNORE_RETURN()
if ( !iCryptoIn.iCryptoSuite.Length() )
@@ -437,9 +444,10 @@
// Sets crypto context to MCC
// -----------------------------------------------------------------------------
//
-void CMceSecureDesStream::SetCryptoContextL( )
+void CMceSecureDesStream::SetCryptoContextL( TBool aAnswer )
{
- MCEMM_DEBUG("SetCryptoContext(), Entry")
+ MCEMM_DEBUG("SetCryptoContext(), Entry")
+ TBool bindContext = ETrue;
TBool storedIgnoreSdpMsg = EFalse;
//Check state first if the crypto has been set
if ( !iCryptoIn.iIfCryptoContextIdSet &&
@@ -454,6 +462,12 @@
CreateCryptoContextL( iCryptoOut );
MCEMM_DEBUG_DVALUE( "iCryptoContextOutId", iCryptoIn.iCryptoContextId )
MCEMM_DEBUG_DVALUE( "iCryptoContextInId", iCryptoOut.iCryptoContextId )
+
+ if( !aAnswer )
+ {
+ bindContext = EFalse;
+ MCEMM_DEBUG("delay to bind!");
+ }
iCryptoOuts->Reset();
@@ -472,7 +486,7 @@
}
MCEMM_DEBUG_DVALUE( "Updated iCryptoContextOutId", iCryptoIn.iCryptoContextId )
MCEMM_DEBUG_DVALUE( "Updated iCryptoContextInId", iCryptoOut.iCryptoContextId )
- if ( iSecureSession.iKeyNeedUpdated )
+ if ( iSecureSession.iKeyNeedUpdated || iRemoteChangeKey )
{
UpdateCryptoContextL( iCryptoIn );
storedIgnoreSdpMsg = iGnoreSdpMsg;
@@ -488,6 +502,10 @@
iGnoreSdpMsg = (iCryptoIn.iIfCryptoContextIdSet &&
iCryptoOut.iIfCryptoContextIdSet ) &&
!iGnoreSdpMsg ? EFalse : ETrue;
+ if ( iWaitingBinding && bindContext )
+ {
+ iSecureSession.BindStreamCrypto();
+ }
MCEMM_DEBUG("SetCryptoContext(), Exit")
}
@@ -839,6 +857,13 @@
}
else
{
+ if( iRemoteChangeKey )
+ {
+ MCEMM_DEBUG("Update CryptoIn" )
+ TBool tmpSet = iCryptoIn.iIfCryptoContextIdSet;
+ iCryptoIn.Copy( iCryptoIns->At( 0 ) );
+ iCryptoIn.iIfCryptoContextIdSet = tmpSet;
+ }
if(iOldLocalMediaPort != iMediaStream.iLocalMediaPort)
{
GenerateRandomKeys( iCryptoOut );
@@ -852,11 +877,8 @@
MSG_IGNORE_RETURN()
if ( iSecureSession.iLSReadyToBind )
{
- SetCryptoContextL();
- if ( iWaitingBinding )
- {
- iSecureSession.BindStreamCrypto();
- }
+ SetCryptoContextL( ETrue );
+ iRemoteChangeKey = EFalse;
}
MSG_IGNORE_RETURN()
}
@@ -1206,13 +1228,14 @@
}
TPtrC8 keyInfo = aSecDec.Mid(keyInfoPos, keyInfoLen);
- if ( iSecureSession.iKeyNeedUpdated )
- {
+
- TBool valid = ValidateSecurityDescriptions( keyInfo );
- if ( valid )
+ TBool valid = ValidateSecurityDescriptions( keyInfo );
+ if ( valid )
+ {
+ iRemoteChangeKey = iCryptoIn.iEncodedKey.Compare( keyInfo ) != 0;
+ if( iSecureSession.iKeyNeedUpdated || iRemoteChangeKey )
{
-
// check keyInfo
if (iCryptoOut.iEncodedKey.Compare( keyInfo ) == 0)
{
@@ -1226,11 +1249,11 @@
iCryptoIn.iEncodedKey = keyInfo;
StoreKeys(iCryptoIn.iEncodedKey);
}
- else
- {
- User::Leave( KErrArgument );
- }
- }
+ }
+ else
+ {
+ User::Leave( KErrArgument );
+ }
}
else
{
@@ -1285,7 +1308,12 @@
if ( valid )
{
-
+ if( !iSecureSession.iKeyNeedUpdated &&
+ iCryptoIn.iEncodedKey.Compare( keyInfo ) != 0 )
+ {
+ MCEMM_DEBUG("Remote change the key");
+ iRemoteChangeKey = ETrue;
+ }
//check keyinfo mki
DecodeMKIValueL( aSecDec, EFalse, crypto );
MSG_IGNORE_RETURN()
@@ -1489,10 +1517,8 @@
cryptoOut.iAuthAlgms == aCrypto.iAuthAlgms &&
cryptoOut.iCryptoSuite.Compare(aCrypto.iCryptoSuite) == 0)
{
- if(!iCryptoOut.iIfCryptoContextIdSet)
- { //SEtCrypto
- iCryptoOut.Copy( cryptoOut );
- }
+ //SEtCrypto
+ iCryptoOut.Copy( cryptoOut );
iCryptoIn.iTag = cryptoOut.iTag;
iCryptoIn.iEncAlgms = cryptoOut.iEncAlgms;
iCryptoIn.iAuthAlgms = cryptoOut.iAuthAlgms;
@@ -1684,8 +1710,7 @@
{
iCryptoOuts->AppendL( aCopyFrom.iCryptoOuts->At( i ) );
}
- iOldLocalMediaPort = aCopyFrom.iOldLocalMediaPort;
- iWaitingBinding = aCopyFrom.iWaitingBinding;
+ iOldLocalMediaPort = aCopyFrom.iOldLocalMediaPort;
MCEMM_DEBUG( "CMceSecureDesStream::CopyStreamCryptoL Exit" )
}