multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecurecryptoinfo.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef MCESECURECRYPTOINFO_H
       
    24 #define MCESECURECRYPTOINFO_H
       
    25 
       
    26 #include <e32std.h>
       
    27 #include "mceclientserver.h"
       
    28 #include <mmccsrtpcryptoparams.h>
       
    29 
       
    30 _LIT( KUnEcryptedSrtp,"UNENCRYPTED_SRTP" );
       
    31 _LIT( KUnEcryptedSrtcp,"UNENCRYPTED_SRTCP" );
       
    32 _LIT( KUnAuthenticcatedSrtp,"UNAUTHENTICATED_SRTP" );
       
    33 _LIT( KKeyDrivationRate,"KDR=");
       
    34 _LIT( KFecOrder,"FEC_ORDER=");
       
    35 _LIT( KFecType,"FEC_SRTP");
       
    36 _LIT( KFecKey,"FEC_Key=");
       
    37 _LIT( KWSH,"WSH=");
       
    38 
       
    39 //2^31 -1 for SRTCP to use as default for both rtp/rtcp
       
    40 /*lint -e435 */
       
    41 
       
    42 const TUint64 	KDefalutMaterKeysLifeTime = 0x7FFFFFFF;
       
    43 const TUint 	KAuthTagLength80 = 80;
       
    44 const TUint 	KAuthTagLength32 = 32;
       
    45 const TUint 	KSaltLength = 0xe ;
       
    46 const TUint 	KMasterKeyLength = 0x10;
       
    47 const TUint 	KMasterKeyAndSaltLength = 0x1e;
       
    48 const TUint 	KEncodedStringLength = 0x28;
       
    49 const TUint 	KSessionExtLen = 0x64;
       
    50 const TUint16 	KMKIDesCLen = 0x101;
       
    51 const TUint64 	KWSHLen = 0x100000000;
       
    52 const TUint	  	KDRLen = 0x2;		 
       
    53 const TUint64  	KMLTLen = 0x1000000000000;
       
    54 const TUint 	KCryptoSuiteLen = 0x18;
       
    55 typedef TBool TSrtpSessionParam;
       
    56 
       
    57 /*
       
    58  * Cryptography Information
       
    59  *
       
    60  */
       
    61 class TMceSecureCryptoInfo
       
    62     {
       
    63 public:
       
    64 
       
    65 	inline TMceSecureCryptoInfo()
       
    66 		: iTag( KMceNotAssigned ),
       
    67 		  iTagLen( KMceNotAssigned ),	
       
    68 		  iCryptoContextId( KMceNotAssigned ),
       
    69 		  iMKIValue( KMceNotAssigned ),
       
    70 		  iMKILength( KMceNotAssigned ),
       
    71 		  iMKLifeTime(0),
       
    72 		  iMKIUsed(EFalse),
       
    73 		  iIfBinded(EFalse),
       
    74 		  iIfCryptoContextIdSet( EFalse ),
       
    75 		  iKeysCreated( EFalse ),
       
    76 		  iEncAlgms( ESrtpEncAES_CM ),
       
    77 		  iAuthAlgms( ESrtpAuthHMAC_SHA1 ),
       
    78           iSetMasterKey( KNullDesC8 ),
       
    79           iSetSaltKey( KNullDesC8 ),
       
    80           iEncodedKey( KNullDesC8 ),
       
    81           iKeyParamCount(0),
       
    82           iIfFEC( EFalse ),
       
    83           iIfUnEncSRTP(EFalse),
       
    84 		  iIfUnEncSRTCP(EFalse),
       
    85 		  iIfUnAuthSRTP(EFalse),
       
    86 		  iIfSrtpSessionExt(EFalse),
       
    87 		  iCryptoSuite( KNullDesC8 ),
       
    88 		  iMKI( KNullDesC8 )
       
    89 		   {}
       
    90 
       
    91 
       
    92 
       
    93 	inline TMceSecureCryptoInfo( const TMceSecureCryptoInfo& aInfo )
       
    94 		: iTag(aInfo.iTag),
       
    95 		  iTagLen(aInfo.iTagLen),
       
    96 		  iCryptoContextId( aInfo.iCryptoContextId ),
       
    97 		  iMKIValue(aInfo.iMKIValue),
       
    98 		  iMKILength(aInfo.iMKILength),
       
    99 		  iMKLifeTime(aInfo.iMKLifeTime),
       
   100 		  iMKIUsed(aInfo.iMKIUsed),
       
   101 		  iIfBinded(aInfo.iIfBinded),
       
   102 		  iIfCryptoContextIdSet( aInfo.iIfCryptoContextIdSet),
       
   103 		  iKeysCreated(aInfo.iKeysCreated),
       
   104 		  iEncAlgms(aInfo.iEncAlgms),
       
   105 		  iAuthAlgms(aInfo.iAuthAlgms),
       
   106           iSetMasterKey(aInfo.iSetMasterKey),
       
   107           iSetSaltKey(aInfo.iSetSaltKey),
       
   108           iEncodedKey(aInfo.iEncodedKey),
       
   109           iKeyParamCount(aInfo.iKeyParamCount),
       
   110           iIfFEC( aInfo.iIfFEC ),
       
   111           iIfUnEncSRTP(aInfo.iIfUnEncSRTP),
       
   112 		  iIfUnEncSRTCP(aInfo.iIfUnEncSRTCP),
       
   113 		  iIfUnAuthSRTP(aInfo.iIfUnAuthSRTP),
       
   114 		  iIfSrtpSessionExt( aInfo.iIfSrtpSessionExt ),
       
   115 		  iCryptoSuite( aInfo.iCryptoSuite ),
       
   116 		  iMKI( aInfo.iMKI ) 
       
   117 		  {
       
   118 		  if(aInfo.iKeyParamCount)
       
   119 			  {
       
   120 			  iMasterKeys.Reset();
       
   121 			  iSaltKeys.Reset();
       
   122 			  iEncodedKeys.Reset();
       
   123 			  TInt count =aInfo.iMasterKeys.Count();
       
   124 			  for (int index=0; index<count; index++)
       
   125 			  	{
       
   126 			  	iMasterKeys.Append(aInfo.iMasterKeys[index]);
       
   127 			  	}
       
   128 			  count =aInfo.iSaltKeys.Count();	
       
   129 			  for (int index=0; index<count; index++)
       
   130 			  	{
       
   131 			  	iSaltKeys.Append(aInfo.iSaltKeys[index]);
       
   132 			  	}	
       
   133 			  count =aInfo.iEncodedKeys.Count();	
       
   134 			  for (int index=0; index<count; index++)
       
   135 			  	{
       
   136 			  	iEncodedKeys.Append(aInfo.iEncodedKeys[index]);
       
   137 			  	}	
       
   138 			  }
       
   139 		  }
       
   140 	
       
   141 	inline void Copy( const TMceSecureCryptoInfo& aInfo )
       
   142 	    {
       
   143 	    iTag = aInfo.iTag;
       
   144 	    iTagLen = aInfo.iTagLen;
       
   145 		iCryptoContextId=aInfo.iCryptoContextId;
       
   146 		iMKIValue = aInfo.iMKIValue;
       
   147 		iMKILength = aInfo.iMKILength;
       
   148 		iMKLifeTime=aInfo.iMKLifeTime;
       
   149 		iMKIUsed=aInfo.iMKIUsed;
       
   150 		iIfBinded=aInfo.iIfBinded;
       
   151 		iIfCryptoContextIdSet=aInfo.iIfCryptoContextIdSet;
       
   152 		iKeysCreated = aInfo.iKeysCreated;
       
   153 		iEncAlgms = aInfo.iEncAlgms;
       
   154 		iAuthAlgms = aInfo.iAuthAlgms;
       
   155 	    iSetMasterKey = aInfo.iSetMasterKey;
       
   156 	    iSetSaltKey = aInfo.iSetSaltKey;
       
   157 	    iEncodedKey = aInfo.iEncodedKey;
       
   158 	      
       
   159 	    iKeyParamCount = aInfo.iKeyParamCount;
       
   160 	    iIfFEC = aInfo.iIfFEC;
       
   161 	    iIfUnEncSRTP = aInfo.iIfUnEncSRTP;
       
   162 		iIfUnEncSRTCP = aInfo.iIfUnEncSRTCP;
       
   163 		iIfUnAuthSRTP = aInfo.iIfUnAuthSRTP;
       
   164 		iIfSrtpSessionExt = aInfo.iIfSrtpSessionExt;
       
   165 		iMKI = aInfo.iMKI;
       
   166 		if( aInfo.iKeyParamCount )
       
   167 		  {
       
   168 		  iMasterKeys.Reset();
       
   169 		  iSaltKeys.Reset();
       
   170 		  iEncodedKeys.Reset();
       
   171 		  TInt count = aInfo.iMasterKeys.Count();
       
   172 		  for (int index=0; index<count; index++)
       
   173 		  	{
       
   174 		  	iMasterKeys.Append(aInfo.iMasterKeys[index]);
       
   175 		  	}
       
   176 		  count = aInfo.iSaltKeys.Count();	
       
   177 		  for (int index=0; index<count; index++)
       
   178 		  	{
       
   179 		  	iSaltKeys.Append(aInfo.iSaltKeys[index]);
       
   180 		  	}	
       
   181 		  count = aInfo.iEncodedKeys.Count();	
       
   182 		  for (int index=0; index<count; index++ )
       
   183 		  	{
       
   184 		  	iEncodedKeys.Append( aInfo.iEncodedKeys[index] );
       
   185 		  	}	
       
   186 		  }
       
   187 	
       
   188 		iCryptoSuite = aInfo.iCryptoSuite;
       
   189         }
       
   190  
       
   191     inline TBool IsContextId(TUint32 aContextId) const
       
   192         {
       
   193         return (
       
   194             iIfCryptoContextIdSet &&
       
   195             iCryptoContextId == aContextId );
       
   196         }
       
   197     
       
   198     inline void ResetKeys() 
       
   199         {
       
   200         iSetMasterKey = KNullDesC8;
       
   201         iSetSaltKey = KNullDesC8;
       
   202         iEncodedKey = KNullDesC8;
       
   203         }    
       
   204 
       
   205     inline void CryptoDestruct() 
       
   206         {
       
   207         iSetMasterKey.Des().Zero();
       
   208         iSetSaltKey.Des().Zero();
       
   209         iEncodedKey.Des().Zero();
       
   210         iMKI.Des().Zero();
       
   211         iMasterKeys.Close();
       
   212         iSaltKeys.Close();
       
   213         iEncodedKeys.Close();
       
   214         }    
       
   215             
       
   216 public://data
       
   217 
       
   218     TUint32     					iTag;     //crypto Tag
       
   219     TUint							iTagLen; //authentication tag len
       
   220     TUint32     					iCryptoContextId;//1
       
   221     TUint32							iKeyParamCount; //2//how many inline under one attribute
       
   222     TUint32							iMKIValue; //3
       
   223     TUint32							iMKILength;//4
       
   224     TUint64 						iMKLifeTime;
       
   225     TBool 							iMKIUsed; 	//5
       
   226     TBool 							iIfBinded; //6
       
   227     TBool							iIfCryptoContextIdSet;
       
   228     TBool							iKeysCreated;
       
   229     TMccSRTPEncAlg 					iEncAlgms;
       
   230     TMccSRTPAuthAlg 				iAuthAlgms;
       
   231     TBufC8< KMasterKeyLength > 		iSetMasterKey;
       
   232     TBufC8< KSaltLength> 			iSetSaltKey;
       
   233     TBufC8< KEncodedStringLength> 	iEncodedKey;
       
   234     
       
   235     RArray <TDesC8> 				iMasterKeys; //if there is more than one inline key method
       
   236     RArray <TDesC8> 				iSaltKeys;
       
   237     RArray <TDesC8> 				iEncodedKeys;
       
   238     
       
   239     TSrtpSessionParam				iIfFEC;/* = EFalse*/
       
   240 	TSrtpSessionParam				iIfUnEncSRTP;
       
   241 	TSrtpSessionParam 				iIfUnEncSRTCP;
       
   242 	TSrtpSessionParam				iIfUnAuthSRTP;
       
   243 	TSrtpSessionParam				iIfSrtpSessionExt;/* = EFlase*/
       
   244 	TBufC8< KCryptoSuiteLen > 		iCryptoSuite;
       
   245 	TBufC8<	KMKIDesCLen >			iMKI;
       
   246 	};
       
   247 
       
   248 #endif // MCESECURECRYPTOINFO_H
       
   249 // End of File