aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-20 19:03:45 +0000
committerlloyd <[email protected]>2008-06-20 19:03:45 +0000
commit7dde81851bfb6cef78c3480acc2f1c1dedb1f126 (patch)
tree06f35288c9c08b9f77468c664dbf8a65aaaf2647 /checks
parent770a9850f1a7c6c65b0316503b99798a6ff910dd (diff)
Similiar combining transform for the ElGamal, DSA, and NR private key
constructors.
Diffstat (limited to 'checks')
-rw-r--r--checks/pk.cpp12
-rw-r--r--checks/pk_bench.cpp17
-rw-r--r--checks/x509.cpp2
3 files changed, 17 insertions, 14 deletions
diff --git a/checks/pk.cpp b/checks/pk.cpp
index 93007c8d8..2dad1b966 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -198,8 +198,10 @@ u32bit validate_elg_enc(const std::string& algo,
if(str.size() != 6 && str.size() != 7)
throw Exception("Invalid input from pk_valid.dat");
+ RandomNumberGenerator& rng = global_state().prng_reference();
+
DL_Group domain(to_bigint(str[0]), to_bigint(str[1]));
- ElGamal_PrivateKey privkey(domain, to_bigint(str[2]), to_bigint(str[3]));
+ ElGamal_PrivateKey privkey(rng, domain, to_bigint(str[2]));
ElGamal_PublicKey pubkey = privkey;
std::string eme = algo.substr(8, std::string::npos);
@@ -407,8 +409,10 @@ u32bit validate_nr_sig(const std::string& algo,
if(str.size() != 8)
throw Exception("Invalid input from pk_valid.dat");
+ RandomNumberGenerator& rng = global_state().prng_reference();
+
DL_Group domain(to_bigint(str[0]), to_bigint(str[1]), to_bigint(str[2]));
- NR_PrivateKey privkey(domain, to_bigint(str[4]), to_bigint(str[3]));
+ NR_PrivateKey privkey(rng, domain, to_bigint(str[4]));
NR_PublicKey pubkey = privkey;
std::string emsa = algo.substr(3, std::string::npos);
@@ -496,14 +500,14 @@ void do_pk_keygen_tests()
#define DL_SIG_KEY(TYPE, GROUP) \
{ \
- TYPE key(DL_Group(GROUP), rng); \
+ TYPE key(rng, DL_Group(GROUP)); \
key.check_key(rng, true); \
std::cout << '.' << std::flush; \
}
#define DL_ENC_KEY(TYPE, GROUP) \
{ \
- TYPE key(DL_Group(GROUP), rng); \
+ TYPE key(rng, DL_Group(GROUP)); \
key.check_key(rng, true); \
std::cout << '.' << std::flush; \
}
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index 8daa1fe91..a0ac7d0ab 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -55,6 +55,8 @@ void bench_pk(const std::string& algo, bool html, double seconds)
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).
*/
+ RandomNumberGenerator& rng = global_state().prng_reference();
+
if(algo == "All" || algo == "RSA")
{
const u32bit keylen[] = { 512, 1024, 1536, 2048, 3072, 4096, 0 };
@@ -65,7 +67,7 @@ void bench_pk(const std::string& algo, bool html, double seconds)
const std::string file = "checks/keys/rsa" + len_str + ".pem";
std::auto_ptr<RSA_PrivateKey> key(
- dynamic_cast<RSA_PrivateKey*>(PKCS8::load_key(file, global_state().prng_reference()))
+ dynamic_cast<RSA_PrivateKey*>(PKCS8::load_key(file, rng))
);
if(key.get() == 0)
@@ -88,8 +90,7 @@ void bench_pk(const std::string& algo, bool html, double seconds)
{
const std::string len_str = to_string(keylen[j]);
- DSA_PrivateKey key("dsa/jce/" + len_str,
- global_state().prng_reference());
+ DSA_PrivateKey key(rng, "dsa/jce/" + len_str);
bench_ver(get_pk_signer(key, "EMSA1(SHA-1)"),
get_pk_verifier(key, "EMSA1(SHA-1)"),
@@ -108,7 +109,7 @@ void bench_pk(const std::string& algo, bool html, double seconds)
{
const std::string len_str = to_string(keylen[j]);
- DH_PrivateKey key(global_state().prng_reference(),
+ DH_PrivateKey key(rng,
"modp/ietf/" + len_str);
bench_kas(get_pk_kas(key, "Raw"), "DH-" + len_str, seconds, html);
@@ -123,8 +124,7 @@ void bench_pk(const std::string& algo, bool html, double seconds)
{
const std::string len_str = to_string(keylen[j]);
- ElGamal_PrivateKey key("modp/ietf/" + len_str,
- global_state().prng_reference());
+ ElGamal_PrivateKey key(rng, "modp/ietf/" + len_str);
bench_enc(get_pk_encryptor(key, "Raw"),
"ELG-" + len_str, seconds, html);
@@ -143,8 +143,7 @@ void bench_pk(const std::string& algo, bool html, double seconds)
{
const std::string len_str = to_string(keylen[j]);
- NR_PrivateKey key("dsa/jce/" + len_str,
- global_state().prng_reference());
+ NR_PrivateKey key(rng, "dsa/jce/" + len_str);
bench_ver(get_pk_signer(key, "EMSA1(SHA-1)"),
get_pk_verifier(key, "EMSA1(SHA-1)"),
@@ -165,7 +164,7 @@ void bench_pk(const std::string& algo, bool html, double seconds)
const std::string file = "checks/keys/rw" + len_str + ".pem";
RW_PrivateKey* key =
- dynamic_cast<RW_PrivateKey*>(PKCS8::load_key(file, global_state().prng_reference()));
+ dynamic_cast<RW_PrivateKey*>(PKCS8::load_key(file, rng));
bench_ver(get_pk_signer(*key, "EMSA2(SHA-1)"),
get_pk_verifier(*key, "EMSA2(SHA-1)"),
diff --git a/checks/x509.cpp b/checks/x509.cpp
index 48cbd8384..92d9d43ed 100644
--- a/checks/x509.cpp
+++ b/checks/x509.cpp
@@ -94,7 +94,7 @@ void do_x509_tests()
/* Create user #1's key and cert request */
std::cout << '.' << std::flush;
- DSA_PrivateKey user1_key(DL_Group("dsa/jce/1024"), rng);
+ DSA_PrivateKey user1_key(rng, DL_Group("dsa/jce/1024"));
std::cout << '.' << std::flush;
PKCS10_Request user1_req = X509::create_cert_req(req_opts1(),