aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/rsa
diff options
context:
space:
mode:
Diffstat (limited to 'src/pubkey/rsa')
-rw-r--r--src/pubkey/rsa/rsa.cpp11
-rw-r--r--src/pubkey/rsa/rsa.h8
2 files changed, 12 insertions, 7 deletions
diff --git a/src/pubkey/rsa/rsa.cpp b/src/pubkey/rsa/rsa.cpp
index 5047fdf7a..b278ade52 100644
--- a/src/pubkey/rsa/rsa.cpp
+++ b/src/pubkey/rsa/rsa.cpp
@@ -80,7 +80,7 @@ RSA_Private_Operation::RSA_Private_Operation(const RSA_PrivateKey& rsa) :
powermod_d2_q(rsa.get_d2(), rsa.get_q()),
mod_p(rsa.get_p())
{
- BigInt k = Blinder::choose_nonce(rsa.get_d(), n);
+ BigInt k = Blinder::choose_nonce(powermod_e_n(q), n);
blinder = Blinder(powermod_e_n(k), inverse_mod(k, n), n);
}
@@ -99,8 +99,13 @@ BigInt RSA_Private_Operation::private_op(const BigInt& m) const
SecureVector<byte>
RSA_Private_Operation::sign(const byte msg[], u32bit msg_len,
- RandomNumberGenerator&) const
+ RandomNumberGenerator& rng)
{
+ /* We don't check signatures against powermod_e_n here because
+ PK_Signer checks verification consistency for all signature
+ algorithms.
+ */
+
BigInt m(msg, msg_len);
BigInt x = blinder.unblind(private_op(blinder.blind(m)));
return BigInt::encode_1363(x, n.bytes());
@@ -110,7 +115,7 @@ RSA_Private_Operation::sign(const byte msg[], u32bit msg_len,
* RSA Decryption Operation
*/
SecureVector<byte>
-RSA_Private_Operation::decrypt(const byte msg[], u32bit msg_len) const
+RSA_Private_Operation::decrypt(const byte msg[], u32bit msg_len)
{
BigInt m(msg, msg_len);
BigInt x = blinder.unblind(private_op(blinder.blind(m)));
diff --git a/src/pubkey/rsa/rsa.h b/src/pubkey/rsa/rsa.h
index 36f9277ef..72cd80fef 100644
--- a/src/pubkey/rsa/rsa.h
+++ b/src/pubkey/rsa/rsa.h
@@ -96,9 +96,9 @@ class BOTAN_DLL RSA_Private_Operation : public PK_Ops::Signature,
u32bit max_input_bits() const { return (n.bits() - 1); }
SecureVector<byte> sign(const byte msg[], u32bit msg_len,
- RandomNumberGenerator& rng) const;
+ RandomNumberGenerator& rng);
- SecureVector<byte> decrypt(const byte msg[], u32bit msg_len) const;
+ SecureVector<byte> decrypt(const byte msg[], u32bit msg_len);
private:
BigInt private_op(const BigInt& m) const;
@@ -123,13 +123,13 @@ class BOTAN_DLL RSA_Public_Operation : public PK_Ops::Verification,
bool with_recovery() const { return true; }
SecureVector<byte> encrypt(const byte msg[], u32bit msg_len,
- RandomNumberGenerator&) const
+ RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
return BigInt::encode_1363(public_op(m), n.bytes());
}
- SecureVector<byte> verify_mr(const byte msg[], u32bit msg_len) const
+ SecureVector<byte> verify_mr(const byte msg[], u32bit msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(public_op(m));