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