sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions are met: sl@0: sl@0: * Redistributions of source code must retain the above copyright notice, this sl@0: * list of conditions and the following disclaimer. sl@0: * Redistributions in binary form must reproduce the above copyright notice, sl@0: * this list of conditions and the following disclaimer in the documentation sl@0: * and/or other materials provided with the distribution. sl@0: * Neither the name of Nokia Corporation nor the names of its contributors sl@0: * may be used to endorse or promote products derived from this software sl@0: * without specific prior written permission. sl@0: sl@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" sl@0: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE sl@0: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE sl@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL sl@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR sl@0: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER sl@0: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, sl@0: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE sl@0: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: * sl@0: * Description: ?Description sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include sl@0: #include sl@0: #include "crypto_test.h" sl@0: #include "tcrypto_test.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: // EXTERNAL DATA STRUCTURES sl@0: //extern ?external_data; sl@0: sl@0: // EXTERNAL FUNCTION PROTOTYPES sl@0: //extern ?external_function( ?arg_type,?arg_type ); sl@0: sl@0: // CONSTANTS sl@0: //const ?type ?constant_var = ?constant; sl@0: sl@0: // MACROS sl@0: //#define ?macro ?macro_def sl@0: sl@0: // LOCAL CONSTANTS AND MACROS sl@0: //const ?type ?constant_var = ?constant; sl@0: //#define ?macro_name ?macro_def sl@0: sl@0: // MODULE DATA STRUCTURES sl@0: //enum ?declaration sl@0: //typedef ?declaration sl@0: sl@0: // LOCAL FUNCTION PROTOTYPES sl@0: //?type ?function_name( ?arg_type, ?arg_type ); sl@0: sl@0: // FORWARD DECLARATIONS sl@0: //class ?FORWARD_CLASSNAME; sl@0: sl@0: // ============================= LOCAL FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // ?function_name ?description. sl@0: // ?description sl@0: // Returns: ?value_1: ?description sl@0: // ?value_n: ?description_line1 sl@0: // ?description_line2 sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: /* sl@0: ?type ?function_name( sl@0: ?arg_type arg, // ?description sl@0: ?arg_type arg) // ?description sl@0: { sl@0: sl@0: ?code // ?comment sl@0: sl@0: // ?comment sl@0: ?code sl@0: } sl@0: */ sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ccrypto_test::Delete sl@0: // Delete here all resources allocated and opened from test methods. sl@0: // Called from destructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void Ccrypto_test::Delete() sl@0: { sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ccrypto_test::RunMethodL sl@0: // Run specified method. Contains also table of test mothods and their names. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ccrypto_test::RunMethodL( sl@0: CStifItemParser& aItem ) sl@0: { sl@0: sl@0: static TStifFunctionInfo const KFunctions[] = sl@0: { sl@0: // Copy this line for every implemented function. sl@0: // First string is the function name used in TestScripter script file. sl@0: // Second is the actual implementation member function. sl@0: ENTRY( "BNTest", Ccrypto_test::BnTest ), sl@0: ENTRY( "DESTest", Ccrypto_test::DesTest ), sl@0: ENTRY( "DHTest", Ccrypto_test::DhTest ), sl@0: ENTRY( "DSATest", Ccrypto_test::DsaTest ), sl@0: ENTRY( "ENGINETest", Ccrypto_test::EngineTest ), sl@0: ENTRY( "EVPTest", Ccrypto_test::EvpTest ), sl@0: ENTRY( "EXPTest", Ccrypto_test::ExpTest ), sl@0: ENTRY( "HMACTest", Ccrypto_test::HmacTest ), sl@0: ENTRY( "MD2Test", Ccrypto_test::Md2Test ), sl@0: ENTRY( "MD5Test", Ccrypto_test::Md5Test ), sl@0: ENTRY( "RANDTest", Ccrypto_test::RandTest ), sl@0: ENTRY( "RC2Test", Ccrypto_test::Rc2Test ), sl@0: ENTRY( "RC4Test", Ccrypto_test::Rc4Test ), sl@0: ENTRY( "RSATest", Ccrypto_test::RsaTest ), sl@0: ENTRY( "SHATest", Ccrypto_test::ShaTest ), sl@0: ENTRY( "SHA1Test", Ccrypto_test::Sha1Test ), sl@0: ENTRY( "SHA256Test", Ccrypto_test::Sha256Test ), sl@0: ENTRY( "SHA512Test", Ccrypto_test::Sha512Test ), sl@0: sl@0: }; sl@0: sl@0: const TInt count = sizeof( KFunctions ) / sl@0: sizeof( TStifFunctionInfo ); sl@0: sl@0: return RunInternalL( KFunctions, count, aItem ); sl@0: sl@0: } sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" sl@0: { sl@0: #endif sl@0: sl@0: FILE *fp_stdout=NULL; sl@0: FILE *fp_stderr=NULL; sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: int cryptotest_init(char *mod) sl@0: { sl@0: char str[200]; sl@0: int len=0; sl@0: if(!mod) sl@0: return 1; sl@0: len=strlen(LOG_STDOUT); sl@0: strcpy(str,LOG_STDOUT); sl@0: strcat(str,"_"); sl@0: strcat(str,mod); sl@0: len+=strlen(mod); sl@0: str[len+1]='\0'; sl@0: fp_stdout = fopen(str,"a+b"); sl@0: if(!fp_stdout) sl@0: return 1; sl@0: fp_stderr=fp_stdout; sl@0: return 0; sl@0: } sl@0: sl@0: void cryptotest_deinit(void) sl@0: { sl@0: fclose(fp_stdout); sl@0: fp_stderr=NULL; sl@0: fp_stdout=NULL; sl@0: } sl@0: char ** MakeArgs(CStifItemParser& aItem,int * argc) sl@0: { sl@0: char *ini_cmd[256]; sl@0: char **cmd_line; sl@0: sl@0: TInt len=0; sl@0: TPtrC string; sl@0: TBuf8<50> buf1; sl@0: char* argument; sl@0: int cnt=0; sl@0: int i; sl@0: sl@0: //parse through the parameters of cfg to find the number and strings of cmd line sl@0: sl@0: while(aItem.GetNextString(string)!=-1) sl@0: { sl@0: buf1.Copy(string); sl@0: argument=(char *)buf1.Ptr(); sl@0: len=buf1.Length(); sl@0: argument[len]='\0'; sl@0: sl@0: ini_cmd[cnt]=(char *)malloc(sizeof(char)*len+1); sl@0: if(ini_cmd[cnt]==NULL) sl@0: { sl@0: for(i=0;i