diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-11-20 22:48:10 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-11-20 09:48:10 -0500 |
commit | f555c74d5419a52648e2a903595c13bd13d13ce2 (patch) | |
tree | 592b855980fecba54c51924b58457607c6da1463 /docs | |
parent | 033bd7167d6546d34576dd0d798318999ec82a07 (diff) | |
download | cryptography-f555c74d5419a52648e2a903595c13bd13d13ce2.tar.gz cryptography-f555c74d5419a52648e2a903595c13bd13d13ce2.tar.bz2 cryptography-f555c74d5419a52648e2a903595c13bd13d13ce2.zip |
support RSA verify with prehashing (#3265)
* support RSA verify with prehashing
* review feedback
* more dedupe
* refactor and move to a separate module
Diffstat (limited to 'docs')
-rw-r--r-- | docs/hazmat/primitives/asymmetric/rsa.rst | 7 | ||||
-rw-r--r-- | docs/hazmat/primitives/asymmetric/utils.rst | 14 |
2 files changed, 19 insertions, 2 deletions
diff --git a/docs/hazmat/primitives/asymmetric/rsa.rst b/docs/hazmat/primitives/asymmetric/rsa.rst index b6acab6b..6cf0e499 100644 --- a/docs/hazmat/primitives/asymmetric/rsa.rst +++ b/docs/hazmat/primitives/asymmetric/rsa.rst @@ -703,6 +703,9 @@ Key interfaces .. method:: verify(signature, data, padding, algorithm) .. versionadded:: 1.4 + .. versionchanged:: 1.6 + :class:`~cryptography.hazmat.primitives.asymmetric.utils.Prehashed` + can now be used as an ``algorithm``. Verify one block of data was signed by the private key associated with this public key. @@ -715,7 +718,9 @@ Key interfaces :class:`~cryptography.hazmat.primitives.asymmetric.padding.AsymmetricPadding`. :param algorithm: An instance of - :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`. + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` or + :class:`~cryptography.hazmat.primitives.asymmetric.utils.Prehashed` + if the ``data`` you want to sign has already been hashed. :raises cryptography.exceptions.InvalidSignature: If the signature does not validate. diff --git a/docs/hazmat/primitives/asymmetric/utils.rst b/docs/hazmat/primitives/asymmetric/utils.rst index f29b3e99..ab49e551 100644 --- a/docs/hazmat/primitives/asymmetric/utils.rst +++ b/docs/hazmat/primitives/asymmetric/utils.rst @@ -35,7 +35,9 @@ Asymmetric Utilities ``Prehashed`` can be passed as the ``algorithm`` in :meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey.sign` - if the data to be signed has been hashed beforehand. + or + :meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey.verify` + if the data to be signed or verified has been hashed beforehand. :param algorithm: An instance of :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`. @@ -62,3 +64,13 @@ Asymmetric Utilities ... ), ... utils.Prehashed(hashes.SHA256()) ... ) + >>> public_key = private_key.public_key() + >>> public_key.verify( + ... signature, + ... prehashed_msg, + ... padding.PSS( + ... mgf=padding.MGF1(hashes.SHA256()), + ... salt_length=padding.PSS.MAX_LENGTH + ... ), + ... utils.Prehashed(hashes.SHA256()) + ... ) |