|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: The header file of DevCertOpenedKeys |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __DEVCERTOPENEDKEYS_H__ |
|
21 #define __DEVCERTOPENEDKEYS_H__ |
|
22 |
|
23 class CDevCertKeyStore; |
|
24 class CMessageDigest; |
|
25 |
|
26 |
|
27 /** |
|
28 * DevToken Client side |
|
29 * Abstract base class for performing crypto operations on keys. |
|
30 * |
|
31 * @lib DevTokenClient.dll |
|
32 * @since S60 v3.2 |
|
33 */ |
|
34 class CDevCertOpenedKey : protected CBase |
|
35 { |
|
36 public: |
|
37 void SetObjectID(TInt aObjectId) {iHandle.iObjectId = aObjectId;} |
|
38 void SetLabel(HBufC* aLabel) {iLabel = aLabel;} |
|
39 // Virtual Release method visible though CDevCertOpenedKey pointers - the |
|
40 // implementation just calls the Release method from the mixin class in each |
|
41 // case. |
|
42 virtual void Release() = 0; |
|
43 |
|
44 protected: |
|
45 virtual ~CDevCertOpenedKey(); |
|
46 |
|
47 protected: |
|
48 TCTTokenObjectHandle iHandle; |
|
49 CDevCertKeyStore* iClient; |
|
50 HBufC* iLabel; |
|
51 }; |
|
52 |
|
53 |
|
54 /** |
|
55 * DevToken Client side |
|
56 * class for performing crypto operations on RSA keys. |
|
57 * |
|
58 * @lib DevTokenClient.dll |
|
59 * @since S60 v3.2 |
|
60 */ |
|
61 class CDevCertRSARepudiableSigner : public CDevCertOpenedKey, public MRSASigner |
|
62 { |
|
63 public: |
|
64 static CDevCertRSARepudiableSigner* New(CDevCertKeyStore* aClient); |
|
65 |
|
66 // MCTTokenObject |
|
67 public: |
|
68 /** |
|
69 * The object's human-readable label |
|
70 * |
|
71 * @param |
|
72 * @return The object's human-readable label |
|
73 */ |
|
74 virtual const TDesC& Label() const; |
|
75 |
|
76 /** |
|
77 * A reference to the associated token |
|
78 * |
|
79 * @param |
|
80 * @return A reference to the associated token |
|
81 */ |
|
82 virtual MCTToken& Token() const; |
|
83 |
|
84 /** |
|
85 * A UID representing the type of the token object. The |
|
86 * meanings of possible UIDs should be documented in the |
|
87 * documentation for the interface that returns them. |
|
88 * |
|
89 * @param |
|
90 * @return A UID representing the type of the token object |
|
91 */ |
|
92 virtual TUid Type() const; |
|
93 |
|
94 /** |
|
95 * A handle for the object. The primary purpose of the |
|
96 * handle is to allow token objects to be 'passed' between |
|
97 * processes. See TCTTokenObjectHandle for more details. |
|
98 * |
|
99 * @param |
|
100 * @return A handle for the object |
|
101 */ |
|
102 virtual TCTTokenObjectHandle Handle() const; |
|
103 |
|
104 // MSigner |
|
105 public: |
|
106 /** |
|
107 * Sign some data. |
|
108 * The data is hashed before the signature is created using the SHA-1 |
|
109 * algorithm. |
|
110 * |
|
111 * @param aPlaintext The string to be signed. |
|
112 * @param aSignature The returned signature. This remains owned |
|
113 by the signer, and is valid until the signer |
|
114 is released or until the next Sign. |
|
115 @param aStatus Async status notification |
|
116 * @return |
|
117 */ |
|
118 virtual void SignMessage(const TDesC8& aPlaintext, CRSASignature*& aSignature, |
|
119 TRequestStatus& aStatus); |
|
120 |
|
121 /** |
|
122 * Perform a raw signing operation. |
|
123 * |
|
124 * @param aDigest The data to be signed - this should be some form of hash of |
|
125 * the actual message to be signed. If the data is too long, |
|
126 this method will return KErrOverflow through aStatus. |
|
127 * @param aSignature The returned signature. This remains owned by the signer, |
|
128 and is valid until the signer is released or until the next |
|
129 Sign. |
|
130 * @param aStatus Async status notification |
|
131 * @return |
|
132 */ |
|
133 virtual void Sign(const TDesC8& aData, CRSASignature*& aSignature, |
|
134 TRequestStatus& aStatus); |
|
135 |
|
136 /** |
|
137 * Cancel an ongoing sign. |
|
138 * |
|
139 * @param |
|
140 * @return |
|
141 */ |
|
142 virtual void CancelSign(); |
|
143 |
|
144 virtual void Release(); |
|
145 |
|
146 private: |
|
147 CDevCertRSARepudiableSigner(CDevCertKeyStore* aClient); |
|
148 virtual ~CDevCertRSARepudiableSigner(); |
|
149 |
|
150 private: |
|
151 CMessageDigest* iDigest; |
|
152 HBufC8* iSignature; |
|
153 }; |
|
154 |
|
155 |
|
156 /** |
|
157 * DevToken Client side |
|
158 * class for performing crypto operations on DSA keys. |
|
159 * |
|
160 * @lib DevTokenClient.dll |
|
161 * @since S60 v3.2 |
|
162 */ |
|
163 class CDevCertDSARepudiableSigner : public CDevCertOpenedKey, public MDSASigner |
|
164 { |
|
165 public: |
|
166 |
|
167 static CDevCertDSARepudiableSigner* New(CDevCertKeyStore* aClient); |
|
168 |
|
169 virtual const TDesC& Label() const; |
|
170 |
|
171 virtual MCTToken& Token() const; |
|
172 |
|
173 virtual TUid Type() const; |
|
174 |
|
175 virtual TCTTokenObjectHandle Handle() const; |
|
176 |
|
177 virtual void SignMessage(const TDesC8& aPlaintext, CDSASignature*& aSignature, |
|
178 TRequestStatus& aStatus); |
|
179 |
|
180 virtual void Sign(const TDesC8& aData, CDSASignature*& aSignature, |
|
181 TRequestStatus& aStatus); |
|
182 |
|
183 virtual void CancelSign(); |
|
184 |
|
185 virtual void Release(); |
|
186 |
|
187 private: |
|
188 |
|
189 CDevCertDSARepudiableSigner(CDevCertKeyStore* aClient); |
|
190 |
|
191 virtual ~CDevCertDSARepudiableSigner(); |
|
192 |
|
193 private: |
|
194 |
|
195 CMessageDigest* iDigest; |
|
196 }; |
|
197 |
|
198 |
|
199 /** |
|
200 * DevToken Client side |
|
201 * class for performing decrypt operations on RSA keys. |
|
202 * |
|
203 * @lib DevTokenClient.dll |
|
204 * @since S60 v3.2 |
|
205 */ |
|
206 class CDevCertRSADecryptor : public CDevCertOpenedKey, public MCTDecryptor |
|
207 { |
|
208 public: |
|
209 |
|
210 static CDevCertRSADecryptor* New(CDevCertKeyStore* aClient); |
|
211 |
|
212 virtual const TDesC& Label() const; |
|
213 |
|
214 virtual MCTToken& Token() const; |
|
215 |
|
216 virtual TUid Type() const; |
|
217 |
|
218 virtual TCTTokenObjectHandle Handle() const; |
|
219 |
|
220 /** |
|
221 * Perform a decrypt operation. |
|
222 * |
|
223 * @param aCiphertext The data to be decrypted |
|
224 * @param aPlaintext The returned decrypted text |
|
225 * @param aStatus Async status notification |
|
226 * @return |
|
227 */ |
|
228 virtual void Decrypt(const TDesC8& aCiphertext, TDes8& aPlaintext, |
|
229 TRequestStatus& aStatus); |
|
230 |
|
231 virtual void CancelDecrypt(); |
|
232 |
|
233 virtual void Release(); |
|
234 |
|
235 private: |
|
236 |
|
237 CDevCertRSADecryptor(CDevCertKeyStore* aClient); |
|
238 |
|
239 virtual ~CDevCertRSADecryptor(); |
|
240 }; |
|
241 |
|
242 |
|
243 /** |
|
244 * DevToken Client side |
|
245 * class for performing crypto operations on DH keys. |
|
246 * |
|
247 * @lib DevTokenClient.dll |
|
248 * @since S60 v3.2 |
|
249 */ |
|
250 class CDevCertDHAgreement : public CDevCertOpenedKey, public MCTDH |
|
251 { |
|
252 public: |
|
253 |
|
254 static CDevCertDHAgreement* New(CDevCertKeyStore* aClient); |
|
255 |
|
256 virtual const TDesC& Label() const; |
|
257 |
|
258 virtual MCTToken& Token() const; |
|
259 |
|
260 virtual TUid Type() const; |
|
261 |
|
262 virtual TCTTokenObjectHandle Handle() const; |
|
263 |
|
264 /** |
|
265 * Get DH public key. |
|
266 * |
|
267 * @param aN Integer N |
|
268 * @param aG Integer G |
|
269 * @param aX DH public key |
|
270 * @param aStatus Async status notification |
|
271 * @return |
|
272 */ |
|
273 |
|
274 virtual void PublicKey(const TInteger& aN, const TInteger& aG, |
|
275 CDHPublicKey*& aX, |
|
276 TRequestStatus& aStatus); |
|
277 /** |
|
278 * Agrees a session key given the public key of the other party. |
|
279 * |
|
280 * @param aY DH PublicKey |
|
281 * @param aAgreedKey Agreed key |
|
282 * @param aStatus Async status notification |
|
283 * @return |
|
284 */ |
|
285 virtual void Agree(const CDHPublicKey& iY, |
|
286 HBufC8*& aAgreedKey, |
|
287 TRequestStatus& aStatus); |
|
288 |
|
289 virtual void CancelAgreement(); |
|
290 |
|
291 virtual void Release(); |
|
292 |
|
293 private: |
|
294 |
|
295 CDevCertDHAgreement(CDevCertKeyStore* aClient); |
|
296 |
|
297 virtual ~CDevCertDHAgreement(); |
|
298 }; |
|
299 #endif |