sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* crypto parameters interface
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@publishedAll
|
sl@0
|
23 |
@released
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef __CRYPTOPARAMS_H__
|
sl@0
|
27 |
#define __CRYPTOPARAMS_H__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <bigint.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
namespace CryptoSpi
|
sl@0
|
32 |
{
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
Abstract base class for generic crypto parameters to enable plug-in
|
sl@0
|
35 |
specific parameters and the externalisation of plug-ins. The type
|
sl@0
|
36 |
of the sub-class is identified by the GetType method.
|
sl@0
|
37 |
|
sl@0
|
38 |
All sub-class contain copies of (instead of references to) the
|
sl@0
|
39 |
supplied values.
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
NONSHARABLE_CLASS(CCryptoParam) : public CBase
|
sl@0
|
42 |
{
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
|
sl@0
|
45 |
/**
|
sl@0
|
46 |
The definition of the data type of the embedded value.
|
sl@0
|
47 |
Other data types may be added in future so applications
|
sl@0
|
48 |
should not panic if the type is not recognised.
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
enum TParamType
|
sl@0
|
51 |
{
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
RCryptoIntParam
|
sl@0
|
54 |
*/
|
sl@0
|
55 |
EInt = 1,
|
sl@0
|
56 |
/**
|
sl@0
|
57 |
RCryptoBigIntParam
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
EBigInt = 2,
|
sl@0
|
60 |
/**
|
sl@0
|
61 |
RCryptoDesC8Param
|
sl@0
|
62 |
*/
|
sl@0
|
63 |
EDesC8 = 3,
|
sl@0
|
64 |
/**
|
sl@0
|
65 |
RCryptoDesC16Param
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
EDesC16 = 4,
|
sl@0
|
68 |
};
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
Returns the data type of the crypto parameter
|
sl@0
|
72 |
@return The data type of the crypto parameter
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
IMPORT_C TInt Type() const;
|
sl@0
|
75 |
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
Returns the Uid of the crypto parameter
|
sl@0
|
78 |
@return The Uid of the crypto parameter
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
IMPORT_C TUid Uid() const;
|
sl@0
|
81 |
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
Destructor
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
IMPORT_C ~CCryptoParam();
|
sl@0
|
86 |
|
sl@0
|
87 |
protected:
|
sl@0
|
88 |
/**
|
sl@0
|
89 |
* @internalComponent
|
sl@0
|
90 |
*
|
sl@0
|
91 |
* Constructor
|
sl@0
|
92 |
* @param aType The data type identifier for the sub-class.
|
sl@0
|
93 |
* @param aUid The Uid of the cryptoparam
|
sl@0
|
94 |
*/
|
sl@0
|
95 |
CCryptoParam(TParamType aType, TUid aUid);
|
sl@0
|
96 |
|
sl@0
|
97 |
protected:
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
The data type of the embedded value
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
TParamType iType;
|
sl@0
|
102 |
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
The Uid of the crypto parameter
|
sl@0
|
105 |
*/
|
sl@0
|
106 |
TUid iUid;
|
sl@0
|
107 |
};
|
sl@0
|
108 |
|
sl@0
|
109 |
/**
|
sl@0
|
110 |
CryptoParam class that wraps a TInt
|
sl@0
|
111 |
*/
|
sl@0
|
112 |
NONSHARABLE_CLASS(CCryptoIntParam) : public CCryptoParam
|
sl@0
|
113 |
{
|
sl@0
|
114 |
public:
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
Factory method for allocating a new CCryptoIntParam object
|
sl@0
|
117 |
that contains a copy of the supplied TInt
|
sl@0
|
118 |
@param aValue The TInt to be wrapped (copied)
|
sl@0
|
119 |
@param aUid The UID of the CryptoParam
|
sl@0
|
120 |
@return A pointer to a CCryptoIntParam instance
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
IMPORT_C static CCryptoIntParam* NewL(TInt aValue, TUid aUid);
|
sl@0
|
123 |
|
sl@0
|
124 |
/**
|
sl@0
|
125 |
Factory method for allocating a new CCryptoIntParam object
|
sl@0
|
126 |
that contains a copy of the supplied TInt
|
sl@0
|
127 |
Leaves the pointer of the CryptoParam on the cleanup stack
|
sl@0
|
128 |
@param aValue The TInt to be wrapped (copied)
|
sl@0
|
129 |
@param aUid The UID of the CryptoParam
|
sl@0
|
130 |
@return A pointer to a CCryptoIntParam instance
|
sl@0
|
131 |
*/
|
sl@0
|
132 |
IMPORT_C static CCryptoIntParam* NewLC(TInt aValue, TUid aUid);
|
sl@0
|
133 |
|
sl@0
|
134 |
/**
|
sl@0
|
135 |
Returns the embedded value.
|
sl@0
|
136 |
@return The embedded integer
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
IMPORT_C TInt Value() const;
|
sl@0
|
139 |
|
sl@0
|
140 |
/**
|
sl@0
|
141 |
Destructor
|
sl@0
|
142 |
*/
|
sl@0
|
143 |
IMPORT_C ~CCryptoIntParam();
|
sl@0
|
144 |
|
sl@0
|
145 |
private:
|
sl@0
|
146 |
/**
|
sl@0
|
147 |
Constructor
|
sl@0
|
148 |
@param aValue The integer to wrap
|
sl@0
|
149 |
@param aUid The UID of the crypto parameter
|
sl@0
|
150 |
*/
|
sl@0
|
151 |
CCryptoIntParam(TInt aValue, TUid aUid);
|
sl@0
|
152 |
|
sl@0
|
153 |
private:
|
sl@0
|
154 |
/**
|
sl@0
|
155 |
The embedded value
|
sl@0
|
156 |
*/
|
sl@0
|
157 |
TInt iValue;
|
sl@0
|
158 |
};
|
sl@0
|
159 |
|
sl@0
|
160 |
/**
|
sl@0
|
161 |
Crypto param class the wraps an RInteger
|
sl@0
|
162 |
*/
|
sl@0
|
163 |
NONSHARABLE_CLASS(CCryptoBigIntParam) : public CCryptoParam
|
sl@0
|
164 |
{
|
sl@0
|
165 |
public:
|
sl@0
|
166 |
/**
|
sl@0
|
167 |
Factory method for allocating a new CCryptoBigIntParam object
|
sl@0
|
168 |
that contains a copy of the supplied TInteger object.
|
sl@0
|
169 |
@param aValue The TInteger to be wrapped (copied)
|
sl@0
|
170 |
@param aUid The UID of the CryptoParam
|
sl@0
|
171 |
@return A pointer to a CCryptoBigIntParam instance
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
IMPORT_C static CCryptoBigIntParam* NewL(const TInteger& aValue, TUid aUid);
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
Factory method for allocating a new CCryptoBigIntParam object
|
sl@0
|
177 |
that contains a copy of the supplied TInteger object.
|
sl@0
|
178 |
Leaves the pointer of the CryptoParam onto the cleanup stack.
|
sl@0
|
179 |
@param aValue The TInteger to be wrapped (copied)
|
sl@0
|
180 |
@param aUid The UID of the CryptoParam
|
sl@0
|
181 |
@return A pointer to a CCryptoBigIntParam instance
|
sl@0
|
182 |
*/
|
sl@0
|
183 |
IMPORT_C static CCryptoBigIntParam* NewLC(const TInteger& aValue, TUid aUid);
|
sl@0
|
184 |
|
sl@0
|
185 |
/**
|
sl@0
|
186 |
Returns the embedded value.
|
sl@0
|
187 |
@return A reference to the embedded TInteger
|
sl@0
|
188 |
*/
|
sl@0
|
189 |
IMPORT_C const TInteger& Value() const;
|
sl@0
|
190 |
|
sl@0
|
191 |
/**
|
sl@0
|
192 |
Destructor
|
sl@0
|
193 |
*/
|
sl@0
|
194 |
IMPORT_C ~CCryptoBigIntParam();
|
sl@0
|
195 |
|
sl@0
|
196 |
private:
|
sl@0
|
197 |
/**
|
sl@0
|
198 |
Constructor
|
sl@0
|
199 |
*/
|
sl@0
|
200 |
CCryptoBigIntParam();
|
sl@0
|
201 |
|
sl@0
|
202 |
/**
|
sl@0
|
203 |
Constructor
|
sl@0
|
204 |
@param aUid The UID of the crypto parameter
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
CCryptoBigIntParam(TUid aUid);
|
sl@0
|
207 |
|
sl@0
|
208 |
/**
|
sl@0
|
209 |
Second Phase Constructor
|
sl@0
|
210 |
@param aValue The TInteger to wrap
|
sl@0
|
211 |
*/
|
sl@0
|
212 |
void ConstructL(const TInteger& aValue);
|
sl@0
|
213 |
|
sl@0
|
214 |
private:
|
sl@0
|
215 |
/**
|
sl@0
|
216 |
The copied RInteger
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
RInteger iValue;
|
sl@0
|
219 |
};
|
sl@0
|
220 |
|
sl@0
|
221 |
/**
|
sl@0
|
222 |
Crypto param class that wraps an 8-bit constant descriptor
|
sl@0
|
223 |
*/
|
sl@0
|
224 |
NONSHARABLE_CLASS(CCryptoDesC8Param) : public CCryptoParam
|
sl@0
|
225 |
{
|
sl@0
|
226 |
public:
|
sl@0
|
227 |
/**
|
sl@0
|
228 |
Factory method for allocating a new CCryptoDesC8Param object
|
sl@0
|
229 |
that contains a copy of the supplied RInteger object.
|
sl@0
|
230 |
@param aValue The TDesC* to be wrapped (copied)
|
sl@0
|
231 |
@param aUid The Uid of the CryptoParam
|
sl@0
|
232 |
@return A pointer to a CCryptoDesC8Param instance
|
sl@0
|
233 |
*/
|
sl@0
|
234 |
IMPORT_C static CCryptoDesC8Param* NewL(const TDesC8& aValue, TUid aUid);
|
sl@0
|
235 |
|
sl@0
|
236 |
/**
|
sl@0
|
237 |
Factory method for allocating a new CCryptoDesC8Param object
|
sl@0
|
238 |
that contains a copy of the supplied RInteger object.
|
sl@0
|
239 |
Leaves the pointer of the CryptoParam on the cleanup stack
|
sl@0
|
240 |
@param aValue The TDesC* to be wrapped (copied)
|
sl@0
|
241 |
@param aUid The Uid of the CryptoParam
|
sl@0
|
242 |
@return A pointer to a CCryptoDesC8Param instance
|
sl@0
|
243 |
*/
|
sl@0
|
244 |
IMPORT_C static CCryptoDesC8Param* NewLC(const TDesC8& aValue, TUid aUid);
|
sl@0
|
245 |
|
sl@0
|
246 |
/**
|
sl@0
|
247 |
Returns the embedded value.
|
sl@0
|
248 |
@return A reference to the embedded TDesC8
|
sl@0
|
249 |
*/
|
sl@0
|
250 |
IMPORT_C const TDesC8& Value() const;
|
sl@0
|
251 |
|
sl@0
|
252 |
/**
|
sl@0
|
253 |
Destructor
|
sl@0
|
254 |
*/
|
sl@0
|
255 |
IMPORT_C ~CCryptoDesC8Param();
|
sl@0
|
256 |
|
sl@0
|
257 |
private:
|
sl@0
|
258 |
/**
|
sl@0
|
259 |
Constructor
|
sl@0
|
260 |
*/
|
sl@0
|
261 |
CCryptoDesC8Param();
|
sl@0
|
262 |
|
sl@0
|
263 |
/**
|
sl@0
|
264 |
Constructor
|
sl@0
|
265 |
@param aUid The UID of the crypto parameter
|
sl@0
|
266 |
*/
|
sl@0
|
267 |
CCryptoDesC8Param(TUid aUid);
|
sl@0
|
268 |
|
sl@0
|
269 |
/**
|
sl@0
|
270 |
Second Phase Constructor
|
sl@0
|
271 |
@param aValue The DesC8 to wrap
|
sl@0
|
272 |
*/
|
sl@0
|
273 |
void ConstructL(const TDesC8& aValue);
|
sl@0
|
274 |
|
sl@0
|
275 |
private:
|
sl@0
|
276 |
/**
|
sl@0
|
277 |
The copied descriptor
|
sl@0
|
278 |
*/
|
sl@0
|
279 |
HBufC8* iValue;
|
sl@0
|
280 |
};
|
sl@0
|
281 |
|
sl@0
|
282 |
/**
|
sl@0
|
283 |
Crypto param class that wraps an 16-bit constant descriptor
|
sl@0
|
284 |
*/
|
sl@0
|
285 |
NONSHARABLE_CLASS(CCryptoDesC16Param) : public CCryptoParam
|
sl@0
|
286 |
{
|
sl@0
|
287 |
public:
|
sl@0
|
288 |
/**
|
sl@0
|
289 |
Factory method for allocating a new CCryptoDesC8Param object
|
sl@0
|
290 |
that contains a copy of the supplied RInteger object.
|
sl@0
|
291 |
@param aValue The TDesC* to be wrapped (copied)
|
sl@0
|
292 |
@param aUid The Uid of the CryptoParam
|
sl@0
|
293 |
@return A pointer to a CCryptoDesC8Param instance
|
sl@0
|
294 |
*/
|
sl@0
|
295 |
IMPORT_C static CCryptoDesC16Param* NewL(const TDesC16& aValue, TUid aUid);
|
sl@0
|
296 |
|
sl@0
|
297 |
/**
|
sl@0
|
298 |
Factory method for allocating a new CCryptoDesC16Param object
|
sl@0
|
299 |
that contains a copy of the supplied RInteger object.
|
sl@0
|
300 |
Leaves the pointer of the CryptoParam on the cleanup stack
|
sl@0
|
301 |
@param aValue The TDesC* to be wrapped (copied)
|
sl@0
|
302 |
@param aUid The Uid of the CryptoParam
|
sl@0
|
303 |
@return A pointer to a CCryptoDesC16Param instance
|
sl@0
|
304 |
*/
|
sl@0
|
305 |
IMPORT_C static CCryptoDesC16Param* NewLC(const TDesC16& aValue, TUid aUid);
|
sl@0
|
306 |
|
sl@0
|
307 |
/**
|
sl@0
|
308 |
Returns the embedded value.
|
sl@0
|
309 |
@return A reference to the embedded TDesC16
|
sl@0
|
310 |
*/
|
sl@0
|
311 |
IMPORT_C const TDesC16& Value() const;
|
sl@0
|
312 |
|
sl@0
|
313 |
/**
|
sl@0
|
314 |
Destructor
|
sl@0
|
315 |
*/
|
sl@0
|
316 |
IMPORT_C ~CCryptoDesC16Param();
|
sl@0
|
317 |
|
sl@0
|
318 |
private:
|
sl@0
|
319 |
/**
|
sl@0
|
320 |
Constructor
|
sl@0
|
321 |
*/
|
sl@0
|
322 |
CCryptoDesC16Param();
|
sl@0
|
323 |
|
sl@0
|
324 |
/**
|
sl@0
|
325 |
Constructor
|
sl@0
|
326 |
@param aUid The UID of the crypto parameter
|
sl@0
|
327 |
*/
|
sl@0
|
328 |
CCryptoDesC16Param(TUid aUid);
|
sl@0
|
329 |
|
sl@0
|
330 |
/**
|
sl@0
|
331 |
Second Phase Constructor
|
sl@0
|
332 |
@param aValue The DesC16 to wrap
|
sl@0
|
333 |
*/
|
sl@0
|
334 |
void ConstructL(const TDesC16& aValue);
|
sl@0
|
335 |
|
sl@0
|
336 |
private:
|
sl@0
|
337 |
/**
|
sl@0
|
338 |
The copied descriptor
|
sl@0
|
339 |
*/
|
sl@0
|
340 |
HBufC16* iValue;
|
sl@0
|
341 |
};
|
sl@0
|
342 |
|
sl@0
|
343 |
NONSHARABLE_CLASS(CCryptoParams) : public CBase
|
sl@0
|
344 |
{
|
sl@0
|
345 |
public:
|
sl@0
|
346 |
IMPORT_C static CCryptoParams* NewL(void);
|
sl@0
|
347 |
IMPORT_C static CCryptoParams* NewLC(void);
|
sl@0
|
348 |
|
sl@0
|
349 |
/**
|
sl@0
|
350 |
* Various adding methods (CCryptoParams takes a copy)
|
sl@0
|
351 |
*/
|
sl@0
|
352 |
IMPORT_C void AddL(const TInteger& aParam, TUid aUid);
|
sl@0
|
353 |
IMPORT_C void AddL(const TInt aParam, TUid aUid);
|
sl@0
|
354 |
IMPORT_C void AddL(const TDesC8& aParam, TUid aUid);
|
sl@0
|
355 |
IMPORT_C void AddL(const TDesC16& aParam, TUid aUid);
|
sl@0
|
356 |
|
sl@0
|
357 |
/**
|
sl@0
|
358 |
* Various retrieving methods
|
sl@0
|
359 |
*/
|
sl@0
|
360 |
IMPORT_C const TInteger& GetBigIntL(TUid aUid) const;
|
sl@0
|
361 |
IMPORT_C TInt GetTIntL(TUid aUid) const;
|
sl@0
|
362 |
IMPORT_C const TDesC8& GetTDesC8L(TUid aUid) const;
|
sl@0
|
363 |
IMPORT_C const TDesC16& GetTDesC16L(TUid aUid) const;
|
sl@0
|
364 |
IMPORT_C const RPointerArray<CCryptoParam>& GetParams() const;
|
sl@0
|
365 |
|
sl@0
|
366 |
/// Queries if a parameter with the specified uid is present
|
sl@0
|
367 |
IMPORT_C TBool IsPresent(TUid aUid) const;
|
sl@0
|
368 |
|
sl@0
|
369 |
/// Return the count of parameters present
|
sl@0
|
370 |
IMPORT_C TInt Count(void) const;
|
sl@0
|
371 |
|
sl@0
|
372 |
/// Copy the passed CCryptoParams
|
sl@0
|
373 |
IMPORT_C CCryptoParams& CopyL(const CCryptoParams& aParams);
|
sl@0
|
374 |
|
sl@0
|
375 |
/// Destructor
|
sl@0
|
376 |
IMPORT_C virtual ~CCryptoParams();
|
sl@0
|
377 |
|
sl@0
|
378 |
protected:
|
sl@0
|
379 |
/** @internalComponent */
|
sl@0
|
380 |
CCryptoParams();
|
sl@0
|
381 |
|
sl@0
|
382 |
/** @internalComponent */
|
sl@0
|
383 |
void ConstructL(void);
|
sl@0
|
384 |
/** @internalComponent */
|
sl@0
|
385 |
CCryptoParam* GetCryptoParam(TUid aUid) const;
|
sl@0
|
386 |
/** @internalComponent */
|
sl@0
|
387 |
CCryptoParam* GetCryptoParamL(TUid aUid) const;
|
sl@0
|
388 |
|
sl@0
|
389 |
private:
|
sl@0
|
390 |
RPointerArray<CCryptoParam> iParams;
|
sl@0
|
391 |
};
|
sl@0
|
392 |
} //End of namespace
|
sl@0
|
393 |
|
sl@0
|
394 |
#endif // __CRYPTOPARAMS_H__
|
sl@0
|
395 |
|