rtp/srtpstack/src/srtpauthentication_rcc.cpp
branchRCL_3
changeset 9 1e1cc61f56c3
parent 0 307788aac0a8
equal deleted inserted replaced
4:dd3853b8dc3f 9:1e1cc61f56c3
    75 	HBufC8* result = HBufC8::NewL(20);  
    75 	HBufC8* result = HBufC8::NewL(20);  
    76 	TPtr8 ptrOutputBuff = result->Des();	
    76 	TPtr8 ptrOutputBuff = result->Des();	
    77 	
    77 	
    78     CleanupStack::PushL(result);
    78     CleanupStack::PushL(result);
    79 
    79 
    80     CSHA1* sha1 = CSHA1::NewL(); 
    80     if ( !iHmac || !iKey || (*iKey != aKey) )
    81     CleanupStack::PushL(sha1);
    81         {
    82     
    82         CreateHmacL(aKey);
    83     CHMAC *hmac = CHMAC::NewL(aKey, sha1);        
    83         }
    84     CleanupStack::Pop(sha1);
    84    
    85     CleanupStack::Pop(result);
    85     CleanupStack::Pop(result);
    86     SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Length is ", aAuthPortion.Length());
    86     SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Length is ", aAuthPortion.Length());
    87     SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Size is ", aAuthPortion.Size());     
    87     SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Size is ", aAuthPortion.Size());     
    88     SRTP_DEBUG_PACKET( DES_AS_8_BIT(aAuthPortion) );    
    88     SRTP_DEBUG_PACKET( DES_AS_8_BIT(aAuthPortion) );    
    89               
    89               
    90     if(aRoc.Length())
    90     if(aRoc.Length())
    91     	{
    91     	{
    92   		hmac->Update(DES_AS_8_BIT(aAuthPortion));
    92   		iHmac->Update(DES_AS_8_BIT(aAuthPortion));
    93     	buf.Copy(hmac->Final(DES_AS_8_BIT(aRoc))); 	
    93     	buf.Copy(iHmac->Final(DES_AS_8_BIT(aRoc))); 	
    94     	}
    94     	}
    95     else
    95     else
    96     	{
    96     	{
    97     	buf.Copy(hmac->Final(DES_AS_8_BIT(aAuthPortion)));
    97     	buf.Copy(iHmac->Final(DES_AS_8_BIT(aAuthPortion)));
    98     	}
    98     	}
    99     *result = buf;    
    99     *result = buf;    
   100     ptrOutputBuff.SetLength(aBitLength/8);
   100     ptrOutputBuff.SetLength(aBitLength/8);
   101     
   101     
   102     delete hmac;
       
   103    	SRTP_DEBUG_DETAIL( "HMAC caculated Authentication tag" );
   102    	SRTP_DEBUG_DETAIL( "HMAC caculated Authentication tag" );
   104    	SRTP_DEBUG_PACKET( *result );    
   103    	SRTP_DEBUG_PACKET( *result );    
   105     
   104     
   106     SRTP_DEBUG_DETAIL( "CSrtpAuthentication_RCC::AuthenticateL Exit" );
   105     SRTP_DEBUG_DETAIL( "CSrtpAuthentication_RCC::AuthenticateL Exit" );
   107                                 
   106                                 
   122 // CSrtpAuthentication_RCC::~CSrtpAuthentication_RCC
   121 // CSrtpAuthentication_RCC::~CSrtpAuthentication_RCC
   123 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   124 //
   123 //
   125 CSrtpAuthentication_RCC::~CSrtpAuthentication_RCC()
   124 CSrtpAuthentication_RCC::~CSrtpAuthentication_RCC()
   126     {    
   125     {    
       
   126     delete iHmac;
       
   127     delete iKey;
   127     }
   128     }
   128 
   129 
   129 // ---------------------------------------------------------------------------
   130 // ---------------------------------------------------------------------------
   130 // CSrtpAuthentication_RCC::CSrtpAuthentication_RCC
   131 // CSrtpAuthentication_RCC::CSrtpAuthentication_RCC
   131 // ---------------------------------------------------------------------------
   132 // ---------------------------------------------------------------------------
   133 CSrtpAuthentication_RCC::CSrtpAuthentication_RCC()
   134 CSrtpAuthentication_RCC::CSrtpAuthentication_RCC()
   134     {    
   135     {    
   135         
   136         
   136     }
   137     }
   137 
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CSrtpAuthentication_RCC::CreateHmacL
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CSrtpAuthentication_RCC::CreateHmacL(const TDesC8& aKey)
       
   144     {
       
   145     delete iHmac;
       
   146     iHmac = 0;
       
   147     delete iKey;
       
   148     iKey = 0;
       
   149     iKey = aKey.AllocL();
       
   150     CSHA1* sha1 = CSHA1::NewL(); 
       
   151     CleanupStack::PushL(sha1);
       
   152     iHmac = CHMAC::NewL(*iKey, sha1);        
       
   153     CleanupStack::Pop(sha1);
       
   154     }
       
   155