|
1 /* |
|
2 * Copyright (c) 2003-2007 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: Header file of the CCertSaverSyncWrapper class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CERTSAVERSYNCWRAPPER_H |
|
20 #define CERTSAVERSYNCWRAPPER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <securitydefs.h> // TCertificateFormat, TCertificateOwnerType |
|
25 #include <ct/rmpointerarray.h> // RMPointerArray |
|
26 #include <mpkcs12.h> |
|
27 #include <mctkeystore.h> |
|
28 |
|
29 typedef TBuf8<20> TKeyIdBuf; |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CUnifiedCertStore; |
|
33 class MCTWritableCertStore; |
|
34 class CCTCertInfo; |
|
35 class CCertAttributeFilter; |
|
36 class CCertificate; |
|
37 class CUnifiedKeyStore; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Synchronous wrapper for asynchronous functions of Crypto Token fw. |
|
43 * |
|
44 * @lib CertSaver.app |
|
45 * @since 2.0 |
|
46 */ |
|
47 class CCertSaverSyncWrapper : public CActive |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 */ |
|
54 static CCertSaverSyncWrapper* NewL(); |
|
55 |
|
56 /** |
|
57 * Destructor. |
|
58 */ |
|
59 virtual ~CCertSaverSyncWrapper(); |
|
60 |
|
61 public: // New functions |
|
62 |
|
63 /** |
|
64 * Initialise unified cert store |
|
65 * @since 2.0 |
|
66 * @param aStore unified cert store |
|
67 * @return status code from CUnifiedCertStore |
|
68 */ |
|
69 TInt InitializeCertStore( CUnifiedCertStore& aStore ); |
|
70 |
|
71 /** |
|
72 * Initialise unified cert store |
|
73 * @since 2.0 |
|
74 * @param aStore unified cert store |
|
75 * @return status code from CUnifiedCertStore |
|
76 */ |
|
77 TInt InitializeKeyStoreL( RFs& aFs ); |
|
78 |
|
79 /** |
|
80 * Add certificate to certman. |
|
81 * @since 2.0 |
|
82 * @param aStore writable certstore interface |
|
83 * @param aLabel label of the certificate |
|
84 * @param aCertFormat format of the certificate |
|
85 * @param aCertType type of the certificate |
|
86 * @param aSubjectKeyId subject key ID |
|
87 * @param aIssuerKeyId issuer key ID |
|
88 * @param aCert certificate to be added |
|
89 * @return status code from MCTWritableCertStore |
|
90 */ |
|
91 TInt AddCert( MCTWritableCertStore& aStore, |
|
92 const TDesC& aLabel, |
|
93 TCertificateFormat aCertFormat, |
|
94 TCertificateOwnerType aCertType, |
|
95 TKeyIdentifier* aSubjectKeyId, |
|
96 TKeyIdentifier* aIssuerKeyId, |
|
97 TPtrC8 aCert ); |
|
98 |
|
99 /** |
|
100 * List certificates matching to filter. |
|
101 * @since 2.0 |
|
102 * @param aStore unified cert store |
|
103 * @param aEntries found certificates |
|
104 * @param aFilter filter defining which certs are listed |
|
105 * @return status code from CUnifiedCertStore |
|
106 */ |
|
107 TInt ListCerts( CUnifiedCertStore& aStore, |
|
108 RMPointerArray<CCTCertInfo>& aEntries, |
|
109 CCertAttributeFilter& aFilter ); |
|
110 |
|
111 /** |
|
112 * Set applicability for certificate. |
|
113 * @since 2.0 |
|
114 * @param aStore writable certstore interface |
|
115 * @param aCertInfo certificate |
|
116 * @param aApplications UIDs of applicable applications |
|
117 * @return status code from MCTWritableCertStore |
|
118 */ |
|
119 TInt SetApplicability( MCTWritableCertStore& aStore, |
|
120 const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications ); |
|
121 |
|
122 /** |
|
123 * Set trust for certificate. |
|
124 * @since 2.0 |
|
125 * @param aStore writable certstore interface |
|
126 * @param aCertInfo certificate |
|
127 * @param aTrust trusted or not |
|
128 * @return status code from MCTWritableCertStore |
|
129 */ |
|
130 TInt SetTrust( MCTWritableCertStore& aStore, |
|
131 const CCTCertInfo& aCertInfo, TBool aTrust ); |
|
132 |
|
133 /** |
|
134 * Retrieve certificate |
|
135 * @since 2.0 |
|
136 * @param aStore writable certstore interface |
|
137 * @param aCertInfo certificate |
|
138 * @param aCert IN NULL |
|
139 * OUT Constructed object. |
|
140 * Ownership moves to caller. |
|
141 * @return status code from MCTWritableCertStore |
|
142 */ |
|
143 TInt Retrieve( CUnifiedCertStore& aStore, |
|
144 const CCTCertInfo& aCertInfo, CCertificate*& aCert ); |
|
145 |
|
146 /** |
|
147 * Add key to the sw keystore |
|
148 * @since 2.8 |
|
149 * @param aKeyStoreIndex Index of the keystore |
|
150 * @param aKeyData PKCS#8 encoded keypair |
|
151 * @param aUsage PKCS#15 usage flags of the key |
|
152 * @param aLabel Label of the key |
|
153 * @param aAccessType Access type of the key |
|
154 * @param aStartDate Start date of the validation period |
|
155 * @param aEndDate End date of the validation period |
|
156 * @param aKeyInfoOut Key info of the added key |
|
157 * @return status code from UnifiedKeyStore |
|
158 */ |
|
159 TInt AddKey( TInt aKeyStoreIndex, |
|
160 const TDesC8& aKeyData, |
|
161 TKeyUsagePKCS15 aUsage, |
|
162 const TDesC& aLabel, |
|
163 TInt aAccessType, |
|
164 TTime aStartDate, |
|
165 TTime aEndDate, |
|
166 CCTKeyInfo*& aKeyInfoOut ); |
|
167 |
|
168 /** |
|
169 * List keys matching to filter. |
|
170 * @since 3.0 |
|
171 * @param aEntries Found Keys |
|
172 * @param aFilter Filter defining which keys are listed |
|
173 * @return status code from UnifiedKeystore |
|
174 */ |
|
175 TInt ListKeys( RMPointerArray<CCTKeyInfo>& aEntries, |
|
176 TCTKeyAttributeFilter& aFilter ); |
|
177 |
|
178 /** |
|
179 * Sets the security policy for key management. |
|
180 * |
|
181 * Specifies which processes are allowed to perform management operations on |
|
182 * the key. |
|
183 * |
|
184 * @param aHandle The handle of the key |
|
185 * @param aPolicy The new security policy. |
|
186 * |
|
187 * @leave KErrPermissionDenied If the caller does not have WriteUserData capability, |
|
188 * or is not the owner of the key. |
|
189 * @leave KErrNotFound If the key the handle referes to does not exist. |
|
190 */ |
|
191 TInt SetManagementPolicy( TCTTokenObjectHandle aHandle, |
|
192 const TSecurityPolicy& aPolicy ); |
|
193 |
|
194 /** |
|
195 * Sets the security policy for key use. |
|
196 * |
|
197 * Specifies which processes are allowed to use the key for cryptographic |
|
198 * operations. |
|
199 * |
|
200 * @param aHandle The handle of the key |
|
201 * @param aPolicy The new security policy. |
|
202 * |
|
203 * @leave KErrPermissionDenied If the caller does not have WriteUserData capability, |
|
204 * or is not the owner of the key. |
|
205 * @leave KErrNotFound If the key the handle referes to does not exist. |
|
206 */ |
|
207 TInt SetUsePolicy( TCTTokenObjectHandle aHandle, |
|
208 const TSecurityPolicy& aPolicy ); |
|
209 |
|
210 /** |
|
211 * Get reference to UnifiedKeyStore. |
|
212 * @since 3.0 |
|
213 * @return Reference to UnifiedKeyStore; |
|
214 */ |
|
215 CUnifiedKeyStore& UnifiedKeyStore(); |
|
216 |
|
217 public: // Functions from base classes |
|
218 |
|
219 |
|
220 protected: // New functions |
|
221 |
|
222 |
|
223 protected: // Functions from base classes |
|
224 |
|
225 /** |
|
226 * From CActive |
|
227 */ |
|
228 void DoCancel(); |
|
229 void RunL(); |
|
230 |
|
231 private: |
|
232 |
|
233 /** |
|
234 * C++ default constructor. |
|
235 */ |
|
236 CCertSaverSyncWrapper(); |
|
237 |
|
238 /** |
|
239 * By default Symbian 2nd phase constructor is private. |
|
240 */ |
|
241 void ConstructL(); |
|
242 |
|
243 /** |
|
244 * Wait until asynchronous call is completed and return status |
|
245 */ |
|
246 TInt SetActiveAndWait(); |
|
247 |
|
248 public: // Data |
|
249 |
|
250 protected: // Data |
|
251 |
|
252 private: // Data |
|
253 CActiveSchedulerWait iWait; |
|
254 CUnifiedKeyStore* iUnifiedKeyStore; |
|
255 |
|
256 }; |
|
257 |
|
258 #endif // CERTSAVERSYNCWRAPPER_H |
|
259 |
|
260 // End of File |