aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-10 16:23:59 +0000
committerlloyd <[email protected]>2008-06-10 16:23:59 +0000
commit2aef9fa5bc25984a838a51a93ac0e918d2d1bbac (patch)
tree9f0b9035c4549380de6c62a7bf941a9396b8f554 /src/pubkey.cpp
parent7ab69d77956048fdc27f49a07724d6b21549b916 (diff)
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.
Diffstat (limited to 'src/pubkey.cpp')
-rw-r--r--src/pubkey.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pubkey.cpp b/src/pubkey.cpp
index 0a4162711..d151878c4 100644
--- a/src/pubkey.cpp
+++ b/src/pubkey.cpp
@@ -62,18 +62,18 @@ PK_Encryptor_MR_with_EME::PK_Encryptor_MR_with_EME(const PK_Encrypting_Key& k,
SecureVector<byte> PK_Encryptor_MR_with_EME::enc(const byte msg[],
u32bit length) const
{
+ RandomNumberGenerator& rng = global_state().prng_reference();
+
SecureVector<byte> message;
if(encoder)
- message = encoder->encode(msg, length,
- key.max_input_bits(),
- global_state().prng_reference());
+ message = encoder->encode(msg, length, key.max_input_bits(), rng);
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");
- return key.encrypt(message, message.size());
+ return key.encrypt(message, message.size(), rng);
}
/*************************************************
@@ -187,7 +187,8 @@ SecureVector<byte> PK_Signer::signature()
{
SecureVector<byte> encoded = emsa->encoding_of(emsa->raw_data(),
key.max_input_bits());
- SecureVector<byte> plain_sig = key.sign(encoded, encoded.size());
+ SecureVector<byte> plain_sig = key.sign(encoded, encoded.size(),
+ global_state().prng_reference());
if(key.message_parts() == 1 || sig_format == IEEE_1363)
return plain_sig;