#include <string.h>#include <stdio.h>#include "runtime.hpp"#include "des.hpp"#include "aes.hpp"#include "twofish.hpp"#include "blowfish.hpp"#include "arc4.hpp"#include "md5.hpp"#include "sha.hpp"#include "ripemd.hpp"#include "rsa.hpp"#include "dh.hpp"#include "dsa.hpp"#include <sys/time.h>Include dependency graph for benchmark.cpp:

Go to the source code of this file.
Functions | |
| void | bench_aes (bool show) |
| void | bench_des () |
| void | bench_blowfish () |
| void | bench_twofish () |
| void | bench_arc4 () |
| void | bench_md5 () |
| void | bench_sha () |
| void | bench_ripemd () |
| void | bench_rsa () |
| void | bench_dh () |
| void | bench_dsa () |
| double | current_time () |
| int | main (int argc, char **argv) |
Variables | |
| const int | megs = 5 |
| const byte | key [] |
| const byte | iv [] |
| byte | plain [1024 *1024] |
| byte | cipher [1024 *1024] |
| RandomNumberGenerator | rng |
| void bench_aes | ( | bool | show | ) |
Definition at line 107 of file benchmark.cpp.
References cipher, current_time(), iv, key, megs, plain, TaoCrypt::BlockCipher< DIR, T, MODE >::Process(), TaoCrypt::BlockCipher< DIR, T, MODE >::SetKey(), and start().
Referenced by main().
00108 { 00109 AES_CBC_Encryption enc; 00110 enc.SetKey(key, 16, iv); 00111 00112 double start = current_time(); 00113 00114 for(int i = 0; i < megs; i++) 00115 enc.Process(plain, cipher, sizeof(plain)); 00116 00117 double total = current_time() - start; 00118 00119 double persec = 1 / total * megs; 00120 00121 if (show) 00122 printf("AES %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00123 persec); 00124 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_arc4 | ( | ) |
Definition at line 166 of file benchmark.cpp.
References cipher, current_time(), key, megs, plain, TaoCrypt::ARC4::Process(), TaoCrypt::ARC4::SetKey(), and start().
Referenced by main().
00167 { 00168 ARC4 enc; 00169 enc.SetKey(key, 16); 00170 00171 double start = current_time(); 00172 00173 for(int i = 0; i < megs; i++) 00174 enc.Process(cipher, plain, sizeof(plain)); 00175 00176 double total = current_time() - start; 00177 00178 double persec = 1 / total * megs; 00179 00180 printf("ARC4 %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00181 persec); 00182 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_blowfish | ( | ) |
Definition at line 147 of file benchmark.cpp.
References cipher, current_time(), iv, key, megs, plain, TaoCrypt::BlockCipher< DIR, T, MODE >::Process(), TaoCrypt::BlockCipher< DIR, T, MODE >::SetKey(), and start().
Referenced by main().
00148 { 00149 Blowfish_CBC_Encryption enc; 00150 enc.SetKey(key, 16, iv); 00151 00152 double start = current_time(); 00153 00154 for(int i = 0; i < megs; i++) 00155 enc.Process(plain, cipher, sizeof(plain)); 00156 00157 double total = current_time() - start; 00158 00159 double persec = 1 / total * megs; 00160 00161 printf("Blowfish %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00162 persec); 00163 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_des | ( | ) |
Definition at line 88 of file benchmark.cpp.
References cipher, current_time(), iv, key, megs, plain, TaoCrypt::BlockCipher< DIR, T, MODE >::Process(), TaoCrypt::BlockCipher< DIR, T, MODE >::SetKey(), and start().
Referenced by main().
00089 { 00090 DES_EDE3_CBC_Encryption enc; 00091 enc.SetKey(key, 16, iv); 00092 00093 double start = current_time(); 00094 00095 for(int i = 0; i < megs; i++) 00096 enc.Process(plain, cipher, sizeof(plain)); 00097 00098 double total = current_time() - start; 00099 00100 double persec = 1 / total * megs; 00101 00102 printf("3DES %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00103 persec); 00104 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_dh | ( | ) |
Definition at line 306 of file benchmark.cpp.
References TaoCrypt::DH::Agree(), current_time(), TaoCrypt::DH::GenerateKeyPair(), key, rng, TaoCrypt::Source::size(), and start().
Referenced by main().
00307 { 00308 const int times = 100; 00309 00310 Source source; 00311 FileSource("./dh1024.der", source); 00312 00313 if (source.size() == 0) { 00314 printf("can't find ./dh1024.der\n"); 00315 return; 00316 } 00317 DH dh(source); 00318 00319 byte pub[128]; // for 1024 bit 00320 byte priv[128]; // for 1024 bit 00321 00322 int i; 00323 double start = current_time(); 00324 00325 for (i = 0; i < times; i++) 00326 dh.GenerateKeyPair(rng, priv, pub); 00327 00328 double total = current_time() - start; 00329 double each = total / times; // per second 00330 double milliEach = each * 1000; // milliseconds 00331 00332 printf("DH 1024 key generation %6.2f milliseconds, avg over %d" 00333 " iterations\n", milliEach, times); 00334 00335 DH dh2(dh); 00336 byte pub2[128]; // for 1024 bit 00337 byte priv2[128]; // for 1024 bit 00338 dh2.GenerateKeyPair(rng, priv2, pub2); 00339 unsigned char key[256]; 00340 00341 start = current_time(); 00342 00343 for (i = 0; i < times; i++) 00344 dh.Agree(key, priv, pub2); 00345 00346 total = current_time() - start; 00347 each = total / times; // per second 00348 milliEach = each * 1000; // in milliseconds 00349 00350 printf("DH 1024 key agreement %6.2f milliseconds, avg over %d" 00351 " iterations\n", milliEach, times); 00352 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_dsa | ( | ) |
Definition at line 354 of file benchmark.cpp.
References current_time(), key, rng, yaSSL::sha, TaoCrypt::DSA_Signer::Sign(), TaoCrypt::Source::size(), start(), and TaoCrypt::DSA_Verifier::Verify().
Referenced by main().
00355 { 00356 const int times = 100; 00357 00358 Source source; 00359 FileSource("./dsa1024.der", source); 00360 00361 if (source.size() == 0) { 00362 printf("can't find ./dsa1024.der\n"); 00363 return; 00364 } 00365 00366 DSA_PrivateKey key(source); 00367 DSA_Signer signer(key); 00368 00369 SHA sha; 00370 byte digest[SHA::DIGEST_SIZE]; 00371 byte signature[40]; 00372 const char msg[] = "this is the message"; 00373 sha.Update((byte*)msg, sizeof(msg)); 00374 sha.Final(digest); 00375 00376 int i; 00377 double start = current_time(); 00378 00379 for (i = 0; i < times; i++) 00380 signer.Sign(digest, signature, rng); 00381 00382 double total = current_time() - start; 00383 double each = total / times; // per second 00384 double milliEach = each * 1000; // milliseconds 00385 00386 printf("DSA 1024 sign took %6.2f milliseconds, avg over %d" 00387 " iterations\n", milliEach, times); 00388 00389 DSA_Verifier verifier(key); 00390 00391 start = current_time(); 00392 00393 for (i = 0; i < times; i++) 00394 verifier.Verify(digest, signature); 00395 00396 total = current_time() - start; 00397 each = total / times; // per second 00398 milliEach = each * 1000; // in milliseconds 00399 00400 printf("DSA 1024 verify took %6.2f milliseconds, avg over %d" 00401 " iterations\n", milliEach, times); 00402 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_md5 | ( | ) |
Definition at line 185 of file benchmark.cpp.
References current_time(), hash(), megs, plain, and start().
Referenced by main().
00186 { 00187 MD5 hash; 00188 byte digest[MD5::DIGEST_SIZE]; 00189 00190 double start = current_time(); 00191 00192 00193 for(int i = 0; i < megs; i++) 00194 hash.Update(plain, sizeof(plain)); 00195 00196 hash.Final(digest); 00197 00198 double total = current_time() - start; 00199 00200 double persec = 1 / total * megs; 00201 00202 printf("MD5 %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00203 persec); 00204 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_ripemd | ( | ) |
Definition at line 235 of file benchmark.cpp.
References current_time(), hash(), megs, plain, and start().
Referenced by main().
00236 { 00237 RIPEMD160 hash; 00238 byte digest[RIPEMD160::DIGEST_SIZE]; 00239 00240 double start = current_time(); 00241 00242 00243 for(int i = 0; i < megs; i++) 00244 hash.Update(plain, sizeof(plain)); 00245 00246 hash.Final(digest); 00247 00248 double total = current_time() - start; 00249 00250 double persec = 1 / total * megs; 00251 00252 printf("RIPEMD %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00253 persec); 00254 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_rsa | ( | ) |
Definition at line 258 of file benchmark.cpp.
References cipher, current_time(), TaoCrypt::RSA_Decryptor< Pad >::Decrypt(), TaoCrypt::RSA_Encryptor< Pad >::Encrypt(), plain, rng, TaoCrypt::Source::size(), start(), and strlen().
Referenced by main().
00259 { 00260 const int times = 100; 00261 00262 Source source; 00263 FileSource("./rsa1024.der", source); 00264 00265 if (source.size() == 0) { 00266 printf("can't find ./rsa1024.der\n"); 00267 return; 00268 } 00269 RSA_PrivateKey priv(source); 00270 RSAES_Encryptor enc(priv); 00271 00272 byte message[] = "Everyone gets Friday off."; 00273 byte cipher[128]; // for 1024 bit 00274 byte plain[128]; // for 1024 bit 00275 const int len = strlen((char*)message); 00276 00277 int i; 00278 double start = current_time(); 00279 00280 for (i = 0; i < times; i++) 00281 enc.Encrypt(message, len, cipher, rng); 00282 00283 double total = current_time() - start; 00284 double each = total / times; // per second 00285 double milliEach = each * 1000; // milliseconds 00286 00287 printf("RSA 1024 encryption took %6.2f milliseconds, avg over %d" 00288 " iterations\n", milliEach, times); 00289 00290 RSAES_Decryptor dec(priv); 00291 00292 start = current_time(); 00293 00294 for (i = 0; i < times; i++) 00295 dec.Decrypt(cipher, 128, plain, rng); 00296 00297 total = current_time() - start; 00298 each = total / times; // per second 00299 milliEach = each * 1000; // milliseconds 00300 00301 printf("RSA 1024 decryption took %6.2f milliseconds, avg over %d" 00302 " iterations\n", milliEach, times); 00303 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_sha | ( | ) |
Definition at line 207 of file benchmark.cpp.
References current_time(), hash(), megs, plain, and start().
Referenced by main().
00208 { 00209 SHA hash; 00210 byte digest[SHA::DIGEST_SIZE]; 00211 00212 double start = current_time(); 00213 00214 00215 for(int i = 0; i < megs; i++) 00216 hash.Update(plain, sizeof(plain)); 00217 00218 hash.Final(digest); 00219 00220 /* 00221 for(int i = 0; i < megs; i++) 00222 hash.AsmTransform(plain, 16384); 00223 */ 00224 00225 00226 double total = current_time() - start; 00227 00228 double persec = 1 / total * megs; 00229 00230 printf("SHA %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00231 persec); 00232 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void bench_twofish | ( | ) |
Definition at line 127 of file benchmark.cpp.
References cipher, current_time(), iv, key, megs, plain, TaoCrypt::BlockCipher< DIR, T, MODE >::Process(), TaoCrypt::BlockCipher< DIR, T, MODE >::SetKey(), and start().
Referenced by main().
00128 { 00129 Twofish_CBC_Encryption enc; 00130 enc.SetKey(key, 16, iv); 00131 00132 double start = current_time(); 00133 00134 for(int i = 0; i < megs; i++) 00135 enc.Process(plain, cipher, sizeof(plain)); 00136 00137 double total = current_time() - start; 00138 00139 double persec = 1 / total * megs; 00140 00141 printf("Twofish %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, 00142 persec); 00143 00144 }
Here is the call graph for this function:

Here is the caller graph for this function:

| double current_time | ( | ) |
Definition at line 431 of file benchmark.cpp.
Referenced by bench_aes(), bench_arc4(), bench_blowfish(), bench_des(), bench_dh(), bench_dsa(), bench_md5(), bench_ripemd(), bench_rsa(), bench_sha(), bench_twofish(), buf_print_io(), Ndb::check_send_timeout(), LOGGER::general_log_print(), log_print(), os_aio_print(), Guardian_thread::process_instance(), Ndb::sendPrepTrans(), LOGGER::slow_log_print(), srv_lock_timeout_and_monitor_thread(), srv_master_thread(), and srv_printf_innodb_monitor().
00432 { 00433 struct timeval tv; 00434 gettimeofday(&tv, 0); 00435 00436 return static_cast<double>(tv.tv_sec) 00437 + static_cast<double>(tv.tv_usec) / 1000000; 00438 }
Here is the caller graph for this function:

| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 42 of file benchmark.cpp.
References bench_aes(), bench_arc4(), bench_blowfish(), bench_des(), bench_dh(), bench_dsa(), bench_md5(), bench_ripemd(), bench_rsa(), bench_sha(), and bench_twofish().
00043 { 00044 bench_aes(false); 00045 bench_aes(true); 00046 bench_blowfish(); 00047 bench_twofish(); 00048 bench_arc4(); 00049 bench_des(); 00050 00051 printf("\n"); 00052 00053 bench_md5(); 00054 bench_sha(); 00055 bench_ripemd(); 00056 00057 printf("\n"); 00058 00059 bench_rsa(); 00060 bench_dh(); 00061 bench_dsa(); 00062 00063 return 0; 00064 }
Here is the call graph for this function:

Definition at line 85 of file benchmark.cpp.
Referenced by bench_aes(), bench_arc4(), bench_blowfish(), bench_des(), bench_rsa(), bench_twofish(), yaSSL::buildMessage(), yaSSL::cipherFinished(), client_test(), yaSSL::decrypt_message(), yaSSL::EVP_BytesToKey(), mysql_ssl_set(), and test_openSSL_des().
Initial value:
{
0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81
}
Definition at line 75 of file benchmark.cpp.
Referenced by bench_aes(), bench_blowfish(), bench_des(), bench_twofish(), and test_openSSL_des().
Initial value:
{
0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,
0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67
}
Definition at line 68 of file benchmark.cpp.
Referenced by _mi_put_key_in_record(), _rl_insert_typein(), _rl_macro_dumper_internal(), Dblqh::accminupdate(), acl_get(), Logfile_client::add_entry(), add_key_part(), add_used_routine(), Tablespace_client::alloc_extent(), Dbtup::alloc_fix_rec(), Dbtup::alloc_fix_rowid(), Lgman::alloc_log_space(), Dbtup::alloc_var_part(), Dbtup::alloc_var_rec(), Dbtup::alloc_var_rowid(), Dbdict::alterIndex_recvReply(), Dbdict::alterTab_writeSchemaConf(), Dbdict::alterTrigger_recvReply(), SimulatedBlock::assembleFragments(), bench_aes(), bench_arc4(), bench_blowfish(), bench_des(), bench_dh(), bench_dsa(), bench_twofish(), best_access_path(), Dbdict::buildIndex_recvReply(), check_if_keyname_exists(), check_one_rb_key(), check_quick_select(), chk_data_link(), chk_index(), chk_key(), QUICK_RANGE_SELECT::cmp_next(), Dbtup::commit_operation(), ConfigValuesFactory::ConfigValuesFactory(), yaSSL::CertManager::CopyCaCert(), ha_archive::create(), ha_heap::create(), create_ref_for_key(), Dbdict::createIndex_recvReply(), Dbdict::createTab_dih(), Dbdict::createTab_drop(), Dbdict::createTrigger_recvReply(), db_find_routine_aux(), TaoCrypt::DH_Decoder::Decode(), TaoCrypt::DSA_Public_Decoder::Decode(), TaoCrypt::RSA_Public_Decoder::Decode(), TaoCrypt::DSA_Private_Decoder::Decode(), TaoCrypt::RSA_Private_Decoder::Decode(), yaSSL::DES_ede3_cbc_encrypt(), descript(), Dbtup::disk_page_abort_prealloc(), Dbtup::disk_page_alloc(), Dbtup::disk_page_free(), Dbtup::disk_page_prealloc(), Dbtup::disk_page_set_dirty(), Dbtup::disk_page_undo_alloc(), Dbtup::disk_page_undo_free(), Dbtup::disk_page_undo_update(), Dbtup::disk_page_unmap_callback(), Dbtup::disk_restart_alloc_extent(), Dbtup::disk_restart_undo_callback(), NdbReceiver::do_get_value(), do_test(), Dbtup::do_tup_abortreq(), Dbtup::drop_fragment_unmap_page_callback(), Page_cache_client::drop_page(), Dbdict::dropIndex_recvReply(), Dbdict::dropTrigger_recvReply(), Dblqh::ScanRecord::equal(), evex_db_find_event_by_name(), Dbdict::execCREATE_OBJ_REQ(), Dbdict::execCREATE_TABLE_REQ(), Dbdict::execDROP_OBJ_REQ(), Tsman::execDUMP_STATE_ORD(), Pgman::execDUMP_STATE_ORD(), Dbtc::execFIRE_TRIG_ORD(), Lgman::execGET_TABINFOREQ(), Dblqh::execREMOVE_MARKER_ORD(), Suma::execSUB_CREATE_REQ(), Suma::execSUB_REMOVE_REQ(), Suma::execSUB_START_REQ(), Suma::execSUB_STOP_REQ(), Suma::execSUB_SYNC_CONTINUE_CONF(), Suma::execSUB_SYNC_REQ(), Dbtc::execTC_COMMIT_ACK(), Dbtc::execTRIG_ATTRINFO(), ConfigValuesFactory::extractCurrentSection(), find_locked_table(), Pgman::find_page_entry(), SEL_ARG::find_range(), find_record_with_key(), find_ref_key(), find_temporary_table(), fixShmKey(), Undo_buffer::free_copy_tuple(), Tablespace_client::free_extent(), Dbtup::free_fix_rec(), Lgman::free_log_space(), Dbtup::free_var_rec(), ha_myisam::ft_init_ext(), handler::get_auto_increment(), ha_myisam::get_auto_increment(), get_cached_table_share(), Dbtup::get_dd_ptr(), get_key_scans_params(), Logfile_client::get_log_buffer(), Dbdict::get_object(), get_one_option(), Tablespace_client::get_page_free_bits(), Tsman::get_page_free_bits(), Undo_buffer::get_ptr(), Dbtup::get_ptr(), get_quick_keys(), get_schema_stat_record(), get_var_key(), NdbLinHash< C >::getData(), NdbLinHash< C >::getKey(), ConfigValues::getPackedSize(), GRANT_TABLE::GRANT_TABLE(), Dbdict::handleTabInfo(), hash_rec_mask(), heap_check_heap(), hp_clear_keys(), SEL_ARG::insert(), key_or(), lock_table_name(), main(), make_join_statistics(), map_bind(), map_init_emacs(), map_init_vi(), merge_buffers(), merge_walk(), mi_check_unique(), mi_disable_non_unique_index(), mi_extra(), mi_init_bulk_insert(), mi_repair_parallel(), mi_sort_index(), mi_sort_records(), mi_test_if_sort_rep(), mi_too_big_key_for_sort(), movepoint(), myisamchk(), mysql_alter_table(), mysql_create_table_internal(), mysql_ha_read(), mysql_ssl_set(), mysql_wait_completed_table(), Dbtup::nr_delete(), Dbtup::nr_read_pk(), Dbtup::nr_update_gci(), open_table(), operator<<(), ConfigValues::pack(), pack_keys(), prepare_for_repair(), Dbtup::prepare_read(), Dblqh::prepareContinueAfterBlockedLab(), handler::print_error(), handler::print_keydup_error(), print_sel_tree(), ConfigValuesFactory::put(), TaoCrypt::RandomNumberGenerator::RandomNumberGenerator(), rb_delete_fixup(), NdbIndexScanOperation::readTuples(), rec_hashnr(), ha_heap::records_in_range(), recreate_table(), Tsman::release_extent_pages_callback(), release_table_share(), remove_table_from_cache(), rename_temporary_table(), reopen_table(), replace_column_table(), Dbtup::restart_setup_page(), Tablespace_client::restart_undo_page_free_bits(), Tsman::restart_undo_page_free_bits(), Dbdict::restartCreateObj(), Dbdict::restartDropTab(), retrieve_auto_increment(), rl_digit_loop(), rl_digit_loop1(), rl_invoking_keyseqs_in_map(), rl_parse_and_bind(), run_test(), Suma::Restart::runSUB_START_CONF(), save_state(), Tsman::scan_extent_headers(), Dbtup::scanFirst(), Dbtup::scanNext(), set_certs(), set_position(), TaoCrypt::Twofish::SetKey(), yaSSL::CertManager::SetPrivateKey(), Undo_buffer::shrink_copy_tuple(), sort_delete_record(), sort_one_index(), TaoCrypt::SSL_Decrypt(), NdbIndexStat::stat_select(), NdbIndexStat::stat_update(), SEL_ARG::store_max_key(), SEL_ARG::store_min_key(), table_is_used(), test_if_open(), test_openSSL_des(), test_when_accessed(), SEL_ARG::tree_delete(), Dbtup::tuxAllocNode(), QUICK_RANGE_SELECT::unique_key_range(), unlink_open_table(), SimpleProperties::unpack(), update_frm_version(), ha_heap::update_key_stats(), Page_cache_client::update_lsn(), Tablespace_client::update_page_free_bits(), Tsman::update_page_free_bits(), Item_func_aes_decrypt::val_str(), Item_func_aes_encrypt::val_str(), yaSSL::CertManager::Validate(), write_record(), and writekeys().
| const int megs = 5 |
Definition at line 66 of file benchmark.cpp.
Referenced by bench_aes(), bench_arc4(), bench_blowfish(), bench_des(), bench_md5(), bench_ripemd(), bench_sha(), and bench_twofish().
Definition at line 84 of file benchmark.cpp.
Referenced by bench_aes(), bench_arc4(), bench_blowfish(), bench_des(), bench_md5(), bench_ripemd(), bench_rsa(), bench_sha(), bench_twofish(), yaSSL::decrypt_message(), TaoCrypt::RSA_Encryptor< Pad >::SSL_Verify(), and test_openSSL_des().
Definition at line 256 of file benchmark.cpp.
Referenced by bench_dh(), bench_dsa(), bench_rsa(), TaoCrypt::RSA_PrivateKey::CalculateInverse(), TaoCrypt::RSA_Decryptor< Pad >::Decrypt(), TaoCrypt::RSA_Encryptor< Pad >::Encrypt(), TaoCrypt::DH::GenerateKeyPair(), TaoCrypt::DH::GeneratePrivate(), TaoCrypt::Integer::Integer(), TaoCrypt::RSA_BlockType2::Pad(), TaoCrypt::Integer::Randomize(), TaoCrypt::DSA_Signer::Sign(), and TaoCrypt::RSA_Decryptor< Pad >::SSL_Sign().
1.4.7

