cryptoservices/filebasedcertificateandkeystores/test/tkeystore/t_keystore_actions.cpp
changeset 15 da2ae96f639b
parent 8 35751d3474b7
child 29 ece3df019add
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
    89 
    89 
    90 
    90 
    91 CKeyStoreTestAction::CKeyStoreTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut) :
    91 CKeyStoreTestAction::CKeyStoreTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut) :
    92 	CTestAction(aConsole, aOut), 
    92 	CTestAction(aConsole, aOut), 
    93 	iFs(aFs),
    93 	iFs(aFs),
    94 	iDisableCheckDialog(0)
    94 	iDisableCheckDialog(0),
       
    95 	iKeyStoreImplIndex(0)
    95 #ifdef SYMBIAN_AUTH_SERVER
    96 #ifdef SYMBIAN_AUTH_SERVER
    96 	,iUseNewApi(EFalse),
    97 	,iUseNewApi(EFalse),
    97 	iFreshness(0)
    98 	iFreshness(0)
    98 #endif // SYMBIAN_AUTH_SERVER
    99 #endif // SYMBIAN_AUTH_SERVER
       
   100 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC))
       
   101 	,iHardwareType(-1)
       
   102 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC
    99 	{
   103 	{
   100 	iFilter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys;
   104 	iFilter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys;
   101 	}
   105 	}
   102 
   106 
   103 void CKeyStoreTestAction::ConstructL(const TTestActionSpec& aTestActionSpec)
   107 void CKeyStoreTestAction::ConstructL(const TTestActionSpec& aTestActionSpec)
   111 	while (SetKeyUsageL(Input::ParseElement(aTestActionSpec.iActionBody, KKeyUsageStart, KKeyUsageEnd, pos)))
   115 	while (SetKeyUsageL(Input::ParseElement(aTestActionSpec.iActionBody, KKeyUsageStart, KKeyUsageEnd, pos)))
   112 		/* do nothing */;
   116 		/* do nothing */;
   113 	
   117 	
   114 	SetKeyLabel(Input::ParseElement(aTestActionSpec.iActionBody, KKeyLabelStart));
   118 	SetKeyLabel(Input::ParseElement(aTestActionSpec.iActionBody, KKeyLabelStart));
   115 	SetKeyAlgorithm(Input::ParseElement(aTestActionSpec.iActionBody, KKeyAlgorithmStart));
   119 	SetKeyAlgorithm(Input::ParseElement(aTestActionSpec.iActionBody, KKeyAlgorithmStart));
       
   120 	SetKeyType(Input::ParseElement(aTestActionSpec.iActionBody, KOpenStart, KOpenEnd));
       
   121 	
   116 	pos = 0;
   122 	pos = 0;
   117 	while (SetKeyAccessType(Input::ParseElement(aTestActionSpec.iActionBody, KKeyAccessTypeStart, KKeyAccessTypeEnd, pos)))
   123 	while (SetKeyAccessType(Input::ParseElement(aTestActionSpec.iActionBody, KKeyAccessTypeStart, KKeyAccessTypeEnd, pos)))
   118 		/* do nothing */;
   124 		/* do nothing */;
   119 	pos = 0;
   125 	pos = 0;
   120 	while (AddExpectedDialogL(Input::ParseElement(aTestActionSpec.iActionBody, KSecDlg, KSecDlgEnd, pos)))
   126 	while (AddExpectedDialogL(Input::ParseElement(aTestActionSpec.iActionBody, KSecDlg, KSecDlgEnd, pos)))
   122 
   128 
   123 	iKeystore = Input::ParseIntElement(aTestActionSpec.iActionBody, KKeystoreStart, KKeystoreEnd);
   129 	iKeystore = Input::ParseIntElement(aTestActionSpec.iActionBody, KKeystoreStart, KKeystoreEnd);
   124 	
   130 	
   125 	iDisableCheckDialog = Input::ParseIntElement(aTestActionSpec.iActionBody, KDisableDialogStart, KDisableDialogEnd, pos);
   131 	iDisableCheckDialog = Input::ParseIntElement(aTestActionSpec.iActionBody, KDisableDialogStart, KDisableDialogEnd, pos);
   126 
   132 
       
   133 	pos = 0;
       
   134 	iKeyStoreImplLabel.Set(Input::ParseElement(aTestActionSpec.iActionBody, KUseKeyStoreStart, KUseKeyStoreEnd, pos));
       
   135 	
   127 #ifdef SYMBIAN_AUTH_SERVER
   136 #ifdef SYMBIAN_AUTH_SERVER
   128 	TPtrC8 authExpr;
   137 	TPtrC8 authExpr;
   129 	TInt authExprPresent = KErrNone;
   138 	TInt authExprPresent = KErrNone;
   130 	authExpr.Set(Input::ParseElement(aTestActionSpec.iActionBody, KAuthExpressionStart, KAuthExpressionEnd, pos , authExprPresent));
   139 	authExpr.Set(Input::ParseElement(aTestActionSpec.iActionBody, KAuthExpressionStart, KAuthExpressionEnd, pos , authExprPresent));
   131 	if(authExpr.Compare(_L8("null")) != 0)
   140 	if(authExpr.Compare(_L8("null")) != 0)
   155 		}
   164 		}
   156 	
   165 	
   157 	iDeauthenticate = Input::ParseIntElement(aTestActionSpec.iActionBody, KAuthenticateStart, KAuthenticateEnd);
   166 	iDeauthenticate = Input::ParseIntElement(aTestActionSpec.iActionBody, KAuthenticateStart, KAuthenticateEnd);
   158 		
   167 		
   159 #endif // SYMBIAN_AUTH_SERVER
   168 #endif // SYMBIAN_AUTH_SERVER
       
   169 	
       
   170 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC))
       
   171 	iHardwareType = Input::ParseIntElement(aTestActionSpec.iActionBody, KHwTypeStart, KHwTypeEnd, pos);
       
   172 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC
   160 	
   173 	
   161 	}
   174 	}
   162 
   175 
   163 TBool CKeyStoreTestAction::AddExpectedDialogL(const TDesC8& aData)
   176 TBool CKeyStoreTestAction::AddExpectedDialogL(const TDesC8& aData)
   164 	{
   177 	{
   459 	else
   472 	else
   460 		ret = EFalse;
   473 		ret = EFalse;
   461 	return ret;
   474 	return ret;
   462 	}
   475 	}
   463 
   476 
       
   477 void CKeyStoreTestAction::SetKeyStoreIndex(CUnifiedKeyStore* aUnifiedKeyStore)
       
   478 	{
       
   479 	TInt keyStoreCount = aUnifiedKeyStore->KeyStoreManagerCount();
       
   480 	for(int index = 0 ; index<keyStoreCount; ++index)
       
   481 		{
       
   482 		MCTKeyStoreManager& mctKeyStoreMngr = aUnifiedKeyStore->KeyStoreManager(index);
       
   483 		const TDesC16& label = mctKeyStoreMngr.Token().Label();
       
   484 		TBuf<50> keyStoreLabel;
       
   485 		keyStoreLabel.Copy(iKeyStoreImplLabel);
       
   486 		if(label.Compare(keyStoreLabel) == 0 )
       
   487 			{
       
   488 			iKeyStoreImplIndex = index;
       
   489 			break;
       
   490 			}
       
   491 		}
       
   492 	
       
   493 	}
       
   494 
       
   495 
   464 void CKeyStoreTestAction::DoPerformPrerequisite(TRequestStatus& aStatus)
   496 void CKeyStoreTestAction::DoPerformPrerequisite(TRequestStatus& aStatus)
   465 	{
   497 	{
   466 	TInt err = KErrNone;
   498 	TInt err = KErrNone;
   467 	#ifdef SYMBIAN_AUTH_SERVER
   499 	#ifdef SYMBIAN_AUTH_SERVER
   468 	if(iDeauthenticate == 1)
   500 	if(iDeauthenticate == 1)
   619 		iOut.writeString(buf);
   651 		iOut.writeString(buf);
   620 		}
   652 		}
   621 	iOut.writeNewLine();
   653 	iOut.writeNewLine();
   622 	}
   654 	}
   623 
   655 
       
   656 void CKeyStoreTestAction::SetKeyType(const TDesC8& aKeyType)
       
   657 {
       
   658 	if (aKeyType.Compare(KAlgRSA)==0)
       
   659 	{
       
   660 		iType = ERSASign;
       
   661 	}
       
   662 	else if (aKeyType.Compare(KAlgDSA)==0)
       
   663 	{
       
   664 		iType = EDSASign;
       
   665 	}
       
   666 	else if (aKeyType.Compare(KDecryptUsage)==0)
       
   667 	{
       
   668 		iType = EDecrypt;
       
   669 	}
       
   670 	else if (aKeyType.Compare(KAlgDH)==0)
       
   671 	{
       
   672 		iType = EDH;
       
   673 	}
       
   674 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC))
       
   675     else if (aKeyType.Compare(KAlgEcc)==0)
       
   676         {
       
   677         iType = EECC;
       
   678         }
       
   679 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC
       
   680 }
       
   681 
   624 /////////////////////////////////////////////////////////////////
   682 /////////////////////////////////////////////////////////////////
   625 //CInitialiseKeyStore::
   683 //CInitialiseKeyStore::
   626 ///////////////////////////////////////////////////////////////////
   684 ///////////////////////////////////////////////////////////////////
   627 CTestAction* CInitialiseKeyStore::NewL(	RFs& aFs,
   685 CTestAction* CInitialiseKeyStore::NewL(	RFs& aFs,
   628 										CConsoleBase& aConsole,
   686 										CConsoleBase& aConsole,
   644 	self->ConstructL(aTestActionSpec);
   702 	self->ConstructL(aTestActionSpec);
   645 	return self;
   703 	return self;
   646 }
   704 }
   647 
   705 
   648 CInitialiseKeyStore::~CInitialiseKeyStore()
   706 CInitialiseKeyStore::~CInitialiseKeyStore()
   649 {
   707 	{
   650 	delete iNewUnifiedKeyStore;
   708 	delete iNewUnifiedKeyStore;
   651 	if (iKeyStoreLabel)
   709 	if (iKeyStoreLabel)
   652 	    {
   710 	    {
   653 	    delete iKeyStoreLabel;
   711 	    delete iKeyStoreLabel;
   654 	    }
   712 	    }