From 2aef9fa5bc25984a838a51a93ac0e918d2d1bbac Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 10 Jun 2008 16:23:59 +0000 Subject: Pass RandomNumberGenerator references to public key operations that need them (encrypt and sign), with the intent of slowly bubbling up the access points to the API level, at which point the application handles managing the RNG. This will allow removing the compiled-in global PRNG, and make testing much simpler. --- include/dl_algo.h | 2 +- include/dsa.h | 3 ++- include/elgamal.h | 3 ++- include/nr.h | 3 ++- include/pk_keys.h | 6 ++++-- include/rsa.h | 8 ++++++-- include/rw.h | 3 ++- 7 files changed, 19 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/dl_algo.h b/include/dl_algo.h index 2bcd67cb9..aaf078bac 100644 --- a/include/dl_algo.h +++ b/include/dl_algo.h @@ -40,7 +40,7 @@ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key * DL Private Key * *************************************************/ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey, - public virtual Private_Key + public virtual Private_Key { public: bool check_key(RandomNumberGenerator& rng, bool) const; diff --git a/include/dsa.h b/include/dsa.h index a858374e6..67de8d137 100644 --- a/include/dsa.h +++ b/include/dsa.h @@ -43,7 +43,8 @@ class BOTAN_DLL DSA_PrivateKey : public DSA_PublicKey, public virtual DL_Scheme_PrivateKey { public: - SecureVector sign(const byte[], u32bit) const; + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const; bool check_key(RandomNumberGenerator& rng, bool) const; diff --git a/include/elgamal.h b/include/elgamal.h index 90fd8c77a..e5de3f965 100644 --- a/include/elgamal.h +++ b/include/elgamal.h @@ -21,7 +21,8 @@ class BOTAN_DLL ElGamal_PublicKey : public PK_Encrypting_Key, std::string algo_name() const { return "ElGamal"; } DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; } - SecureVector encrypt(const byte[], u32bit) const; + SecureVector encrypt(const byte[], u32bit, + RandomNumberGenerator& rng) const; u32bit max_input_bits() const; ElGamal_PublicKey() {} diff --git a/include/nr.h b/include/nr.h index 0f5e1d677..c8eaaf32e 100644 --- a/include/nr.h +++ b/include/nr.h @@ -43,7 +43,8 @@ class BOTAN_DLL NR_PrivateKey : public NR_PublicKey, public virtual DL_Scheme_PrivateKey { public: - SecureVector sign(const byte[], u32bit) const; + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const; bool check_key(RandomNumberGenerator& rng, bool) const; diff --git a/include/pk_keys.h b/include/pk_keys.h index fed96d37b..c6f9ced3c 100644 --- a/include/pk_keys.h +++ b/include/pk_keys.h @@ -54,7 +54,8 @@ class BOTAN_DLL Private_Key : public virtual Public_Key class BOTAN_DLL PK_Encrypting_Key : public virtual Public_Key { public: - virtual SecureVector encrypt(const byte[], u32bit) const = 0; + virtual SecureVector encrypt(const byte[], u32bit, + RandomNumberGenerator&) const = 0; virtual ~PK_Encrypting_Key() {} }; @@ -74,7 +75,8 @@ class BOTAN_DLL PK_Decrypting_Key : public virtual Private_Key class BOTAN_DLL PK_Signing_Key : public virtual Private_Key { public: - virtual SecureVector sign(const byte[], u32bit) const = 0; + virtual SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const = 0; virtual ~PK_Signing_Key() {} }; diff --git a/include/rsa.h b/include/rsa.h index e9f92db51..7ca8068f9 100644 --- a/include/rsa.h +++ b/include/rsa.h @@ -20,7 +20,9 @@ class BOTAN_DLL RSA_PublicKey : public PK_Encrypting_Key, public: std::string algo_name() const { return "RSA"; } - SecureVector encrypt(const byte[], u32bit) const; + SecureVector encrypt(const byte[], u32bit, + RandomNumberGenerator& rng) const; + SecureVector verify(const byte[], u32bit) const; RSA_PublicKey() {} @@ -38,8 +40,10 @@ class BOTAN_DLL RSA_PrivateKey : public RSA_PublicKey, public IF_Scheme_PrivateKey { public: + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator&) const; + SecureVector decrypt(const byte[], u32bit) const; - SecureVector sign(const byte[], u32bit) const; bool check_key(RandomNumberGenerator& rng, bool) const; diff --git a/include/rw.h b/include/rw.h index a809041d1..2cc2fb6a4 100644 --- a/include/rw.h +++ b/include/rw.h @@ -35,7 +35,8 @@ class BOTAN_DLL RW_PrivateKey : public RW_PublicKey, public IF_Scheme_PrivateKey { public: - SecureVector sign(const byte[], u32bit) const; + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const; bool check_key(RandomNumberGenerator& rng, bool) const; -- cgit v1.2.3