// -----------------------------------------------------------------------------
// CSdpOriginFieldPtrs::SetSessionVersionL
// -----------------------------------------------------------------------------
// 
void CSdpOriginFieldPtrs::SetSessionVersionL( TInt64 aSessionVersion )
	{
	TBuf8< KMaxTInt64Digits > number;
    number.AppendNum( aSessionVersion );
    HBufC8* tmp = number.AllocL();
	delete iSessionVersion;
    iSessionVersion = tmp;
	}
Ejemplo n.º 2
0
/*
Mode:RC4 with weak encryption
Protocol: TLS
Tests covered:
	1.Generation of weak keys are also being tested
	2.MAC computations
	3.Encryption
	4.Decryption
*/
TVerdict CTlsProvTestActive::TestProvider_6_0L( CTlsProvStep* aStep )
	{

	
	CTLSProvider* PtrProvider = 0;
	CTLSSession* PtrSession;
	CTlsCryptoAttributes* PtrTlsCryptoAttributes;

	INFO_PRINTF1(_L("1"));
	InitProviderL(PtrProvider,PtrSession,PtrTlsCryptoAttributes,/*IsTls?*/ETrue,/*IsExport?*/ETrue,aStep);

	//Want client authentication?
	PtrTlsCryptoAttributes->iClientAuthenticate = EFalse;

	//Any dialogs
	PtrTlsCryptoAttributes->iDialogNonAttendedMode = ETrue;

	//Required ciphersuite
	TTLSCipherSuite	 CipherSuite;
	CipherSuite.iHiByte = 0;
	CipherSuite.iLoByte = 0x19;
	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
	PtrTlsCryptoAttributes->iNegotiatedProtocol = KTLS1_0;	

	
	//dummy flag untuill the token panic is resolved
	RFs fs;
	RFile file;
	fs.Connect();

	TBuf8<800> boom;
	file.Open(fs, 
				aStep->iServerCertChain,  
	 			EFileShareAny|EFileRead);
	file.Read(boom);
	
	iStatus = KRequestPending;
	CX509Certificate* serverCert;
	HBufC8* servrc = boom.AllocL();
	PtrProvider->VerifyServerCertificate(servrc->Des(), serverCert, iStatus);
	SetActive();
	CActiveScheduler::Start();
	INFO_PRINTF1(_L("2"));

	CipherSuite.iHiByte = 0;
	CipherSuite.iLoByte = 0x19;
	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;

	iStatus = KRequestPending;		
	PtrProvider->CreateL(PtrSession,iStatus);
	SetActive();
	CActiveScheduler::Start();
	INFO_PRINTF1(_L("3"));


	CipherSuite.iHiByte = 0;
	CipherSuite.iLoByte = 3;
	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
	
	iStatus = KRequestPending;
	HBufC8* clntkeyexchang;
	if(!PtrSession)
   {
   	iLogInfo.Copy(_L("	6.1:  !PtrSession"));
		return EFail;
   }


	PtrSession->ClientKeyExchange(clntkeyexchang,iStatus);
	SetActive();
	CActiveScheduler::Start();
	INFO_PRINTF1(_L("4"));

	if(PtrSession)
   {
   	iLogInfo.Copy(_L("	6.1:  EncryptAndDecryptL"));
		TVerdict ver = (EncryptAndDecryptL(PtrSession,aStep));
      delete PtrProvider;
      delete PtrSession;
      return ver;
   }
	else
   {
      delete PtrProvider;
      delete PtrSession;
		return EFail;
   }

	}
Ejemplo n.º 3
0
HBufC8* CPolicyPatchInfo::CheckSubjectNameSyntaxL(const TDesC8& aSubj)
    {
    const TInt KMaxSubjectItems = 20;
    
    _LIT8(KEqualSign, "=");
    _LIT8(KCommaSign, ",");
    _LIT8(KReplacementChar, "\"");
    
    //counts positions for equal sign characters
    CArrayFixFlat<TInt>* equalSignArr=new (ELeave) CArrayFixFlat<TInt> (KMaxSubjectItems); 
    
    //counts positions for comma characters
    CArrayFixFlat<TInt>* commaSignArr=new (ELeave) CArrayFixFlat<TInt> (KMaxSubjectItems); 
    
    //counts positions for double quatiation characters
    CArrayFixFlat<TInt>* updateArr=new (ELeave) CArrayFixFlat<TInt> (KMaxSubjectItems);
    
    TInt subjLth=aSubj.Length();
    TInt equalArrItemCount=0;
    TInt commaArrItemCount=0;
    TInt updateArrCount=0;
    
    CleanupStack::PushL(equalSignArr);
    CleanupStack::PushL(commaSignArr);
    
    //register '=' and ',' character positions 
    for (TInt i=0; i<subjLth; i++)
        {
        if ( aSubj.Mid(i, 1)== KEqualSign )
            {
            equalSignArr->AppendL(i);
            equalArrItemCount++;
            }
        
        if ( aSubj.Mid(i, 1)== KCommaSign )
            {
            commaSignArr->AppendL(i);
            commaArrItemCount++;
            }
        }
    
    CleanupStack::PushL(updateArr);
    
    TInt i=0;
    TInt j=0;
    
    // At least one comma required. Otherwise there is no chance for extra commas
    if ( commaArrItemCount )
        {
        while ( i< equalArrItemCount )
            {
            
            //advance starting position for every iteration
            TInt eqSignStartIndex=i;
            
            TInt cmCount=0;
        
            //check wether there is more than one comma between two adjacent fields.
            while ( commaSignArr->At(j)< equalSignArr->At(eqSignStartIndex) )
                {
                cmCount++;
                
                j++;
                
                if ( j==commaArrItemCount )
                    break;
                }
            
            //at least one extra comma character found. Mark positions for mofifications.
            if (cmCount>1)
                {
                TInt equalPos=equalSignArr->At(eqSignStartIndex-1) + 1;
                updateArr->AppendL(equalPos);
                
                TInt commaPos=commaSignArr->At(j-1);
                updateArr->AppendL(commaPos);
                
                updateArrCount++;
                updateArrCount++;
                }
            i++;    
            }
        }
        
        //Checking also last attribute of Subject Name string
        if ( j<commaArrItemCount )
            {
            updateArr->AppendL(equalSignArr->At(equalArrItemCount-1) + 1);
            updateArr->AppendL(subjLth);
            
            updateArrCount++;
            updateArrCount++;
            }
       
       TBuf8<256> resultBuf;
       resultBuf.Copy(aSubj);
       
       i=0;       
       
       //update subjectname acoording to updateArr array.
       if ( updateArr->Count()>0 )
           {
           while (i<updateArrCount)
               {
               if ( resultBuf.Length()<256 )
                   resultBuf.Insert(updateArr->At(i) + i, KReplacementChar);
               else
                   User::Leave(KErrNotSupported);
               i++;
               }
           }
       
       CleanupStack::Pop(updateArr);
       CleanupStack::Pop(commaSignArr);
       CleanupStack::Pop(equalSignArr);
       
       delete equalSignArr;
       equalSignArr=NULL;
       
       delete commaSignArr;
       commaSignArr=NULL;
       
       delete updateArr;
       updateArr=NULL;
       
       HBufC8* resultHeap = resultBuf.AllocL();
       
       return resultHeap;
    }