aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-10 18:14:54 +0000
committerlloyd <[email protected]>2008-06-10 18:14:54 +0000
commit54fecdc60438d15f970055bb691e18c6469e1785 (patch)
tree1bd44b39489876256adf3d9a0f4ae88e88cfc9d5 /checks
parentdec416d649715617e0eb66b18d69f6dbe9c308b3 (diff)
PK_Encryptor::encrypt now takes a RandomNumberGenerator reference, instead
of using the global RNG object.
Diffstat (limited to 'checks')
-rw-r--r--checks/pk.cpp13
-rw-r--r--checks/pk_bench.cpp8
2 files changed, 7 insertions, 14 deletions
diff --git a/checks/pk.cpp b/checks/pk.cpp
index cc3d82a5c..8c2231313 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -209,12 +209,10 @@ void validate_encryption(PK_Encryptor* e, PK_Decryptor* d,
bool& failure)
{
SecureVector<byte> message = decode_hex(input);
-
- global_state().set_prng(new Fixed_Output_RNG(decode_hex(random)));
-
SecureVector<byte> expected = decode_hex(exp);
+ Fixed_Output_RNG rng(decode_hex(random));
- SecureVector<byte> out = e->encrypt(message);
+ SecureVector<byte> out = e->encrypt(message, rng);
if(out != expected)
{
std::cout << "FAILED (encrypt): " << algo << std::endl;
@@ -222,13 +220,6 @@ void validate_encryption(PK_Encryptor* e, PK_Decryptor* d,
failure = true;
}
- global_state().set_prng(new ANSI_X931_RNG("AES-128",
- new Randpool("AES-256",
- "HMAC(SHA-256)")));
-
- for(u32bit j = 0; j != 2; j++)
- global_state().seed_prng(true, 384);
-
validate_decryption(d, algo, out, message, failure);
delete e;
}
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index 58d0a2f39..c34827258 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -226,7 +226,7 @@ void bench_enc(PK_Encryptor* enc, const std::string& algo_name,
global_state().randomize(msg, MSG_SIZE);
u64bit start = get_clock();
- enc->encrypt(msg, MSG_SIZE);
+ enc->encrypt(msg, MSG_SIZE, global_state().prng_reference());
clocks_used += get_clock() - start;
}
@@ -247,7 +247,8 @@ void bench_dec(PK_Encryptor* enc, PK_Decryptor* dec,
u32bit runs = 0;
u64bit clocks_used = 0;
- SecureVector<byte> encrypted_msg = enc->encrypt(msg, MSG_SIZE);
+ SecureVector<byte> encrypted_msg = enc->encrypt(msg, MSG_SIZE,
+ global_state().prng_reference());
const u64bit ticks = get_ticks();
while(clocks_used < seconds * ticks)
@@ -256,7 +257,8 @@ void bench_dec(PK_Encryptor* enc, PK_Decryptor* dec,
global_state().randomize(msg, MSG_SIZE);
msg[0] |= 0x80; // make sure it works with "Raw" padding
- encrypted_msg = enc->encrypt(msg, MSG_SIZE);
+ encrypted_msg = enc->encrypt(msg, MSG_SIZE,
+ global_state().prng_reference());
u64bit start = get_clock();
output = dec->decrypt(encrypted_msg);