aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-04 18:54:47 -0430
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-04 18:54:47 -0430
commit826b374c5707294681ccc920e35e1dbbdd02febe (patch)
tree8ae41679bea4d093a8b34e999b0cd78777f6b200
parentaee8b1aee873f125ba6fad172c2fcbe205fe8fe4 (diff)
parent29aa3aad4405f90c98ff7498718d1cca91fe7c8b (diff)
downloadcryptography-826b374c5707294681ccc920e35e1dbbdd02febe.tar.gz
cryptography-826b374c5707294681ccc920e35e1dbbdd02febe.tar.bz2
cryptography-826b374c5707294681ccc920e35e1dbbdd02febe.zip
Merge pull request #719 from skeuomorf/master
Add DSA interfaces
-rw-r--r--cryptography/hazmat/primitives/interfaces.py92
-rw-r--r--docs/hazmat/primitives/interfaces.rst108
2 files changed, 200 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py
index 11696160..3824bcde 100644
--- a/cryptography/hazmat/primitives/interfaces.py
+++ b/cryptography/hazmat/primitives/interfaces.py
@@ -287,6 +287,98 @@ class RSAPublicKey(six.with_metaclass(abc.ABCMeta)):
"""
+class DSAParameters(six.with_metaclass(abc.ABCMeta)):
+ @abc.abstractproperty
+ def modulus(self):
+ """
+ The prime modulus that's used in generating the DSA keypair and used
+ in the DSA signing and verification processes.
+ """
+
+ @abc.abstractproperty
+ def subgroup_order(self):
+ """
+ The subgroup order that's used in generating the DSA keypair
+ by the generator and used in the DSA signing and verification
+ processes.
+ """
+
+ @abc.abstractproperty
+ def generator(self):
+ """
+ The generator that is used in generating the DSA keypair and used
+ in the DSA signing and verification processes.
+ """
+
+ @abc.abstractproperty
+ def p(self):
+ """
+ The prime modulus that's used in generating the DSA keypair and used
+ in the DSA signing and verification processes. Alias for modulus.
+ """
+
+ @abc.abstractproperty
+ def q(self):
+ """
+ The subgroup order that's used in generating the DSA keypair
+ by the generator and used in the DSA signing and verification
+ processes. Alias for subgroup_order.
+ """
+
+ @abc.abstractproperty
+ def g(self):
+ """
+ The generator that is used in generating the DSA keypair and used
+ in the DSA signing and verification processes. Alias for generator.
+ """
+
+
+class DSAPrivateKey(six.with_metaclass(abc.ABCMeta)):
+ @abc.abstractproperty
+ def key_size(self):
+ """
+ The bit length of the prime modulus.
+ """
+
+ @abc.abstractmethod
+ def public_key(self):
+ """
+ The DSAPublicKey associated with this private key.
+ """
+
+ @abc.abstractproperty
+ def x(self):
+ """
+ The private key "x" in the DSA structure.
+ """
+
+ @abc.abstractproperty
+ def y(self):
+ """
+ The public key.
+ """
+
+ @abc.abstractmethod
+ def parameters(self):
+ """
+ The DSAParameters object associated with this private key.
+ """
+
+
+class DSAPublicKey(six.with_metaclass(abc.ABCMeta)):
+ @abc.abstractproperty
+ def y(self):
+ """
+ The public key.
+ """
+
+ @abc.abstractmethod
+ def parameters(self):
+ """
+ The DSAParameters object associated with this public key.
+ """
+
+
class AsymmetricSignatureContext(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def update(self, data):
diff --git a/docs/hazmat/primitives/interfaces.rst b/docs/hazmat/primitives/interfaces.rst
index 15ad1d1b..cc2a3000 100644
--- a/docs/hazmat/primitives/interfaces.rst
+++ b/docs/hazmat/primitives/interfaces.rst
@@ -231,6 +231,113 @@ Asymmetric Interfaces
The public exponent. Alias for :attr:`public_exponent`.
+.. class:: DSAParameters
+
+ .. versionadded:: 0.3
+
+ `DSA`_ parameters.
+
+ .. attribute:: modulus
+
+ :type: int
+
+ The prime modulus that is used in generating the DSA key pair and used
+ in the DSA signing and verification processes.
+
+ .. attribute:: subgroup_order
+
+ :type: int
+
+ The subgroup order that is used in generating the DSA key pair
+ by the generator and used in the DSA signing and verification
+ processes.
+
+ .. attribute:: generator
+
+ :type: int
+
+ The generator that is used in generating the DSA key pair and used
+ in the DSA signing and verification processes.
+
+ .. attribute:: p
+
+ :type: int
+
+ The prime modulus that is used in generating the DSA key pair and used
+ in the DSA signing and verification processes. Alias for :attr:`modulus`.
+
+ .. attribute:: q
+
+ :type: int
+
+ The subgroup order that is used in generating the DSA key pair
+ by the generator and used in the DSA signing and verification
+ processes. Alias for :attr:`subgroup_order`.
+
+ .. attribute:: g
+
+ :type: int
+
+ The generator that is used in generating the DSA key pair and used
+ in the DSA signing and verification processes. Alias for :attr:`generator`.
+
+
+.. class:: DSAPrivateKey
+
+ .. versionadded:: 0.3
+
+ A `DSA`_ private key.
+
+ .. method:: public_key()
+
+ :return: :class:`~cryptography.hazmat.primitives.interfaces.DSAPublicKey`
+
+ An DSA public key object corresponding to the values of the private key.
+
+ .. method:: parameters()
+
+ :return: :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
+
+ The DSAParameters object associated with this private key.
+
+ .. attribute:: key_size
+
+ :type: int
+
+ The bit length of the modulus.
+
+ .. attribute:: x
+
+ :type: int
+
+ The private key.
+
+ .. attribute:: y
+
+ :type: int
+
+ The public key.
+
+
+.. class:: DSAPublicKey
+
+ .. versionadded:: 0.3
+
+ A `DSA`_ private key.
+
+ .. method:: parameters()
+
+ :return: :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
+
+ The DSAParameters object associated with this public key.
+
+ .. attribute:: y
+
+ :type: int
+
+ The public key.
+
+
.. class:: AsymmetricSignatureContext
.. versionadded:: 0.2
@@ -335,3 +442,4 @@ Key Derivation Functions
.. _`RSA`: https://en.wikipedia.org/wiki/RSA_(cryptosystem)
.. _`Chinese remainder theorem`: https://en.wikipedia.org/wiki/Chinese_remainder_theorem
+.. _`DSA`: https://en.wikipedia.org/wiki/Digital_Signature_Algorithm