2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * plugin selector interface
26 #ifndef __CRYPTOAPI_PLUGINSELECTORBASE_H__
27 #define __CRYPTOAPI_PLUGINSELECTORBASE_H__
36 class CSymmetricCipher;
37 class CAsymmetricCipher;
41 class CKeyPairGenerator;
44 class CAsyncSymmetricCipher;
45 class CAsyncAsymmetricCipher;
48 class CAsyncKeyAgreement;
49 class CAsyncKeyPairGenerator;
54 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
60 Base class for the selectors
68 inline virtual ~MPluginSelector() = 0;
73 * Create a new instance of a hash object
75 * @param aHash The pointer to CHash
76 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1
77 * @param aOperationMode The operation mode of the hash e.g. Hash mode, Hmac mode
78 * @param aKey The key for Hmac mode, which should be NULL in Hash mode
79 * @param aAlgorithmParams The parameters that are specific to a particular
80 * algorithm. This is for extendibility and will normally be null.
81 * @leave KErrNone if successful; otherwise, a system wide error code.
83 virtual void CreateHashL(CHash*& aHash,
87 const CCryptoParams* aAlgorithmParams) = 0;
90 Creates a new instance of a Random object.
92 @param aRandom A reference to a pointer that should be set to point to the new CRandom object.
93 @param aAlgorithmUid The algorithm to use
94 @param aAlgorithmParams Parameters that are specific this algorithm.
95 @leave KErrNone if successful; otherwise, a system wide error code.
97 virtual void CreateRandomL(CRandom*& aRandom,
99 const CCryptoParams* aAlgorithmParams) = 0;
102 Creates a new synchronous instance of a symmetric cipher
104 @param aCipher A reference to a pointer that should be set to point to the new symmetric object.
105 @param aAlgorithmUid The algorithm to use
106 @param aKey The encryption/decryption key.
107 @param aCryptoMode The Symmetric cipher mode.
108 @param aOperationMode The Symmetric cipher operation mode.
109 @param aPaddingMode The Symmetric cipher padding mode.
110 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
111 @leave KErrNone if successful; otherwise, a system wide error code.
113 virtual void CreateSymmetricCipherL(CSymmetricCipher*& aCipher,
119 const CCryptoParams* aAlgorithmParams) = 0;
122 Creates a new instance of an asymmetric cipher
124 @param aCipher A reference to a pointer that should be set to point to the new asymmetric cipher object.
125 @param aAlgorithmUid The asymmetric cipher algorithm to use (e.g. KRsaCipherUid)
126 @param aKey The encryption/decryption key.
127 @param aCryptoMode whether to encrypt or decrypt
128 @param aPaddingMode The padding mode to use
129 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
130 @leave KErrNone if successful; otherwise, a system wide error code.
132 virtual void CreateAsymmetricCipherL(CAsymmetricCipher*& aCipher,
137 const CCryptoParams* aAlgorithmParams) = 0;
140 Creates a new instance of a synchronous signer.
142 @param aSigner A reference to a pointer that should be set to point to the new signer object.
143 @param aAlgorithmUid The algorithm to use.
144 @param aKey The signing key.
145 @param aPaddingMode The padding mode of the signer.
146 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
147 @leave KErrNone if successful; otherwise, a system wide error code.
149 virtual void CreateSignerL(CSigner*& aSigner,
153 const CCryptoParams* aAlgorithmParams) = 0;
156 Creates a new instance of a verifier.
158 @param aVerifier A reference to a pointer that should be set to point to the new verifier object.
159 @param aAlgorithmUid The algorithm to use
160 @param aKey The key to verify the signature with.
161 @param aPaddingMode The padding mode of the signer.
162 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
163 @leave KErrNone if successful; otherwise, a system wide error code.
165 virtual void CreateVerifierL(CVerifier*& aVerifier,
169 const CCryptoParams* aAlgorithmParams) = 0;
172 Creates a new instance of a key pair generator.
174 @param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object.
175 @param aKeyAlgorithmUid The algorithm UID
176 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
177 @leave KErrNone if successful; otherwise, a system wide error code.
179 virtual void CreateKeyPairGeneratorL(CKeyPairGenerator*& aKeyPairGenerator,
180 TUid aKeyAlgorithmUid,
181 const CCryptoParams* aAlgorithmParams) = 0;
185 Creates a new instance of a key agreement system.
187 @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object.
188 @param aAlgorithmUid The algorithm to use
189 @param aPrivateKey The private key to combine with the other parties public key during the agreement.
190 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
191 @leave KErrNone if successful; otherwise, a system wide error code.
193 virtual void CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement,
195 const CKey& aPrivateKey,
196 const CCryptoParams* aAlgorithmParams) = 0;
201 * Create a new instance of a asynchronous hash object
203 * @param aHash The pointer to CHash
204 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1
205 * @param aOperationMode The operation mode of the hash e.g. Hash mode, Hmac mode
206 * @param aKey The key for Hmac mode, which should be NULL in Hash mode
207 * @param aAlgorithmParams The parameters that are specific to a particular
208 * algorithm. This is for extendibility and will normally be null.
209 * @leave KErrNone if successful; otherwise, a system wide error code.
211 virtual void CreateAsyncHashL(CAsyncHash*& aHash,
215 const CCryptoParams* aAlgorithmParams) = 0;
217 Creates a new instance of a asynchronous random object.
219 @param aRandom A reference to a pointer that should be set to point to the new CRandom object.
220 @param aAlgorithmUid The algorithm to use
221 @param aAlgorithmParams Parameters that are specific this algorithm.
222 @leave KErrNone if successful; otherwise, a system wide error code.
224 virtual void CreateAsyncRandomL(CAsyncRandom*& aRandom,
226 const CCryptoParams* aAlgorithmParams) = 0;
228 Creates a new synchronous instance of a asynchronous symmetric cipher
230 @param aCipher A reference to a pointer that should be set to point to the new symmetric object.
231 @param aAlgorithmUid The algorithm to use
232 @param aKey The encryption/decryption key.
233 @param aCryptoMode The Symmetric cipher mode.
234 @param aOperationMode The Symmetric cipher operation mode.
235 @param aPaddingMode The Symmetric cipher padding mode.
236 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
237 @leave KErrNone if successful; otherwise, a system wide error code.
239 virtual void CreateAsyncSymmetricCipherL(CAsyncSymmetricCipher*& aCipher,
245 const CCryptoParams* aAlgorithmParams) = 0;
248 Creates a new instance of an asynchronous asymmetric cipher
250 @param aCipher A reference to a pointer that should be set to point to the new asymmetric cipher object.
251 @param aAlgorithmUid The asymmetric cipher algorithm to use (e.g. KRsaCipherUid)
252 @param aKey The encryption/decryption key.
253 @param aCryptoMode whether to encrypt or decrypt
254 @param aPaddingMode The padding mode to use
255 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
256 @leave KErrNone if successful; otherwise, a system wide error code.
258 virtual void CreateAsyncAsymmetricCipherL(CAsyncAsymmetricCipher*& aCipher,
263 const CCryptoParams* aAlgorithmParams) = 0;
265 Creates a new instance of a asynchronous signer.
267 @param aSigner A reference to a pointer that should be set to point to the new signer object.
268 @param aAlgorithmUid The algorithm to use.
269 @param aKey The signing key.
270 @param aPaddingMode The padding mode of the signer.
271 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
272 @leave KErrNone if successful; otherwise, a system wide error code.
274 virtual void CreateAsyncSignerL(CAsyncSigner*& aSigner,
278 const CCryptoParams* aAlgorithmParams) = 0;
280 Creates a new instance of a asynchronous verifier.
282 @param aVerifier A reference to a pointer that should be set to point to the new verifier object.
283 @param aAlgorithmUid The algorithm to use
284 @param aKey The key to verify the signature with.
285 @param aPaddingMode The padding mode of the signer.
286 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
287 @leave KErrNone if successful; otherwise, a system wide error code.
289 virtual void CreateAsyncVerifierL(CAsyncVerifier*& aVerifier,
293 const CCryptoParams* aAlgorithmParams) = 0;
296 Creates a new instance of a asynchronous key pair generator.
298 @param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object.
299 @param aKeyAlgorithmUid The algorithm UID
300 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
301 @leave KErrNone if successful; otherwise, a system wide error code.
303 virtual void CreateAsyncKeyPairGeneratorL(CAsyncKeyPairGenerator*& aKeyPairGenerator,
305 const CCryptoParams* aAlgorithmParams) = 0;
308 Creates a new instance of a asynchronous key agreement system.
310 @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object.
311 @param aAlgorithmUid The algorithm to use
312 @param aPrivateKey The private key to combine with the other parties public key during the agreement.
313 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
314 @leave KErrNone if successful; otherwise, a system wide error code.
316 virtual void CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& aKeyAgreement,
318 const CKey& aPrivateKey,
319 const CCryptoParams* aAlgorithmParams) = 0;
321 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
324 * Create a CMac instance (for software based MAC plug-in dll implementation)
326 * @param aMac The pointer to CMac. This will be initialised with
327 * the plug-in implementation of the desired MAC algorithm.
328 * @param aAlgorithmUid The specific MAC algorithm desired for evaluation of MAC value.
329 * e.g. MD2, SHA1 or AES-XCBC-MAC-96, AES-XCBC-PRF-128
330 * @param aKey Symmetric key for calculating message authentication code value.
331 * @param aAlgorithmParams The parameters those are specific to a particular MAC algorithm.
332 * This is for extendibility and will normally be null.
333 * @leave KErrNone if successful; otherwise, leaves with a system wide error code.
335 virtual void CreateMacL(CMac*& aMac,
336 const TUid aAlgorithmUid,
338 const CCryptoParams* aAlgorithmParams) = 0;
341 * Create a CAsyncMac instance (for hardware based MAC plug-in dll implementation)
343 * @param aMac The pointer to CMac. This will be initialised with
344 * the plug-in implementation of the desired MAC algorithm.
345 * @param aAlgorithmUid The specific MAC algorithm desired for evaluation of MAC value.
346 * e.g. MD2, SHA1 or AES-XCBC-MAC-96, AES-XCBC-PRF-128
347 * @param aKey Symmetric key for calculating message authentication code value.
348 * @param aAlgorithmParams The parameters those are specific to a particular MAC algorithm.
349 * This is for extendibility and will normally be null.
350 * @leave KErrNone if successful; otherwise, leaves with a system wide error code.
352 virtual void CreateAsyncMacL(CAsyncMac*& aMac,
353 const TUid aAlgorithmUid,
355 const CCryptoParams* aAlgorithmParams) = 0;
358 * Create a CHash instance
360 * @param aHash The pointer to CHash
361 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1, MD4
362 * @param aAlgorithmParams The parameters that are specific to a particular
363 * algorithm. This is for extendibility and will normally be null.
364 * @leave KErrNone if successful; otherwise, a system wide error code.
366 virtual void CreateHashL(CHash*& aHash,
368 const CCryptoParams* aAlgorithmParams) = 0;
371 * Create a CAsyncHash instance
373 * @param aAsyncHash The pointer to CAsyncHash
374 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1, MD4
375 * @param aAlgorithmParams The parameters that are specific to a particular
376 * algorithm. This is for extendibility and will normally be null.
377 * @leave KErrNone if successful; otherwise, a system wide error code.
379 virtual void CreateAsyncHashL(CAsyncHash*& aAsyncHash,
381 const CCryptoParams* aAlgorithmParams) = 0;
386 MPluginSelector::~MPluginSelector()
390 #endif //__CRYPTOAPI_PLUGINSELECTORBASE_H__