williamr@4: /* williamr@4: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of the License "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: williamr@4: * plugin selector interface williamr@4: * williamr@4: */ williamr@4: williamr@4: williamr@4: /** williamr@4: @file williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: williamr@4: #ifndef __CRYPTOAPI_PLUGINSELECTORBASE_H__ williamr@4: #define __CRYPTOAPI_PLUGINSELECTORBASE_H__ williamr@4: williamr@4: #include williamr@4: williamr@4: williamr@4: namespace CryptoSpi williamr@4: { williamr@4: class CHash; williamr@4: class CRandom; williamr@4: class CSymmetricCipher; williamr@4: class CAsymmetricCipher; williamr@4: class CSigner; williamr@4: class CVerifier; williamr@4: class CKeyAgreement; williamr@4: class CKeyPairGenerator; williamr@4: class CAsyncHash; williamr@4: class CAsyncRandom; williamr@4: class CAsyncSymmetricCipher; williamr@4: class CAsyncAsymmetricCipher; williamr@4: class CAsyncSigner; williamr@4: class CAsyncVerifier; williamr@4: class CAsyncKeyAgreement; williamr@4: class CAsyncKeyPairGenerator; williamr@4: class CKey; williamr@4: class CCryptoParams; williamr@4: williamr@4: williamr@4: #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT williamr@4: class CMac; williamr@4: class CAsyncMac; williamr@4: #endif williamr@4: williamr@4: /** williamr@4: Base class for the selectors williamr@4: */ williamr@4: class MPluginSelector williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Destructor williamr@4: */ williamr@4: inline virtual ~MPluginSelector() = 0; williamr@4: williamr@4: /** williamr@4: * @deprecated williamr@4: * williamr@4: * Create a new instance of a hash object williamr@4: * williamr@4: * @param aHash The pointer to CHash williamr@4: * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1 williamr@4: * @param aOperationMode The operation mode of the hash e.g. Hash mode, Hmac mode williamr@4: * @param aKey The key for Hmac mode, which should be NULL in Hash mode williamr@4: * @param aAlgorithmParams The parameters that are specific to a particular williamr@4: * algorithm. This is for extendibility and will normally be null. williamr@4: * @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateHashL(CHash*& aHash, williamr@4: TUid aAlgorithmUid, williamr@4: TUid aOperationMode, williamr@4: const CKey* aKey, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of a Random object. williamr@4: williamr@4: @param aRandom A reference to a pointer that should be set to point to the new CRandom object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aAlgorithmParams Parameters that are specific this algorithm. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateRandomL(CRandom*& aRandom, williamr@4: TUid aAlgorithmUid, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new synchronous instance of a symmetric cipher williamr@4: williamr@4: @param aCipher A reference to a pointer that should be set to point to the new symmetric object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aKey The encryption/decryption key. williamr@4: @param aCryptoMode The Symmetric cipher mode. williamr@4: @param aOperationMode The Symmetric cipher operation mode. williamr@4: @param aPaddingMode The Symmetric cipher padding mode. williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateSymmetricCipherL(CSymmetricCipher*& aCipher, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aCryptoMode, williamr@4: TUid aOperationMode, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of an asymmetric cipher williamr@4: williamr@4: @param aCipher A reference to a pointer that should be set to point to the new asymmetric cipher object. williamr@4: @param aAlgorithmUid The asymmetric cipher algorithm to use (e.g. KRsaCipherUid) williamr@4: @param aKey The encryption/decryption key. williamr@4: @param aCryptoMode whether to encrypt or decrypt williamr@4: @param aPaddingMode The padding mode to use williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsymmetricCipherL(CAsymmetricCipher*& aCipher, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aCryptoMode, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of a synchronous signer. williamr@4: williamr@4: @param aSigner A reference to a pointer that should be set to point to the new signer object. williamr@4: @param aAlgorithmUid The algorithm to use. williamr@4: @param aKey The signing key. williamr@4: @param aPaddingMode The padding mode of the signer. williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateSignerL(CSigner*& aSigner, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of a verifier. williamr@4: williamr@4: @param aVerifier A reference to a pointer that should be set to point to the new verifier object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aKey The key to verify the signature with. williamr@4: @param aPaddingMode The padding mode of the signer. williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateVerifierL(CVerifier*& aVerifier, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of a key pair generator. williamr@4: williamr@4: @param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object. williamr@4: @param aKeyAlgorithmUid The algorithm UID williamr@4: @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateKeyPairGeneratorL(CKeyPairGenerator*& aKeyPairGenerator, williamr@4: TUid aKeyAlgorithmUid, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: williamr@4: /** williamr@4: Creates a new instance of a key agreement system. williamr@4: williamr@4: @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aPrivateKey The private key to combine with the other parties public key during the agreement. williamr@4: @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aPrivateKey, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: * @deprecated williamr@4: * williamr@4: * Create a new instance of a asynchronous hash object williamr@4: * williamr@4: * @param aHash The pointer to CHash williamr@4: * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1 williamr@4: * @param aOperationMode The operation mode of the hash e.g. Hash mode, Hmac mode williamr@4: * @param aKey The key for Hmac mode, which should be NULL in Hash mode williamr@4: * @param aAlgorithmParams The parameters that are specific to a particular williamr@4: * algorithm. This is for extendibility and will normally be null. williamr@4: * @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncHashL(CAsyncHash*& aHash, williamr@4: TUid aAlgorithmUid, williamr@4: TUid aOperationMode, williamr@4: const CKey* aKey, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: /** williamr@4: Creates a new instance of a asynchronous random object. williamr@4: williamr@4: @param aRandom A reference to a pointer that should be set to point to the new CRandom object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aAlgorithmParams Parameters that are specific this algorithm. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncRandomL(CAsyncRandom*& aRandom, williamr@4: TUid aAlgorithmUid, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: /** williamr@4: Creates a new synchronous instance of a asynchronous symmetric cipher williamr@4: williamr@4: @param aCipher A reference to a pointer that should be set to point to the new symmetric object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aKey The encryption/decryption key. williamr@4: @param aCryptoMode The Symmetric cipher mode. williamr@4: @param aOperationMode The Symmetric cipher operation mode. williamr@4: @param aPaddingMode The Symmetric cipher padding mode. williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncSymmetricCipherL(CAsyncSymmetricCipher*& aCipher, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aCryptoMode, williamr@4: TUid aOperationMode, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of an asynchronous asymmetric cipher williamr@4: williamr@4: @param aCipher A reference to a pointer that should be set to point to the new asymmetric cipher object. williamr@4: @param aAlgorithmUid The asymmetric cipher algorithm to use (e.g. KRsaCipherUid) williamr@4: @param aKey The encryption/decryption key. williamr@4: @param aCryptoMode whether to encrypt or decrypt williamr@4: @param aPaddingMode The padding mode to use williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncAsymmetricCipherL(CAsyncAsymmetricCipher*& aCipher, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aCryptoMode, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: /** williamr@4: Creates a new instance of a asynchronous signer. williamr@4: williamr@4: @param aSigner A reference to a pointer that should be set to point to the new signer object. williamr@4: @param aAlgorithmUid The algorithm to use. williamr@4: @param aKey The signing key. williamr@4: @param aPaddingMode The padding mode of the signer. williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncSignerL(CAsyncSigner*& aSigner, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: /** williamr@4: Creates a new instance of a asynchronous verifier. williamr@4: williamr@4: @param aVerifier A reference to a pointer that should be set to point to the new verifier object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aKey The key to verify the signature with. williamr@4: @param aPaddingMode The padding mode of the signer. williamr@4: @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncVerifierL(CAsyncVerifier*& aVerifier, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: TUid aPaddingMode, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of a asynchronous key pair generator. williamr@4: williamr@4: @param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object. williamr@4: @param aKeyAlgorithmUid The algorithm UID williamr@4: @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncKeyPairGeneratorL(CAsyncKeyPairGenerator*& aKeyPairGenerator, williamr@4: TUid aAlgorithmUid, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: Creates a new instance of a asynchronous key agreement system. williamr@4: williamr@4: @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object. williamr@4: @param aAlgorithmUid The algorithm to use williamr@4: @param aPrivateKey The private key to combine with the other parties public key during the agreement. williamr@4: @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. williamr@4: @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& aKeyAgreement, williamr@4: TUid aAlgorithmUid, williamr@4: const CKey& aPrivateKey, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT williamr@4: williamr@4: /** williamr@4: * Create a CMac instance (for software based MAC plug-in dll implementation) williamr@4: * williamr@4: * @param aMac The pointer to CMac. This will be initialised with williamr@4: * the plug-in implementation of the desired MAC algorithm. williamr@4: * @param aAlgorithmUid The specific MAC algorithm desired for evaluation of MAC value. williamr@4: * e.g. MD2, SHA1 or AES-XCBC-MAC-96, AES-XCBC-PRF-128 williamr@4: * @param aKey Symmetric key for calculating message authentication code value. williamr@4: * @param aAlgorithmParams The parameters those are specific to a particular MAC algorithm. williamr@4: * This is for extendibility and will normally be null. williamr@4: * @leave KErrNone if successful; otherwise, leaves with a system wide error code. williamr@4: */ williamr@4: virtual void CreateMacL(CMac*& aMac, williamr@4: const TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: * Create a CAsyncMac instance (for hardware based MAC plug-in dll implementation) williamr@4: * williamr@4: * @param aMac The pointer to CMac. This will be initialised with williamr@4: * the plug-in implementation of the desired MAC algorithm. williamr@4: * @param aAlgorithmUid The specific MAC algorithm desired for evaluation of MAC value. williamr@4: * e.g. MD2, SHA1 or AES-XCBC-MAC-96, AES-XCBC-PRF-128 williamr@4: * @param aKey Symmetric key for calculating message authentication code value. williamr@4: * @param aAlgorithmParams The parameters those are specific to a particular MAC algorithm. williamr@4: * This is for extendibility and will normally be null. williamr@4: * @leave KErrNone if successful; otherwise, leaves with a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncMacL(CAsyncMac*& aMac, williamr@4: const TUid aAlgorithmUid, williamr@4: const CKey& aKey, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: * Create a CHash instance williamr@4: * williamr@4: * @param aHash The pointer to CHash williamr@4: * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1, MD4 williamr@4: * @param aAlgorithmParams The parameters that are specific to a particular williamr@4: * algorithm. This is for extendibility and will normally be null. williamr@4: * @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateHashL(CHash*& aHash, williamr@4: TUid aAlgorithmUid, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: /** williamr@4: * Create a CAsyncHash instance williamr@4: * williamr@4: * @param aAsyncHash The pointer to CAsyncHash williamr@4: * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1, MD4 williamr@4: * @param aAlgorithmParams The parameters that are specific to a particular williamr@4: * algorithm. This is for extendibility and will normally be null. williamr@4: * @leave KErrNone if successful; otherwise, a system wide error code. williamr@4: */ williamr@4: virtual void CreateAsyncHashL(CAsyncHash*& aAsyncHash, williamr@4: TUid aAlgorithmUid, williamr@4: const CCryptoParams* aAlgorithmParams) = 0; williamr@4: williamr@4: #endif williamr@4: }; williamr@4: williamr@4: MPluginSelector::~MPluginSelector() williamr@4: { williamr@4: } williamr@4: } williamr@4: #endif //__CRYPTOAPI_PLUGINSELECTORBASE_H__ williamr@4: williamr@4: