aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-27 14:29:33 +0000
committerlloyd <[email protected]>2008-06-27 14:29:33 +0000
commit34d5da54da524018580935da11525bd72b5a560e (patch)
tree398e07f035b4e72bf7a315f0d9f1e6e55b46795f /checks
parentd1bc1ae91003bc10b46b0d1e38f0ac64080b4c81 (diff)
Remove load checking, as it requires an RNG (at least at the moment).
Probably some variation of it will be added back in later, at least to do basic checks like that primes are really odd (and we can do basic primality checks, etc, even with an RNG). Alternative: call check_key() manually on public keys you load with an RNG object.
Diffstat (limited to 'checks')
-rw-r--r--checks/pk.cpp54
-rw-r--r--checks/x509.cpp4
2 files changed, 34 insertions, 24 deletions
diff --git a/checks/pk.cpp b/checks/pk.cpp
index 2dad1b966..f7199c86d 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -178,8 +178,12 @@ u32bit validate_rsa_enc(const std::string& algo,
if(str.size() != 6)
throw Exception("Invalid input from pk_valid.dat");
- RSA_PrivateKey privkey(to_bigint(str[1]), to_bigint(str[2]),
+ RandomNumberGenerator& rng = global_state().prng_reference();
+
+ RSA_PrivateKey privkey(rng,
+ to_bigint(str[1]), to_bigint(str[2]),
to_bigint(str[0]));
+
RSA_PublicKey pubkey = privkey;
std::string eme = algo.substr(6, std::string::npos);
@@ -227,8 +231,12 @@ u32bit validate_rsa_sig(const std::string& algo,
if(str.size() != 6)
throw Exception("Invalid input from pk_valid.dat");
- RSA_PrivateKey privkey(to_bigint(str[1]), to_bigint(str[2]),
+ RandomNumberGenerator& rng = global_state().prng_reference();
+
+ RSA_PrivateKey privkey(rng,
+ to_bigint(str[1]), to_bigint(str[2]),
to_bigint(str[0]));
+
RSA_PublicKey pubkey = privkey;
std::string emsa = algo.substr(7, std::string::npos);
@@ -322,7 +330,9 @@ u32bit validate_rw_sig(const std::string& algo,
if(str.size() != 6)
throw Exception("Invalid input from pk_valid.dat");
- RW_PrivateKey privkey(to_bigint(str[1]), to_bigint(str[2]),
+ RandomNumberGenerator& rng = global_state().prng_reference();
+
+ RW_PrivateKey privkey(rng, to_bigint(str[1]), to_bigint(str[2]),
to_bigint(str[0]));
RW_PublicKey pubkey = privkey;
@@ -491,32 +501,32 @@ void do_pk_keygen_tests()
std::cout << "Testing PK key generation: " << std::flush;
/* Putting each key in a block reduces memory pressure, speeds it up */
-#define IF_SIG_KEY(TYPE, BITS) \
- { \
- TYPE key(BITS, rng); \
- key.check_key(rng, true); \
- std::cout << '.' << std::flush; \
+#define IF_SIG_KEY(TYPE, BITS) \
+ { \
+ TYPE key(rng, BITS); \
+ key.check_key(rng, true); \
+ std::cout << '.' << std::flush; \
}
-#define DL_SIG_KEY(TYPE, GROUP) \
- { \
- TYPE key(rng, DL_Group(GROUP)); \
- key.check_key(rng, true); \
- std::cout << '.' << std::flush; \
+#define DL_SIG_KEY(TYPE, GROUP) \
+ { \
+ TYPE key(rng, DL_Group(GROUP)); \
+ key.check_key(rng, true); \
+ std::cout << '.' << std::flush; \
}
-#define DL_ENC_KEY(TYPE, GROUP) \
- { \
- TYPE key(rng, DL_Group(GROUP)); \
- key.check_key(rng, true); \
- std::cout << '.' << std::flush; \
+#define DL_ENC_KEY(TYPE, GROUP) \
+ { \
+ TYPE key(rng, DL_Group(GROUP)); \
+ key.check_key(rng, true); \
+ std::cout << '.' << std::flush; \
}
-#define DL_KEY(TYPE, GROUP) \
- { \
+#define DL_KEY(TYPE, GROUP) \
+ { \
TYPE key(rng, DL_Group(GROUP)); \
- key.check_key(rng, true); \
- std::cout << '.' << std::flush; \
+ key.check_key(rng, true); \
+ std::cout << '.' << std::flush; \
}
RandomNumberGenerator& rng = global_state().prng_reference();
diff --git a/checks/x509.cpp b/checks/x509.cpp
index 92d9d43ed..015b050f6 100644
--- a/checks/x509.cpp
+++ b/checks/x509.cpp
@@ -84,7 +84,7 @@ void do_x509_tests()
/* Create the CA's key and self-signed cert */
std::cout << '.' << std::flush;
- RSA_PrivateKey ca_key(1024, rng);
+ RSA_PrivateKey ca_key(rng, 1024);
std::cout << '.' << std::flush;
X509_Certificate ca_cert = X509::create_self_signed_cert(ca_opts(),
@@ -103,7 +103,7 @@ void do_x509_tests()
/* Create user #2's key and cert request */
std::cout << '.' << std::flush;
- RSA_PrivateKey user2_key(1024, rng);
+ RSA_PrivateKey user2_key(rng, 1024);
std::cout << '.' << std::flush;
PKCS10_Request user2_req = X509::create_cert_req(req_opts2(),
user2_key,