From cc90f60109a6d123de679330363494356948aa54 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Sat, 3 Jan 2015 09:28:23 -0800 Subject: Only split out ec and dsa RSA is being mvoed out of the interfaces namespace in PR #1592. --- .../hazmat/primitives/interfaces/__init__.py | 76 +++++++++++++++++++--- .../hazmat/primitives/interfaces/asymmetric/rsa.py | 75 --------------------- 2 files changed, 67 insertions(+), 84 deletions(-) delete mode 100644 src/cryptography/hazmat/primitives/interfaces/asymmetric/rsa.py (limited to 'src') diff --git a/src/cryptography/hazmat/primitives/interfaces/__init__.py b/src/cryptography/hazmat/primitives/interfaces/__init__.py index 8b6b1f8c..fb5ceeae 100644 --- a/src/cryptography/hazmat/primitives/interfaces/__init__.py +++ b/src/cryptography/hazmat/primitives/interfaces/__init__.py @@ -17,10 +17,6 @@ from cryptography.hazmat.primitives.interfaces.asymmetric.ec import ( EllipticCurvePublicKey, EllipticCurvePublicKeyWithNumbers, EllipticCurveSignatureAlgorithm ) -from cryptography.hazmat.primitives.interfaces.asymmetric.rsa import ( - RSAPrivateKey, RSAPrivateKeyWithNumbers, RSAPublicKey, - RSAPublicKeyWithNumbers -) from cryptography.hazmat.primitives.interfaces.ciphers import ( BlockCipherAlgorithm, CipherAlgorithm, Mode, ModeWithAuthenticationTag, ModeWithInitializationVector, ModeWithNonce @@ -44,11 +40,7 @@ __all__ = [ "Mode", "ModeWithAuthenticationTag", "ModeWithInitializationVector", - "ModeWithNonce", - "RSAPrivateKey", - "RSAPrivateKeyWithNumbers", - "RSAPublicKey", - "RSAPublicKeyWithNumbers" + "ModeWithNonce" ] @@ -150,6 +142,72 @@ class HashContext(object): """ +@six.add_metaclass(abc.ABCMeta) +class RSAPrivateKey(object): + @abc.abstractmethod + def signer(self, padding, algorithm): + """ + Returns an AsymmetricSignatureContext used for signing data. + """ + + @abc.abstractmethod + def decrypt(self, ciphertext, padding): + """ + Decrypts the provided ciphertext. + """ + + @abc.abstractproperty + def key_size(self): + """ + The bit length of the public modulus. + """ + + @abc.abstractmethod + def public_key(self): + """ + The RSAPublicKey associated with this private key. + """ + + +@six.add_metaclass(abc.ABCMeta) +class RSAPrivateKeyWithNumbers(RSAPrivateKey): + @abc.abstractmethod + def private_numbers(self): + """ + Returns an RSAPrivateNumbers. + """ + + +@six.add_metaclass(abc.ABCMeta) +class RSAPublicKey(object): + @abc.abstractmethod + def verifier(self, signature, padding, algorithm): + """ + Returns an AsymmetricVerificationContext used for verifying signatures. + """ + + @abc.abstractmethod + def encrypt(self, plaintext, padding): + """ + Encrypts the given plaintext. + """ + + @abc.abstractproperty + def key_size(self): + """ + The bit length of the public modulus. + """ + + +@six.add_metaclass(abc.ABCMeta) +class RSAPublicKeyWithNumbers(RSAPublicKey): + @abc.abstractmethod + def public_numbers(self): + """ + Returns an RSAPublicNumbers + """ + + @six.add_metaclass(abc.ABCMeta) class AsymmetricSignatureContext(object): @abc.abstractmethod diff --git a/src/cryptography/hazmat/primitives/interfaces/asymmetric/rsa.py b/src/cryptography/hazmat/primitives/interfaces/asymmetric/rsa.py deleted file mode 100644 index 35c3e9e6..00000000 --- a/src/cryptography/hazmat/primitives/interfaces/asymmetric/rsa.py +++ /dev/null @@ -1,75 +0,0 @@ -# This file is dual licensed under the terms of the Apache License, Version -# 2.0, and the BSD License. See the LICENSE file in the root of this repository -# for complete details. - -from __future__ import absolute_import, division, print_function - -import abc - -import six - - -@six.add_metaclass(abc.ABCMeta) -class RSAPrivateKey(object): - @abc.abstractmethod - def signer(self, padding, algorithm): - """ - Returns an AsymmetricSignatureContext used for signing data. - """ - - @abc.abstractmethod - def decrypt(self, ciphertext, padding): - """ - Decrypts the provided ciphertext. - """ - - @abc.abstractproperty - def key_size(self): - """ - The bit length of the public modulus. - """ - - @abc.abstractmethod - def public_key(self): - """ - The RSAPublicKey associated with this private key. - """ - - -@six.add_metaclass(abc.ABCMeta) -class RSAPrivateKeyWithNumbers(RSAPrivateKey): - @abc.abstractmethod - def private_numbers(self): - """ - Returns an RSAPrivateNumbers. - """ - - -@six.add_metaclass(abc.ABCMeta) -class RSAPublicKey(object): - @abc.abstractmethod - def verifier(self, signature, padding, algorithm): - """ - Returns an AsymmetricVerificationContext used for verifying signatures. - """ - - @abc.abstractmethod - def encrypt(self, plaintext, padding): - """ - Encrypts the given plaintext. - """ - - @abc.abstractproperty - def key_size(self): - """ - The bit length of the public modulus. - """ - - -@six.add_metaclass(abc.ABCMeta) -class RSAPublicKeyWithNumbers(RSAPublicKey): - @abc.abstractmethod - def public_numbers(self): - """ - Returns an RSAPublicNumbers - """ -- cgit v1.2.3