int nb_true_args(int argc, char **argv) { char **tab; int x; x = 0; tab = test_args(argc, argv); while (tab[x] != NULL) { x++; } return (x); }
int main(int argc, char *argv[]) { bool vkt, ecb, cbc; #ifdef __cplusplus mars _mars; rc6 _rc6; rijndael _rijndael; serpent _serpent; twofish _twofish; #else alg_struct _mars; alg_struct _rc6; alg_struct _rijndael; alg_struct _serpent; alg_struct _twofish; _mars.name = MARS(name); _mars.set_key = MARS(set_key); _mars.encrypt = MARS(encrypt); _mars.decrypt = MARS(decrypt); _rc6.name = RC6(name); _rc6.set_key = RC6(set_key); _rc6.encrypt = RC6(encrypt); _rc6.decrypt = RC6(decrypt); _rijndael.name = RIJNDAEL(name); _rijndael.set_key = RIJNDAEL(set_key); _rijndael.encrypt = RIJNDAEL(encrypt); _rijndael.decrypt = RIJNDAEL(decrypt); _serpent.name = SERPENT(name); _serpent.set_key = SERPENT(set_key); _serpent.encrypt = SERPENT(encrypt); _serpent.decrypt = SERPENT(decrypt); _twofish.name = TWOFISH(name); _twofish.set_key = TWOFISH(set_key); _twofish.encrypt = TWOFISH(encrypt); _twofish.decrypt = TWOFISH(decrypt); #endif if(argc == 1) { con_string("\nusage: aes_rav /a:[12345] /t:[kec] [/h]"); con_string("\nwhere:"); con_string("\n /a:[12345] algorithms to be tested"); con_string("\n /t:[kec] type of test"); con_string("\n /h use author's byte order (serpent)"); con_string("\nand:"); con_string("\n 1:mars, 2:rc6, 3:rijndael, 4:serpent, 5:twofish"); con_string("\n k: run ECB Known Answer tests"); con_string("\n e: run ECB Monte Carlo tests"); con_string("\n c: run CBC Monte Carlo tests"); con_string("\n\n"); exit(0); } vkt = test_args(argc, argv, 't', 'k'); ecb = test_args(argc, argv, 't', 'e'); cbc = test_args(argc, argv, 't', 'c'); serpent_hack = false; if(test_args(argc, argv, 'a', '1')) do_tests(vkt, ecb, cbc, _mars); if(test_args(argc, argv, 'a', '2')) do_tests(vkt, ecb, cbc, _rc6); if(test_args(argc, argv, 'a', '3')) do_tests(vkt, ecb, cbc, _rijndael); if(test_args(argc, argv, 'a', '4')) { serpent_hack = test_args(argc, argv, 'h', '\0'); do_tests(vkt, ecb, cbc, _serpent); serpent_hack = false; } if(test_args(argc, argv, 'a', '5')) do_tests(vkt, ecb, cbc, _twofish); return 0; }
int main(int argc, char *argv[]) { OFILE outf; #ifdef __cplusplus mars _mars; rc6 _rc6; rijndael _rijndael; serpent _serpent; twofish _twofish; #else alg_struct _mars; alg_struct _rc6; alg_struct _rijndael; alg_struct _serpent; alg_struct _twofish; _mars.name = MARS(name); _mars.set_key = MARS(set_key); _mars.encrypt = MARS(encrypt); _mars.decrypt = MARS(decrypt); _rc6.name = RC6(name); _rc6.set_key = RC6(set_key); _rc6.encrypt = RC6(encrypt); _rc6.decrypt = RC6(decrypt); _rijndael.name = RIJNDAEL(name); _rijndael.set_key = RIJNDAEL(set_key); _rijndael.encrypt = RIJNDAEL(encrypt); _rijndael.decrypt = RIJNDAEL(decrypt); _serpent.name = SERPENT(name); _serpent.set_key = SERPENT(set_key); _serpent.encrypt = SERPENT(encrypt); _serpent.decrypt = SERPENT(decrypt); _twofish.name = TWOFISH(name); _twofish.set_key = TWOFISH(set_key); _twofish.encrypt = TWOFISH(encrypt); _twofish.decrypt = TWOFISH(decrypt); #endif if(argc != 2 && argc != 3) { con_string("\nusage: aes_tmr /a:[12345]"); con_string("\nwhere:"); con_string("\n /a:[12345] algorithms to be tested"); con_string("\nand:"); con_string("\n 1:mars, 2:rc6, 3:rijndael, 4:serpent, 5:twofish"); con_string("\n\n"); exit(0); } outf = open_ofile(outf, argc == 3 ? argv[2] : "CON"); header(outf); if(test_args(argc, argv, 'a', '1')) { time(_mars); do_out(outf, _mars); } if(test_args(argc, argv, 'a', '2')) { time(_rc6); do_out(outf, _rc6); } if(test_args(argc, argv, 'a', '3')) { time(_rijndael); do_out(outf, _rijndael); } if(test_args(argc, argv, 'a', '4')) { time(_serpent); do_out(outf, _serpent); } if(test_args(argc, argv, 'a', '5')) { time(_twofish); do_out(outf, _twofish); } close_ofile(outf); return 0; }
/*------------------------------------------------------------------------------ | main +-----------------------------------------------------------------------------*/ int main(int argc, char** argv) { #if defined(QT_QML_LIB) && defined(QT_QUICK_LIB) QGuiApplication a(argc, argv); #endif #if 0 QElapsedTimer timer; timer.start(); // Test with lc_logging. for (int i = 0; i < 100000; i++) log_verbose("Test: %d.", i); qDebug("Result lc_logging: %lld.", timer.elapsed()); // Test with printf. timer.restart(); for (int i = 0; i < 100000; i++) { fprintf(stdout, "- DEBUG:%s: Test: %d.\n", lc_current_time().c_str(), i); fflush(stdout); } qDebug("Result printf: %lld.", timer.elapsed()); // Test with qDebug. timer.restart(); for (int i = 0; i < 100000; i++) { qDebug("- DEBUG:%s: Test: %d.\n", lc_current_time().c_str(), i); fflush(stderr); } qDebug("Result qDebug: %lld.", timer.elapsed()); #endif #ifdef __GNUC__ LOG_CRITICAL("MyTag", "Oooops!"); #endif log_info("Info log."); log_info_t("MyTag", "Info log."); test_args("Testing %d va_args functions.", 2); log_debug("Some message for debugging..."); log_disabled("A disabled log!!!!!!!!!!! You won't see this."); log_critical("Print int: %d.", 5); log_critical_t("MyTag", "Print int: %d.", 5); log_critical_t("MyTag", "Print with tag only."); /*lc_formatted_printf(stdout, LC_LOG_ATTR_UNDERLINE, LC_LOG_COL_MAGENTA, "Underlined %s! ;-)\n", "magenta");*/ log_formatted(LC_LOG_ATTR_UNDERLINE, LC_LOG_COL_YELLOW, "Formatted text."); log_formatted(LC_LOG_COL_YELLOW, "Formatted text with %s.", "param"); #ifndef __ANDROID__ test_func(); #endif // Using streams. { LC_LogDef logger(NULL, LC_LOG_ATTR_RESET, LC_LOG_COL_BLUE); logger.stream() << "Blue log using stream. " << "Params can be added like " << 1234 << "."; LC_LogDef l(NULL); Q_UNUSED(l); } { LC_Log<LC_Output2Std> logger(LC_LOG_DEBUG); logger.stream() << "Debug log with stream."; } { LC_Log<LC_Output2Std> logger(LC_LOG_WARN); logger.stream() << "Warning log with stream."; } { LC_Log<LC_Output2Std> logger(LC_LOG_CRITICAL); logger.stream() << "Critical log with stream."; } #if defined(QT_QML_LIB) && defined(QT_QUICK_LIB) QQuickView view; LC_QMLLogger::registerObject(view.rootContext()); view.setSource(QUrl("qrc:///main.qml")); #endif assert(log_verbose("") == true); assert(log_info("") == true); assert(log_warn("") == false); assert(log_err("") == false); assert(log_critical("") == false); return 0; }
int main (int, char *[]) { /************ * The values below should match the config file. */ const std::string test_orb_options ("-ORBDottedDecimalAddresses 1 -ORBObjRefStyle IOR"); Lorica::Config::Endpoint ep1; ep1.external_ = true; ep1.hostname_ = "proxyhost"; ep1.port_ = 951; ep1.alias_ = "ociweb.com"; ep1.is_ipv6_ = false; ep1.ssl_port_ = 952; Lorica::Config::Endpoint ep2; ep2.external_ = false; ep2.hostname_ = "proxyhost"; ep2.port_ = 1951; ep2.alias_ = ""; ep2.is_ipv6_ = false; ep2.ssl_port_ = 1952; Lorica::Config::Endpoints test_eps; test_eps.push_back (ep1); test_eps.push_back (ep2); ACE_ARGV test_args ("lorica " "-ORBUseSharedProfile 0 -ORBDottedDecimalAddresses 1 -ORBObjRefStyle IOR " "-ORBListenEndpoints iiop://1.2@proxyhost:951/ssl_port=952," "hostname_in_ior=ociweb.com " "-ORBListenEndpoints iiop://1.2@proxyhost:1951/ssl_port=1952"); bool test_generic_eval (false); bool test_null_eval_unknown (false); std::string test_null_ids ("IDL:someID:1.0 IDL:someOtherID:1.0"); /*** * End of test configuration */ const std::string config_file ("test.conf"); Lorica::FileConfig *config = Lorica::FileConfig::instance (); try { config->init (config_file); } catch (const Lorica::FileConfig::InitError& ) { std::cerr << "Failed to load config file: " << config_file << std::endl; return -1; } std::string orb_option = config->get_value ("ORB_Option"); if (test_orb_options != orb_option) { std::cerr << "ORB_OPTION mismatch." << std::endl; return -1; } std::cout << "ORB_Option: " << orb_option << std::endl; Lorica::Config::Endpoints eps = config->get_endpoints (true); Lorica::Config::Endpoints eps2 = config->get_endpoints (false); for (size_t count = 0; count < eps2.size(); count++) eps.push_back(eps2[count]); for (size_t count = 0; count < test_eps.size(); count++) { if (test_eps[count] != eps[count]) { std::cout <<"eps[" << count <<"] = " << eps[count].hostname_ << ":" << eps[count].port_ << "/ssl_port=" << eps[count].ssl_port_ << ",alias=" << eps[count].alias_ << " (" << (eps[count].external_ ? "ex" : "in") << "ternal" << std::endl; std::cout <<"test_eps[" << count <<"] = " << test_eps[count].hostname_ << ":" << test_eps[count].port_ << "/ssl_port=" << test_eps[count].ssl_port_ << ",alias=" << test_eps[count].alias_ << " (" << (test_eps[count].external_ ? "ex" : "in") << "ternal" << std::endl; std::cerr << "Endpoints mismatch." << std::endl; return 0; } } std::cout << "Endpoint info: "; for (unsigned int count = 0; count < eps.size(); count++) std::cout << eps[count].hostname_ << ":" << eps[count].port_ << " <> "; std::cout << std::endl; std::auto_ptr <ACE_ARGV> args (config->get_orb_options ()); if (args.get() == 0) std::cerr << "No ORB args found" << std::endl; ACE_TCHAR **test_argv = test_args.argv(); ACE_TCHAR **the_argv = args->argv(); if (test_args.argc() != args->argc ()) { std::cerr << "ORB argv count mismatch" << std::endl; return -1; } for (int count = 0; count < test_args.argc(); count++) { if (ACE_OS::strcmp (test_argv[count], the_argv[count]) != 0) { std::cerr << "ORB argv[" << count << "] mismatch, " << test_argv[count] << " != " << the_argv[count] << std::endl; return -1; } } std::cout << "ORB Options: "; size_t the_argc = args->argc (); for (size_t count = 0; count < the_argc; count++) std::cout << the_argv [count] << " "; std::cout << std::endl; bool generic_eval = config->generic_evaluator (); if (test_generic_eval != generic_eval) { std::cerr << "Incorrect general evaluator configuration." << std::endl; } std::cout << "Generic evaluator " << (generic_eval ? "" : "not ") << "applied." << std::endl; bool null_eval_unknown = config->null_eval_any (); if (test_null_eval_unknown != null_eval_unknown) std::cerr << "Incorrect null evaluator any configuration." << std::endl; std::cout << "Null evaluator any " << (null_eval_unknown ? "" : "not ") << "applied." << std::endl; std::string null_ids = config->null_eval_type_ids (); if (test_null_ids != null_ids) std::cerr << "Incorrect null evaluator ID string." << std::endl; std::cout << "Null evaluator ID's: " << null_ids << std::endl; return 0; }
int main(int argc, char *argv[]) { int do_cmp, tyf[4], kf[3], ki; f_ectx alg[1]; #if defined(DLL_IMPORT) && defined(DLL_DYNAMIC_LOAD) HINSTANCE h_dll; if(!(h_dll = init_dll(&fn))) return -1; #else aes_init(); #endif if(argc == 1) { printf("\nusage: aes_gav /t:[knec] /k:[468] [/c]"); printf("\n"); printf("\nwhere the symbols in square brackets can be used in"); printf("\nany combination (without the brackets) and have the"); printf("\nfollowing meanings:"); printf("\n"); printf("\n /t:[knec] selects which tests are used"); printf("\n /k:[468] selects the key lengths used"); printf("\n /c compares output with reference"); printf("\nwhere:"); printf("\n k: generate ECB Known Answer Test files"); printf("\n n: generate ECB Known Answer Test files (new)"); printf("\n e: generate ECB Monte Carlo Test files"); printf("\n c: generate CBC Monte Carlo Test files"); printf("\n"); printf("\nand the characters giving block and key lengths are"); printf("\ndigits representing the lengths in 32-bit units.\n\n"); exit(0); } printf("\nRun tests for the AES algorithm %s", #if defined(DLL_IMPORT) " (DLL Version)\n"); #elif defined(AES_CPP) " (CPP Version)\n"); #else ""); #endif do_cmp = test_args(argc, argv, 'c', '\0'); tyf[0] = test_args(argc, argv, 't', 'k'); tyf[1] = test_args(argc, argv, 't', 'n'); tyf[2] = test_args(argc, argv, 't', 'e'); tyf[3] = test_args(argc, argv, 't', 'c'); kf[0] = test_args(argc, argv, 'k', '4'); kf[1] = test_args(argc, argv, 'k', '6'); kf[2] = test_args(argc, argv, 'k', '8'); if(!(kf[0] || kf[1] || kf[2])) { kf[0] = kf[1] = kf[2] = TRUE; // AES key sizes if not specified } for(ki = 0; ki < 3; ++ki) if(kf[ki]) { do_tests(do_cmp, tyf, alg, 16, 16 + 8 * ki); } #if defined(DLL_IMPORT) && defined(DLL_DYNAMIC_LOAD) if(h_dll) FreeLibrary(h_dll); #endif printf("\n\n"); return 0; }