This section provides information on deleting keys.
The unified keystore allows the deletion of any key. The following steps explain the process of deleting a key:
The selected key is deleted from the keystore.
The following code snippet shows how to initialise the unified keystore, list the keys in a keystore, select a particular key and delete it.
//Create a file system session object RFs iFs; CleanupClosePushL(&iFs); //Initialise the keystore and member functions CUnifiedKeyStore* keyStore = CUnifiedKeyStore::NewL(iFs); keyStore->Initialize(iStatus); //iStatus is a TRequestStatus object //List the keys of the keystore RPointerArray<CCTKeyInfo> iKeys; // This variable will contain the key for deletion TCTKeyAttributeFilter filter.iUsage = EPKCS15UsageAll; keyStore->List(iKeys, filter, iStatus); ... //Retrieve the handle of the key to be deleted _LIT(KLabel,”keylabel”); //Select the key with the label you are looking for for (TInt j = 0; j < iKeys.Count(); j++) { if (Keys[j]->Label() == KLabel) { keyIndex = j; break; } } ... //Delete the selected key keyStore->DeleteKey(*iKeys[keyIndex], iStatus); //Clean up CleanupStack::PopAndDestroy(); // iFs