|
1 /* |
|
2 * Copyright (c) 2007-2009 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 the License "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: |
|
15 * Example file/test code to demonstrate how to develop a TestExecute Server |
|
16 * Developers should take this project as a template and substitute their own |
|
17 * for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started |
|
18 * in the process of the client. The client initialises the server by calling the |
|
19 * one and only ordinal. |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 /** |
|
25 @file |
|
26 @internalTechnology |
|
27 */ |
|
28 |
|
29 #include "te_cryptospiserver.h" |
|
30 |
|
31 #include "symmetriccipherpositiveobjectloadstep.h" |
|
32 #include "symmetriccipherencrypteddatacheckstep.h" |
|
33 #include "symmetriccipherencryptdecryptstep.h" |
|
34 #include "symmetriccipherincrementalencryptdecryptstep.h" |
|
35 #include "symmetriccipherobjectreusestep.h" |
|
36 #include "symmetriccipherprocessbeforeivsetstep.h" |
|
37 #include "symmetriccipherbadivlengthstep.h" |
|
38 #include "symmetriccipherctrmodeoutoforderstep.h" |
|
39 |
|
40 #include "asymmetriccipherpositiveobjectloadstep.h" |
|
41 #include "asymmetriccipherencrypteddatacheckstep.h" |
|
42 #include "asymmetriccipherencryptdecryptstep.h" |
|
43 |
|
44 #include "hashpositiveobjectloadstep.h" |
|
45 #include "hashbasichashofdatastep.h" |
|
46 #include "hashincrementalhashstep.h" |
|
47 #include "hashincrementalhashwithresetstep.h" |
|
48 #include "hashincrementalhashwithcopystep.h" |
|
49 #include "hashincrementalhashwithreplicatestep.h" |
|
50 |
|
51 #include "hmacpositiveobjectloadstep.h" |
|
52 #include "hmacbasichashofdatastep.h" |
|
53 #include "hmacincrementalhmacstep.h" |
|
54 #include "hmacincrementalhmacwithresetstep.h" |
|
55 #include "hmacincrementalhmacwithcopystep.h" |
|
56 #include "hmacincrementalhmacwithreplicatestep.h" |
|
57 #include "hmacsetkeycheckingstep.h" |
|
58 #include "hmacsetoperationmodecheckingstep.h" |
|
59 |
|
60 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
61 #include "hash_basic_data_step.h" |
|
62 #include "hash_incremental_step.h" |
|
63 #include "hash_incremental_with_copy_step.h" |
|
64 #include "hash_incremental_with_replicate_step.h" |
|
65 #include "hash_incremental_with_reset_step.h" |
|
66 #include "hash_positive_object_load_step.h" |
|
67 |
|
68 #include "mac_basic_data_step.h" |
|
69 #include "mac_incremental_with_copy_step.h" |
|
70 #include "mac_incremental_with_replicate_step.h" |
|
71 #include "mac_incremental_reset_step.h" |
|
72 #include "mac_incremental_step.h" |
|
73 #include "mac_positive_object_load_step.h" |
|
74 #include "symmetric_mac_basic_data_step.h" |
|
75 #include "symmetric_mac_incremental_with_replicate_step.h" |
|
76 #include "symmetric_mac_incremental_with_copy_step.h" |
|
77 #include "symmetric_mac_incremental_reset_step.h" |
|
78 #include "symmetric_mac_incremental_re_init_step.h" |
|
79 #include "symmetric_mac_incremental_step.h" |
|
80 |
|
81 #include "plugincharsmacstep.h" |
|
82 |
|
83 #include "plugin_chars_new_hash_step.h" |
|
84 #endif |
|
85 |
|
86 #include "randomnumbergeneratorgeneralusagestep.h" |
|
87 |
|
88 #include "keyexchangesyncstep.h" |
|
89 #include "keypairgeneratorpositiveobjectloadstep.h" |
|
90 #include "signerpositiveobjectloadstep.h" |
|
91 #include "verifierpositiveobjectloadstep.h" |
|
92 #include "signerverifierstep.h" |
|
93 |
|
94 #include "pluginloadstep.h" |
|
95 |
|
96 #include "plugincharscommonstep.h" |
|
97 #include "plugincharssymmetriccipherstep.h" |
|
98 #include "plugincharsasymmetriccipherstep.h" |
|
99 #include "plugincharshashstep.h" |
|
100 #include "plugincharsrandomstep.h" |
|
101 #include "plugincharsasymsignstep.h" |
|
102 #include "plugincharskeyagreestep.h" |
|
103 #include "plugincharsasymkeypairstep.h" |
|
104 #include "plugincharsextendedstep.h" |
|
105 |
|
106 #include "ruleselectcommonstep.h" |
|
107 |
|
108 //#include "pluginruleselectstep.h" |
|
109 |
|
110 _LIT(KServerName,"Te_CryptoSpi"); |
|
111 CTe_CryptoSpi* CTe_CryptoSpi::NewL() |
|
112 /** |
|
113 * @return - Instance of the test server |
|
114 * Same code for Secure and non-secure variants |
|
115 * Called inside the MainL() function to create and start the |
|
116 * CTestServer derived server. |
|
117 */ |
|
118 { |
|
119 CTe_CryptoSpi * server = new (ELeave) CTe_CryptoSpi(); |
|
120 CleanupStack::PushL(server); |
|
121 |
|
122 server->ConstructL(KServerName); |
|
123 CleanupStack::Pop(server); |
|
124 return server; |
|
125 } |
|
126 |
|
127 |
|
128 // Secure variants much simpler |
|
129 // For EKA2, just an E32Main and a MainL() |
|
130 LOCAL_C void MainL() |
|
131 /** |
|
132 * Secure variant |
|
133 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
134 */ |
|
135 { |
|
136 // Leave the hooks in for platform security |
|
137 #if (defined __DATA_CAGING__) |
|
138 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
139 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
140 #endif |
|
141 CActiveScheduler* sched=NULL; |
|
142 sched=new(ELeave) CActiveScheduler; |
|
143 CActiveScheduler::Install(sched); |
|
144 CTe_CryptoSpi* server = NULL; |
|
145 // Create the CTestServer derived server |
|
146 TRAPD(err,server = CTe_CryptoSpi::NewL()); |
|
147 if(!err) |
|
148 { |
|
149 // Sync with the client and enter the active scheduler |
|
150 RProcess::Rendezvous(KErrNone); |
|
151 sched->Start(); |
|
152 } |
|
153 delete server; |
|
154 delete sched; |
|
155 } |
|
156 |
|
157 |
|
158 |
|
159 GLDEF_C TInt E32Main() |
|
160 /** |
|
161 * @return - Standard Epoc error code on process exit |
|
162 * Secure variant only |
|
163 * Process entry point. Called by client using RProcess API |
|
164 */ |
|
165 { |
|
166 __UHEAP_MARK; |
|
167 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
168 if(cleanup == NULL) |
|
169 { |
|
170 return KErrNoMemory; |
|
171 } |
|
172 TRAPD(err,MainL()); |
|
173 delete cleanup; |
|
174 __UHEAP_MARKEND; |
|
175 return err; |
|
176 } |
|
177 |
|
178 |
|
179 CTestStep* CTe_CryptoSpi::CreateTestStep(const TDesC& aStepName) |
|
180 /** |
|
181 * @return - A CTestStep derived instance |
|
182 * Secure and non-secure variants |
|
183 * Implementation of CTestServer pure virtual |
|
184 */ |
|
185 { |
|
186 CTestStep* testStep = NULL; |
|
187 |
|
188 if(aStepName == KSymmetricCipherPositiveObjectLoadStep) |
|
189 testStep = new CSymmetricCipherPositiveObjectLoadStep(); |
|
190 else if(aStepName == KSymmetricCipherEncryptDecryptStep) |
|
191 testStep = new CSymmetricCipherEncryptDecryptStep(); |
|
192 else if(aStepName == KSymmetricCipherEncryptedDataCheckStep) |
|
193 testStep = new CSymmetricCipherEncryptedDataCheckStep(); |
|
194 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptStep) |
|
195 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(); |
|
196 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptMinus1ByteStep) |
|
197 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(-1); |
|
198 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptMinus3BytesStep) |
|
199 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(-3); |
|
200 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptPlus1ByteStep) |
|
201 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(1); |
|
202 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptPlus3BytesStep) |
|
203 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(3); |
|
204 else if(aStepName == KSymmetricCipherObjectReuseStep) |
|
205 testStep = new CSymmetricCipherObjectReuseStep(); |
|
206 else if(aStepName == KSymmetricCipherProcessBeforeIvSetStep) |
|
207 testStep = new CSymmetricCipherProcessBeforeIvSetStep(); |
|
208 else if(aStepName == KSymmetricCipherBadIvLengthStep) |
|
209 testStep = new CSymmetricCipherBadIvLengthStep(); |
|
210 else if(aStepName == KSymmetricCipherCtrModeOutOfOrderStep) |
|
211 testStep = new CSymmetricCipherCtrModeOutOfOrderStep(); |
|
212 |
|
213 else if(aStepName == KASymmetricCipherPositiveObjectLoadStep) |
|
214 testStep = new CASymmetricCipherPositiveObjectLoadStep(); |
|
215 else if(aStepName == KASymmetricCipherEncryptedDataCheckStep) |
|
216 testStep = new CASymmetricCipherEncryptedDataCheckStep(); |
|
217 else if(aStepName == KASymmetricCipherEncryptDecryptStep) |
|
218 testStep = new CASymmetricCipherEncryptDecryptStep(); |
|
219 |
|
220 else if(aStepName == KHashPositiveObjectLoadStep) |
|
221 testStep = new CHashPositiveObjectLoadStep(); |
|
222 else if(aStepName == KHashBasicHashOfDataStep) |
|
223 testStep = new CHashBasicHashOfDataStep(); |
|
224 else if(aStepName == KHashIncrementalHashStep) |
|
225 testStep = new CHashIncrementalHashStep(); |
|
226 else if(aStepName == KHashIncrementalHashWithResetStep) |
|
227 testStep = new CHashIncrementalHashWithResetStep(); |
|
228 else if(aStepName == KHashIncrementalHashWithCopyStep) |
|
229 testStep = new CHashIncrementalHashWithCopyStep(); |
|
230 else if(aStepName == KHashIncrementalHashWithReplicateStep) |
|
231 testStep = new CHashIncrementalHashWithReplicateStep(); |
|
232 |
|
233 else if(aStepName == KHmacPositiveObjectLoadStep) |
|
234 testStep = new CHmacPositiveObjectLoadStep(); |
|
235 else if(aStepName == KHmacBasicHashOfDataStep) |
|
236 testStep = new CHmacBasicHashOfDataStep(); |
|
237 else if(aStepName == KHmacIncrementalHmacStep) |
|
238 testStep = new CHmacIncrementalHmacStep(); |
|
239 else if(aStepName == KHmacIncrementalHmacWithResetStep) |
|
240 testStep = new CHmacIncrementalHmacWithResetStep(); |
|
241 else if(aStepName == KHmacIncrementalHmacWithCopyStep) |
|
242 testStep = new CHmacIncrementalHmacWithCopyStep(); |
|
243 else if(aStepName == KHmacIncrementalHmacWithReplicateStep) |
|
244 testStep = new CHmacIncrementalHmacWithReplicateStep(); |
|
245 else if(aStepName == KHmacSetKeyCheckingStep) |
|
246 testStep = new CHmacSetKeyCheckingStep(); |
|
247 else if(aStepName == KHmacSetOperationModeCheckingStep) |
|
248 testStep = new CHmacSetOperationModeCheckingStep(); |
|
249 |
|
250 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
251 else if(aStepName == KHashPositiveLoadStep) |
|
252 testStep = new CHashPositiveLoadStep(); |
|
253 else if(aStepName == KHashBasicDataStep) |
|
254 testStep = new CHashBasicDataStep(); |
|
255 else if(aStepName == KHashIncrementalStep) |
|
256 testStep = new CHashIncrementalStep(); |
|
257 else if(aStepName == KHashIncrementalWithCopyStep) |
|
258 testStep = new CHashIncrementalWithCopyStep(); |
|
259 else if(aStepName == KHashIncrementalWithReplicateStep) |
|
260 testStep = new CHashIncrementalWithReplicateStep(); |
|
261 else if(aStepName == KHashIncrementalWithResetStep) |
|
262 testStep = new CHashIncrementalWithResetStep(); |
|
263 |
|
264 else if(aStepName == KMacPositiveObjectLoadStep) |
|
265 testStep = new CMacPositiveObjectLoadStep(); |
|
266 else if(aStepName == KMacBasicDataStep) |
|
267 testStep = new CMacBasicDataStep(); |
|
268 else if(aStepName == KMacIncrementalStep) |
|
269 testStep = new CMacIncrementalStep(); |
|
270 else if(aStepName == KMacIncrementalWithCopyStep) |
|
271 testStep = new CMacIncrementalWithCopyStep(); |
|
272 else if(aStepName == KMacIncrementalWithReplicateStep) |
|
273 testStep = new CMacIncrementalWithReplicateStep(); |
|
274 else if(aStepName == KMacIncrementalResetStep) |
|
275 testStep = new CMacIncrementalResetStep(); |
|
276 else if(aStepName == KSymmetricMacBasicDataStep) |
|
277 testStep = new CSymmetricMacBasicDataStep(); |
|
278 else if(aStepName == KSymmetricMacIncrementalWithReplicateStep) |
|
279 testStep = new CSymmetricMacIncrementalWithReplicateStep(); |
|
280 else if(aStepName == KSymmetricMacIncrementalWithCopyStep) |
|
281 testStep = new CSymmetricMacIncrementalWithCopyStep(); |
|
282 else if(aStepName == KSymmetricMacIncrementalResetStep) |
|
283 testStep = new CSymmetricMacIncrementalResetStep(); |
|
284 else if(aStepName == KSymmetricMacIncrementalReInitStep) |
|
285 testStep = new CSymmetricMacIncrementalReInitStep(); |
|
286 |
|
287 else if(aStepName == KSymmetricMacIncrementalStep) |
|
288 testStep = new CSymmetricMacIncrementalStep(); |
|
289 |
|
290 else if(aStepName == KPluginCharsMacStep) |
|
291 testStep = new CPluginCharsMacStep(); |
|
292 else if(aStepName == KPluginCharsNewHashStep) |
|
293 testStep = new CPluginCharsNewHashStep(); |
|
294 #endif |
|
295 |
|
296 else if(aStepName == KKeyExchangeSyncStep) |
|
297 testStep = new CKeyExchangeSyncStep(); |
|
298 else if(aStepName == KKeyPairGeneratorPositiveObjectLoadStep) |
|
299 testStep = new CKeyPairGeneratorPositiveObjectLoadStep(); |
|
300 else if(aStepName == KRandomNumberGeneratorGeneralUsageStep) |
|
301 testStep = new CRandomNumberGeneratorGeneralUsageStep(); |
|
302 else if(aStepName == KSignerPositiveObjectLoadStep) |
|
303 testStep = new CSignerPositiveObjectLoadStep(); |
|
304 else if(aStepName == KVerifierPositiveObjectLoadStep) |
|
305 testStep = new CVerifierPositiveObjectLoadStep(); |
|
306 else if(aStepName == KSignerVerifierStep) |
|
307 testStep = new CSignerVerifierStep(); |
|
308 |
|
309 else if(aStepName == KPluginLoadStep) |
|
310 testStep = new CPluginLoadStep(); |
|
311 |
|
312 else if(aStepName == KPluginCharsCommonStep) |
|
313 testStep = new CPluginCharsCommonStep(); |
|
314 else if(aStepName == KPluginCharsSymmetricCipherStep) |
|
315 testStep = new CPluginCharsSymmetricCipherStep(); |
|
316 else if(aStepName == KPluginCharsAsymmetricCipherStep) |
|
317 testStep = new CPluginCharsAsymmetricCipherStep(); |
|
318 else if(aStepName == KPluginCharsHashStep) |
|
319 testStep = new CPluginCharsHashStep(); |
|
320 else if(aStepName == KPluginCharsRandomStep) |
|
321 testStep = new CPluginCharsRandomStep(); |
|
322 else if(aStepName == KPluginCharsAsymSignStep) |
|
323 testStep = new CPluginCharsAsymSignStep(); |
|
324 else if(aStepName == KPluginCharsKeyAgreeStep) |
|
325 testStep = new CPluginCharsKeyAgreeStep(); |
|
326 else if(aStepName == KPluginCharsAsymKeyPairStep) |
|
327 testStep = new CPluginCharsAsymKeyPairStep(); |
|
328 else if(aStepName == KPluginCharsExtendedStep) |
|
329 testStep = new CPluginCharsExtendedStep(); |
|
330 |
|
331 else if(aStepName == KRuleSelectCommonStep) |
|
332 testStep = new CRuleSelectCommonStep(); |
|
333 |
|
334 return testStep; |
|
335 } |