aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammed Attia <skeuomorf@gmail.com>2014-04-25 22:44:40 +0200
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-04-30 15:55:10 -0500
commit59edb613d278bb93dc165e486f354b69fc12fdee (patch)
tree727d339938f94ce7592b6659ddc96d3505bfc931
parent643b314ede639c2fa100a5b20740c8827952299b (diff)
downloadcryptography-59edb613d278bb93dc165e486f354b69fc12fdee.tar.gz
cryptography-59edb613d278bb93dc165e486f354b69fc12fdee.tar.bz2
cryptography-59edb613d278bb93dc165e486f354b69fc12fdee.zip
Add DSA verification docs
-rw-r--r--docs/hazmat/backends/interfaces.rst32
-rw-r--r--docs/hazmat/backends/openssl.rst1
-rw-r--r--docs/hazmat/primitives/asymmetric/dsa.rst49
-rw-r--r--docs/hazmat/primitives/interfaces.rst26
4 files changed, 105 insertions, 3 deletions
diff --git a/docs/hazmat/backends/interfaces.rst b/docs/hazmat/backends/interfaces.rst
index 2f63f3e0..e0937f97 100644
--- a/docs/hazmat/backends/interfaces.rst
+++ b/docs/hazmat/backends/interfaces.rst
@@ -345,6 +345,38 @@ A specific ``backend`` may provide one or more of these interfaces.
1.0.0 and the key size is larger than 1024; older OpenSSL versions
do not support keys larger than 1024 bits.
+ .. method:: create_dsa_verification_ctx(public_key, signature, algorithm)
+
+ :param public_key: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.DSAPublicKey`
+ provider.
+
+ :param bytes signature: The signature to verify.
+
+ :param algorithm: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
+ provider.
+
+ :returns:
+ :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricVerificationContext`
+
+ .. method:: dsa_signature_from_components(r, s)
+
+ :param int r: The r value which is part of a DSA signature.
+
+ :param int s: The s value which is part of a DSA signature.
+
+ :returns: A DSA signature in DER format.
+
+ .. method:: dsa_hash_supported(algorithm):
+
+ :param algorithm: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
+ provider.
+
+ :returns: ``True`` if the specified ``algorithm`` is supported by this
+ backend, otherwise ``False``.
+
.. class:: CMACBackend
diff --git a/docs/hazmat/backends/openssl.rst b/docs/hazmat/backends/openssl.rst
index 43e5d8f3..f15bc282 100644
--- a/docs/hazmat/backends/openssl.rst
+++ b/docs/hazmat/backends/openssl.rst
@@ -14,6 +14,7 @@ Red Hat Enterprise Linux 5) and greater. Earlier versions may work but are
It implements the following interfaces:
* :class:`~cryptography.hazmat.backends.interfaces.CipherBackend`
+ * :class:`~cryptography.hazmat.backends.interfaces.DSABackend`
* :class:`~cryptography.hazmat.backends.interfaces.HashBackend`
* :class:`~cryptography.hazmat.backends.interfaces.HMACBackend`
* :class:`~cryptography.hazmat.backends.interfaces.PBKDF2HMACBackend`
diff --git a/docs/hazmat/primitives/asymmetric/dsa.rst b/docs/hazmat/primitives/asymmetric/dsa.rst
index 2819bbdb..5cee5705 100644
--- a/docs/hazmat/primitives/asymmetric/dsa.rst
+++ b/docs/hazmat/primitives/asymmetric/dsa.rst
@@ -118,6 +118,55 @@ DSA
``subgroup_order``, ``generator``, or ``y``
do not match the bounds specified in `FIPS 186-4`_.
+ .. method:: verifier(signature, algorithm, backend)
+
+ .. versionadded:: 0.4
+
+ Verify data was signed by the private key associated with this public
+ key.
+
+ .. code-block:: pycon
+
+ >>> from cryptography.hazmat.backends import default_backend
+ >>> from cryptography.hazmat.primitives import hashes
+ >>> from cryptography.hazmat.primitives.asymmetric import dsa
+ >>> parameters = dsa.DSAParameters.generate(
+ ... key_size=1024,
+ ... backend=default_backend()
+ ... )
+ >>> private_key = dsa.DSAPrivateKey.generate(
+ ... parameters=parameters,
+ ... backend=default_backend()
+ ... )
+ >>> signer = private_key.signer(
+ ... hashes.SHA256(),
+ ... default_backend()
+ ... )
+ >>> data= b"this is some data I'd like to sign"
+ >>> signer.update(data)
+ >>> signature = signer.finalize()
+ >>> public_key = private_key.public_key()
+ >>> verifier = public_key.verifier(
+ ... signature,
+ ... hashes.SHA256(),
+ ... default_backend()
+ ... )
+ >>> verifier.update(data)
+ >>> verifier.verify()
+
+ :param bytes signature: The signature to verify in DER encoding as
+ specified in :rfc:`6979`.
+
+ :param algorithm: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
+ provider.
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.DSABackend`
+ provider.
+
+ :returns:
+ :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricVerificationContext`
.. _`DSA`: https://en.wikipedia.org/wiki/Digital_Signature_Algorithm
.. _`public-key`: https://en.wikipedia.org/wiki/Public-key_cryptography
diff --git a/docs/hazmat/primitives/interfaces.rst b/docs/hazmat/primitives/interfaces.rst
index c76582c0..c1d01f74 100644
--- a/docs/hazmat/primitives/interfaces.rst
+++ b/docs/hazmat/primitives/interfaces.rst
@@ -412,17 +412,37 @@ Asymmetric interfaces
The bit length of the modulus.
+ .. attribute:: y
+
+ :type: int
+
+ The public key.
+
.. method:: parameters()
:return: :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
The DSAParameters object associated with this public key.
- .. attribute:: y
+ .. method:: verifier(signature, algorithm, backend)
- :type: int
+ .. versionadded:: 0.4
- The public key.
+ Verify data was signed by the private key associated with this public
+ key.
+
+ :param bytes signature: The signature to verify.
+
+ :param algorithm: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
+ provider.
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.DSABackend`
+ provider.
+
+ :returns:
+ :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricVerificationContext`
.. class:: AsymmetricSignatureContext