crypto/weakcryptospi/test/tpadding/tpaddingServer.cpp
changeset 8 35751d3474b7
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2004-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 * paddingServer.cpp
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include "tpaddingServer.h"
       
    22 #include "tpaddingTestSteps.h"
       
    23 #include "tpaddingNone.h"
       
    24 #include "tpaddingSSLv3.h"
       
    25 #include "tpaddingPKCS1.h"
       
    26 #include "tpaddingPKCS7.h"
       
    27 
       
    28 // name of test server 
       
    29 _LIT(KServerName, "tpaddingserver");
       
    30 
       
    31 // server class name
       
    32 CPaddingServer* CPaddingServer::NewL()
       
    33 /**
       
    34  * @return - Instance of the test server
       
    35  * Called inside the MainL() function to create and start the
       
    36  * CTestServer derived server.
       
    37  */
       
    38 {
       
    39    // new server class 
       
    40    CPaddingServer * server = new (ELeave) CPaddingServer();
       
    41    CleanupStack::PushL(server);
       
    42 	
       
    43    // Either use a StartL or ConstructL, the latter will permit
       
    44    // Server Logging.
       
    45 
       
    46    //server->StartL(KServerName); 
       
    47    server->ConstructL(KServerName);
       
    48    CleanupStack::Pop(server);
       
    49    return server;
       
    50 }
       
    51 
       
    52 // EKA2 much simpler
       
    53 // Just an E32Main and a MainL()
       
    54 LOCAL_C void MainL()
       
    55 /**
       
    56  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    57  */
       
    58 {
       
    59    // Leave the hooks in for platform security
       
    60 #if (defined __DATA_CAGING__)
       
    61    RProcess().DataCaging(RProcess::EDataCagingOn);
       
    62    RProcess().SecureApi(RProcess::ESecureApiOn);
       
    63 #endif
       
    64    CActiveScheduler* sched=NULL;
       
    65    sched=new(ELeave) CActiveScheduler;
       
    66    CActiveScheduler::Install(sched);
       
    67    // server name
       
    68    CPaddingServer* server = NULL;
       
    69    // Create the CTestServer derived server
       
    70    // server name
       
    71    TRAPD(err,server = CPaddingServer::NewL());
       
    72    if(!err)
       
    73    {
       
    74       // Sync with the client and enter the active scheduler
       
    75       RProcess::Rendezvous(KErrNone);
       
    76       sched->Start();
       
    77    }
       
    78    delete server;
       
    79    delete sched;
       
    80 }
       
    81 
       
    82 // Only a DLL on emulator for typhoon and earlier
       
    83 
       
    84 GLDEF_C TInt E32Main()
       
    85 /**
       
    86  * @return - Standard Epoc error code on exit
       
    87  */
       
    88 {
       
    89    CTrapCleanup* cleanup = CTrapCleanup::New();
       
    90    if(cleanup == NULL)
       
    91    {
       
    92       return KErrNoMemory;
       
    93    }
       
    94    TRAP_IGNORE(MainL());
       
    95    delete cleanup;
       
    96    return KErrNone;
       
    97 }
       
    98 
       
    99 // Create a thread in the calling process
       
   100 // Emulator typhoon and earlier
       
   101 
       
   102 CTestStep* CPaddingServer::CreateTestStep(const TDesC& aStepName)
       
   103 /**
       
   104  * @return - A CTestStep derived instance
       
   105  * Implementation of CTestServer pure virtual
       
   106  */
       
   107 {
       
   108    CTestStep* testStep = NULL;
       
   109    // __EDIT_ME__ - Create your own test steps here
       
   110    // This server creates just one step but create as many as you want
       
   111    // They are created "just in time" when the worker thread is created
       
   112 
       
   113    if (aStepName == KPadNone)
       
   114       testStep = new (ELeave) CTestPadNone();
       
   115    else if (aStepName == KUnpadNone)
       
   116       testStep = new (ELeave) CTestUnpadNone();
       
   117    else if (aStepName == KPadSSLv3)
       
   118       testStep = new (ELeave) CTestPadSSLv3();
       
   119    else if (aStepName == KUnpadSSLv3)
       
   120       testStep = new (ELeave) CTestUnpadSSLv3();
       
   121    else if (aStepName == KPadPKCS1)
       
   122       testStep = new (ELeave) CTestPadPKCS1();
       
   123    else if (aStepName == KUnpadPKCS1)
       
   124       testStep = new (ELeave) CTestUnpadPKCS1();
       
   125    else if (aStepName == KPadPKCS7)
       
   126       testStep = new (ELeave) CTestPadPKCS7();
       
   127    else if (aStepName == KUnpadPKCS7)
       
   128       testStep = new (ELeave) CTestUnpadPKCS7();
       
   129    else if (aStepName == KUnpadCorruptPKCS7)
       
   130       testStep = new (ELeave) CTestUnpadCorruptPKCS7(); 
       
   131    else if (aStepName == KPaddingCorruptPKCS7)
       
   132    	  testStep = new (ELeave) CTestPaddingCorruptPKCS7();
       
   133    return testStep;
       
   134 }