diff options
Diffstat (limited to 'lib/Crypto/PublicKey/RSA.py')
-rw-r--r-- | lib/Crypto/PublicKey/RSA.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Crypto/PublicKey/RSA.py b/lib/Crypto/PublicKey/RSA.py index a5afeb9..c323295 100644 --- a/lib/Crypto/PublicKey/RSA.py +++ b/lib/Crypto/PublicKey/RSA.py @@ -229,6 +229,8 @@ class _RSAobj(pubkey.pubkey): return pubkey.pubkey.verify(self, M, signature) def _encrypt(self, c, K): + if not 0 < c < self.n: + raise ValueError("Plaintext too large") return (self.key._encrypt(c),) def _decrypt(self, c): @@ -238,6 +240,9 @@ class _RSAobj(pubkey.pubkey): # going to replace the Crypto.PublicKey API soon # anyway. + if not 0 < ciphertext < self.n: + raise ValueError("Ciphertext too large") + # Blinded RSA decryption (to prevent timing attacks): # Step 1: Generate random secret blinding factor r, such that 0 < r < n-1 r = getRandomRange(1, self.key.n-1, randfunc=self._randfunc) |