diff options
author | lloyd <[email protected]> | 2007-12-24 20:57:31 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2007-12-24 20:57:31 +0000 |
commit | eff9a5f8056f9556d28902871e129a6f2f076e51 (patch) | |
tree | 2c0a218510837e6ff112e1fa709b6e6c4a3f4e49 /checks | |
parent | 1ea96f920373b411ae08c9c9141845f2e4a96efc (diff) | |
parent | 769e503fd8e4cf0f3072e04afffb61db5b48d777 (diff) |
merge of '3d9e9476c5b2a2ee125eee7e0dd10bfe460d0546'
and '9fe0310805932b889bdfa17c9213f2b97d47ab6a'
Diffstat (limited to 'checks')
-rw-r--r-- | checks/algos.cpp | 3 | ||||
-rw-r--r-- | checks/bench.cpp | 8 | ||||
-rw-r--r-- | checks/check.cpp | 4 | ||||
-rw-r--r-- | checks/dolook2.cpp | 2 | ||||
-rw-r--r-- | checks/keys/rsa1024.pem (renamed from checks/keys/rsa1024.key) | 0 | ||||
-rw-r--r-- | checks/keys/rsa1536.pem (renamed from checks/keys/rsa1536.key) | 0 | ||||
-rw-r--r-- | checks/keys/rsa2048.pem (renamed from checks/keys/rsa2048.key) | 0 | ||||
-rw-r--r-- | checks/keys/rsa3072.pem (renamed from checks/keys/rsa3072.key) | 0 | ||||
-rw-r--r-- | checks/keys/rsa4096.pem (renamed from checks/keys/rsa4096.key) | 0 | ||||
-rw-r--r-- | checks/keys/rsa512.pem (renamed from checks/keys/rsa512.key) | 0 | ||||
-rw-r--r-- | checks/keys/rw1024.key | 3 | ||||
-rw-r--r-- | checks/keys/rw1024.pem | 16 | ||||
-rw-r--r-- | checks/keys/rw512.key | 3 | ||||
-rw-r--r-- | checks/keys/rw512.pem | 10 | ||||
-rw-r--r-- | checks/pk.cpp | 17 | ||||
-rw-r--r-- | checks/pk_bench.cpp | 282 | ||||
-rw-r--r-- | checks/validate.cpp | 2 | ||||
-rw-r--r-- | checks/validate.dat | 356 |
18 files changed, 364 insertions, 342 deletions
diff --git a/checks/algos.cpp b/checks/algos.cpp index be9e2e358..f9d8dc0aa 100644 --- a/checks/algos.cpp +++ b/checks/algos.cpp @@ -84,5 +84,8 @@ std::vector<algorithm> get_algos() algos.push_back(algorithm("RNG", "Randpool")); algos.push_back(algorithm("RNG", "X9.31-RNG")); + algos.push_back(algorithm("Codec", "Base64_Encode")); + algos.push_back(algorithm("Codec", "Base64_Decode")); + return algos; } diff --git a/checks/bench.cpp b/checks/bench.cpp index b8d1cbd23..089b229f2 100644 --- a/checks/bench.cpp +++ b/checks/bench.cpp @@ -35,7 +35,7 @@ double bench_filter(std::string name, Botan::Filter* filter, u32bit iterations = 0; u64bit start = get_clock(), clocks_used = 0; - u64bit go_up_to = (u64bit)(seconds * get_ticks()); + u64bit go_up_to = static_cast<u64bit>(seconds * get_ticks()); while(clocks_used < go_up_to) { @@ -44,8 +44,8 @@ double bench_filter(std::string name, Botan::Filter* filter, clocks_used = get_clock() - start; } - double bytes_per_sec = ((double)iterations * BUFFERSIZE) / - ((double)clocks_used / get_ticks()); + double bytes_per_sec = (static_cast<double>(iterations) * BUFFERSIZE) / + (static_cast<double>(clocks_used) / get_ticks()); double mbytes_per_sec = bytes_per_sec / (1024.0 * 1024.0); std::cout.setf(std::ios::fixed, std::ios::floatfield); @@ -121,7 +121,7 @@ void benchmark(const std::string& what, bool html, double seconds) if(html) std::cout << "</TABLE>\n\n"; - double average = std::exp(sum / (double)how_many); + double average = std::exp(sum / static_cast<double>(how_many)); if(what == "All" && html) std::cout << "\n<P>Overall speed average: " << average diff --git a/checks/check.cpp b/checks/check.cpp index a6074b685..f31c9d204 100644 --- a/checks/check.cpp +++ b/checks/check.cpp @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) << " --validate: Check test vectors\n" << " --benchmark: Benchmark everything\n" << " --bench-type={block,mode,stream,hash,mac,rng,pk}:\n" - << " Benchmark only algorithms of a particular type\n" + << " Benchmark only algorithms of a particular type\n" << " --html: Produce HTML output for benchmarks\n" << " --seconds=n: Benchmark for n seconds\n" << " --init=<str>: Pass <str> to the library\n" @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) if(opts.is_set("seconds")) { seconds = std::atof(opts.value("seconds").c_str()); - if((seconds < 0.1 || seconds > 30) && seconds != 0) + if(seconds && (seconds < 0.1 || seconds > (5 * 60))) { std::cout << "Invalid argument to --seconds\n"; return 2; diff --git a/checks/dolook2.cpp b/checks/dolook2.cpp index 53e71dc26..b6c9ba339 100644 --- a/checks/dolook2.cpp +++ b/checks/dolook2.cpp @@ -19,7 +19,7 @@ class S2K_Filter : public Filter { public: void write(const byte in[], u32bit len) - { passphrase += std::string((const char*)in, len); } + { passphrase += std::string(reinterpret_cast<const char*>(in), len); } void end_msg() { s2k->change_salt(salt, salt.size()); diff --git a/checks/keys/rsa1024.key b/checks/keys/rsa1024.pem index 6ab9326ca..6ab9326ca 100644 --- a/checks/keys/rsa1024.key +++ b/checks/keys/rsa1024.pem diff --git a/checks/keys/rsa1536.key b/checks/keys/rsa1536.pem index 4475a3d9d..4475a3d9d 100644 --- a/checks/keys/rsa1536.key +++ b/checks/keys/rsa1536.pem diff --git a/checks/keys/rsa2048.key b/checks/keys/rsa2048.pem index 6c23215ee..6c23215ee 100644 --- a/checks/keys/rsa2048.key +++ b/checks/keys/rsa2048.pem diff --git a/checks/keys/rsa3072.key b/checks/keys/rsa3072.pem index 1101062bc..1101062bc 100644 --- a/checks/keys/rsa3072.key +++ b/checks/keys/rsa3072.pem diff --git a/checks/keys/rsa4096.key b/checks/keys/rsa4096.pem index ec6855e01..ec6855e01 100644 --- a/checks/keys/rsa4096.key +++ b/checks/keys/rsa4096.pem diff --git a/checks/keys/rsa512.key b/checks/keys/rsa512.pem index e359f492c..e359f492c 100644 --- a/checks/keys/rsa512.key +++ b/checks/keys/rsa512.pem diff --git a/checks/keys/rw1024.key b/checks/keys/rw1024.key deleted file mode 100644 index b17e34343..000000000 --- a/checks/keys/rw1024.key +++ /dev/null @@ -1,3 +0,0 @@ -2 -E39815FB87BACBCCF779BC66EA0AE9784FC95E0DA094E9BEDE99FB45F73E20783038AE0488539A2CE982B4F180FC71858F2E5759E61E2C5A5FAFA435BA3A62A3 -CDC7D5FE3805572EA3FF554C086C7DD4020A3CE48DF5A09A5CEB75E6AABCD338F800F362448E87CE7E1A55331ADF2BBF3A22B3E6134035FDA52D9578FD3F72F7 diff --git a/checks/keys/rw1024.pem b/checks/keys/rw1024.pem new file mode 100644 index 000000000..8272014bf --- /dev/null +++ b/checks/keys/rw1024.pem @@ -0,0 +1,16 @@ +-----BEGIN PRIVATE KEY----- +MIICdQIBADAOBgorBgEEAYHFKgEBBQAEggJeMIICWgIBAAKBgQC28nMTDzUzMD+c +YqWG1FoW3FDMJxyr2RLMufrpAr2pKkBDHuzHBzzcFV2T8/0zuFFDlD5A3waqXV0E +3uYXGpv4AiiXPiIs75cQIkEsKfcaKR+TkkTIhfiZ1nvFcrDuwBKvaQzt24326xRI +DdOi8L2+vJQSQSjsAdG4SgAGC17BRQIBAgKBgANEVFcyjqoOk2vvedAfOHdD7yg3 +jjntBOg6LZ+W5/VOeAEy1oON1/Gk8/Ttf/M1k7yipa7faUMKz2AWRBvXVRIc3wMO +73jMy+s54NkFj/6fXxpI/OdSNEEnVq84G7IRXSuOj6JpZ6PNbDnpNWlE8t2bM3uN +vEcZtHV9XvhqpBZ/AkEA45gV+4e6y8z3ebxm6grpeE/JXg2glOm+3pn7Rfc+IHgw +OK4EiFOaLOmCtPGA/HGFjy5XWeYeLFpfr6Q1ujpiowJBAM3H1f44BVcuo/9VTAhs +fdQCCjzkjfWgmlzrdeaqvNM4+ADzYkSOh85+GlUzGt8rvzois+YTQDX9pS2VeP0/ +cvcCQDjmBX7h7rLzPd5vGbqCul4T8leDaCU6b7emftF9z4geDA4rgSIU5os6YK08 +YD8cYWPLldZ5h4sWl+vpDW6OmKkCQQCaVeB+qgQBYvr/f/kGUV5fAYetq2p4OHPF +sJhtAA2earoAtomzauXa3pO/5lQnYM9rmgbsjnAofjviMBq975Y5AkAXYycCq+zk +1z1CYY9D7/hTagRK3tRYweFh9zR6PdwN6NfnWYktFOONzHz2eupU73A3dG+TbTDy +HeFDKOXf54Ar +-----END PRIVATE KEY----- diff --git a/checks/keys/rw512.key b/checks/keys/rw512.key deleted file mode 100644 index ea6ba4226..000000000 --- a/checks/keys/rw512.key +++ /dev/null @@ -1,3 +0,0 @@ -2 -F21624A28732743BBE9B1A2B320CA31EF4A127456547ACDF5C523995E25A990B -BC6EDE730E7CEC8993A6E6296EA8DFBBC7D46615122F23F635FF988E284E31CF diff --git a/checks/keys/rw512.pem b/checks/keys/rw512.pem new file mode 100644 index 000000000..05e900c61 --- /dev/null +++ b/checks/keys/rw512.pem @@ -0,0 +1,10 @@ +-----BEGIN PRIVATE KEY----- +MIIBVAIBADAOBgorBgEEAYHFKgEBBQAEggE9MIIBOQIBAAJBALIxGscaieOzc3oN +cq5T0xOxYRm9WcSUeydWU6fFE2GbKEUkmYmMiaoAUnNd0GJU0aiiSChgfT5dbJ/M +I7fm2uUCAQICQBZGI1jjUTx2bm9BrlXKemJ2LCM3qziSj2TqynT4omwzLzgEMH57 +pRyVwg5hJfWaPt2Fl1m9IM2w+0m/P/WnwgICIQDyFiSihzJ0O76bGisyDKMe9KEn +RWVHrN9cUjmV4lqZCwIhALxu3nMOfOyJk6bmKW6o37vH1GYVEi8j9jX/mI4oTjHP +AiEAtZCbeeVl1yzO9FOgZYl6Vzd43XQL9cGnhT2rMGnD8sgCIC8bt5zDnzsiZOm5 +iluqN+7x9RmFRIvI/Y1/5iOKE4x0AiEAqgdTQJW1OyOYKkA62QcUyP5gexP/n0X8 +prrrIxjkekA= +-----END PRIVATE KEY----- diff --git a/checks/pk.cpp b/checks/pk.cpp index bb0a27f2a..f2c2401fd 100644 --- a/checks/pk.cpp +++ b/checks/pk.cpp @@ -28,7 +28,7 @@ using namespace Botan; static BigInt to_bigint(const std::string& h) { - return BigInt::decode((const byte*)h.data(), + return BigInt::decode(reinterpret_cast<const byte*>(h.data()), h.length(), BigInt::Hexadecimal); } @@ -326,7 +326,9 @@ u32bit validate_rsa_enc_pkcs8(const std::string& algo, strip_newlines(pass); /* it will have a newline thanks to the messy decoding method we use */ - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()), + str[0].length()); + Private_Key* privkey = PKCS8::load_key(keysource, pass); RSA_PrivateKey* rsapriv = dynamic_cast<RSA_PrivateKey*>(privkey); @@ -441,7 +443,8 @@ u32bit validate_rsa_ver_x509(const std::string& algo, if(str.size() != 5) /* is actually 3, parse() adds extra empty ones */ throw Exception("Invalid input from pk_valid.dat"); - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()), + str[0].length()); Public_Key* key = X509::load_key(keysource); @@ -518,7 +521,9 @@ u32bit validate_dsa_sig(const std::string& algo, strip_newlines(pass); /* it will have a newline thanks to the messy decoding method we use */ - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()), + str[0].length()); + Private_Key* privkey = PKCS8::load_key(keysource, pass); DSA_PrivateKey* dsapriv = dynamic_cast<DSA_PrivateKey*>(privkey); @@ -545,7 +550,9 @@ u32bit validate_dsa_ver(const std::string& algo, if(str.size() != 5) /* is actually 3, parse() adds extra empty ones */ throw Exception("Invalid input from pk_valid.dat"); - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()), + str[0].length()); + Public_Key* key = X509::load_key(keysource); DSA_PublicKey* dsakey = dynamic_cast<DSA_PublicKey*>(key); diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp index f3b4ad04e..c6277b4bd 100644 --- a/checks/pk_bench.cpp +++ b/checks/pk_bench.cpp @@ -16,88 +16,21 @@ using namespace Botan; #include <iostream> #include <fstream> #include <string> - -#define DEBUG 0 +#include <memory> #define PRINT_MS_PER_OP 0 /* If 0, print ops / second */ -RSA_PrivateKey* load_rsa_key(const std::string&); -RW_PrivateKey load_rw_key(const std::string&); - -static BigInt to_bigint(const std::string& h) - { - return BigInt::decode((const byte*)h.data(), - h.length(), BigInt::Hexadecimal); - } - void bench_enc(PK_Encryptor*, const std::string&, double, bool); void bench_dec(PK_Encryptor*, PK_Decryptor*, const std::string&, double, bool); void bench_sig(PK_Signer*, const std::string&, double, bool); void bench_ver(PK_Signer*, PK_Verifier*, const std::string&, double, bool); void bench_kas(PK_Key_Agreement*, const std::string&, double, bool); -void bench_rsa(RSA_PrivateKey& key, const std::string keybits, - double seconds, bool html) - { - bench_enc(get_pk_encryptor(key, "Raw"), - "RSA-" + keybits, seconds, html); - bench_dec(get_pk_encryptor(key, "Raw"), - get_pk_decryptor(key, "Raw"), - "RSA-" + keybits, seconds, html); - } - -void bench_dsa(DSA_PrivateKey& key, const std::string keybits, - double seconds, bool html) - { - bench_ver(get_pk_signer(key, "EMSA1(SHA-1)"), - get_pk_verifier(key, "EMSA1(SHA-1)"), - "DSA-" + keybits, seconds, html); - bench_sig(get_pk_signer(key, "EMSA1(SHA-1)"), - "DSA-" + keybits, seconds, html); - } - -void bench_dh(DH_PrivateKey& key, const std::string keybits, - double seconds, bool html) - { - bench_kas(get_pk_kas(key, "Raw"), - "DH-" + keybits, seconds, html); - } - -void bench_rw(RW_PrivateKey& key, const std::string keybits, - double seconds, bool html) - { - bench_ver(get_pk_signer(key, "EMSA2(SHA-1)"), - get_pk_verifier(key, "EMSA2(SHA-1)"), - "RW-" + keybits, seconds, html); - bench_sig(get_pk_signer(key, "EMSA2(SHA-1)"), - "RW-" + keybits, seconds, html); - } - -void bench_nr(NR_PrivateKey& key, const std::string keybits, - double seconds, bool html) - { - bench_ver(get_pk_signer(key, "EMSA1(SHA-1)"), - get_pk_verifier(key, "EMSA1(SHA-1)"), - "NR-" + keybits, seconds, html); - bench_sig(get_pk_signer(key, "EMSA1(SHA-1)"), - "NR-" + keybits, seconds, html); - } - -void bench_elg(ElGamal_PrivateKey& key, const std::string keybits, - double seconds, bool html) - { - bench_enc(get_pk_encryptor(key, "Raw"), - "ELG-" + keybits, seconds, html); - bench_dec(get_pk_encryptor(key, "Raw"), - get_pk_decryptor(key, "Raw"), - "ELG-" + keybits, seconds, html); - } - void bench_pk(const std::string& algo, bool html, double seconds) { /* There is some strangeness going on here. It looks like algorithms - at the end take some kind of pentalty. For example, running the RW tests + at the end take some kind of penalty. For example, running the RW tests first got a result of: RW-1024: 148.14 ms / private operation but running them last output: @@ -124,123 +57,130 @@ void bench_pk(const std::string& algo, bool html, double seconds) if(algo == "All" || algo == "RSA") { - #define DO_RSA(NUM_STR, FILENAME) \ - { \ - RSA_PrivateKey* rsa = load_rsa_key(FILENAME); \ - bench_rsa(*rsa, NUM_STR, seconds, html); \ - delete rsa; \ - } + const u32bit keylen[] = { 512, 1024, 1536, 2048, 3072, 4096, 0 }; - DO_RSA("512", "checks/keys/rsa512.key") - DO_RSA("1024", "checks/keys/rsa1024.key") - DO_RSA("1536", "checks/keys/rsa1536.key") - DO_RSA("2048", "checks/keys/rsa2048.key") - DO_RSA("3072", "checks/keys/rsa3072.key") - DO_RSA("4096", "checks/keys/rsa4096.key") - #undef DO_RSA + for(size_t j = 0; keylen[j]; j++) + { + const std::string len_str = to_string(keylen[j]); + const std::string file = "checks/keys/rsa" + len_str + ".pem"; + + std::auto_ptr<RSA_PrivateKey> key( + dynamic_cast<RSA_PrivateKey*>(PKCS8::load_key(file)) + ); + + if(key.get() == 0) + throw Invalid_Argument(file + " doesn't have an RSA key in it!"); + + bench_enc(get_pk_encryptor(*key, "Raw"), + "RSA-" + len_str, seconds, html); + + bench_dec(get_pk_encryptor(*key, "Raw"), + get_pk_decryptor(*key, "Raw"), + "RSA-" + len_str, seconds, html); + } } + if(algo == "All" || algo == "DSA") { - #define DO_DSA(NUM_STR, GROUP) \ - { \ - DSA_PrivateKey dsa(GROUP); \ - bench_dsa(dsa, NUM_STR, seconds, html); \ - } + const u32bit keylen[] = { 512, 768, 1024, 0 }; + + for(size_t j = 0; keylen[j]; j++) + { + const std::string len_str = to_string(keylen[j]); + + DSA_PrivateKey key("dsa/jce/" + len_str); - DO_DSA("512", DL_Group("dsa/jce/512")); - DO_DSA("768", DL_Group("dsa/jce/768")); - DO_DSA("1024", DL_Group("dsa/jce/1024")); - //DO_DSA("2048", DL_Group(DL_Group::DSA_Kosherizer, 2048, 256)); - //DO_DSA("3072", DL_Group(DL_Group::DSA_Kosherizer, 3072, 256)); - #undef DO_DSA + bench_ver(get_pk_signer(key, "EMSA1(SHA-1)"), + get_pk_verifier(key, "EMSA1(SHA-1)"), + "DSA-" + len_str, seconds, html); + + bench_sig(get_pk_signer(key, "EMSA1(SHA-1)"), + "DSA-" + len_str, seconds, html); + } } + if(algo == "All" || algo == "DH") { - #define DO_DH(NUM_STR, GROUP) \ - { \ - DH_PrivateKey dh(DL_Group(GROUP)); \ - bench_dh(dh, NUM_STR, seconds, html); \ - } + const u32bit keylen[] = { 768, 1024, 1536, 2048, 3072, 4096, 0 }; - DO_DH("768", "modp/ietf/768"); - DO_DH("1024", "modp/ietf/1024"); - DO_DH("1536", "modp/ietf/1536"); - DO_DH("2048", "modp/ietf/2048"); - DO_DH("3072", "modp/ietf/3072"); - DO_DH("4096", "modp/ietf/4096"); - #undef DO_DH + for(size_t j = 0; keylen[j]; j++) + { + const std::string len_str = to_string(keylen[j]); + + DH_PrivateKey key("modp/ietf/" + len_str); + + bench_kas(get_pk_kas(key, "Raw"), "DH-" + len_str, seconds, html); + } } if(algo == "All" || algo == "ELG" || algo == "ElGamal") { - #define DO_ELG(NUM_STR, GROUP) \ - { \ - ElGamal_PrivateKey elg(DL_Group(GROUP)); \ - bench_elg(elg, NUM_STR, seconds, html); \ + const u32bit keylen[] = { 768, 1024, 1536, 2048, 3072, 4096, 0 }; + + for(size_t j = 0; keylen[j]; j++) + { + const std::string len_str = to_string(keylen[j]); + + ElGamal_PrivateKey key("modp/ietf/" + len_str); + + bench_enc(get_pk_encryptor(key, "Raw"), + "ELG-" + len_str, seconds, html); + + bench_dec(get_pk_encryptor(key, "Raw"), + get_pk_decryptor(key, "Raw"), + "ELG-" + len_str, seconds, html); } - DO_ELG("768", "modp/ietf/768"); - DO_ELG("1024", "modp/ietf/1024"); - DO_ELG("1536", "modp/ietf/1536"); - DO_ELG("2048", "modp/ietf/2048"); - DO_ELG("3072", "modp/ietf/3072"); - DO_ELG("4096", "modp/ietf/4096"); - #undef DO_ELG } if(algo == "All" || algo == "NR") { - #define DO_NR(NUM_STR, GROUP) \ - { \ - NR_PrivateKey nr(DL_Group(GROUP)); \ - bench_nr(nr, NUM_STR, seconds, html); \ - } + const u32bit keylen[] = { 512, 768, 1024, 0 }; + + for(size_t j = 0; keylen[j]; j++) + { + const std::string len_str = to_string(keylen[j]); - DO_NR("512", "dsa/jce/512"); - DO_NR("768", "dsa/jce/768"); - DO_NR("1024", "dsa/jce/1024"); - #undef DO_NR + NR_PrivateKey key("dsa/jce/" + len_str); + + bench_ver(get_pk_signer(key, "EMSA1(SHA-1)"), + get_pk_verifier(key, "EMSA1(SHA-1)"), + "NR-" + len_str, seconds, html); + + bench_sig(get_pk_signer(key, "EMSA1(SHA-1)"), + "NR-" + len_str, seconds, html); + } } if(algo == "All" || algo == "RW") { - #define DO_RW(NUM_STR, FILENAME) \ - { \ - RW_PrivateKey rw = load_rw_key(FILENAME); \ - bench_rw(rw, NUM_STR, seconds, html); \ - } + const u32bit keylen[] = { 512, 1024, 0 }; - DO_RW("512", "checks/keys/rw512.key") - DO_RW("1024", "checks/keys/rw1024.key") - #undef DO_RW - } - } - catch(Botan::Exception& e) - { - std::cout << "Exception caught: " << e.what() << std::endl; - return; - } - catch(std::exception& e) - { - std::cout << "Standard library exception caught: " - << e.what() << std::endl; - return; - } - catch(...) - { - std::cout << "Unknown exception caught." << std::endl; - return; - } + for(size_t j = 0; keylen[j]; j++) + { + const std::string len_str = to_string(keylen[j]); + const std::string file = "checks/keys/rw" + len_str + ".pem"; + RW_PrivateKey* key = + dynamic_cast<RW_PrivateKey*>(PKCS8::load_key(file)); + + bench_ver(get_pk_signer(*key, "EMSA2(SHA-1)"), + get_pk_verifier(*key, "EMSA2(SHA-1)"), + "RW-" + len_str, seconds, html); + bench_sig(get_pk_signer(*key, "EMSA2(SHA-1)"), + "RW-" + len_str, seconds, html); + + delete key; + } + } } void print_result(bool html, u32bit runs, u64bit clocks_used, const std::string& algo_name, const std::string& op) { - double seconds = (double)clocks_used / get_ticks(); + double seconds = static_cast<double>(clocks_used) / get_ticks(); double mseconds_per_run = 1000 * (seconds / runs); double runs_per_sec = runs / seconds; - if(html) { std::cout << " <TR><TH>" << algo_name << " (" << op << ") <TH>"; @@ -260,9 +200,9 @@ void print_result(bool html, u32bit runs, u64bit clocks_used, std::cout.precision(2); if(PRINT_MS_PER_OP) - std::cout << mseconds_per_run << " ms / " << op << std::endl; + std::cout << mseconds_per_run << " ms / " << op << "\n"; else - std::cout << runs_per_sec << " ops / second (" << op << ")" << std::endl; + std::cout << runs_per_sec << " ops / second (" << op << ")\n"; } } @@ -424,35 +364,3 @@ void bench_kas(PK_Key_Agreement* kas, const std::string& algo_name, print_result(html, runs, clocks_used, algo_name, "key agreement"); } - -/************************************************* -* Key loading procedures * -*************************************************/ -RSA_PrivateKey* load_rsa_key(const std::string& file) - { - Private_Key* key = PKCS8::load_key(file); - - RSA_PrivateKey* rsakey = dynamic_cast<RSA_PrivateKey*>(key); - - if(rsakey == 0) - throw Invalid_Argument(file + " doesn't have an RSA key in it!"); - - return rsakey; - } - -RW_PrivateKey load_rw_key(const std::string& file) - { - std::ifstream keyfile(file.c_str()); - if(!keyfile) - throw Exception("Couldn't open the RW key file " + file); - - std::string e, p, q; - - std::getline(keyfile, e); - std::getline(keyfile, p); - std::getline(keyfile, q); - - RW_PrivateKey key(to_bigint(p), to_bigint(q), to_bigint(e)); - - return key; - } diff --git a/checks/validate.cpp b/checks/validate.cpp index b10b53b98..d634d3bb3 100644 --- a/checks/validate.cpp +++ b/checks/validate.cpp @@ -263,7 +263,7 @@ bool failed_test(const std::string& algo, bool OK = true; for(u32bit j = offset; j != offset+length; j++) - if((byte)output[j] != peekbuf[j-offset]) + if(static_cast<byte>(output[j]) != peekbuf[j-offset]) OK = false; if(!OK) diff --git a/checks/validate.dat b/checks/validate.dat index 99a1b7e1c..5852836a0 100644 --- a/checks/validate.dat +++ b/checks/validate.dat @@ -31180,142 +31180,226 @@ D41D8CD98F00B204E9800998ECF8427E # MAC format is input:mac:key -#[CBC-MAC(DES)] -#37363534333231204E6F77206973207468652074696D6520666F7220:\ -#F1D30F6849312CA4:0123456789ABCDEF -# -#:0000000000000000:67C6697351FF4AEC -# -#29:616FE88F809D55FE:CDBAABF2FBE3467C -# -#C254:AED0202A4D19E0E1:F81BE8E78D765A2E -# -#63339F:69E2BBE362FFA373:C99A66320DB73158 -# -#A35A255D:99AF085AE0872883:051758E95ED4ABB2 -# -#CDC69BB454:346750C009F85AE7:110E827441213DDC -# -#8770E93EA141:457FA6D39A704CDB:E1FC673E017E97EA -# -#DC6B968F385C2A:725FFF0F41477E42:ECB03BFB32AF3C54 -# -#EC18DB5C021AFE43:1D119FAEB0BB44C3:FBFAAA3AFB29D1E6 -# -#053C7C9475D8BE6189:E4DD5474534FE9DA:F95CBBA8990F95B1 -# -#EBF1B305EFF700E9A13A:BEE63E65CAEFA450:E5CA0BCBD0484764 -# -#BD1F231EA81C7B64C51473:495FF947F6665F45:5AC55E4B79633B70 -# -#6424119E09DCAAD4ACF21B10:53C806C8B69CF03C:AF3B33CDE3504847 -# -#155CBB6F2219BA9B7DF50BE11A:2CFD97F2BD38C7A0:1C7F23F829F8A41B -# -#13B5CA4EE8983238E0794D3D34BC:A83C88744DF51267:5F4E77FACB6C05AC -# -#86212BAA1A55A2BE70B5733B045CD3:112C46B74BD7D1EC:3694B3AFE2F0E49E -# -#4F321549FD824EA90870D4B28A295448:F12831C24A551F5C:9A0ABCD50E18A844 -# -#AC5BF38E4CD72D9B0942E506C433AFCDA3:0AB4EC81A81F5C6C:847F2DADD47647DE -# -#321CEC4AC430F62023856CFBB20704F4EC0B:B2D3297BE75E9505:B920BA86C33E05F1 -# -#ECD96733B79950A3E314D3D934F75EA0F210A8:0AA5F1B82E138AB3:F6059401BEB4BC44 -# -#78FA4969E623D01ADA696A7E4C7E5125B3488453:7143592230891CC9:3A94FB3199903257 -# -#44EE9BBCE9E525CF08F5E9E25E5360AAD2B2D085FA:90E6F543EDA1AC82:54D835E8D4668264 -# -#98D9A8877565705A8A3F62802944DE7CA5894E5759D3:491310A9E2B8B18C:51ADAC869580EC17 -# -#E485F18C0C66F17CC07CBB22FCE466DA610B63AF62BC83:302E436ABB2B6193:B4692F3AFFAF2716 -# -#93AC071FB86D11342D8DEF4F89D4B66335C1C7E4248367D8:\ -#1ED636A10A187609:ED9612EC453902D8 -# -#E50AF89D7709D1A596C1F41F95AA82CA6C49AE90CD1668BAAC:\ -#2A02740B45449296:7AA6F2B4A8CA99B2 -# -#C2372ACB08CF61C9C3805E6E0328DA4CD76A19EDD2D3994C798B:\ -#CEA8016EAE33A92B:0022569AD418D1FE -# -#E4D9CD45A391C601FFC92AD91501432FEE150287617C13629E69FC:\ -#E584507E7606DD42:7281CD7165A63EAB -# -#49CF714BCE3A75A74F76EA7E64FF81EB61FDFEC39B67BF0DE98C7E4E:\ -#5A09D5EF7B21251E:32BDF97C8C6AC75B -# -#A43C02F4B2ED7216ECF3014DF000108B67CF99505B179F8ED4980A6103:\ -#3AA4E5750CA579D9:D1BCA70DBE9BBFAB -# -#0ED59801D6E5F2D6F67D3EC5168E212E2DAF02C6B963C98A1F7097DE0C56:\ -#FAC262455D9691C6:891A2B211B01070D -# -#D8FD8B16C2A1A4E3CFD292D2984B3561D555D16C33DDC2BCF7EDDE13EFE520:\ -#32127540A949B873:C7E2ABDDA44D8188 -# -#[CBC-MAC(AES-128)] -# -#:00000000000000000000000000000000:67C6697351FF4AEC29CDBAABF2FBE346 -# -#7C:A2F5C113EBEE0F124B649287C7F7986F:C254F81BE8E78D765A2E63339FC99A66 -# -#320D:5C787D4CDAF3B4D106A7AA09F41BCFCA:B73158A35A255D051758E95ED4ABB2CD -# -#C69BB4:B32F25C34E061A972C49E4B0A0678AA5:54110E827441213DDC8770E93EA141E1 -# -#FC673E01:B5D6A0E8F3202BFF37796DB5EB920B7E:7E97EADC6B968F385C2AECB03BFB32AF -# -#3C54EC18DB:F3896484B179F90BE3B62DCE3F748C52:5C021AFE43FBFAAA3AFB29D1E6053C7C -# -#9475D8BE6189:100D2CDA97B85428D785D9EECC8D51E2:F95CBBA8990F95B1EBF1B305EFF700E9 -# -#A13AE5CA0BCBD0:\ -#92A7A024C4F6D8C82C53030545C23C10:484764BD1F231EA81C7B64C514735AC5 -# -#5E4B79633B706424:\ -#E235CFD4C307E2B3D44199E83E5D83C6:119E09DCAAD4ACF21B10AF3B33CDE350 -# -#4847155CBB6F2219BA:\ -#2379D24A48EF60E46807E92C1A602AA6:9B7DF50BE11A1C7F23F829F8A41B13B5 -# -#CA4EE8983238E0794D3D:\ -#D6DA42CAE5C664F3C4D597CF6CE1DDD7:34BC5F4E77FACB6C05AC86212BAA1A55 -# -#A2BE70B5733B045CD33694:\ -#93990491923BF761B3220C1E45ACD359:B3AFE2F0E49E4F321549FD824EA90870 -# -#D4B28A2954489A0ABCD50E18:\ -#9B14531370EE1EFFCF5A3BBC2161D25C:A844AC5BF38E4CD72D9B0942E506C433 -# -#AFCDA3847F2DADD47647DE321C:\ -#EB597AD53F1B208B4FEB5C20D78545AB:EC4AC430F62023856CFBB20704F4EC0B -# -#B920BA86C33E05F1ECD96733B799:\ -#91C3626B64EA3B16E15C2F9B32189C68:50A3E314D3D934F75EA0F210A8F60594 -# -#01BEB4BC4478FA4969E623D01ADA69:\ -#F6251F1A89FE388121DED78B8CA9FD7C:6A7E4C7E5125B34884533A94FB319990 -# -#325744EE9BBCE9E525CF08F5E9E25E53:\ -#E55A004723589CAA843140BA5AC52119:60AAD2B2D085FA54D835E8D466826498 -# -#D9A8877565705A8A3F62802944DE7CA589:\ -#53A217151AA961BBF0C7AD4AFDCB9B5F:4E5759D351ADAC869580EC17E485F18C -# -#0C66F17CC07CBB22FCE466DA610B63AF62BC:\ -#CE21D27F4D455511CD327D205853EE85:83B4692F3AFFAF271693AC071FB86D11 -# -#342D8DEF4F89D4B66335C1C7E4248367D8ED96:\ -#4DC9B5ED541B7382F0FCC7CFAB5AAFE0:12EC453902D8E50AF89D7709D1A596C1 -# -#F41F95AA82CA6C49AE90CD1668BAAC7AA6F2B4A8:\ -#2FB0B595042C8D7AD592583D7E6C76F7:CA99B2C2372ACB08CF61C9C3805E6E03 -# -#28DA4CD76A19EDD2D3994C798B0022569AD418D1FE:\ -#AC464531064DA66A2F8591AFAB2931D0:E4D9CD45A391C601FFC92AD91501432F +[CBC-MAC(DES)] +37363534333231204E6F77206973207468652074696D6520666F7220:\ +F1D30F6849312CA4:0123456789ABCDEF + +:0000000000000000:67C6697351FF4AEC + +29:616FE88F809D55FE:CDBAABF2FBE3467C + +C254:AED0202A4D19E0E1:F81BE8E78D765A2E + +63339F:69E2BBE362FFA373:C99A66320DB73158 + +A35A255D:99AF085AE0872883:051758E95ED4ABB2 + +CDC69BB454:346750C009F85AE7:110E827441213DDC + +8770E93EA141:457FA6D39A704CDB:E1FC673E017E97EA + +DC6B968F385C2A:725FFF0F41477E42:ECB03BFB32AF3C54 + +EC18DB5C021AFE43:1D119FAEB0BB44C3:FBFAAA3AFB29D1E6 + +053C7C9475D8BE6189:E4DD5474534FE9DA:F95CBBA8990F95B1 + +EBF1B305EFF700E9A13A:BEE63E65CAEFA450:E5CA0BCBD0484764 + +BD1F231EA81C7B64C51473:495FF947F6665F45:5AC55E4B79633B70 + +6424119E09DCAAD4ACF21B10:53C806C8B69CF03C:AF3B33CDE3504847 + +155CBB6F2219BA9B7DF50BE11A:2CFD97F2BD38C7A0:1C7F23F829F8A41B + +13B5CA4EE8983238E0794D3D34BC:A83C88744DF51267:5F4E77FACB6C05AC + +86212BAA1A55A2BE70B5733B045CD3:112C46B74BD7D1EC:3694B3AFE2F0E49E + +4F321549FD824EA90870D4B28A295448:F12831C24A551F5C:9A0ABCD50E18A844 + +AC5BF38E4CD72D9B0942E506C433AFCDA3:0AB4EC81A81F5C6C:847F2DADD47647DE + +321CEC4AC430F62023856CFBB20704F4EC0B:B2D3297BE75E9505:B920BA86C33E05F1 + +ECD96733B79950A3E314D3D934F75EA0F210A8:0AA5F1B82E138AB3:F6059401BEB4BC44 + +78FA4969E623D01ADA696A7E4C7E5125B3488453:7143592230891CC9:3A94FB3199903257 + +44EE9BBCE9E525CF08F5E9E25E5360AAD2B2D085FA:90E6F543EDA1AC82:54D835E8D4668264 + +98D9A8877565705A8A3F62802944DE7CA5894E5759D3:491310A9E2B8B18C:51ADAC869580EC17 + +E485F18C0C66F17CC07CBB22FCE466DA610B63AF62BC83:\ +302E436ABB2B6193:B4692F3AFFAF2716 + +93AC071FB86D11342D8DEF4F89D4B66335C1C7E4248367D8:\ +1ED636A10A187609:ED9612EC453902D8 + +E50AF89D7709D1A596C1F41F95AA82CA6C49AE90CD1668BAAC:\ +2A02740B45449296:7AA6F2B4A8CA99B2 + +C2372ACB08CF61C9C3805E6E0328DA4CD76A19EDD2D3994C798B:\ +CEA8016EAE33A92B:0022569AD418D1FE + +E4D9CD45A391C601FFC92AD91501432FEE150287617C13629E69FC:\ +E584507E7606DD42:7281CD7165A63EAB + +49CF714BCE3A75A74F76EA7E64FF81EB61FDFEC39B67BF0DE98C7E4E:\ +5A09D5EF7B21251E:32BDF97C8C6AC75B + +A43C02F4B2ED7216ECF3014DF000108B67CF99505B179F8ED4980A6103:\ +3AA4E5750CA579D9:D1BCA70DBE9BBFAB + +0ED59801D6E5F2D6F67D3EC5168E212E2DAF02C6B963C98A1F7097DE0C56:\ +FAC262455D9691C6:891A2B211B01070D + +D8FD8B16C2A1A4E3CFD292D2984B3561D555D16C33DDC2BCF7EDDE13EFE520:\ +32127540A949B873:C7E2ABDDA44D8188 + +[CBC-MAC(AES-128)] + +:00000000000000000000000000000000:67C6697351FF4AEC29CDBAABF2FBE346 + +7C:A2F5C113EBEE0F124B649287C7F7986F:C254F81BE8E78D765A2E63339FC99A66 + +320D:5C787D4CDAF3B4D106A7AA09F41BCFCA:B73158A35A255D051758E95ED4ABB2CD + +C69BB4:B32F25C34E061A972C49E4B0A0678AA5:54110E827441213DDC8770E93EA141E1 + +FC673E01:B5D6A0E8F3202BFF37796DB5EB920B7E:7E97EADC6B968F385C2AECB03BFB32AF + +3C54EC18DB:F3896484B179F90BE3B62DCE3F748C52:5C021AFE43FBFAAA3AFB29D1E6053C7C + +9475D8BE6189:100D2CDA97B85428D785D9EECC8D51E2:F95CBBA8990F95B1EBF1B305EFF700E9 + +A13AE5CA0BCBD0:\ +92A7A024C4F6D8C82C53030545C23C10:484764BD1F231EA81C7B64C514735AC5 + +5E4B79633B706424:\ +E235CFD4C307E2B3D44199E83E5D83C6:119E09DCAAD4ACF21B10AF3B33CDE350 + +4847155CBB6F2219BA:\ +2379D24A48EF60E46807E92C1A602AA6:9B7DF50BE11A1C7F23F829F8A41B13B5 + +CA4EE8983238E0794D3D:\ +D6DA42CAE5C664F3C4D597CF6CE1DDD7:34BC5F4E77FACB6C05AC86212BAA1A55 + +A2BE70B5733B045CD33694:\ +93990491923BF761B3220C1E45ACD359:B3AFE2F0E49E4F321549FD824EA90870 + +D4B28A2954489A0ABCD50E18:\ +9B14531370EE1EFFCF5A3BBC2161D25C:A844AC5BF38E4CD72D9B0942E506C433 + +AFCDA3847F2DADD47647DE321C:\ +EB597AD53F1B208B4FEB5C20D78545AB:EC4AC430F62023856CFBB20704F4EC0B + +B920BA86C33E05F1ECD96733B799:\ +91C3626B64EA3B16E15C2F9B32189C68:50A3E314D3D934F75EA0F210A8F60594 + +01BEB4BC4478FA4969E623D01ADA69:\ +F6251F1A89FE388121DED78B8CA9FD7C:6A7E4C7E5125B34884533A94FB319990 + +325744EE9BBCE9E525CF08F5E9E25E53:\ +E55A004723589CAA843140BA5AC52119:60AAD2B2D085FA54D835E8D466826498 + +D9A8877565705A8A3F62802944DE7CA589:\ +53A217151AA961BBF0C7AD4AFDCB9B5F:4E5759D351ADAC869580EC17E485F18C + +0C66F17CC07CBB22FCE466DA610B63AF62BC:\ +CE21D27F4D455511CD327D205853EE85:83B4692F3AFFAF271693AC071FB86D11 + +342D8DEF4F89D4B66335C1C7E4248367D8ED96:\ +4DC9B5ED541B7382F0FCC7CFAB5AAFE0:12EC453902D8E50AF89D7709D1A596C1 + +F41F95AA82CA6C49AE90CD1668BAAC7AA6F2B4A8:\ +2FB0B595042C8D7AD592583D7E6C76F7:CA99B2C2372ACB08CF61C9C3805E6E03 + +28DA4CD76A19EDD2D3994C798B0022569AD418D1FE:\ +AC464531064DA66A2F8591AFAB2931D0:E4D9CD45A391C601FFC92AD91501432F + +D4A628D05B1663A1BABEA82646DE1005197A63C1EB5C:\ +A16EADA7B6D32D01FE75759FB6DE2E1D:F466C626BC51E907F0BDAE188D092EF1 + +ABE8AF530FF6311FFB4B995F0C84BB00EA8226A7D30FAE:\ +7D980A5E6DA633CE4FED22E815A1C5AD:C3CC5CDB5A660A4B11F2FA6401F09621 + +ECE1BA4BED3F06ED298813D05B237F1EEFDBFA4941049452:\ +425497C221479FC5696D3078D062E725:F68FB7F87F4D196B2ED3B61B12BD083C + +451B0CA13E8BBF2E67B977A8BD0CFBB49BB2AC1AFFC5862D98:\ +90029A6EE195A0665D02997A844BE499:3C48ABF950E73F6BF3E0AA7F9FD8E659 + +4F8E165B89CAF63B76113A3B9767D4D3AF7FCDFF660C6B59EC15:\ +BCA39FFF3C95AB00DACF2B2A9A37C7FE:D88BEDBEE43C4DFB98D6C58E123C9F4C + +7736B44B0A63CAD76330E3CE8ACFE3625AD0213F0C6E3AA444FF33:\ +D55DC707BA4568B0642E3D70116308D1:563BD2A3B30957FE13BAC9EA1DF9CDEB + +839CCEE6F69E0735AB756F4FB96F8210AA55B35D5E0A5C71C4255BE2:\ +295F3F2DC91B300874147AADBF2132FE:1E28CDA2C49C88BA3A8FF0E5045F35BD + +CEB7CD790C80D66A8A32DB4F573631765EFE18229AA0DDD52FCDBA332C:\ +049AE1796CE825B2ABB88AA1EBE8D7D2:EFF0FBA7BE74B33E4A1EC97DF918D430 + +494A8E4762B1E2028EB7315B7164876155820813F6BB5141D91ABED33292:\ +AD921BBF28C028B76D9E1B4F92D36DCC:037BDD91C33F42A542D05C732BCDD8B3 + +2E2D3536402CF2916DCBAC2B9EDEBDA15A9A331DDA75C21C461E8F71EB6724:\ +952D487FE1B8A1F63B26B2027217AC14:1A945A50D4864266F30E121EACF0DB4E + +4A76816750F6296C3C47FBAE3363D24DF72C9DCCB2E032A5EE44C39A349FE87F:\ +ED1B41F593FF135A1E6DC7C85A2F1A2B:1569E6656010D19C57CC4A8A2F1DD727 + +4975F3FC5525A1436965DD9D04C61C192F037E8F134F2C6A1B76F54B93CC72DD41:\ +29326E91479F46720D9D1B067B10E617:65D9968A7AD9F3DFB790E37DADFCACB0 + +7A3CC3C9682DE5DE223072EFA24F300728C791A2A08482571465D4C1628171DCBD34:\ +440A055C9D93DE336B725E0FAE8BCB3D:A625628B0384BB75735DC4A464EC6BF5 + +8F0B7911638D76374FD8B8C0B575F55B9A57E69EDBA1134FFED8F362C45E575369D064:\ +345B392931218A9395F08BD1A45A9B43:CC5DDB04ACB3BC6D683262C3CCB9A96A + +944A7EE34856D6AA1A34016E9ED1D26A2FAD6EDB612B48C95DAA8D29633694F88112DBC9:\ +2D49E335B07A2519287CDA50D482FC48:68B27482E675F08447C3EF76705D51D1 + +889A9BE544280FA85EA3A0DFB57BA91D2D1D9F14929098D953874FC3E5A1956D3B30537F58:\ +900A6FB8FD5661FF12B7F391279DB085:6227B605C796BA433FD7705C7684EE06 + +1DC859A4171D89B8B2F7F3E24A733AAC9AF0B162866BA5C5421521B89A10BFB7D8185BEF35E5:\ +096DCD92F3919145B298201BC3820612:A8E7DC9BC9260E03D2A9F4830B7AEEB0 + +4030C561E85F71A71649C07239F557E1DD337CA6\ +598BAA2B349EAE3F189CEF58CCB4BAB4142B5C:\ +2E8B2AF6CFF3FD6AF55898BC1374609D:2A751C9CAE11F38FEE260B957F963FAA + +CADD5809F5F4F84EC0AD0875C133D1EBA8ED8856\ +FE7BE5EDA2F1822187C1CC529E245B931954E1D9:\ +351E0741D63B5CCED0131A483C3B89F0:01E94EC21D1FADC50C351C0BB101F853 + +F27A747A3B40CCD965276C7E7B4E577C37A63E54\ +C5EC1AD22136DDD237D5252A4F9AA48ADA70633F97:\ +5F144222C4B8C33CA82A85CCC177A0AF:CFBD131D158F55BBCEA980BAC352DBF9 + +2FAE3104D35B536DFFDD486F4087061045192D5A\ +A98215772C9531EFE80CE917BA1A1C8E756FFB744D43:\ +5FD061418DDE0BB0A8A3E6A4FD5BD2A8:E38DCBE99D1003CB6AAC4D7F23791454 + +69FC6052141B6C30A9E19FA455ECE8387AB32117\ +C324E22DD030ACF3A9C04712BDA864D1C3D0016CB1A010:\ +73E376B5D0B9466453438B5CEFB27EEF:068DF83E07AB601E6E84019B55314748 + +DA0890EDC5385196FB229767D33777DAC47018CB\ +1B78EA8AFDEB25521C6D9AF6752AE33A6235D05D5767C42A:\ +03F54C4F6B9E5E214BE93289CB2F2D4B:9E3C0463AC1D2EC7951851920377E41F + +E47F1659A9F9930C2E636985CA2EB0686AB4CB16\ +D1FADD67122FF916A6DE358A5D4BE30645761273D97CF9A3AA:\ +9FA99D925751C9613D3A8D42E3B604B0:A90B145DD72A2FD10796E3368FF9DC6D + +2F66CA7A49D1BFBFE333985F2C3B09D5471D321E\ +4761EF4FF7D28587CC62F4FBC8BF75129035D173686AD394A5DC:\ +BF0557B787C01A589BBD6EBB83F3A330:69ECFA9B0A41FDF990F4CC167B987870 [CMAC(AES)] # First twelve vectors come from a paper, they were generated by Eisuke Kuroda |