aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--checks/x509.cpp12
-rw-r--r--include/x509self.h9
-rw-r--r--src/x509self.cpp13
3 files changed, 21 insertions, 13 deletions
diff --git a/checks/x509.cpp b/checks/x509.cpp
index 6a61ad361..30c4dbd53 100644
--- a/checks/x509.cpp
+++ b/checks/x509.cpp
@@ -78,7 +78,9 @@ void do_x509_tests()
RSA_PrivateKey ca_key(1024, rng);
std::cout << '.' << std::flush;
- X509_Certificate ca_cert = X509::create_self_signed_cert(ca_opts(), ca_key);
+ X509_Certificate ca_cert = X509::create_self_signed_cert(ca_opts(),
+ ca_key,
+ rng);
std::cout << '.' << std::flush;
/* Create user #1's key and cert request */
@@ -86,13 +88,17 @@ void do_x509_tests()
DSA_PrivateKey user1_key(DL_Group("dsa/jce/1024"), rng);
std::cout << '.' << std::flush;
- PKCS10_Request user1_req = X509::create_cert_req(req_opts1(), user1_key);
+ PKCS10_Request user1_req = X509::create_cert_req(req_opts1(),
+ user1_key,
+ rng);
/* Create user #2's key and cert request */
std::cout << '.' << std::flush;
RSA_PrivateKey user2_key(1024, rng);
std::cout << '.' << std::flush;
- PKCS10_Request user2_req = X509::create_cert_req(req_opts2(), user2_key);
+ PKCS10_Request user2_req = X509::create_cert_req(req_opts2(),
+ user2_key,
+ rng);
/* Create the CA object */
std::cout << '.' << std::flush;
diff --git a/include/x509self.h b/include/x509self.h
index 8f3308492..2f83a12be 100644
--- a/include/x509self.h
+++ b/include/x509self.h
@@ -56,14 +56,17 @@ namespace X509 {
/*************************************************
* Create a self-signed X.509 certificate *
*************************************************/
-BOTAN_DLL X509_Certificate create_self_signed_cert(const X509_Cert_Options&,
- const Private_Key&);
+BOTAN_DLL X509_Certificate
+create_self_signed_cert(const X509_Cert_Options&,
+ const Private_Key&,
+ RandomNumberGenerator& rng);
/*************************************************
* Create a PKCS #10 certificate request *
*************************************************/
BOTAN_DLL PKCS10_Request create_cert_req(const X509_Cert_Options&,
- const Private_Key&);
+ const Private_Key&,
+ RandomNumberGenerator& rng);
}
diff --git a/src/x509self.cpp b/src/x509self.cpp
index 9e035ff7d..046ca4c8d 100644
--- a/src/x509self.cpp
+++ b/src/x509self.cpp
@@ -1,6 +1,6 @@
/*************************************************
* PKCS #10/Self Signed Cert Creation Source File *
-* (C) 1999-2007 Jack Lloyd *
+* (C) 1999-2008 Jack Lloyd *
*************************************************/
#include <botan/x509self.h>
@@ -9,7 +9,6 @@
#include <botan/der_enc.h>
#include <botan/config.h>
#include <botan/look_pk.h>
-#include <botan/libstate.h>
#include <botan/oids.h>
#include <botan/pipe.h>
#include <memory>
@@ -64,7 +63,8 @@ namespace X509 {
* Create a new self-signed X.509 certificate *
*************************************************/
X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts,
- const Private_Key& key)
+ const Private_Key& key,
+ RandomNumberGenerator& rng)
{
AlgorithmIdentifier sig_algo;
X509_DN subject_dn;
@@ -91,8 +91,6 @@ X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts,
extensions.add(
new Cert_Extension::Basic_Constraints(opts.is_CA, opts.path_limit));
- RandomNumberGenerator& rng = global_state().prng_reference();
-
return X509_CA::make_cert(signer.get(), rng, sig_algo, pub_key,
opts.start, opts.end,
subject_dn, subject_dn,
@@ -103,7 +101,8 @@ X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts,
* Create a PKCS #10 certificate request *
*************************************************/
PKCS10_Request create_cert_req(const X509_Cert_Options& opts,
- const Private_Key& key)
+ const Private_Key& key,
+ RandomNumberGenerator& rng)
{
AlgorithmIdentifier sig_algo;
X509_DN subject_dn;
@@ -163,7 +162,7 @@ PKCS10_Request create_cert_req(const X509_Cert_Options& opts,
DataSource_Memory source(
X509_Object::make_signed(signer.get(),
- global_state().prng_reference(),
+ rng,
sig_algo,
tbs_req.get_contents())
);