aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dsa.cpp6
-rw-r--r--src/elgamal.cpp6
-rw-r--r--src/keypair.cpp11
-rw-r--r--src/nr.cpp6
-rw-r--r--src/rsa.cpp9
-rw-r--r--src/rw.cpp6
6 files changed, 28 insertions, 16 deletions
diff --git a/src/dsa.cpp b/src/dsa.cpp
index 1a61c0cd2..1d755e045 100644
--- a/src/dsa.cpp
+++ b/src/dsa.cpp
@@ -120,8 +120,10 @@ bool DSA_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const
if(!strong)
return true;
- try {
- KeyPair::check_key(get_pk_signer(*this, "EMSA1(SHA-1)"),
+ try
+ {
+ KeyPair::check_key(rng,
+ get_pk_signer(*this, "EMSA1(SHA-1)"),
get_pk_verifier(*this, "EMSA1(SHA-1)")
);
}
diff --git a/src/elgamal.cpp b/src/elgamal.cpp
index 133fdae68..b815dd396 100644
--- a/src/elgamal.cpp
+++ b/src/elgamal.cpp
@@ -112,8 +112,10 @@ bool ElGamal_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) cons
if(!strong)
return true;
- try {
- KeyPair::check_key(get_pk_encryptor(*this, "EME1(SHA-1)"),
+ try
+ {
+ KeyPair::check_key(rng,
+ get_pk_encryptor(*this, "EME1(SHA-1)"),
get_pk_decryptor(*this, "EME1(SHA-1)")
);
}
diff --git a/src/keypair.cpp b/src/keypair.cpp
index edec0b572..e16656dbc 100644
--- a/src/keypair.cpp
+++ b/src/keypair.cpp
@@ -5,7 +5,6 @@
#include <botan/keypair.h>
#include <botan/look_pk.h>
-#include <botan/libstate.h>
#include <memory>
namespace Botan {
@@ -15,7 +14,8 @@ namespace KeyPair {
/*************************************************
* Check an encryption key pair for consistency *
*************************************************/
-void check_key(PK_Encryptor* encryptor, PK_Decryptor* decryptor)
+void check_key(RandomNumberGenerator& rng,
+ PK_Encryptor* encryptor, PK_Decryptor* decryptor)
{
if(encryptor->maximum_input_size() == 0)
return;
@@ -24,7 +24,7 @@ void check_key(PK_Encryptor* encryptor, PK_Decryptor* decryptor)
std::auto_ptr<PK_Decryptor> dec(decryptor);
SecureVector<byte> message(enc->maximum_input_size() - 1);
- global_state().randomize(message, message.size());
+ rng.randomize(message, message.size());
SecureVector<byte> ciphertext = enc->encrypt(message);
if(ciphertext == message)
@@ -38,13 +38,14 @@ void check_key(PK_Encryptor* encryptor, PK_Decryptor* decryptor)
/*************************************************
* Check a signature key pair for consistency *
*************************************************/
-void check_key(PK_Signer* signer, PK_Verifier* verifier)
+void check_key(RandomNumberGenerator& rng,
+ PK_Signer* signer, PK_Verifier* verifier)
{
std::auto_ptr<PK_Signer> sig(signer);
std::auto_ptr<PK_Verifier> ver(verifier);
SecureVector<byte> message(16);
- global_state().randomize(message, message.size());
+ rng.randomize(message, message.size());
SecureVector<byte> signature;
diff --git a/src/nr.cpp b/src/nr.cpp
index 7e76d67ad..0acbd0bb0 100644
--- a/src/nr.cpp
+++ b/src/nr.cpp
@@ -119,8 +119,10 @@ bool NR_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const
if(!strong)
return true;
- try {
- KeyPair::check_key(get_pk_signer(*this, "EMSA1(SHA-1)"),
+ try
+ {
+ KeyPair::check_key(rng,
+ get_pk_signer(*this, "EMSA1(SHA-1)"),
get_pk_verifier(*this, "EMSA1(SHA-1)")
);
}
diff --git a/src/rsa.cpp b/src/rsa.cpp
index 75789fc10..574eca2da 100644
--- a/src/rsa.cpp
+++ b/src/rsa.cpp
@@ -136,12 +136,15 @@ bool RSA_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const
if((e * d) % lcm(p - 1, q - 1) != 1)
return false;
- try {
- KeyPair::check_key(get_pk_encryptor(*this, "EME1(SHA-1)"),
+ try
+ {
+ KeyPair::check_key(rng,
+ get_pk_encryptor(*this, "EME1(SHA-1)"),
get_pk_decryptor(*this, "EME1(SHA-1)")
);
- KeyPair::check_key(get_pk_signer(*this, "EMSA4(SHA-1)"),
+ KeyPair::check_key(rng,
+ get_pk_signer(*this, "EMSA4(SHA-1)"),
get_pk_verifier(*this, "EMSA4(SHA-1)")
);
}
diff --git a/src/rw.cpp b/src/rw.cpp
index 35e3bbf8d..4da0cdede 100644
--- a/src/rw.cpp
+++ b/src/rw.cpp
@@ -126,8 +126,10 @@ bool RW_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const
if((e * d) % (lcm(p - 1, q - 1) / 2) != 1)
return false;
- try {
- KeyPair::check_key(get_pk_signer(*this, "EMSA2(SHA-1)"),
+ try
+ {
+ KeyPair::check_key(rng,
+ get_pk_signer(*this, "EMSA2(SHA-1)"),
get_pk_verifier(*this, "EMSA2(SHA-1)")
);
}