--- a/cryptoservices/certificateandkeymgmt/certstore/unifiedkeystore.cpp Thu Aug 19 11:38:48 2010 +0300
+++ b/cryptoservices/certificateandkeymgmt/certstore/unifiedkeystore.cpp Tue Aug 31 17:00:08 2010 +0300
@@ -372,6 +372,49 @@
}
}
+#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
+ CryptoSpi::CSigner*& aSigner,
+ TRequestStatus& aStatus)
+ {
+ if (DoOpen(aHandle, aStatus))
+ {
+ iKeyStore->Open(aHandle, aSigner, iStatus);
+ }
+ }
+
+void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
+ CryptoSpi:: CAsymmetricCipher*& asymmetricCipherObj,
+ TRequestStatus& aStatus)
+ {
+ if (DoOpen(aHandle, aStatus))
+ {
+ iKeyStore->Open(aHandle, asymmetricCipherObj, iStatus);
+ }
+ }
+
+void CUnifiedKeyStore::Decrypt(const TCTTokenObjectHandle& aHandle,
+ const TDesC8& aCiphertext,
+ HBufC8*& aPlaintextPtr,
+ TRequestStatus& aStatus)
+ {
+ if (DoOpen(aHandle, aStatus))
+ {
+ iKeyStore->Decrypt(aHandle, aCiphertext, aPlaintextPtr, iStatus);
+ }
+ }
+
+void CUnifiedKeyStore::Sign(const TCTTokenObjectHandle& aHandle,
+ const TDesC8& aPlaintext,
+ CryptoSpi::CCryptoParams*& aSignature,
+ TRequestStatus& aStatus)
+ {
+ if (DoOpen(aHandle, aStatus))
+ {
+ iKeyStore->Sign(aHandle, aPlaintext, aSignature, iStatus);
+ }
+ }
+#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
// ************************************************************************
// MKeyStoreManager
@@ -594,6 +637,112 @@
return *result;
}
+#ifdef SYMBIAN_AUTH_SERVER
+
+EXPORT_C void CUnifiedKeyStore::CreateKey( TInt aKeyStoreIndex, TKeyUsagePKCS15 aUsage,TUint aSize,
+ const TDesC& aLabel, CCTKeyInfo::EKeyAlgorithm aAlgorithm,
+ TInt aAccessType, TTime aStartDate, TTime aEndDate,
+ const TDesC& aAuthenticationString, TInt aFreshness,
+ CCTKeyInfo*& aKeyInfoOut, TRequestStatus& aStatus)
+ {
+
+ StartAsyncOperation(ECreateKey, aStatus);
+ TRAPD(err, PrepareToCreateKeyL(aKeyStoreIndex, aUsage, aSize, aLabel, aAlgorithm, aAccessType,
+ aStartDate, aEndDate, aStatus));
+ if (KErrNone != err)
+ {
+ Complete(err);
+ return;
+ }
+
+ iKeyInfoOut = &aKeyInfoOut;
+ aKeyInfoOut = NULL;
+ iKeyStoreManager->CreateKey(aAuthenticationString, aFreshness, iKeyInfo, iStatus);
+ SetActive();
+
+ }
+
+
+EXPORT_C void CUnifiedKeyStore::ImportKey( TInt aKeyStoreIndex, const TDesC8& aKeyData,
+ TKeyUsagePKCS15 aUsage, const TDesC& aLabel,
+ TInt aAccessType, TTime aStartDate, TTime aEndDate,
+ const TDesC& aAuthenticationString, TInt aFreshness,
+ CCTKeyInfo*& aKeyInfoOut, TRequestStatus& aStatus)
+ {
+ TBool isEncrypted = TASN1DecPKCS8::IsEncryptedPKCS8Data(aKeyData);
+ StartAsyncOperation(isEncrypted ? EImportKeyEncrypted : EImportKey, aStatus);
+
+ ASSERT(!iKeyData);
+ iKeyData = aKeyData.Alloc();
+ if (!iKeyData) // OOM or some other catastrophe
+ {
+ Complete(KErrNoMemory);
+ return;
+ }
+
+ TRAPD(err, PrepareToCreateKeyL(aKeyStoreIndex, aUsage, 0, aLabel, CCTKeyInfo::EInvalidAlgorithm, aAccessType,
+ aStartDate, aEndDate, aStatus));
+ if (KErrNone != err)
+ {
+ Complete(err);
+ return;
+ }
+
+ iKeyInfoOut = &aKeyInfoOut;
+ aKeyInfoOut = NULL;
+
+ if (isEncrypted)
+ {
+ iKeyStoreManager->ImportEncryptedKey(*iKeyData, aAuthenticationString, aFreshness, iKeyInfo, iStatus);
+ }
+ else
+ {
+ iKeyStoreManager->ImportKey(*iKeyData, aAuthenticationString, aFreshness, iKeyInfo, iStatus);
+ }
+ SetActive();
+ }
+
+EXPORT_C void CUnifiedKeyStore::SetAuthenticationPolicy( const TCTTokenObjectHandle aHandle,
+ const TDesC& aAuthenticationString,
+ TInt aFreshness,
+ TRequestStatus& aStatus)
+ {
+ StartAsyncOperation(ESetAuthenticationPolicy, aStatus);
+
+ ASSERT(!iKeyStoreManager);
+ iKeyStoreManager = FindKeyStoreManager(aHandle);
+ if (!iKeyStoreManager)
+ {
+ Complete(KErrNotFound);
+ return;
+ }
+
+ iKeyStoreManager->SetAuthenticationPolicy(aHandle, aAuthenticationString, aFreshness, iStatus);
+ SetActive();
+
+ }
+
+EXPORT_C void CUnifiedKeyStore::GetAuthenticationPolicy( const TCTTokenObjectHandle aHandle,
+ HBufC*& aAuthenticationString,
+ TInt& aFreshness,
+ TRequestStatus& aStatus)
+ {
+ StartAsyncOperation(EGetAuthenticationPolicy, aStatus);
+
+ ASSERT(!iKeyStoreManager);
+ iKeyStoreManager = FindKeyStoreManager(aHandle);
+ if (!iKeyStoreManager)
+ {
+ Complete(KErrNotFound);
+ return;
+ }
+
+ iKeyStoreManager->GetAuthenticationPolicy(aHandle, aAuthenticationString, aFreshness, iStatus);
+ SetActive();
+
+ }
+
+#endif // SYMBIAN_AUTH_SERVER
CUnifiedKeyStore::CUnifiedKeyStore(RFs& aFs)
: CActive(EPriorityNormal), iFs(aFs), iState(EIdle)