diff options
author | lloyd <[email protected]> | 2008-06-27 14:29:33 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-06-27 14:29:33 +0000 |
commit | 34d5da54da524018580935da11525bd72b5a560e (patch) | |
tree | 398e07f035b4e72bf7a315f0d9f1e6e55b46795f /checks/pk.cpp | |
parent | d1bc1ae91003bc10b46b0d1e38f0ac64080b4c81 (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/pk.cpp')
-rw-r--r-- | checks/pk.cpp | 54 |
1 files changed, 32 insertions, 22 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(); |