summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/usage.rst3
-rw-r--r--rsa/pkcs1.py2
-rw-r--r--tests/test_bigfile.py2
-rw-r--r--tests/test_pkcs1.py2
4 files changed, 6 insertions, 3 deletions
diff --git a/doc/usage.rst b/doc/usage.rst
index 611e868..8a736fb 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -197,10 +197,11 @@ possible, check the :py:func:`rsa.sign` function documentation for
details. The hash is then signed with the private key.
In order to verify the signature, use the :py:func:`rsa.verify`
-function.
+function. This function returns True if the verification is successful:
>>> message = 'Go left at the blue tree'
>>> rsa.verify(message, signature, pubkey)
+ True
Modify the message, and the signature is no longer valid and a
:py:class:`rsa.pkcs1.VerificationError` is thrown:
diff --git a/rsa/pkcs1.py b/rsa/pkcs1.py
index 1274fe3..15e4cf6 100644
--- a/rsa/pkcs1.py
+++ b/rsa/pkcs1.py
@@ -321,6 +321,8 @@ def verify(message, signature, pub_key):
if message_hash != signature_hash:
raise VerificationError('Verification failed')
+ return True
+
def _hash(message, method_name):
'''Returns the message digest.
diff --git a/tests/test_bigfile.py b/tests/test_bigfile.py
index 974da8b..86bcbba 100644
--- a/tests/test_bigfile.py
+++ b/tests/test_bigfile.py
@@ -51,7 +51,7 @@ class BigfileTest(unittest2.TestCase):
# Check the signature
msgfile.seek(0)
- pkcs1.verify(msgfile, signature, pub_key)
+ self.assertTrue(pkcs1.verify(msgfile, signature, pub_key))
# Alter the message, re-check
msgfile = BytesIO(b('123456sybren'))
diff --git a/tests/test_pkcs1.py b/tests/test_pkcs1.py
index 55098e2..d5882df 100644
--- a/tests/test_pkcs1.py
+++ b/tests/test_pkcs1.py
@@ -64,7 +64,7 @@ class SignatureTest(unittest2.TestCase):
signature = pkcs1.sign(message, self.priv, 'SHA-256')
print("\tSignature: %r" % signature)
- pkcs1.verify(message, signature, self.pub)
+ self.assertTrue(pkcs1.verify(message, signature, self.pub))
def test_alter_message(self):
'''Altering the message should let the verification fail.'''