Listing Keys

This section explains how to list keys in all the keystores.

Use the CUnifiedKeyStore::List() function to list the keys in all of the keystores.

The following steps explain the process of listing keys:


  1. Create a file system session using an RFs object.

  2. Create an object of type CUnifiedKeyStore using CUnifiedKeyStore::NewL() or CUnifiedKeyStore::NewLC() .

  3. Initialise the member functions and keystore using the asynchronous function CUnifiedKeyStore::Initialize() .

  4. Use the CUnifiedKeyStore::List() function to list the keys in the keystores.

The List() function returns all the keys from all the keystores.

Example

The following code snippet shows how to set a file system session object, initialise keystore and member functions, and list keys.

       
        
       
       //Create a file system session object
RFs iFs;
CleanupClosePushL(&iFs);


//Initialise the keystore and member functions
CUnifiedKeyStore* keyStore = CUnifiedKeyStore::NewL(fs);
keyStore->Initialize(iStatus); //iStatus is a TRequestStatus object

...

//List the keys in the keystores
RPointerArray<CCTKeyInfo> iKeys; // This variable will contain the result after the completion of the list operation
TCTKeyAttributeFilter  filter.iUsage = EPKCS15UsageAll;
keyStore->List(iKeys, filter, iStatus);

//Clean up
CleanupStack::PopAndDestroy(); // iFs