sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-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 |
* X.509 key classes and utility classes for key encoding/decoding.
|
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 |
#if !defined (__X509KEYS_H__)
|
sl@0
|
27 |
#define __X509KEYS_H__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <e32base.h>
|
sl@0
|
30 |
#include <e32std.h>
|
sl@0
|
31 |
#include <asymmetrickeys.h>
|
sl@0
|
32 |
#include <asymmetric.h>
|
sl@0
|
33 |
#include <hash.h>
|
sl@0
|
34 |
#include <bigint.h>
|
sl@0
|
35 |
#include <signed.h>
|
sl@0
|
36 |
|
sl@0
|
37 |
// Forward declarations
|
sl@0
|
38 |
class CASN1EncBase;
|
sl@0
|
39 |
class CASN1EncContainer;
|
sl@0
|
40 |
class CASN1EncSequence;
|
sl@0
|
41 |
class CASN1EncBitString;
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
|
sl@0
|
45 |
#include <x509keyencoder.h>
|
sl@0
|
46 |
#endif
|
sl@0
|
47 |
|
sl@0
|
48 |
class CX509RSAPublicKey : public CRSAPublicKey
|
sl@0
|
49 |
/** Adds the capability to decode DER-encoded RSA public keys.
|
sl@0
|
50 |
*
|
sl@0
|
51 |
* Adds a commitment to a specific encoding scheme allowing X.509 RSA public key
|
sl@0
|
52 |
* superclasses to remain encoding-independent.
|
sl@0
|
53 |
*
|
sl@0
|
54 |
*
|
sl@0
|
55 |
* @since v6.0
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
{
|
sl@0
|
58 |
public:
|
sl@0
|
59 |
/** Creates a new RSA Public key object from the specified buffer containing the
|
sl@0
|
60 |
* encoded binary representation.
|
sl@0
|
61 |
*
|
sl@0
|
62 |
* Initialises the object from its encoded binary form into an internal representation.
|
sl@0
|
63 |
*
|
sl@0
|
64 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
65 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
sl@0
|
66 |
IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData);
|
sl@0
|
67 |
|
sl@0
|
68 |
/** Creates a new RSA Public Key object from the specified buffer containing the
|
sl@0
|
69 |
* encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
70 |
*
|
sl@0
|
71 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
72 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
sl@0
|
73 |
IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData);
|
sl@0
|
74 |
|
sl@0
|
75 |
/** Creates a new RSA Public key object from the specified buffer containing the
|
sl@0
|
76 |
* encoded binary representation, starting at the specified offset.
|
sl@0
|
77 |
*
|
sl@0
|
78 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
79 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
80 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
sl@0
|
81 |
IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
82 |
|
sl@0
|
83 |
/** Creates a new RSA Public key object from the specified buffer containing the
|
sl@0
|
84 |
* encoded binary representation, starting at the specified offset, and puts
|
sl@0
|
85 |
* a pointer to it onto the cleanup stack.
|
sl@0
|
86 |
*
|
sl@0
|
87 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
88 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
89 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
sl@0
|
90 |
IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
91 |
private:
|
sl@0
|
92 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
93 |
CX509RSAPublicKey();
|
sl@0
|
94 |
};
|
sl@0
|
95 |
|
sl@0
|
96 |
class TASN1EncRSAPublicKey
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
* Class for encoding RSA public keys to ASN.1 encoding.
|
sl@0
|
99 |
*
|
sl@0
|
100 |
* @since v8.0
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
{
|
sl@0
|
103 |
public:
|
sl@0
|
104 |
/**
|
sl@0
|
105 |
* Encodes the supplied public key into buffer in DER format ASN.1:
|
sl@0
|
106 |
* @code
|
sl@0
|
107 |
* SEQUENCE-OF
|
sl@0
|
108 |
* INTEGER modulus
|
sl@0
|
109 |
* INTEGER exponent
|
sl@0
|
110 |
* @endcode
|
sl@0
|
111 |
*
|
sl@0
|
112 |
* @param aKey Key to encode.
|
sl@0
|
113 |
* @return Allocated buffer containing DER encoding of
|
sl@0
|
114 |
* the supplied key aKey.
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
IMPORT_C HBufC8* EncodeDERL(const CRSAPublicKey& aKey) const;
|
sl@0
|
117 |
};
|
sl@0
|
118 |
|
sl@0
|
119 |
class TASN1DecRSAPublicKey
|
sl@0
|
120 |
/**
|
sl@0
|
121 |
* Class for decoding RSA public keys from ASN.1 DER encoding.
|
sl@0
|
122 |
*
|
sl@0
|
123 |
* @since v8.0
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
{
|
sl@0
|
126 |
public:
|
sl@0
|
127 |
/**
|
sl@0
|
128 |
* Decodes an RSA key from the supplied buffer starting at the
|
sl@0
|
129 |
* specified position.
|
sl@0
|
130 |
*
|
sl@0
|
131 |
* @param aDER Buffer containing DER ASN.1 encoding of the key.
|
sl@0
|
132 |
* @param aPos Starting position in the buffer (updated on exit).
|
sl@0
|
133 |
* @return A pointer to the new CRSAPublicKey object.
|
sl@0
|
134 |
*/
|
sl@0
|
135 |
IMPORT_C CRSAPublicKey* DecodeDERL(const TDesC8& aDER, TInt& aPos) const;
|
sl@0
|
136 |
};
|
sl@0
|
137 |
|
sl@0
|
138 |
class TASN1DecRSAKeyPair
|
sl@0
|
139 |
/**
|
sl@0
|
140 |
* Class for decoding RSA key pairs from ASN.1 DER encoding.
|
sl@0
|
141 |
*
|
sl@0
|
142 |
* @since v8.0
|
sl@0
|
143 |
*/
|
sl@0
|
144 |
{
|
sl@0
|
145 |
public:
|
sl@0
|
146 |
/**
|
sl@0
|
147 |
* Decodes an RSA key pair from buffer containing ASN.1
|
sl@0
|
148 |
* DER-encoded private key. The encoding of a private key
|
sl@0
|
149 |
* contains public key components as well.
|
sl@0
|
150 |
*
|
sl@0
|
151 |
* @param aDER DER-encoded private key.
|
sl@0
|
152 |
* @param aPos Position in the buffer to start decoding
|
sl@0
|
153 |
* (updated on exit).
|
sl@0
|
154 |
* @param aPublicKey On return, the RSA public key object
|
sl@0
|
155 |
* @param aPrivateKey On return, the RSA private key object
|
sl@0
|
156 |
* @param aKeyType Key type, default is @c EStandardCRT
|
sl@0
|
157 |
*/
|
sl@0
|
158 |
IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos,
|
sl@0
|
159 |
CRSAPublicKey*& aPublicKey,
|
sl@0
|
160 |
CRSAPrivateKey*& aPrivateKey,
|
sl@0
|
161 |
TRSAPrivateKeyType aKeyType = EStandardCRT);
|
sl@0
|
162 |
};
|
sl@0
|
163 |
|
sl@0
|
164 |
class CX509DSAPublicKey : public CDSAPublicKey
|
sl@0
|
165 |
/** Encapsulates the X.509 DSA public key.
|
sl@0
|
166 |
*
|
sl@0
|
167 |
* Adds a commitment to a specific encoding scheme allowing superclasses to remain
|
sl@0
|
168 |
* encoding-independent.
|
sl@0
|
169 |
*
|
sl@0
|
170 |
* @since v6.0
|
sl@0
|
171 |
*/
|
sl@0
|
172 |
// DSA public key, params, signature.
|
sl@0
|
173 |
{
|
sl@0
|
174 |
public:
|
sl@0
|
175 |
/** Creates a new X.509 DSA public key object.
|
sl@0
|
176 |
*
|
sl@0
|
177 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
178 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
179 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
180 |
IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData);
|
sl@0
|
181 |
|
sl@0
|
182 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
183 |
*
|
sl@0
|
184 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
185 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
186 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
187 |
IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData);
|
sl@0
|
188 |
|
sl@0
|
189 |
/** Creates a new X.509 DSA public key object.
|
sl@0
|
190 |
*
|
sl@0
|
191 |
* @param aParams The DSA parameters.
|
sl@0
|
192 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
193 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
194 |
IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData);
|
sl@0
|
195 |
|
sl@0
|
196 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
197 |
*
|
sl@0
|
198 |
* @param aParams The DSA parameters.
|
sl@0
|
199 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
200 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
201 |
IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData);
|
sl@0
|
202 |
|
sl@0
|
203 |
/** Creates a new X.509 DSA public key object.
|
sl@0
|
204 |
*
|
sl@0
|
205 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
206 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
207 |
* @param aPos The position from which to start decoding.
|
sl@0
|
208 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
209 |
IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData,TInt& aPos);
|
sl@0
|
210 |
|
sl@0
|
211 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
212 |
*
|
sl@0
|
213 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
214 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
215 |
* @param aPos The position from which to start decoding.
|
sl@0
|
216 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
217 |
IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
218 |
|
sl@0
|
219 |
/** Creates a new X.509 DSA public key object.
|
sl@0
|
220 |
*
|
sl@0
|
221 |
* @param aParams The DSA parameters.
|
sl@0
|
222 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
223 |
* @param aPos The position from which to start decoding.
|
sl@0
|
224 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
225 |
IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
226 |
|
sl@0
|
227 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
228 |
*
|
sl@0
|
229 |
* @param aParams The DSA parameters.
|
sl@0
|
230 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
231 |
* @param aPos The position from which to start decoding.
|
sl@0
|
232 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
sl@0
|
233 |
IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
234 |
public:
|
sl@0
|
235 |
/** Gets the DSA parameters from the encoding key.
|
sl@0
|
236 |
*
|
sl@0
|
237 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
238 |
* @return The DSA parameters. */
|
sl@0
|
239 |
IMPORT_C static CDSAParameters* DSAParametersL(const TDesC8& aParamsData);
|
sl@0
|
240 |
protected:
|
sl@0
|
241 |
/** @internalComponent */
|
sl@0
|
242 |
void ConstructL(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
243 |
/** @internalComponent */
|
sl@0
|
244 |
void ConstructL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
245 |
/** @internalComponent */
|
sl@0
|
246 |
CX509DSAPublicKey();
|
sl@0
|
247 |
};
|
sl@0
|
248 |
|
sl@0
|
249 |
class TASN1DecDSAKeyPair
|
sl@0
|
250 |
/**
|
sl@0
|
251 |
* Class for decoding DSA key pairs from ASN.1 DER encoding.
|
sl@0
|
252 |
*
|
sl@0
|
253 |
* @since v8.0
|
sl@0
|
254 |
*/
|
sl@0
|
255 |
{
|
sl@0
|
256 |
public:
|
sl@0
|
257 |
/**
|
sl@0
|
258 |
* Decodes a DSA key pair from a buffer containing an ASN.1
|
sl@0
|
259 |
* DER-encoded private key.
|
sl@0
|
260 |
*
|
sl@0
|
261 |
* The encoding of the private key contains public key components as well.
|
sl@0
|
262 |
*
|
sl@0
|
263 |
* The DER encoding has the following format:
|
sl@0
|
264 |
* @verbatim
|
sl@0
|
265 |
* SEQUENCE-OF
|
sl@0
|
266 |
* INTEGER version (==0, ignored)
|
sl@0
|
267 |
* INTEGER p (public prime)
|
sl@0
|
268 |
* INTEGER q (160-bit public subprime, q | p-1)
|
sl@0
|
269 |
* INTEGER g (public generator of subgroup)
|
sl@0
|
270 |
* INTEGER x (private key)
|
sl@0
|
271 |
* INTEGER y (public key y=g^x)
|
sl@0
|
272 |
* @endverbatim
|
sl@0
|
273 |
*
|
sl@0
|
274 |
* @param aDER DER-encoded private key.
|
sl@0
|
275 |
* @param aPos Position in the buffer to start decoding
|
sl@0
|
276 |
* (updated on exit).
|
sl@0
|
277 |
* @param aPublicKey On return, the DSA public key object
|
sl@0
|
278 |
* @param aPrivateKey On return, the DSA private key object
|
sl@0
|
279 |
*/
|
sl@0
|
280 |
IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos,
|
sl@0
|
281 |
CDSAPublicKey*& aPublicKey, CDSAPrivateKey*& aPrivateKey);
|
sl@0
|
282 |
};
|
sl@0
|
283 |
|
sl@0
|
284 |
/**
|
sl@0
|
285 |
* Class for encoding DSA public keys to ASN.1 encoding.
|
sl@0
|
286 |
*
|
sl@0
|
287 |
* @since v8.0
|
sl@0
|
288 |
*/
|
sl@0
|
289 |
class TASN1EncDSAPublicKey
|
sl@0
|
290 |
{
|
sl@0
|
291 |
public:
|
sl@0
|
292 |
/**
|
sl@0
|
293 |
* Encodes the supplied public key into a buffer in DER format.
|
sl@0
|
294 |
*
|
sl@0
|
295 |
* Note that the encoding has the following format:
|
sl@0
|
296 |
* @code
|
sl@0
|
297 |
* SEQUENCE-OF
|
sl@0
|
298 |
* SEQUENCE-OF
|
sl@0
|
299 |
* INTEGER p
|
sl@0
|
300 |
* INTEGER q
|
sl@0
|
301 |
* INTEGER g
|
sl@0
|
302 |
* BIT STRING (encoded INTEGER public value)
|
sl@0
|
303 |
* @endcode
|
sl@0
|
304 |
*
|
sl@0
|
305 |
* @param aKey Key to encode.
|
sl@0
|
306 |
* @return Sequence containing public key information.
|
sl@0
|
307 |
*/
|
sl@0
|
308 |
IMPORT_C CASN1EncSequence* EncodeDERL(const CDSAPublicKey& aKey) const;
|
sl@0
|
309 |
|
sl@0
|
310 |
/**
|
sl@0
|
311 |
* Encodes DSA parameters into an ASN.1 encoding structure suitable for
|
sl@0
|
312 |
* inclusion into other objects, like a PKCS#10 certificate request.
|
sl@0
|
313 |
*
|
sl@0
|
314 |
* Note that the encoding has the following form:
|
sl@0
|
315 |
* @code
|
sl@0
|
316 |
* SEQUENCE-OF
|
sl@0
|
317 |
* INTEGER p
|
sl@0
|
318 |
* INTEGER q
|
sl@0
|
319 |
* INTEGER g
|
sl@0
|
320 |
* @endcode
|
sl@0
|
321 |
*
|
sl@0
|
322 |
* @param aKey DSA public key.
|
sl@0
|
323 |
* @return ASN.1 encoding structure on the cleanup stack.
|
sl@0
|
324 |
*/
|
sl@0
|
325 |
IMPORT_C CASN1EncSequence* EncodeParamsLC(const CDSAPublicKey& aKey) const;
|
sl@0
|
326 |
|
sl@0
|
327 |
/**
|
sl@0
|
328 |
* Encodes a public key as a bit string.
|
sl@0
|
329 |
*
|
sl@0
|
330 |
* @param aKey DSA public key.
|
sl@0
|
331 |
* @return ASN.1 bit string (public key). This is left on the cleanup stack.
|
sl@0
|
332 |
*/
|
sl@0
|
333 |
|
sl@0
|
334 |
IMPORT_C CASN1EncBitString* EncodePublicValueLC(const CDSAPublicKey& aKey) const;
|
sl@0
|
335 |
};
|
sl@0
|
336 |
|
sl@0
|
337 |
class CX509DSASignature : public CDSASignature
|
sl@0
|
338 |
/** Encapsulates the X.509 DSA signature.
|
sl@0
|
339 |
*
|
sl@0
|
340 |
* Adds a commitment to a specific encoding scheme allowing superclasses to remain
|
sl@0
|
341 |
* encoding-independent.
|
sl@0
|
342 |
*
|
sl@0
|
343 |
* @since v6.0 */
|
sl@0
|
344 |
{
|
sl@0
|
345 |
public:
|
sl@0
|
346 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
sl@0
|
347 |
* encoded binary representation.
|
sl@0
|
348 |
*
|
sl@0
|
349 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
350 |
* @return A pointer to the new CX509DSASignature object. */
|
sl@0
|
351 |
IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData);
|
sl@0
|
352 |
|
sl@0
|
353 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
sl@0
|
354 |
* encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
355 |
*
|
sl@0
|
356 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
357 |
* @return A pointer to the new CX509DSASignature object. */
|
sl@0
|
358 |
IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData);
|
sl@0
|
359 |
|
sl@0
|
360 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
sl@0
|
361 |
* encoded binary representation, starting at the specified offset.
|
sl@0
|
362 |
*
|
sl@0
|
363 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
364 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
365 |
* @return A pointer to the new CX509DSASignature object. */
|
sl@0
|
366 |
IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
367 |
|
sl@0
|
368 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
sl@0
|
369 |
* encoded binary representation, starting at the specified offset, and puts
|
sl@0
|
370 |
* a pointer to it onto the cleanup stack.
|
sl@0
|
371 |
*
|
sl@0
|
372 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
373 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
374 |
* @return A pointer to the new CX509DSASignature object. */
|
sl@0
|
375 |
IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
376 |
private:
|
sl@0
|
377 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
378 |
CX509DSASignature();
|
sl@0
|
379 |
};
|
sl@0
|
380 |
|
sl@0
|
381 |
class CX509DHPublicKey : public CDHPublicKey
|
sl@0
|
382 |
/** Provides clients with the information they need for Diffie-Hellman key exchange
|
sl@0
|
383 |
* within a protocol.
|
sl@0
|
384 |
*
|
sl@0
|
385 |
* @since v6.0 */
|
sl@0
|
386 |
{
|
sl@0
|
387 |
public:
|
sl@0
|
388 |
/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded
|
sl@0
|
389 |
* binary representation.
|
sl@0
|
390 |
*
|
sl@0
|
391 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
392 |
* @param aKeyData
|
sl@0
|
393 |
* @return A pointer to the new CX509DHPublicKey object.*/
|
sl@0
|
394 |
IMPORT_C static CX509DHPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aKeyData);
|
sl@0
|
395 |
|
sl@0
|
396 |
/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded
|
sl@0
|
397 |
* binary representation, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
398 |
*
|
sl@0
|
399 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
400 |
* @param aKeyData
|
sl@0
|
401 |
* @return A pointer to the new CX509DHPublicKey object.*/
|
sl@0
|
402 |
IMPORT_C static CX509DHPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aKeyData);
|
sl@0
|
403 |
public:
|
sl@0
|
404 |
/** Destructor.
|
sl@0
|
405 |
*
|
sl@0
|
406 |
* Frees all resources owned by the object, prior to its destruction. */
|
sl@0
|
407 |
IMPORT_C virtual ~CX509DHPublicKey();
|
sl@0
|
408 |
protected:
|
sl@0
|
409 |
/** @internalComponent */
|
sl@0
|
410 |
CX509DHPublicKey();
|
sl@0
|
411 |
/** @internalComponent */
|
sl@0
|
412 |
void ConstructL(const TDesC8& aParamsData, const TDesC8& aKeyData);
|
sl@0
|
413 |
};
|
sl@0
|
414 |
|
sl@0
|
415 |
class CX509DHKeyPair : public CDHKeyPair
|
sl@0
|
416 |
/** This class represents the Diffie-Hellman Key Pair.
|
sl@0
|
417 |
*
|
sl@0
|
418 |
* @since v8.0 */
|
sl@0
|
419 |
{
|
sl@0
|
420 |
public:
|
sl@0
|
421 |
/** Creates a new DH key pair object from the specified buffer containing
|
sl@0
|
422 |
* the encoded binary representation .
|
sl@0
|
423 |
*
|
sl@0
|
424 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
425 |
* @return A pointer to the new CX509DHKeyPair object.
|
sl@0
|
426 |
*/
|
sl@0
|
427 |
IMPORT_C static CX509DHKeyPair* NewL(const TDesC8& aParamsData);
|
sl@0
|
428 |
|
sl@0
|
429 |
/** Creates a new DH Key Pair object from the specified buffer containing the encoded binary
|
sl@0
|
430 |
* representation, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
431 |
*
|
sl@0
|
432 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
433 |
* @return A pointer to the new CX509DHKeyPair object.
|
sl@0
|
434 |
*/
|
sl@0
|
435 |
IMPORT_C static CX509DHKeyPair* NewLC(const TDesC8& aParamsData);
|
sl@0
|
436 |
public:
|
sl@0
|
437 |
|
sl@0
|
438 |
/** Virtual Destructor.
|
sl@0
|
439 |
* Frees all resources owned by the object, prior to its destruction.
|
sl@0
|
440 |
*
|
sl@0
|
441 |
*/
|
sl@0
|
442 |
IMPORT_C virtual ~CX509DHKeyPair();
|
sl@0
|
443 |
protected:
|
sl@0
|
444 |
/** @internalComponent */
|
sl@0
|
445 |
CX509DHKeyPair();
|
sl@0
|
446 |
/** @internalComponent */
|
sl@0
|
447 |
void ConstructL(const TDesC8& aParamsData);
|
sl@0
|
448 |
};
|
sl@0
|
449 |
|
sl@0
|
450 |
class CX509DHValidationParams : public CBase
|
sl@0
|
451 |
/** Validates Diffie-Hellman (DH) Domain parameters.
|
sl@0
|
452 |
*
|
sl@0
|
453 |
* Provides access to the DH Validation Parameters, which are used to determine
|
sl@0
|
454 |
* if the DH Public Key has been generated in conformance with the algorithm
|
sl@0
|
455 |
* specified in ESDH (see RFC 2631).
|
sl@0
|
456 |
*
|
sl@0
|
457 |
* @since v6.0 */
|
sl@0
|
458 |
{
|
sl@0
|
459 |
public:
|
sl@0
|
460 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
sl@0
|
461 |
* the encoded binary representation.
|
sl@0
|
462 |
*
|
sl@0
|
463 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
464 |
* @return A pointer to the new CX509DHValidationParams object. */
|
sl@0
|
465 |
IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData);
|
sl@0
|
466 |
|
sl@0
|
467 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
sl@0
|
468 |
* the encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
469 |
*
|
sl@0
|
470 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
471 |
* @return A pointer to the new CX509DHValidationParams object. */
|
sl@0
|
472 |
IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData);
|
sl@0
|
473 |
|
sl@0
|
474 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
sl@0
|
475 |
* the encoded binary representation, starting at the specified offset.
|
sl@0
|
476 |
*
|
sl@0
|
477 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
478 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
479 |
* @return A pointer to the new CX509DHValidationParams object. */
|
sl@0
|
480 |
IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
481 |
|
sl@0
|
482 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
sl@0
|
483 |
* the encoded binary representation, starting at the specified offset, and puts
|
sl@0
|
484 |
* a pointer to it onto the cleanup stack.
|
sl@0
|
485 |
*
|
sl@0
|
486 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
487 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
488 |
* @return A pointer to the new CX509DHValidationParams object. */
|
sl@0
|
489 |
IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
490 |
|
sl@0
|
491 |
/** Gets a DSA prime generation seed.
|
sl@0
|
492 |
*
|
sl@0
|
493 |
* @return The bit string parameter used as the seed. */
|
sl@0
|
494 |
IMPORT_C const TPtrC8 Seed() const;
|
sl@0
|
495 |
|
sl@0
|
496 |
/** Gets the output from a DSA prime generation counter.
|
sl@0
|
497 |
*
|
sl@0
|
498 |
* @return The integer value output. */
|
sl@0
|
499 |
IMPORT_C const TInteger& PGenCounter() const;
|
sl@0
|
500 |
|
sl@0
|
501 |
/** Destructor.
|
sl@0
|
502 |
*
|
sl@0
|
503 |
* Frees all resources owned by the object, prior to its destruction. */
|
sl@0
|
504 |
virtual ~CX509DHValidationParams();
|
sl@0
|
505 |
protected:
|
sl@0
|
506 |
/** @internalComponent */
|
sl@0
|
507 |
CX509DHValidationParams();
|
sl@0
|
508 |
/** @internalComponent */
|
sl@0
|
509 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
510 |
HBufC8* iSeed;
|
sl@0
|
511 |
RInteger iPGenCounter;
|
sl@0
|
512 |
};
|
sl@0
|
513 |
|
sl@0
|
514 |
class CX509DHDomainParams : public CBase
|
sl@0
|
515 |
/** Encapsulates the compulsory Diffie-Hellman domain parameter values P and G
|
sl@0
|
516 |
* (See RFC 2459).
|
sl@0
|
517 |
*
|
sl@0
|
518 |
* @since v6.0 */
|
sl@0
|
519 |
{
|
sl@0
|
520 |
public:
|
sl@0
|
521 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
sl@0
|
522 |
* the encoded binary representation.
|
sl@0
|
523 |
*
|
sl@0
|
524 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
525 |
* @return A pointer to the new CX509DHDomainParams object. */
|
sl@0
|
526 |
IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData);
|
sl@0
|
527 |
|
sl@0
|
528 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
sl@0
|
529 |
* the encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
530 |
*
|
sl@0
|
531 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
532 |
* @return A pointer to the new CX509DHDomainParams object. */
|
sl@0
|
533 |
IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData);
|
sl@0
|
534 |
|
sl@0
|
535 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
sl@0
|
536 |
* the encoded binary representation, starting at the specified offset.
|
sl@0
|
537 |
*
|
sl@0
|
538 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
539 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
540 |
* @return A pointer to the new CX509DHDomainParams object. */
|
sl@0
|
541 |
IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
542 |
|
sl@0
|
543 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
sl@0
|
544 |
* the encoded binary representation, starting at the specified offset, and puts
|
sl@0
|
545 |
* a pointer to it onto the cleanup stack.
|
sl@0
|
546 |
*
|
sl@0
|
547 |
* @param aBinaryData The encoded binary representation.
|
sl@0
|
548 |
* @param aPos The offset position from which to start decoding.
|
sl@0
|
549 |
* @return A pointer to the new CX509DHDomainParams object. */
|
sl@0
|
550 |
IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
551 |
|
sl@0
|
552 |
/** Gets the compulsory parameter value P.
|
sl@0
|
553 |
*
|
sl@0
|
554 |
* @return The compulsory parameter value P. */
|
sl@0
|
555 |
IMPORT_C const TInteger& P() const;
|
sl@0
|
556 |
|
sl@0
|
557 |
/** Gets the compulsory parameter value G.
|
sl@0
|
558 |
*
|
sl@0
|
559 |
* @return The compulsory parameter value G. */
|
sl@0
|
560 |
IMPORT_C const TInteger& G() const;
|
sl@0
|
561 |
|
sl@0
|
562 |
//the next 3 members are optional, in which case NULL is returned
|
sl@0
|
563 |
//the returned objects remain the property of this object
|
sl@0
|
564 |
|
sl@0
|
565 |
//N.B. according to RFC 2459 the Q member is *not* optional,
|
sl@0
|
566 |
//however it is not essential for doing DH, and empirical studies
|
sl@0
|
567 |
//suggest it doesn't get included much, so I'm relaxing the spec here
|
sl@0
|
568 |
//to permit DomainParams objects which contain no Q.
|
sl@0
|
569 |
|
sl@0
|
570 |
/** Gets the optional value Q.
|
sl@0
|
571 |
*
|
sl@0
|
572 |
* @return The optional value Q. */
|
sl@0
|
573 |
IMPORT_C const TInteger& Q() const;
|
sl@0
|
574 |
|
sl@0
|
575 |
/** Gets the optional value J.
|
sl@0
|
576 |
*
|
sl@0
|
577 |
* @return The optional value J. */
|
sl@0
|
578 |
IMPORT_C const TInteger& J() const;
|
sl@0
|
579 |
|
sl@0
|
580 |
/** Gets the optional validation parameters.
|
sl@0
|
581 |
*
|
sl@0
|
582 |
* @return The optional validation parameters. */
|
sl@0
|
583 |
IMPORT_C const CX509DHValidationParams* ValidationParams() const;
|
sl@0
|
584 |
|
sl@0
|
585 |
/** Destructor.
|
sl@0
|
586 |
*
|
sl@0
|
587 |
* Frees all resources owned by the object, prior to its destruction. */
|
sl@0
|
588 |
virtual ~CX509DHDomainParams();
|
sl@0
|
589 |
protected:
|
sl@0
|
590 |
/** @internalComponent */
|
sl@0
|
591 |
CX509DHDomainParams();
|
sl@0
|
592 |
/** @internalComponent */
|
sl@0
|
593 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
sl@0
|
594 |
RInteger iP;
|
sl@0
|
595 |
RInteger iG;
|
sl@0
|
596 |
RInteger iQ;
|
sl@0
|
597 |
RInteger iJ;
|
sl@0
|
598 |
CX509DHValidationParams* iValidationParams;
|
sl@0
|
599 |
};
|
sl@0
|
600 |
|
sl@0
|
601 |
#endif
|