Update contrib.
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
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.
29 #include "te_cryptospiserver.h"
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"
40 #include "asymmetriccipherpositiveobjectloadstep.h"
41 #include "asymmetriccipherencrypteddatacheckstep.h"
42 #include "asymmetriccipherencryptdecryptstep.h"
44 #include "hashpositiveobjectloadstep.h"
45 #include "hashbasichashofdatastep.h"
46 #include "hashincrementalhashstep.h"
47 #include "hashincrementalhashwithresetstep.h"
48 #include "hashincrementalhashwithcopystep.h"
49 #include "hashincrementalhashwithreplicatestep.h"
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"
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"
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"
81 #include "plugincharsmacstep.h"
83 #include "plugin_chars_new_hash_step.h"
86 #include "randomnumbergeneratorgeneralusagestep.h"
88 #include "keyexchangesyncstep.h"
89 #include "keypairgeneratorpositiveobjectloadstep.h"
90 #include "signerpositiveobjectloadstep.h"
91 #include "verifierpositiveobjectloadstep.h"
92 #include "signerverifierstep.h"
94 #include "pluginloadstep.h"
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"
106 #include "ruleselectcommonstep.h"
108 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC))
109 #include "dummyecccipherloadstep.h"
110 #include "dummyeccsignerloadstep.h"
112 //#include "pluginruleselectstep.h"
114 _LIT(KServerName,"Te_CryptoSpi");
115 CTe_CryptoSpi* CTe_CryptoSpi::NewL()
117 * @return - Instance of the test server
118 * Same code for Secure and non-secure variants
119 * Called inside the MainL() function to create and start the
120 * CTestServer derived server.
123 CTe_CryptoSpi * server = new (ELeave) CTe_CryptoSpi();
124 CleanupStack::PushL(server);
126 server->ConstructL(KServerName);
127 CleanupStack::Pop(server);
132 // Secure variants much simpler
133 // For EKA2, just an E32Main and a MainL()
137 * Much simpler, uses the new Rendezvous() call to sync with the client
140 // Leave the hooks in for platform security
141 #if (defined __DATA_CAGING__)
142 RProcess().DataCaging(RProcess::EDataCagingOn);
143 RProcess().DataCaging(RProcess::ESecureApiOn);
145 CActiveScheduler* sched=NULL;
146 sched=new(ELeave) CActiveScheduler;
147 CActiveScheduler::Install(sched);
148 CTe_CryptoSpi* server = NULL;
149 // Create the CTestServer derived server
150 TRAPD(err,server = CTe_CryptoSpi::NewL());
153 // Sync with the client and enter the active scheduler
154 RProcess::Rendezvous(KErrNone);
163 GLDEF_C TInt E32Main()
165 * @return - Standard Epoc error code on process exit
166 * Secure variant only
167 * Process entry point. Called by client using RProcess API
171 CTrapCleanup* cleanup = CTrapCleanup::New();
183 CTestStep* CTe_CryptoSpi::CreateTestStep(const TDesC& aStepName)
185 * @return - A CTestStep derived instance
186 * Secure and non-secure variants
187 * Implementation of CTestServer pure virtual
190 CTestStep* testStep = NULL;
192 if(aStepName == KSymmetricCipherPositiveObjectLoadStep)
193 testStep = new CSymmetricCipherPositiveObjectLoadStep();
194 else if(aStepName == KSymmetricCipherEncryptDecryptStep)
195 testStep = new CSymmetricCipherEncryptDecryptStep();
196 else if(aStepName == KSymmetricCipherEncryptedDataCheckStep)
197 testStep = new CSymmetricCipherEncryptedDataCheckStep();
198 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptStep)
199 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep();
200 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptMinus1ByteStep)
201 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(-1);
202 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptMinus3BytesStep)
203 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(-3);
204 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptPlus1ByteStep)
205 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(1);
206 else if(aStepName == KSymmetricCipherIncrementalEncryptDecryptPlus3BytesStep)
207 testStep = new CSymmetricCipherIncrementalEncryptDecryptStep(3);
208 else if(aStepName == KSymmetricCipherObjectReuseStep)
209 testStep = new CSymmetricCipherObjectReuseStep();
210 else if(aStepName == KSymmetricCipherProcessBeforeIvSetStep)
211 testStep = new CSymmetricCipherProcessBeforeIvSetStep();
212 else if(aStepName == KSymmetricCipherBadIvLengthStep)
213 testStep = new CSymmetricCipherBadIvLengthStep();
214 else if(aStepName == KSymmetricCipherCtrModeOutOfOrderStep)
215 testStep = new CSymmetricCipherCtrModeOutOfOrderStep();
217 else if(aStepName == KASymmetricCipherPositiveObjectLoadStep)
218 testStep = new CASymmetricCipherPositiveObjectLoadStep();
219 else if(aStepName == KASymmetricCipherEncryptedDataCheckStep)
220 testStep = new CASymmetricCipherEncryptedDataCheckStep();
221 else if(aStepName == KASymmetricCipherEncryptDecryptStep)
222 testStep = new CASymmetricCipherEncryptDecryptStep();
224 else if(aStepName == KHashPositiveObjectLoadStep)
225 testStep = new CHashPositiveObjectLoadStep();
226 else if(aStepName == KHashBasicHashOfDataStep)
227 testStep = new CHashBasicHashOfDataStep();
228 else if(aStepName == KHashIncrementalHashStep)
229 testStep = new CHashIncrementalHashStep();
230 else if(aStepName == KHashIncrementalHashWithResetStep)
231 testStep = new CHashIncrementalHashWithResetStep();
232 else if(aStepName == KHashIncrementalHashWithCopyStep)
233 testStep = new CHashIncrementalHashWithCopyStep();
234 else if(aStepName == KHashIncrementalHashWithReplicateStep)
235 testStep = new CHashIncrementalHashWithReplicateStep();
237 else if(aStepName == KHmacPositiveObjectLoadStep)
238 testStep = new CHmacPositiveObjectLoadStep();
239 else if(aStepName == KHmacBasicHashOfDataStep)
240 testStep = new CHmacBasicHashOfDataStep();
241 else if(aStepName == KHmacIncrementalHmacStep)
242 testStep = new CHmacIncrementalHmacStep();
243 else if(aStepName == KHmacIncrementalHmacWithResetStep)
244 testStep = new CHmacIncrementalHmacWithResetStep();
245 else if(aStepName == KHmacIncrementalHmacWithCopyStep)
246 testStep = new CHmacIncrementalHmacWithCopyStep();
247 else if(aStepName == KHmacIncrementalHmacWithReplicateStep)
248 testStep = new CHmacIncrementalHmacWithReplicateStep();
249 else if(aStepName == KHmacSetKeyCheckingStep)
250 testStep = new CHmacSetKeyCheckingStep();
251 else if(aStepName == KHmacSetOperationModeCheckingStep)
252 testStep = new CHmacSetOperationModeCheckingStep();
254 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
255 else if(aStepName == KHashPositiveLoadStep)
256 testStep = new CHashPositiveLoadStep();
257 else if(aStepName == KHashBasicDataStep)
258 testStep = new CHashBasicDataStep();
259 else if(aStepName == KHashIncrementalStep)
260 testStep = new CHashIncrementalStep();
261 else if(aStepName == KHashIncrementalWithCopyStep)
262 testStep = new CHashIncrementalWithCopyStep();
263 else if(aStepName == KHashIncrementalWithReplicateStep)
264 testStep = new CHashIncrementalWithReplicateStep();
265 else if(aStepName == KHashIncrementalWithResetStep)
266 testStep = new CHashIncrementalWithResetStep();
268 else if(aStepName == KMacPositiveObjectLoadStep)
269 testStep = new CMacPositiveObjectLoadStep();
270 else if(aStepName == KMacBasicDataStep)
271 testStep = new CMacBasicDataStep();
272 else if(aStepName == KMacIncrementalStep)
273 testStep = new CMacIncrementalStep();
274 else if(aStepName == KMacIncrementalWithCopyStep)
275 testStep = new CMacIncrementalWithCopyStep();
276 else if(aStepName == KMacIncrementalWithReplicateStep)
277 testStep = new CMacIncrementalWithReplicateStep();
278 else if(aStepName == KMacIncrementalResetStep)
279 testStep = new CMacIncrementalResetStep();
280 else if(aStepName == KSymmetricMacBasicDataStep)
281 testStep = new CSymmetricMacBasicDataStep();
282 else if(aStepName == KSymmetricMacIncrementalWithReplicateStep)
283 testStep = new CSymmetricMacIncrementalWithReplicateStep();
284 else if(aStepName == KSymmetricMacIncrementalWithCopyStep)
285 testStep = new CSymmetricMacIncrementalWithCopyStep();
286 else if(aStepName == KSymmetricMacIncrementalResetStep)
287 testStep = new CSymmetricMacIncrementalResetStep();
288 else if(aStepName == KSymmetricMacIncrementalReInitStep)
289 testStep = new CSymmetricMacIncrementalReInitStep();
291 else if(aStepName == KSymmetricMacIncrementalStep)
292 testStep = new CSymmetricMacIncrementalStep();
294 else if(aStepName == KPluginCharsMacStep)
295 testStep = new CPluginCharsMacStep();
296 else if(aStepName == KPluginCharsNewHashStep)
297 testStep = new CPluginCharsNewHashStep();
300 else if(aStepName == KKeyExchangeSyncStep)
301 testStep = new CKeyExchangeSyncStep();
302 else if(aStepName == KKeyPairGeneratorPositiveObjectLoadStep)
303 testStep = new CKeyPairGeneratorPositiveObjectLoadStep();
304 else if(aStepName == KRandomNumberGeneratorGeneralUsageStep)
305 testStep = new CRandomNumberGeneratorGeneralUsageStep();
306 else if(aStepName == KSignerPositiveObjectLoadStep)
307 testStep = new CSignerPositiveObjectLoadStep();
308 else if(aStepName == KVerifierPositiveObjectLoadStep)
309 testStep = new CVerifierPositiveObjectLoadStep();
310 else if(aStepName == KSignerVerifierStep)
311 testStep = new CSignerVerifierStep();
313 else if(aStepName == KPluginLoadStep)
314 testStep = new CPluginLoadStep();
316 else if(aStepName == KPluginCharsCommonStep)
317 testStep = new CPluginCharsCommonStep();
318 else if(aStepName == KPluginCharsSymmetricCipherStep)
319 testStep = new CPluginCharsSymmetricCipherStep();
320 else if(aStepName == KPluginCharsAsymmetricCipherStep)
321 testStep = new CPluginCharsAsymmetricCipherStep();
322 else if(aStepName == KPluginCharsHashStep)
323 testStep = new CPluginCharsHashStep();
324 else if(aStepName == KPluginCharsRandomStep)
325 testStep = new CPluginCharsRandomStep();
326 else if(aStepName == KPluginCharsAsymSignStep)
327 testStep = new CPluginCharsAsymSignStep();
328 else if(aStepName == KPluginCharsKeyAgreeStep)
329 testStep = new CPluginCharsKeyAgreeStep();
330 else if(aStepName == KPluginCharsAsymKeyPairStep)
331 testStep = new CPluginCharsAsymKeyPairStep();
332 else if(aStepName == KPluginCharsExtendedStep)
333 testStep = new CPluginCharsExtendedStep();
335 else if(aStepName == KRuleSelectCommonStep)
336 testStep = new CRuleSelectCommonStep();
338 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC))
339 else if(aStepName == KDummyEccCipherLoadStep)
340 testStep = new CDummyEccCipherLoadStep();
341 else if(aStepName == KDummyEccSignerLoadStep)
342 testStep = new CDummyEccSignerLoadStep();