williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description:
|
williamr@2
|
15 |
* X.509 key classes and utility classes for key encoding/decoding.
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
*/
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
/**
|
williamr@2
|
23 |
@file
|
williamr@2
|
24 |
@internalTechnology
|
williamr@2
|
25 |
*/
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#if !defined (__X509KEYS_H__)
|
williamr@2
|
28 |
#define __X509KEYS_H__
|
williamr@2
|
29 |
|
williamr@2
|
30 |
#include <e32base.h>
|
williamr@2
|
31 |
#include <e32std.h>
|
williamr@2
|
32 |
#include <asymmetrickeys.h>
|
williamr@2
|
33 |
#include <asymmetric.h>
|
williamr@2
|
34 |
#include <hash.h>
|
williamr@2
|
35 |
#include <bigint.h>
|
williamr@2
|
36 |
#include <signed.h>
|
williamr@2
|
37 |
|
williamr@2
|
38 |
// Forward declarations
|
williamr@2
|
39 |
class CASN1EncBase;
|
williamr@2
|
40 |
class CASN1EncContainer;
|
williamr@2
|
41 |
class CASN1EncSequence;
|
williamr@2
|
42 |
class CASN1EncBitString;
|
williamr@2
|
43 |
|
williamr@2
|
44 |
class CX509RSAPublicKey : public CRSAPublicKey
|
williamr@2
|
45 |
/** Adds the capability to decode DER-encoded RSA public keys.
|
williamr@2
|
46 |
*
|
williamr@2
|
47 |
* Adds a commitment to a specific encoding scheme allowing X.509 RSA public key
|
williamr@2
|
48 |
* superclasses to remain encoding-independent.
|
williamr@2
|
49 |
*
|
williamr@2
|
50 |
* @publishedAll
|
williamr@2
|
51 |
* @released
|
williamr@2
|
52 |
*
|
williamr@2
|
53 |
* @since v6.0
|
williamr@2
|
54 |
*/
|
williamr@2
|
55 |
{
|
williamr@2
|
56 |
public:
|
williamr@2
|
57 |
/** Creates a new RSA Public key object from the specified buffer containing the
|
williamr@2
|
58 |
* encoded binary representation.
|
williamr@2
|
59 |
*
|
williamr@2
|
60 |
* Initialises the object from its encoded binary form into an internal representation.
|
williamr@2
|
61 |
*
|
williamr@2
|
62 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
63 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
williamr@2
|
64 |
IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData);
|
williamr@2
|
65 |
|
williamr@2
|
66 |
/** Creates a new RSA Public Key object from the specified buffer containing the
|
williamr@2
|
67 |
* encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
68 |
*
|
williamr@2
|
69 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
70 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
williamr@2
|
71 |
IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData);
|
williamr@2
|
72 |
|
williamr@2
|
73 |
/** Creates a new RSA Public key object from the specified buffer containing the
|
williamr@2
|
74 |
* encoded binary representation, starting at the specified offset.
|
williamr@2
|
75 |
*
|
williamr@2
|
76 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
77 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
78 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
williamr@2
|
79 |
IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
80 |
|
williamr@2
|
81 |
/** Creates a new RSA Public key object from the specified buffer containing the
|
williamr@2
|
82 |
* encoded binary representation, starting at the specified offset, and puts
|
williamr@2
|
83 |
* a pointer to it onto the cleanup stack.
|
williamr@2
|
84 |
*
|
williamr@2
|
85 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
86 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
87 |
* @return A pointer to the new CX509RSAPublicKey object. */
|
williamr@2
|
88 |
IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
89 |
private:
|
williamr@2
|
90 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
91 |
CX509RSAPublicKey();
|
williamr@2
|
92 |
};
|
williamr@2
|
93 |
|
williamr@2
|
94 |
class TASN1EncRSAPublicKey
|
williamr@2
|
95 |
/**
|
williamr@2
|
96 |
* Class for encoding RSA public keys to ASN.1 encoding.
|
williamr@2
|
97 |
*
|
williamr@2
|
98 |
* @publishedAll
|
williamr@2
|
99 |
* @released
|
williamr@2
|
100 |
* @since v8.0
|
williamr@2
|
101 |
*/
|
williamr@2
|
102 |
{
|
williamr@2
|
103 |
public:
|
williamr@2
|
104 |
/**
|
williamr@2
|
105 |
* Encodes the supplied public key into buffer in DER format ASN.1:
|
williamr@2
|
106 |
* @code
|
williamr@2
|
107 |
* SEQUENCE-OF
|
williamr@2
|
108 |
* INTEGER modulus
|
williamr@2
|
109 |
* INTEGER exponent
|
williamr@2
|
110 |
* @endcode
|
williamr@2
|
111 |
*
|
williamr@2
|
112 |
* @param aKey Key to encode.
|
williamr@2
|
113 |
* @return Allocated buffer containing DER encoding of
|
williamr@2
|
114 |
* the supplied key aKey.
|
williamr@2
|
115 |
*/
|
williamr@2
|
116 |
IMPORT_C HBufC8* EncodeDERL(const CRSAPublicKey& aKey) const;
|
williamr@2
|
117 |
};
|
williamr@2
|
118 |
|
williamr@2
|
119 |
class TASN1DecRSAPublicKey
|
williamr@2
|
120 |
/**
|
williamr@2
|
121 |
* Class for decoding RSA public keys from ASN.1 DER encoding.
|
williamr@2
|
122 |
*
|
williamr@2
|
123 |
* @publishedAll
|
williamr@2
|
124 |
* @released
|
williamr@2
|
125 |
* @since v8.0
|
williamr@2
|
126 |
*/
|
williamr@2
|
127 |
{
|
williamr@2
|
128 |
public:
|
williamr@2
|
129 |
/**
|
williamr@2
|
130 |
* Decodes an RSA key from the supplied buffer starting at the
|
williamr@2
|
131 |
* specified position.
|
williamr@2
|
132 |
*
|
williamr@2
|
133 |
* @param aDER Buffer containing DER ASN.1 encoding of the key.
|
williamr@2
|
134 |
* @param aPos Starting position in the buffer (updated on exit).
|
williamr@2
|
135 |
* @return A pointer to the new CRSAPublicKey object.
|
williamr@2
|
136 |
*/
|
williamr@2
|
137 |
IMPORT_C CRSAPublicKey* DecodeDERL(const TDesC8& aDER, TInt& aPos) const;
|
williamr@2
|
138 |
};
|
williamr@2
|
139 |
|
williamr@2
|
140 |
class TASN1DecRSAKeyPair
|
williamr@2
|
141 |
/**
|
williamr@2
|
142 |
* Class for decoding RSA key pairs from ASN.1 DER encoding.
|
williamr@2
|
143 |
*
|
williamr@2
|
144 |
* @publishedAll
|
williamr@2
|
145 |
* @released
|
williamr@2
|
146 |
* @since v8.0
|
williamr@2
|
147 |
*/
|
williamr@2
|
148 |
{
|
williamr@2
|
149 |
public:
|
williamr@2
|
150 |
/**
|
williamr@2
|
151 |
* Decodes an RSA key pair from buffer containing ASN.1
|
williamr@2
|
152 |
* DER-encoded private key. The encoding of a private key
|
williamr@2
|
153 |
* contains public key components as well.
|
williamr@2
|
154 |
*
|
williamr@2
|
155 |
* @param aDER DER-encoded private key.
|
williamr@2
|
156 |
* @param aPos Position in the buffer to start decoding
|
williamr@2
|
157 |
* (updated on exit).
|
williamr@2
|
158 |
* @param aPublicKey On return, the RSA public key object
|
williamr@2
|
159 |
* @param aPrivateKey On return, the RSA private key object
|
williamr@2
|
160 |
* @param aKeyType Key type, default is @c EStandardCRT
|
williamr@2
|
161 |
*/
|
williamr@2
|
162 |
IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos,
|
williamr@2
|
163 |
CRSAPublicKey*& aPublicKey,
|
williamr@2
|
164 |
CRSAPrivateKey*& aPrivateKey,
|
williamr@2
|
165 |
TRSAPrivateKeyType aKeyType = EStandardCRT);
|
williamr@2
|
166 |
};
|
williamr@2
|
167 |
|
williamr@2
|
168 |
class CX509DSAPublicKey : public CDSAPublicKey
|
williamr@2
|
169 |
/** Encapsulates the X.509 DSA public key.
|
williamr@2
|
170 |
*
|
williamr@2
|
171 |
* Adds a commitment to a specific encoding scheme allowing superclasses to remain
|
williamr@2
|
172 |
* encoding-independent.
|
williamr@2
|
173 |
*
|
williamr@2
|
174 |
* @publishedAll
|
williamr@2
|
175 |
* @released
|
williamr@2
|
176 |
* @since v6.0
|
williamr@2
|
177 |
*/
|
williamr@2
|
178 |
// DSA public key, params, signature.
|
williamr@2
|
179 |
{
|
williamr@2
|
180 |
public:
|
williamr@2
|
181 |
/** Creates a new X.509 DSA public key object.
|
williamr@2
|
182 |
*
|
williamr@2
|
183 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
184 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
185 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
186 |
IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData);
|
williamr@2
|
187 |
|
williamr@2
|
188 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
189 |
*
|
williamr@2
|
190 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
191 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
192 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
193 |
IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData);
|
williamr@2
|
194 |
|
williamr@2
|
195 |
/** Creates a new X.509 DSA public key object.
|
williamr@2
|
196 |
*
|
williamr@2
|
197 |
* @param aParams The DSA parameters.
|
williamr@2
|
198 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
199 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
200 |
IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData);
|
williamr@2
|
201 |
|
williamr@2
|
202 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
203 |
*
|
williamr@2
|
204 |
* @param aParams The DSA parameters.
|
williamr@2
|
205 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
206 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
207 |
IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData);
|
williamr@2
|
208 |
|
williamr@2
|
209 |
/** Creates a new X.509 DSA public key object.
|
williamr@2
|
210 |
*
|
williamr@2
|
211 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
212 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
213 |
* @param aPos The position from which to start decoding.
|
williamr@2
|
214 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
215 |
IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData,TInt& aPos);
|
williamr@2
|
216 |
|
williamr@2
|
217 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
218 |
*
|
williamr@2
|
219 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
220 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
221 |
* @param aPos The position from which to start decoding.
|
williamr@2
|
222 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
223 |
IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
224 |
|
williamr@2
|
225 |
/** Creates a new X.509 DSA public key object.
|
williamr@2
|
226 |
*
|
williamr@2
|
227 |
* @param aParams The DSA parameters.
|
williamr@2
|
228 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
229 |
* @param aPos The position from which to start decoding.
|
williamr@2
|
230 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
231 |
IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
232 |
|
williamr@2
|
233 |
/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
234 |
*
|
williamr@2
|
235 |
* @param aParams The DSA parameters.
|
williamr@2
|
236 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
237 |
* @param aPos The position from which to start decoding.
|
williamr@2
|
238 |
* @return A pointer to the new CX509DSAPublicKey object. */
|
williamr@2
|
239 |
IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
240 |
public:
|
williamr@2
|
241 |
/** Gets the DSA parameters from the encoding key.
|
williamr@2
|
242 |
*
|
williamr@2
|
243 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
244 |
* @return The DSA parameters. */
|
williamr@2
|
245 |
IMPORT_C static CDSAParameters* DSAParametersL(const TDesC8& aParamsData);
|
williamr@2
|
246 |
protected:
|
williamr@2
|
247 |
/** @internalComponent */
|
williamr@2
|
248 |
void ConstructL(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
249 |
/** @internalComponent */
|
williamr@2
|
250 |
void ConstructL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
251 |
/** @internalComponent */
|
williamr@2
|
252 |
CX509DSAPublicKey();
|
williamr@2
|
253 |
};
|
williamr@2
|
254 |
|
williamr@2
|
255 |
class TASN1DecDSAKeyPair
|
williamr@2
|
256 |
/**
|
williamr@2
|
257 |
* Class for decoding DSA key pairs from ASN.1 DER encoding.
|
williamr@2
|
258 |
*
|
williamr@2
|
259 |
* @publishedAll
|
williamr@2
|
260 |
* @released
|
williamr@2
|
261 |
* @since v8.0
|
williamr@2
|
262 |
*/
|
williamr@2
|
263 |
{
|
williamr@2
|
264 |
public:
|
williamr@2
|
265 |
/**
|
williamr@2
|
266 |
* Decodes a DSA key pair from a buffer containing an ASN.1
|
williamr@2
|
267 |
* DER-encoded private key.
|
williamr@2
|
268 |
*
|
williamr@2
|
269 |
* The encoding of the private key contains public key components as well.
|
williamr@2
|
270 |
*
|
williamr@2
|
271 |
* The DER encoding has the following format:
|
williamr@2
|
272 |
* @verbatim
|
williamr@2
|
273 |
* SEQUENCE-OF
|
williamr@2
|
274 |
* INTEGER version (==0, ignored)
|
williamr@2
|
275 |
* INTEGER p (public prime)
|
williamr@2
|
276 |
* INTEGER q (160-bit public subprime, q | p-1)
|
williamr@2
|
277 |
* INTEGER g (public generator of subgroup)
|
williamr@2
|
278 |
* INTEGER x (private key)
|
williamr@2
|
279 |
* INTEGER y (public key y=g^x)
|
williamr@2
|
280 |
* @endverbatim
|
williamr@2
|
281 |
*
|
williamr@2
|
282 |
* @param aDER DER-encoded private key.
|
williamr@2
|
283 |
* @param aPos Position in the buffer to start decoding
|
williamr@2
|
284 |
* (updated on exit).
|
williamr@2
|
285 |
* @param aPublicKey On return, the DSA public key object
|
williamr@2
|
286 |
* @param aPrivateKey On return, the DSA private key object
|
williamr@2
|
287 |
*/
|
williamr@2
|
288 |
IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos,
|
williamr@2
|
289 |
CDSAPublicKey*& aPublicKey, CDSAPrivateKey*& aPrivateKey);
|
williamr@2
|
290 |
};
|
williamr@2
|
291 |
|
williamr@2
|
292 |
/**
|
williamr@2
|
293 |
* Class for encoding DSA public keys to ASN.1 encoding.
|
williamr@2
|
294 |
*
|
williamr@2
|
295 |
* @publishedAll
|
williamr@2
|
296 |
* @released
|
williamr@2
|
297 |
* @since v8.0
|
williamr@2
|
298 |
*/
|
williamr@2
|
299 |
class TASN1EncDSAPublicKey
|
williamr@2
|
300 |
{
|
williamr@2
|
301 |
public:
|
williamr@2
|
302 |
/**
|
williamr@2
|
303 |
* Encodes the supplied public key into a buffer in DER format.
|
williamr@2
|
304 |
*
|
williamr@2
|
305 |
* Note that the encoding has the following format:
|
williamr@2
|
306 |
* @code
|
williamr@2
|
307 |
* SEQUENCE-OF
|
williamr@2
|
308 |
* SEQUENCE-OF
|
williamr@2
|
309 |
* INTEGER p
|
williamr@2
|
310 |
* INTEGER q
|
williamr@2
|
311 |
* INTEGER g
|
williamr@2
|
312 |
* BIT STRING (encoded INTEGER public value)
|
williamr@2
|
313 |
* @endcode
|
williamr@2
|
314 |
*
|
williamr@2
|
315 |
* @param aKey Key to encode.
|
williamr@2
|
316 |
* @return Sequence containing public key information.
|
williamr@2
|
317 |
*/
|
williamr@2
|
318 |
IMPORT_C CASN1EncSequence* EncodeDERL(const CDSAPublicKey& aKey) const;
|
williamr@2
|
319 |
|
williamr@2
|
320 |
/**
|
williamr@2
|
321 |
* Encodes DSA parameters into an ASN.1 encoding structure suitable for
|
williamr@2
|
322 |
* inclusion into other objects, like a PKCS#10 certificate request.
|
williamr@2
|
323 |
*
|
williamr@2
|
324 |
* Note that the encoding has the following form:
|
williamr@2
|
325 |
* @code
|
williamr@2
|
326 |
* SEQUENCE-OF
|
williamr@2
|
327 |
* INTEGER p
|
williamr@2
|
328 |
* INTEGER q
|
williamr@2
|
329 |
* INTEGER g
|
williamr@2
|
330 |
* @endcode
|
williamr@2
|
331 |
*
|
williamr@2
|
332 |
* @param aKey DSA public key.
|
williamr@2
|
333 |
* @return ASN.1 encoding structure on the cleanup stack.
|
williamr@2
|
334 |
*/
|
williamr@2
|
335 |
IMPORT_C CASN1EncSequence* EncodeParamsLC(const CDSAPublicKey& aKey) const;
|
williamr@2
|
336 |
|
williamr@2
|
337 |
/**
|
williamr@2
|
338 |
* Encodes a public key as a bit string.
|
williamr@2
|
339 |
*
|
williamr@2
|
340 |
* @param aKey DSA public key.
|
williamr@2
|
341 |
* @return ASN.1 bit string (public key). This is left on the cleanup stack.
|
williamr@2
|
342 |
*/
|
williamr@2
|
343 |
|
williamr@2
|
344 |
IMPORT_C CASN1EncBitString* EncodePublicValueLC(const CDSAPublicKey& aKey) const;
|
williamr@2
|
345 |
};
|
williamr@2
|
346 |
|
williamr@2
|
347 |
class CX509DSASignature : public CDSASignature
|
williamr@2
|
348 |
/** Encapsulates the X.509 DSA signature.
|
williamr@2
|
349 |
*
|
williamr@2
|
350 |
* Adds a commitment to a specific encoding scheme allowing superclasses to remain
|
williamr@2
|
351 |
* encoding-independent.
|
williamr@2
|
352 |
*
|
williamr@2
|
353 |
* @publishedAll
|
williamr@2
|
354 |
* @released
|
williamr@2
|
355 |
* @since v6.0 */
|
williamr@2
|
356 |
{
|
williamr@2
|
357 |
public:
|
williamr@2
|
358 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
williamr@2
|
359 |
* encoded binary representation.
|
williamr@2
|
360 |
*
|
williamr@2
|
361 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
362 |
* @return A pointer to the new CX509DSASignature object. */
|
williamr@2
|
363 |
IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData);
|
williamr@2
|
364 |
|
williamr@2
|
365 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
williamr@2
|
366 |
* encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
367 |
*
|
williamr@2
|
368 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
369 |
* @return A pointer to the new CX509DSASignature object. */
|
williamr@2
|
370 |
IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData);
|
williamr@2
|
371 |
|
williamr@2
|
372 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
williamr@2
|
373 |
* encoded binary representation, starting at the specified offset.
|
williamr@2
|
374 |
*
|
williamr@2
|
375 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
376 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
377 |
* @return A pointer to the new CX509DSASignature object. */
|
williamr@2
|
378 |
IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
379 |
|
williamr@2
|
380 |
/** Creates a new DSA Signature object from the specified buffer containing the
|
williamr@2
|
381 |
* encoded binary representation, starting at the specified offset, and puts
|
williamr@2
|
382 |
* a pointer to it onto the cleanup stack.
|
williamr@2
|
383 |
*
|
williamr@2
|
384 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
385 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
386 |
* @return A pointer to the new CX509DSASignature object. */
|
williamr@2
|
387 |
IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
388 |
private:
|
williamr@2
|
389 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
390 |
CX509DSASignature();
|
williamr@2
|
391 |
};
|
williamr@2
|
392 |
|
williamr@2
|
393 |
class CX509DHPublicKey : public CDHPublicKey
|
williamr@2
|
394 |
/** Provides clients with the information they need for Diffie-Hellman key exchange
|
williamr@2
|
395 |
* within a protocol.
|
williamr@2
|
396 |
*
|
williamr@2
|
397 |
* @publishedAll
|
williamr@2
|
398 |
* @released
|
williamr@2
|
399 |
* @since v6.0 */
|
williamr@2
|
400 |
{
|
williamr@2
|
401 |
public:
|
williamr@2
|
402 |
/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded
|
williamr@2
|
403 |
* binary representation.
|
williamr@2
|
404 |
*
|
williamr@2
|
405 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
406 |
* @param aKeyData
|
williamr@2
|
407 |
* @return A pointer to the new CX509DHPublicKey object.*/
|
williamr@2
|
408 |
IMPORT_C static CX509DHPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aKeyData);
|
williamr@2
|
409 |
|
williamr@2
|
410 |
/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded
|
williamr@2
|
411 |
* binary representation, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
412 |
*
|
williamr@2
|
413 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
414 |
* @param aKeyData
|
williamr@2
|
415 |
* @return A pointer to the new CX509DHPublicKey object.*/
|
williamr@2
|
416 |
IMPORT_C static CX509DHPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aKeyData);
|
williamr@2
|
417 |
public:
|
williamr@2
|
418 |
/** Destructor.
|
williamr@2
|
419 |
*
|
williamr@2
|
420 |
* Frees all resources owned by the object, prior to its destruction. */
|
williamr@2
|
421 |
IMPORT_C virtual ~CX509DHPublicKey();
|
williamr@2
|
422 |
protected:
|
williamr@2
|
423 |
/** @internalComponent */
|
williamr@2
|
424 |
CX509DHPublicKey();
|
williamr@2
|
425 |
/** @internalComponent */
|
williamr@2
|
426 |
void ConstructL(const TDesC8& aParamsData, const TDesC8& aKeyData);
|
williamr@2
|
427 |
};
|
williamr@2
|
428 |
|
williamr@2
|
429 |
class CX509DHKeyPair : public CDHKeyPair
|
williamr@2
|
430 |
/** This class represents the Diffie-Hellman Key Pair.
|
williamr@2
|
431 |
*
|
williamr@2
|
432 |
* @publishedAll
|
williamr@2
|
433 |
* @released
|
williamr@2
|
434 |
* @since v8.0 */
|
williamr@2
|
435 |
{
|
williamr@2
|
436 |
public:
|
williamr@2
|
437 |
/** Creates a new DH key pair object from the specified buffer containing
|
williamr@2
|
438 |
* the encoded binary representation .
|
williamr@2
|
439 |
*
|
williamr@2
|
440 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
441 |
* @return A pointer to the new CX509DHKeyPair object.
|
williamr@2
|
442 |
*/
|
williamr@2
|
443 |
IMPORT_C static CX509DHKeyPair* NewL(const TDesC8& aParamsData);
|
williamr@2
|
444 |
|
williamr@2
|
445 |
/** Creates a new DH Key Pair object from the specified buffer containing the encoded binary
|
williamr@2
|
446 |
* representation, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
447 |
*
|
williamr@2
|
448 |
* @param aParamsData A non-modifiable descriptor representing the entire encoding.
|
williamr@2
|
449 |
* @return A pointer to the new CX509DHKeyPair object.
|
williamr@2
|
450 |
*/
|
williamr@2
|
451 |
IMPORT_C static CX509DHKeyPair* NewLC(const TDesC8& aParamsData);
|
williamr@2
|
452 |
public:
|
williamr@2
|
453 |
|
williamr@2
|
454 |
/** Virtual Destructor.
|
williamr@2
|
455 |
* Frees all resources owned by the object, prior to its destruction.
|
williamr@2
|
456 |
*
|
williamr@2
|
457 |
*/
|
williamr@2
|
458 |
IMPORT_C virtual ~CX509DHKeyPair();
|
williamr@2
|
459 |
protected:
|
williamr@2
|
460 |
/** @internalComponent */
|
williamr@2
|
461 |
CX509DHKeyPair();
|
williamr@2
|
462 |
/** @internalComponent */
|
williamr@2
|
463 |
void ConstructL(const TDesC8& aParamsData);
|
williamr@2
|
464 |
};
|
williamr@2
|
465 |
|
williamr@2
|
466 |
class CX509DHValidationParams : public CBase
|
williamr@2
|
467 |
/** Validates Diffie-Hellman (DH) Domain parameters.
|
williamr@2
|
468 |
*
|
williamr@2
|
469 |
* Provides access to the DH Validation Parameters, which are used to determine
|
williamr@2
|
470 |
* if the DH Public Key has been generated in conformance with the algorithm
|
williamr@2
|
471 |
* specified in ESDH (see RFC 2631).
|
williamr@2
|
472 |
*
|
williamr@2
|
473 |
* @publishedAll
|
williamr@2
|
474 |
* @released
|
williamr@2
|
475 |
* @since v6.0 */
|
williamr@2
|
476 |
{
|
williamr@2
|
477 |
public:
|
williamr@2
|
478 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
williamr@2
|
479 |
* the encoded binary representation.
|
williamr@2
|
480 |
*
|
williamr@2
|
481 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
482 |
* @return A pointer to the new CX509DHValidationParams object. */
|
williamr@2
|
483 |
IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData);
|
williamr@2
|
484 |
|
williamr@2
|
485 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
williamr@2
|
486 |
* the encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
487 |
*
|
williamr@2
|
488 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
489 |
* @return A pointer to the new CX509DHValidationParams object. */
|
williamr@2
|
490 |
IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData);
|
williamr@2
|
491 |
|
williamr@2
|
492 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
williamr@2
|
493 |
* the encoded binary representation, starting at the specified offset.
|
williamr@2
|
494 |
*
|
williamr@2
|
495 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
496 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
497 |
* @return A pointer to the new CX509DHValidationParams object. */
|
williamr@2
|
498 |
IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
499 |
|
williamr@2
|
500 |
/** Creates a new DH Validation parameters object from the specified buffer containing
|
williamr@2
|
501 |
* the encoded binary representation, starting at the specified offset, and puts
|
williamr@2
|
502 |
* a pointer to it onto the cleanup stack.
|
williamr@2
|
503 |
*
|
williamr@2
|
504 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
505 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
506 |
* @return A pointer to the new CX509DHValidationParams object. */
|
williamr@2
|
507 |
IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
508 |
|
williamr@2
|
509 |
/** Gets a DSA prime generation seed.
|
williamr@2
|
510 |
*
|
williamr@2
|
511 |
* @return The bit string parameter used as the seed. */
|
williamr@2
|
512 |
IMPORT_C const TPtrC8 Seed() const;
|
williamr@2
|
513 |
|
williamr@2
|
514 |
/** Gets the output from a DSA prime generation counter.
|
williamr@2
|
515 |
*
|
williamr@2
|
516 |
* @return The integer value output. */
|
williamr@2
|
517 |
IMPORT_C const TInteger& PGenCounter() const;
|
williamr@2
|
518 |
|
williamr@2
|
519 |
/** Destructor.
|
williamr@2
|
520 |
*
|
williamr@2
|
521 |
* Frees all resources owned by the object, prior to its destruction. */
|
williamr@2
|
522 |
virtual ~CX509DHValidationParams();
|
williamr@2
|
523 |
protected:
|
williamr@2
|
524 |
/** @internalComponent */
|
williamr@2
|
525 |
CX509DHValidationParams();
|
williamr@2
|
526 |
/** @internalComponent */
|
williamr@2
|
527 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
528 |
HBufC8* iSeed;
|
williamr@2
|
529 |
RInteger iPGenCounter;
|
williamr@2
|
530 |
};
|
williamr@2
|
531 |
|
williamr@2
|
532 |
class CX509DHDomainParams : public CBase
|
williamr@2
|
533 |
/** Encapsulates the compulsory Diffie-Hellman domain parameter values P and G
|
williamr@2
|
534 |
* (See RFC 2459).
|
williamr@2
|
535 |
*
|
williamr@2
|
536 |
* @publishedAll
|
williamr@2
|
537 |
* @released
|
williamr@2
|
538 |
* @since v6.0 */
|
williamr@2
|
539 |
{
|
williamr@2
|
540 |
public:
|
williamr@2
|
541 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
williamr@2
|
542 |
* the encoded binary representation.
|
williamr@2
|
543 |
*
|
williamr@2
|
544 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
545 |
* @return A pointer to the new CX509DHDomainParams object. */
|
williamr@2
|
546 |
IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData);
|
williamr@2
|
547 |
|
williamr@2
|
548 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
williamr@2
|
549 |
* the encoded binary representation, and puts a pointer to it onto the cleanup stack.
|
williamr@2
|
550 |
*
|
williamr@2
|
551 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
552 |
* @return A pointer to the new CX509DHDomainParams object. */
|
williamr@2
|
553 |
IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData);
|
williamr@2
|
554 |
|
williamr@2
|
555 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
williamr@2
|
556 |
* the encoded binary representation, starting at the specified offset.
|
williamr@2
|
557 |
*
|
williamr@2
|
558 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
559 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
560 |
* @return A pointer to the new CX509DHDomainParams object. */
|
williamr@2
|
561 |
IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
562 |
|
williamr@2
|
563 |
/** Creates a new DH Domain parameters object from the specified buffer containing
|
williamr@2
|
564 |
* the encoded binary representation, starting at the specified offset, and puts
|
williamr@2
|
565 |
* a pointer to it onto the cleanup stack.
|
williamr@2
|
566 |
*
|
williamr@2
|
567 |
* @param aBinaryData The encoded binary representation.
|
williamr@2
|
568 |
* @param aPos The offset position from which to start decoding.
|
williamr@2
|
569 |
* @return A pointer to the new CX509DHDomainParams object. */
|
williamr@2
|
570 |
IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
571 |
|
williamr@2
|
572 |
/** Gets the compulsory parameter value P.
|
williamr@2
|
573 |
*
|
williamr@2
|
574 |
* @return The compulsory parameter value P. */
|
williamr@2
|
575 |
IMPORT_C const TInteger& P() const;
|
williamr@2
|
576 |
|
williamr@2
|
577 |
/** Gets the compulsory parameter value G.
|
williamr@2
|
578 |
*
|
williamr@2
|
579 |
* @return The compulsory parameter value G. */
|
williamr@2
|
580 |
IMPORT_C const TInteger& G() const;
|
williamr@2
|
581 |
|
williamr@2
|
582 |
//the next 3 members are optional, in which case NULL is returned
|
williamr@2
|
583 |
//the returned objects remain the property of this object
|
williamr@2
|
584 |
|
williamr@2
|
585 |
//N.B. according to RFC 2459 the Q member is *not* optional,
|
williamr@2
|
586 |
//however it is not essential for doing DH, and empirical studies
|
williamr@2
|
587 |
//suggest it doesn't get included much, so I'm relaxing the spec here
|
williamr@2
|
588 |
//to permit DomainParams objects which contain no Q.
|
williamr@2
|
589 |
|
williamr@2
|
590 |
/** Gets the optional value Q.
|
williamr@2
|
591 |
*
|
williamr@2
|
592 |
* @return The optional value Q. */
|
williamr@2
|
593 |
IMPORT_C const TInteger& Q() const;
|
williamr@2
|
594 |
|
williamr@2
|
595 |
/** Gets the optional value J.
|
williamr@2
|
596 |
*
|
williamr@2
|
597 |
* @return The optional value J. */
|
williamr@2
|
598 |
IMPORT_C const TInteger& J() const;
|
williamr@2
|
599 |
|
williamr@2
|
600 |
/** Gets the optional validation parameters.
|
williamr@2
|
601 |
*
|
williamr@2
|
602 |
* @return The optional validation parameters. */
|
williamr@2
|
603 |
IMPORT_C const CX509DHValidationParams* ValidationParams() const;
|
williamr@2
|
604 |
|
williamr@2
|
605 |
/** Destructor.
|
williamr@2
|
606 |
*
|
williamr@2
|
607 |
* Frees all resources owned by the object, prior to its destruction. */
|
williamr@2
|
608 |
virtual ~CX509DHDomainParams();
|
williamr@2
|
609 |
protected:
|
williamr@2
|
610 |
/** @internalComponent */
|
williamr@2
|
611 |
CX509DHDomainParams();
|
williamr@2
|
612 |
/** @internalComponent */
|
williamr@2
|
613 |
void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
|
williamr@2
|
614 |
RInteger iP;
|
williamr@2
|
615 |
RInteger iG;
|
williamr@2
|
616 |
RInteger iQ;
|
williamr@2
|
617 |
RInteger iJ;
|
williamr@2
|
618 |
CX509DHValidationParams* iValidationParams;
|
williamr@2
|
619 |
};
|
williamr@2
|
620 |
|
williamr@2
|
621 |
class TX509KeyEncoder
|
williamr@2
|
622 |
/**
|
williamr@2
|
623 |
* Abstract class that is the base class for RSA and DSA key encoder classes.
|
williamr@2
|
624 |
* These classes are used to encode the X509 ASN.1 types AlgorithmIdentifier and
|
williamr@2
|
625 |
* SubjectPublicKeyInfo.
|
williamr@2
|
626 |
*
|
williamr@2
|
627 |
* This class is part of the pkcs10 API, and will be changed or removed in a
|
williamr@2
|
628 |
* future release. You should not use it.
|
williamr@2
|
629 |
*
|
williamr@2
|
630 |
* @internalTechnology
|
williamr@2
|
631 |
*/
|
williamr@2
|
632 |
{
|
williamr@2
|
633 |
public:
|
williamr@2
|
634 |
/**
|
williamr@2
|
635 |
* Constructor that takes an algorithm identifier and saves it into the
|
williamr@2
|
636 |
* corresponding member variable. It is then used in the
|
williamr@2
|
637 |
* EncodeSignatureAlgorithm() function.
|
williamr@2
|
638 |
*
|
williamr@2
|
639 |
* @param aDigestAlg Digest algorithm to use. Currently the following
|
williamr@2
|
640 |
* algorithms are supported: MD2, MD5, and SHA-1.
|
williamr@2
|
641 |
*/
|
williamr@2
|
642 |
IMPORT_C TX509KeyEncoder(TAlgorithmId aDigestAlg);
|
williamr@2
|
643 |
|
williamr@2
|
644 |
/**
|
williamr@2
|
645 |
* Produces the SubjectPublicKeyInfo encoding.
|
williamr@2
|
646 |
*
|
williamr@2
|
647 |
* The encoding has the following ASN.1 format:
|
williamr@2
|
648 |
* @code
|
williamr@2
|
649 |
* SubjectPublicKeyInfo {ALGORITHM : IOSet} ::= SEQUENCE {
|
williamr@2
|
650 |
* algorithm AlgorithmIdentifier {{IOSet}},
|
williamr@2
|
651 |
* subjectPublicKey BIT STRING
|
williamr@2
|
652 |
* }
|
williamr@2
|
653 |
* @endcode
|
williamr@2
|
654 |
*/
|
williamr@2
|
655 |
IMPORT_C virtual CASN1EncBase* EncodeKeyLC() const = 0;
|
williamr@2
|
656 |
|
williamr@2
|
657 |
/**
|
williamr@2
|
658 |
* Produces the AlgorithmIdentifier encoding.
|
williamr@2
|
659 |
*
|
williamr@2
|
660 |
* @return ASN.1 sequence containing signature algorithm
|
williamr@2
|
661 |
*/
|
williamr@2
|
662 |
IMPORT_C virtual CASN1EncSequence* EncodeSignatureAlgorithmLC() const = 0;
|
williamr@2
|
663 |
|
williamr@2
|
664 |
/**
|
williamr@2
|
665 |
* Produces the DigestAlgorithmIdentifier encoder.
|
williamr@2
|
666 |
*
|
williamr@2
|
667 |
* The encoding has the following ASN.1 format
|
williamr@2
|
668 |
* @code
|
williamr@2
|
669 |
* DigestAlgorithmIdentifier ::= SEQUENCE {
|
williamr@2
|
670 |
* algorithm AlgorithmIdentifier,
|
williamr@2
|
671 |
* parameters ANY DEFINED BY algorithm OPTIONAL }
|
williamr@2
|
672 |
*
|
williamr@2
|
673 |
* AlgorithmIdentifier ::= OBJECT IDENTIFIER
|
williamr@2
|
674 |
* @endcode
|
williamr@2
|
675 |
*
|
williamr@2
|
676 |
* @return Appropriate ASN.1 sequence of type <code>DigestAlgorithmIdentifier</code>
|
williamr@2
|
677 |
*/
|
williamr@2
|
678 |
IMPORT_C virtual CASN1EncSequence* EncodeDigestAlgorithmLC() const;
|
williamr@2
|
679 |
|
williamr@2
|
680 |
protected:
|
williamr@2
|
681 |
/** Digest algorithm to use. */
|
williamr@2
|
682 |
TAlgorithmId iDigestAlg;
|
williamr@2
|
683 |
};
|
williamr@2
|
684 |
|
williamr@2
|
685 |
class TX509RSAKeyEncoder : public TX509KeyEncoder
|
williamr@2
|
686 |
/**
|
williamr@2
|
687 |
* Subclasses TC509KeyEncoder to provides key encoding capability for RSA public keys.
|
williamr@2
|
688 |
*
|
williamr@2
|
689 |
* This class is part of the pkcs10 API, and will be changed or removed in a
|
williamr@2
|
690 |
* future release. You should not use it.
|
williamr@2
|
691 |
*
|
williamr@2
|
692 |
* @internalTechnology
|
williamr@2
|
693 |
*/
|
williamr@2
|
694 |
{
|
williamr@2
|
695 |
public:
|
williamr@2
|
696 |
/**
|
williamr@2
|
697 |
* Constructs a RSA key pair encoder, saving reference to the passed
|
williamr@2
|
698 |
* key pair in the member variable.
|
williamr@2
|
699 |
*
|
williamr@2
|
700 |
* @param aPublicKey RSA public key to use for encoding.
|
williamr@2
|
701 |
* @param aDigestAlg Digest algorithm to use.
|
williamr@2
|
702 |
*/
|
williamr@2
|
703 |
IMPORT_C TX509RSAKeyEncoder(const CRSAPublicKey& aPublicKey, TAlgorithmId aDigestAlg);
|
williamr@2
|
704 |
|
williamr@2
|
705 |
/**
|
williamr@2
|
706 |
* Produces the SubjectPublicKeyInfo encoding.
|
williamr@2
|
707 |
*
|
williamr@2
|
708 |
* The resulting encoding has the following form:
|
williamr@2
|
709 |
* @code
|
williamr@2
|
710 |
* SEQUENCE-OF
|
williamr@2
|
711 |
* SEQUENCE-OF
|
williamr@2
|
712 |
* OID of the encryption algorithm (KRSA)
|
williamr@2
|
713 |
* NULL
|
williamr@2
|
714 |
* BIT STRING encoded public key.
|
williamr@2
|
715 |
* @endcode
|
williamr@2
|
716 |
*
|
williamr@2
|
717 |
* @return DER-encoded public key information, placed on the cleanup stack.
|
williamr@2
|
718 |
*/
|
williamr@2
|
719 |
IMPORT_C virtual CASN1EncBase* EncodeKeyLC() const;
|
williamr@2
|
720 |
|
williamr@2
|
721 |
/**
|
williamr@2
|
722 |
* Produces the AlgorithmIdentifier encoding.
|
williamr@2
|
723 |
*
|
williamr@2
|
724 |
* This has the following form:
|
williamr@2
|
725 |
* @code
|
williamr@2
|
726 |
* SEQUENCE-OF
|
williamr@2
|
727 |
* OID signature-algorithm
|
williamr@2
|
728 |
* NULL
|
williamr@2
|
729 |
* @endcode
|
williamr@2
|
730 |
*
|
williamr@2
|
731 |
* @return ASN.1 sequence containing signature algorithm encoding,
|
williamr@2
|
732 |
* placed on the cleanup stack.
|
williamr@2
|
733 |
*/
|
williamr@2
|
734 |
IMPORT_C virtual CASN1EncSequence* EncodeSignatureAlgorithmLC() const;
|
williamr@2
|
735 |
|
williamr@2
|
736 |
private:
|
williamr@2
|
737 |
/**
|
williamr@2
|
738 |
* Saved reference to the RSA public key to be used for encoding.
|
williamr@2
|
739 |
*/
|
williamr@2
|
740 |
const CRSAPublicKey& iPublicKey;
|
williamr@2
|
741 |
};
|
williamr@2
|
742 |
|
williamr@2
|
743 |
class TX509DSAKeyEncoder : public TX509KeyEncoder
|
williamr@2
|
744 |
/**
|
williamr@2
|
745 |
* Provides key encoding and signing capability using a DSA public key.
|
williamr@2
|
746 |
*
|
williamr@2
|
747 |
* This class is part of the pkcs10 API, and will be changed or removed in a
|
williamr@2
|
748 |
* future release. You should not use it.
|
williamr@2
|
749 |
*
|
williamr@2
|
750 |
* @internalTechnology
|
williamr@2
|
751 |
*/
|
williamr@2
|
752 |
{
|
williamr@2
|
753 |
public:
|
williamr@2
|
754 |
/**
|
williamr@2
|
755 |
* Constructs a DSA key pair encoder, saving reference to the passed
|
williamr@2
|
756 |
* public key in the member variable.
|
williamr@2
|
757 |
*
|
williamr@2
|
758 |
* @param aKeyPublic DSA public key to use for encoding.
|
williamr@2
|
759 |
* @param aDigestAlg Digest algorithm to use.
|
williamr@2
|
760 |
*/
|
williamr@2
|
761 |
IMPORT_C TX509DSAKeyEncoder(const CDSAPublicKey& aKeyPublic,
|
williamr@2
|
762 |
TAlgorithmId aDigestAlg);
|
williamr@2
|
763 |
|
williamr@2
|
764 |
/**
|
williamr@2
|
765 |
* Produces the SubjectPublicKeyInfo encoding.
|
williamr@2
|
766 |
*
|
williamr@2
|
767 |
* The ASN.1 encoding of a DSA key has the following form:
|
williamr@2
|
768 |
* @code
|
williamr@2
|
769 |
* SEQUENCE-OF
|
williamr@2
|
770 |
* SEQUENCE-OF
|
williamr@2
|
771 |
* OID dsa (1.2.840.10040.4.1)
|
williamr@2
|
772 |
* SEQUENCE-OF
|
williamr@2
|
773 |
* INTEGER p
|
williamr@2
|
774 |
* INTEGER q
|
williamr@2
|
775 |
* INTEGER g
|
williamr@2
|
776 |
* BIT STRING
|
williamr@2
|
777 |
* INTEGER public value (y)
|
williamr@2
|
778 |
* @endcode
|
williamr@2
|
779 |
*
|
williamr@2
|
780 |
* @return DER-encoded public key information, placed on the cleanup stack.
|
williamr@2
|
781 |
*/
|
williamr@2
|
782 |
IMPORT_C virtual CASN1EncBase* EncodeKeyLC() const;
|
williamr@2
|
783 |
|
williamr@2
|
784 |
/**
|
williamr@2
|
785 |
* Produces the AlgorithmIdentifier encoding.
|
williamr@2
|
786 |
*
|
williamr@2
|
787 |
* This has the following form:
|
williamr@2
|
788 |
* @code
|
williamr@2
|
789 |
* SEQUENCE-OF
|
williamr@2
|
790 |
* OID dsa-signature-oid
|
williamr@2
|
791 |
* SEQUENCE-OF dsa-params
|
williamr@2
|
792 |
* INTEGER p
|
williamr@2
|
793 |
* INTEGER q
|
williamr@2
|
794 |
* INTEGER g
|
williamr@2
|
795 |
* @endcode
|
williamr@2
|
796 |
*
|
williamr@2
|
797 |
* @return ASN.1 sequence containing signature algorithm encoding,
|
williamr@2
|
798 |
* placed on the cleanup stack.
|
williamr@2
|
799 |
*/
|
williamr@2
|
800 |
IMPORT_C virtual CASN1EncSequence* EncodeSignatureAlgorithmLC() const;
|
williamr@2
|
801 |
|
williamr@2
|
802 |
private:
|
williamr@2
|
803 |
/**
|
williamr@2
|
804 |
* Saved reference to the DSA public key to be used for encoding.
|
williamr@2
|
805 |
*/
|
williamr@2
|
806 |
const CDSAPublicKey& iPublicKey;
|
williamr@2
|
807 |
};
|
williamr@2
|
808 |
|
williamr@2
|
809 |
#endif
|