diff options
author | Justin Simon <jls5177@gmail.com> | 2017-05-07 04:39:47 -0500 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-05-07 11:39:47 +0200 |
commit | 425eb24854f1c3397aaaba61fa1cf71c76b27c4b (patch) | |
tree | 824a0e34f6bc4e88bbbb6bfa7e2f7a80d5399aa3 /doc | |
parent | 000e84a97a8ab25a5d9b4185a2e02efc033f7e8a (diff) | |
download | rsa-git-425eb24854f1c3397aaaba61fa1cf71c76b27c4b.tar.gz |
Support signing a pre-calculated hash (#87)
* Split the hashing out of the sign method
This code change adds support to split the hashing of a message
and the actual signing of the message.
* Updating unit test and documentation
This commit updates the unit test and usage docs. In addition,
This change removes a redundant error check inside rsa.sign().
* Refactore unit tests and code comments
Removed the print statements from the unit test and refactored a
few code comments to improve readability.
* Rename hash function
The new hash function had the same name as a function in the
standard library. This commit changes the name to avoid conflicts.
* Rename hash function to compute_hash()
This commit renames the hash function to compute_hash().
Diffstat (limited to 'doc')
-rw-r--r-- | doc/usage.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/usage.rst b/doc/usage.rst index b4f8426..6ac9e82 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -203,6 +203,15 @@ This hashes the message using SHA-1. Other hash methods are also possible, check the :py:func:`rsa.sign` function documentation for details. The hash is then signed with the private key. +It is possible to calculate the hash and signature in separate operations +(i.e for generating the hash on a client machine and then sign with a +private key on remote server). To hash a message use the :py:func:`rsa.compute_hash` +function and then use the :py:func:`rsa.sign_hash` function to sign the hash: + + >>> message = 'Go left at the blue tree' + >>> hash = rsa.compute_hash(message, 'SHA-1') + >>> signature = rsa.sign_hash(hash, privkey, 'SHA-1') + In order to verify the signature, use the :py:func:`rsa.verify` function. This function returns True if the verification is successful: |