aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-05-24 19:02:31 +0000
committerlloyd <[email protected]>2008-05-24 19:02:31 +0000
commitdf8691c753ad17d364c868f9b34a56a1f52bb9cf (patch)
tree2fd98f1fadff870727154a7085e2caa2a5e4b457
parentc66c9ad30fc635f25a0564ad8b7722fceda92a73 (diff)
Keypair::check_key no longer references global PRNG
-rw-r--r--include/keypair.h4
-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
7 files changed, 30 insertions, 18 deletions
diff --git a/include/keypair.h b/include/keypair.h
index 0bd8f51bf..da322c075 100644
--- a/include/keypair.h
+++ b/include/keypair.h
@@ -15,8 +15,8 @@ namespace KeyPair {
/*************************************************
* Check key pair consistency *
*************************************************/
-BOTAN_DLL void check_key(PK_Encryptor*, PK_Decryptor*);
-BOTAN_DLL void check_key(PK_Signer*, PK_Verifier*);
+BOTAN_DLL void check_key(RandomNumberGenerator&, PK_Encryptor*, PK_Decryptor*);
+BOTAN_DLL void check_key(RandomNumberGenerator&, PK_Signer*, PK_Verifier*);
}
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)")
);
}