The unified diff between revisions [8b1818b2..] and [4e40e885..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'checks/pk_bench.cpp'
#
#
# patch "checks/pk_bench.cpp"
# from [7127408e364db54d1dd15f5d911a96f6588f6cd8]
# to [cfa4efb5884ff9975c16091b3d7f70310dbf1c5e]
#
============================================================
--- checks/pk_bench.cpp 7127408e364db54d1dd15f5d911a96f6588f6cd8
+++ checks/pk_bench.cpp cfa4efb5884ff9975c16091b3d7f70310dbf1c5e
@@ -4,13 +4,12 @@
#include <botan/nr.h>
#include <botan/rw.h>
#include <botan/elgamal.h>
+#include <botan/parsing.h>
#include <botan/pkcs8.h>
#include <botan/look_pk.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
-#include <botan/parsing.h>
-
using namespace Botan;
#include "common.h"
@@ -55,7 +54,6 @@ void bench_pk(const std::string& algo, b
ad-hoc format (the RW algorithm has no assigned OID that I know of, so
there is no way to encode a RW key into a PKCS #8 structure).
*/
-
if(algo == "All" || algo == "RSA")
{
const u32bit keylen[] = { 512, 1024, 1536, 2048, 3072, 4096, 0 };
@@ -70,7 +68,7 @@ void bench_pk(const std::string& algo, b
);
if(key.get() == 0)
- throw Invalid_Argument(file + " doesn't have an RSA key in it!");
+ throw Invalid_Argument("Failure reading RSA key from " + file);
bench_enc(get_pk_encryptor(*key, "Raw"),
"RSA-" + len_str, seconds, html);
@@ -178,11 +176,10 @@ void print_result(bool html, u32bit runs
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>";
@@ -222,7 +219,7 @@ void bench_enc(PK_Encryptor* enc, const
while(clocks_used < seconds * ticks)
{
runs++;
- Global_RNG::randomize(msg, MSG_SIZE);
+ global_state().randomize(msg, MSG_SIZE);
u64bit start = get_clock();
enc->encrypt(msg, MSG_SIZE);
@@ -240,7 +237,7 @@ void bench_dec(PK_Encryptor* enc, PK_Dec
{
static const u32bit MSG_SIZE = 16;
byte msg[MSG_SIZE];
- Global_RNG::randomize(msg, MSG_SIZE);
+ global_state().randomize(msg, MSG_SIZE);
SecureVector<byte> output;
u32bit runs = 0;
@@ -253,7 +250,7 @@ void bench_dec(PK_Encryptor* enc, PK_Dec
{
runs++;
- Global_RNG::randomize(msg, MSG_SIZE);
+ global_state().randomize(msg, MSG_SIZE);
msg[0] |= 0x80; // make sure it works with "Raw" padding
encrypted_msg = enc->encrypt(msg, MSG_SIZE);
@@ -289,7 +286,7 @@ void bench_sig(PK_Signer* sig, const std
while(clocks_used < seconds * ticks)
{
runs++;
- Global_RNG::randomize(msg, MSG_SIZE);
+ global_state().randomize(msg, MSG_SIZE);
u64bit start = get_clock();
sig->update(msg, MSG_SIZE);
sig->signature();
@@ -307,7 +304,7 @@ void bench_ver(PK_Signer* sig, PK_Verifi
{
static const u32bit MSG_SIZE = 16;
byte msg[MSG_SIZE];
- Global_RNG::randomize(msg, MSG_SIZE);
+ global_state().randomize(msg, MSG_SIZE);
sig->update(msg, MSG_SIZE);
SecureVector<byte> signature = sig->signature();
@@ -320,7 +317,7 @@ void bench_ver(PK_Signer* sig, PK_Verifi
// feel free to tweak, but make sure this always runs when runs == 0
if(runs % 100 == 0)
{
- Global_RNG::randomize(msg, MSG_SIZE);
+ global_state().randomize(msg, MSG_SIZE);
sig->update(msg, MSG_SIZE);
signature = sig->signature();
}
@@ -355,7 +352,7 @@ void bench_kas(PK_Key_Agreement* kas, co
while(clocks_used < seconds * ticks)
{
runs++;
- Global_RNG::randomize(key, REMOTE_KEY_SIZE);
+ global_state().randomize(key, REMOTE_KEY_SIZE);
u64bit start = get_clock();
kas->derive_key(0, key, REMOTE_KEY_SIZE);