Merge pull request #509 from reaperhulk/rsa-interface-only

RSA private/public key interface
diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py
index 7a6bf3e..293fcd7 100644
--- a/cryptography/hazmat/primitives/interfaces.py
+++ b/cryptography/hazmat/primitives/interfaces.py
@@ -169,3 +169,91 @@
         """
         Return a HashContext that is a copy of the current context.
         """
+
+
+class RSAPrivateKey(six.with_metaclass(abc.ABCMeta)):
+    @abc.abstractproperty
+    def modulus(self):
+        """
+        The public modulus of the RSA key.
+        """
+
+    @abc.abstractproperty
+    def public_exponent(self):
+        """
+        The public exponent of the RSA key.
+        """
+
+    @abc.abstractproperty
+    def key_length(self):
+        """
+        The bit length of the public modulus.
+        """
+
+    @abc.abstractmethod
+    def public_key(self):
+        """
+        The RSAPublicKey associated with this private key.
+        """
+
+    @abc.abstractproperty
+    def n(self):
+        """
+        The public modulus of the RSA key. Alias for modulus.
+        """
+
+    @abc.abstractproperty
+    def p(self):
+        """
+        One of the two primes used to generate d.
+        """
+
+    @abc.abstractproperty
+    def q(self):
+        """
+        One of the two primes used to generate d.
+        """
+
+    @abc.abstractproperty
+    def d(self):
+        """
+        The private exponent. This can be calculated using p and q.
+        """
+
+    @abc.abstractproperty
+    def e(self):
+        """
+        The public exponent of the RSA key. Alias for public_exponent.
+        """
+
+
+class RSAPublicKey(six.with_metaclass(abc.ABCMeta)):
+    @abc.abstractproperty
+    def modulus(self):
+        """
+        The public modulus of the RSA key.
+        """
+
+    @abc.abstractproperty
+    def public_exponent(self):
+        """
+        The public exponent of the RSA key.
+        """
+
+    @abc.abstractproperty
+    def key_length(self):
+        """
+        The bit length of the public modulus.
+        """
+
+    @abc.abstractproperty
+    def n(self):
+        """
+        The public modulus of the RSA key. Alias for modulus.
+        """
+
+    @abc.abstractproperty
+    def e(self):
+        """
+        The public exponent of the RSA key. Alias for public_exponent.
+        """
diff --git a/docs/hazmat/primitives/interfaces.rst b/docs/hazmat/primitives/interfaces.rst
index edb24cd..4739680 100644
--- a/docs/hazmat/primitives/interfaces.rst
+++ b/docs/hazmat/primitives/interfaces.rst
@@ -102,3 +102,105 @@
 
         Exact requirements of the nonce are described by the documentation of
         individual modes.
+
+Asymmetric Interfaces
+~~~~~~~~~~~~~~~~~~~~~
+
+.. class:: RSAPrivateKey
+
+    .. versionadded:: 0.2
+
+    An `RSA`_ private key.
+
+    .. method:: public_key()
+
+        :return: :class:`~cryptography.hazmat.primitives.interfaces.RSAPublicKey`
+
+        An RSA public key object corresponding to the values of the private key.
+
+    .. attribute:: modulus
+
+        :type: int
+
+        The public modulus.
+
+    .. attribute:: public_exponent
+
+        :type: int
+
+        The public exponent.
+
+    .. attribute:: key_length
+
+        :type: int
+
+        The bit length of the modulus.
+
+    .. attribute:: p
+
+        :type: int
+
+        ``p``, one of the two primes composing ``n``.
+
+    .. attribute:: q
+
+        :type: int
+
+        ``q``, one of the two primes composing ``n``.
+
+    .. attribute:: d
+
+        :type: int
+
+        The private exponent.
+
+    .. attribute:: n
+
+        :type: int
+
+        The public modulus. Alias for ``modulus``.
+
+    .. attribute:: e
+
+        :type: int
+
+        The public exponent. Alias for ``public_exponent``.
+
+
+.. class:: RSAPublicKey
+
+    .. versionadded:: 0.2
+
+    An `RSA`_ public key.
+
+    .. attribute:: modulus
+
+        :type: int
+
+        The public modulus.
+
+    .. attribute:: key_length
+
+        :type: int
+
+        The bit length of the modulus.
+
+    .. attribute:: public_exponent
+
+        :type: int
+
+        The public exponent.
+
+    .. attribute:: n
+
+        :type: int
+
+        The public modulus. Alias for ``modulus``.
+
+    .. attribute:: e
+
+        :type: int
+
+        The public exponent. Alias for ``public_exponent``.
+
+.. _`RSA`: http://en.wikipedia.org/wiki/RSA_(cryptosystem)