aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-01-26 11:38:23 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2014-01-26 11:38:23 -0800
commit77d63d39b58fa97943fda0e391a3e43b5f84f9ea (patch)
tree32962d487be31639764aaae16c3b54eec509b6f0 /cryptography
parentd062dc8a617f95e4e0b1893f384c482e16f10550 (diff)
parent46688b11ed7b4f8c53a61feb1bf355a38d3e939c (diff)
downloadcryptography-77d63d39b58fa97943fda0e391a3e43b5f84f9ea.tar.gz
cryptography-77d63d39b58fa97943fda0e391a3e43b5f84f9ea.tar.bz2
cryptography-77d63d39b58fa97943fda0e391a3e43b5f84f9ea.zip
Merge pull request #509 from reaperhulk/rsa-interface-only
RSA private/public key interface
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/primitives/interfaces.py88
1 files changed, 88 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py
index 7a6bf3e2..293fcd78 100644
--- a/cryptography/hazmat/primitives/interfaces.py
+++ b/cryptography/hazmat/primitives/interfaces.py
@@ -169,3 +169,91 @@ class HashContext(six.with_metaclass(abc.ABCMeta)):
"""
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.
+ """