aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-05-24 19:56:35 +0000
committerlloyd <[email protected]>2008-05-24 19:56:35 +0000
commit7d9843775ec5d28c15d1070223185575cebe46ec (patch)
tree04d7053b50c57efc7654bcb082d7850bc1187926 /src
parent8283202b8bfd5fe088f87a91a3158bef0072311f (diff)
Pass an RNG reference to EME::pad
PK_Encryptor_MR_with_EME::enc references the global PRNG currently
Diffstat (limited to 'src')
-rw-r--r--src/eme1.cpp7
-rw-r--r--src/eme_pkcs.cpp3
-rw-r--r--src/pk_util.cpp10
-rw-r--r--src/pubkey.cpp9
4 files changed, 18 insertions, 11 deletions
diff --git a/src/eme1.cpp b/src/eme1.cpp
index 43b5a0027..ca96e29e0 100644
--- a/src/eme1.cpp
+++ b/src/eme1.cpp
@@ -4,9 +4,7 @@
*************************************************/
#include <botan/eme.h>
-#include <botan/libstate.h>
#include <botan/lookup.h>
-#include <botan/look_pk.h>
#include <memory>
namespace Botan {
@@ -15,7 +13,8 @@ namespace Botan {
* EME1 Pad Operation *
*************************************************/
SecureVector<byte> EME1::pad(const byte in[], u32bit in_length,
- u32bit key_length) const
+ u32bit key_length,
+ RandomNumberGenerator& rng) const
{
key_length /= 8;
@@ -26,7 +25,7 @@ SecureVector<byte> EME1::pad(const byte in[], u32bit in_length,
out.clear();
- global_state().randomize(out, HASH_LENGTH);
+ rng.randomize(out, HASH_LENGTH);
out.copy(HASH_LENGTH, Phash, Phash.size());
out[out.size() - in_length - 1] = 0x01;
diff --git a/src/eme_pkcs.cpp b/src/eme_pkcs.cpp
index 8296681d8..e6c9ae2d2 100644
--- a/src/eme_pkcs.cpp
+++ b/src/eme_pkcs.cpp
@@ -12,7 +12,8 @@ namespace Botan {
* PKCS1 Pad Operation *
*************************************************/
SecureVector<byte> EME_PKCS1v15::pad(const byte in[], u32bit inlen,
- u32bit olen) const
+ u32bit olen,
+ RandomNumberGenerator&) const
{
olen /= 8;
diff --git a/src/pk_util.cpp b/src/pk_util.cpp
index 86f3578ab..c5f7f8d67 100644
--- a/src/pk_util.cpp
+++ b/src/pk_util.cpp
@@ -11,18 +11,20 @@ namespace Botan {
* Encode a message *
*************************************************/
SecureVector<byte> EME::encode(const byte msg[], u32bit msg_len,
- u32bit key_bits) const
+ u32bit key_bits,
+ RandomNumberGenerator& rng) const
{
- return pad(msg, msg_len, key_bits);
+ return pad(msg, msg_len, key_bits, rng);
}
/*************************************************
* Encode a message *
*************************************************/
SecureVector<byte> EME::encode(const MemoryRegion<byte>& msg,
- u32bit key_bits) const
+ u32bit key_bits,
+ RandomNumberGenerator& rng) const
{
- return pad(msg, msg.size(), key_bits);
+ return pad(msg, msg.size(), key_bits, rng);
}
/*************************************************
diff --git a/src/pubkey.cpp b/src/pubkey.cpp
index afc38dc8a..0a4162711 100644
--- a/src/pubkey.cpp
+++ b/src/pubkey.cpp
@@ -10,6 +10,7 @@
#include <botan/bigint.h>
#include <botan/parsing.h>
#include <botan/bit_ops.h>
+#include <botan/libstate.h>
#include <memory>
namespace Botan {
@@ -62,8 +63,12 @@ SecureVector<byte> PK_Encryptor_MR_with_EME::enc(const byte msg[],
u32bit length) const
{
SecureVector<byte> message;
- if(encoder) message = encoder->encode(msg, length, key.max_input_bits());
- else message.set(msg, length);
+ if(encoder)
+ message = encoder->encode(msg, length,
+ key.max_input_bits(),
+ global_state().prng_reference());
+ else
+ message.set(msg, length);
if(8*(message.size() - 1) + high_bit(message[0]) > key.max_input_bits())
throw Exception("PK_Encryptor_MR_with_EME: Input is too large");