You can use various types of algorithms (for example RSA sign, DSA sign, Decrypt, DH key agreement, and so on) to perform cryptographic operations with keys in the unified keystore. This section provides information on the signing process.
The following steps explain the process of signing keys by considering the example of an RSA signing operation:
The CRSASignature object contains the value of the signing operation.
The following code snippet shows RSA signing operation:
//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 ... // Create a filter to retrieve all keys from the store TCTKeyAttributeFilter filter; filter.iPolicyFilter = TCTKeyAttributeFilter:EAllKeys; // Retrieve a list of all the keys from the key store RPointerArray<CCTKeyInfo> iKeys; // This variable will contain the key to be signed iKeyStore->List(iKeys,filter,iStatus); ... // Retrieve the key based on the label you are looking for _LIT(Klabel,”keylabel”); TInt keyCount = iKeys.Count(); for (i = 0; i < keyCount; i++) { CCTKeyInfo* keyInfo = iKeys[i]; if (keyInfo->Label() == Klabel) { // Create a signer object for the key MRSASigner* iRSASigner // The signer object will be returned after the key has been opened for signing keyStore->Open(*keyInfo, iRSASigner, iStatus); break; } } // Perform the signing operation // Define the data for signing HBufC* dataToSign; dataToSign = HBufC::NewL(20); _LIT(KTxtSign,"Data to be signed"); *dataToSign = KTxtSign; CRSASignature* iRSASignature; // iRSASignature will contain the result after the completion // of the following request iRSASigner->SignMessage(*dataToSign, iRSASignature, iStatus); ... // Retrieve the RSA signature value through the CRSASignature object TInt signature = iRSASignature->S();