Move the bindings into the hazmat module
diff --git a/cryptography/bindings/__init__.py b/cryptography/hazmat/bindings/__init__.py
similarity index 92%
rename from cryptography/bindings/__init__.py
rename to cryptography/hazmat/bindings/__init__.py
index 5006d13..eb82899 100644
--- a/cryptography/bindings/__init__.py
+++ b/cryptography/hazmat/bindings/__init__.py
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from cryptography.bindings import openssl
+from cryptography.hazmat.bindings import openssl
_default_backend = openssl.backend
diff --git a/cryptography/bindings/openssl/__init__.py b/cryptography/hazmat/bindings/openssl/__init__.py
similarity index 89%
rename from cryptography/bindings/openssl/__init__.py
rename to cryptography/hazmat/bindings/openssl/__init__.py
index cfe2e66..44267ef 100644
--- a/cryptography/bindings/openssl/__init__.py
+++ b/cryptography/hazmat/bindings/openssl/__init__.py
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from cryptography.bindings.openssl.backend import backend
+from cryptography.hazmat.bindings.openssl.backend import backend
__all__ = ["backend"]
diff --git a/cryptography/bindings/openssl/asn1.py b/cryptography/hazmat/bindings/openssl/asn1.py
similarity index 100%
rename from cryptography/bindings/openssl/asn1.py
rename to cryptography/hazmat/bindings/openssl/asn1.py
diff --git a/cryptography/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py
similarity index 97%
rename from cryptography/bindings/openssl/backend.py
rename to cryptography/hazmat/bindings/openssl/backend.py
index 3477d3e..4b6ea1f 100644
--- a/cryptography/bindings/openssl/backend.py
+++ b/cryptography/hazmat/bindings/openssl/backend.py
@@ -60,8 +60,10 @@
functions = []
macros = []
for name in self._modules:
- __import__("cryptography.bindings.openssl." + name)
- module = sys.modules["cryptography.bindings.openssl." + name]
+ __import__("cryptography.hazmat.bindings.openssl." + name)
+ module = (
+ sys.modules["cryptography.hazmat.bindings.openssl." + name]
+ )
self.ffi.cdef(module.TYPES)
macros.append(module.MACROS)
diff --git a/cryptography/bindings/openssl/bignum.py b/cryptography/hazmat/bindings/openssl/bignum.py
similarity index 100%
rename from cryptography/bindings/openssl/bignum.py
rename to cryptography/hazmat/bindings/openssl/bignum.py
diff --git a/cryptography/bindings/openssl/bio.py b/cryptography/hazmat/bindings/openssl/bio.py
similarity index 100%
rename from cryptography/bindings/openssl/bio.py
rename to cryptography/hazmat/bindings/openssl/bio.py
diff --git a/cryptography/bindings/openssl/conf.py b/cryptography/hazmat/bindings/openssl/conf.py
similarity index 100%
rename from cryptography/bindings/openssl/conf.py
rename to cryptography/hazmat/bindings/openssl/conf.py
diff --git a/cryptography/bindings/openssl/crypto.py b/cryptography/hazmat/bindings/openssl/crypto.py
similarity index 100%
rename from cryptography/bindings/openssl/crypto.py
rename to cryptography/hazmat/bindings/openssl/crypto.py
diff --git a/cryptography/bindings/openssl/dh.py b/cryptography/hazmat/bindings/openssl/dh.py
similarity index 100%
rename from cryptography/bindings/openssl/dh.py
rename to cryptography/hazmat/bindings/openssl/dh.py
diff --git a/cryptography/bindings/openssl/dsa.py b/cryptography/hazmat/bindings/openssl/dsa.py
similarity index 100%
rename from cryptography/bindings/openssl/dsa.py
rename to cryptography/hazmat/bindings/openssl/dsa.py
diff --git a/cryptography/bindings/openssl/engine.py b/cryptography/hazmat/bindings/openssl/engine.py
similarity index 100%
rename from cryptography/bindings/openssl/engine.py
rename to cryptography/hazmat/bindings/openssl/engine.py
diff --git a/cryptography/bindings/openssl/err.py b/cryptography/hazmat/bindings/openssl/err.py
similarity index 100%
rename from cryptography/bindings/openssl/err.py
rename to cryptography/hazmat/bindings/openssl/err.py
diff --git a/cryptography/bindings/openssl/evp.py b/cryptography/hazmat/bindings/openssl/evp.py
similarity index 100%
rename from cryptography/bindings/openssl/evp.py
rename to cryptography/hazmat/bindings/openssl/evp.py
diff --git a/cryptography/bindings/openssl/hmac.py b/cryptography/hazmat/bindings/openssl/hmac.py
similarity index 100%
rename from cryptography/bindings/openssl/hmac.py
rename to cryptography/hazmat/bindings/openssl/hmac.py
diff --git a/cryptography/bindings/openssl/nid.py b/cryptography/hazmat/bindings/openssl/nid.py
similarity index 100%
rename from cryptography/bindings/openssl/nid.py
rename to cryptography/hazmat/bindings/openssl/nid.py
diff --git a/cryptography/bindings/openssl/opensslv.py b/cryptography/hazmat/bindings/openssl/opensslv.py
similarity index 100%
rename from cryptography/bindings/openssl/opensslv.py
rename to cryptography/hazmat/bindings/openssl/opensslv.py
diff --git a/cryptography/bindings/openssl/pem.py b/cryptography/hazmat/bindings/openssl/pem.py
similarity index 100%
rename from cryptography/bindings/openssl/pem.py
rename to cryptography/hazmat/bindings/openssl/pem.py
diff --git a/cryptography/bindings/openssl/pkcs12.py b/cryptography/hazmat/bindings/openssl/pkcs12.py
similarity index 100%
rename from cryptography/bindings/openssl/pkcs12.py
rename to cryptography/hazmat/bindings/openssl/pkcs12.py
diff --git a/cryptography/bindings/openssl/pkcs7.py b/cryptography/hazmat/bindings/openssl/pkcs7.py
similarity index 100%
rename from cryptography/bindings/openssl/pkcs7.py
rename to cryptography/hazmat/bindings/openssl/pkcs7.py
diff --git a/cryptography/bindings/openssl/rand.py b/cryptography/hazmat/bindings/openssl/rand.py
similarity index 100%
rename from cryptography/bindings/openssl/rand.py
rename to cryptography/hazmat/bindings/openssl/rand.py
diff --git a/cryptography/bindings/openssl/rsa.py b/cryptography/hazmat/bindings/openssl/rsa.py
similarity index 100%
rename from cryptography/bindings/openssl/rsa.py
rename to cryptography/hazmat/bindings/openssl/rsa.py
diff --git a/cryptography/bindings/openssl/ssl.py b/cryptography/hazmat/bindings/openssl/ssl.py
similarity index 100%
rename from cryptography/bindings/openssl/ssl.py
rename to cryptography/hazmat/bindings/openssl/ssl.py
diff --git a/cryptography/bindings/openssl/x509.py b/cryptography/hazmat/bindings/openssl/x509.py
similarity index 100%
rename from cryptography/bindings/openssl/x509.py
rename to cryptography/hazmat/bindings/openssl/x509.py
diff --git a/cryptography/bindings/openssl/x509name.py b/cryptography/hazmat/bindings/openssl/x509name.py
similarity index 100%
rename from cryptography/bindings/openssl/x509name.py
rename to cryptography/hazmat/bindings/openssl/x509name.py
diff --git a/cryptography/bindings/openssl/x509v3.py b/cryptography/hazmat/bindings/openssl/x509v3.py
similarity index 100%
rename from cryptography/bindings/openssl/x509v3.py
rename to cryptography/hazmat/bindings/openssl/x509v3.py
diff --git a/cryptography/hazmat/primitives/block/base.py b/cryptography/hazmat/primitives/block/base.py
index b4cc32a..ece3b32 100644
--- a/cryptography/hazmat/primitives/block/base.py
+++ b/cryptography/hazmat/primitives/block/base.py
@@ -21,7 +21,9 @@
super(BlockCipher, self).__init__()
if backend is None:
- from cryptography.bindings import _default_backend as backend
+ from cryptography.hazmat.bindings import (
+ _default_backend as backend,
+ )
self.cipher = cipher
self.mode = mode
diff --git a/cryptography/hazmat/primitives/hashes.py b/cryptography/hazmat/primitives/hashes.py
index 023041c..3ccb59d 100644
--- a/cryptography/hazmat/primitives/hashes.py
+++ b/cryptography/hazmat/primitives/hashes.py
@@ -23,7 +23,7 @@
class BaseHash(six.with_metaclass(abc.ABCMeta)):
def __init__(self, data=None, backend=None, ctx=None):
if backend is None:
- from cryptography.bindings import _default_backend
+ from cryptography.hazmat.bindings import _default_backend
backend = _default_backend
self._backend = backend
if ctx is None:
diff --git a/docs/architecture.rst b/docs/architecture.rst
index 8de8649..4cf639c 100644
--- a/docs/architecture.rst
+++ b/docs/architecture.rst
@@ -8,11 +8,11 @@
``cryptography`` has three different layers:
-* ``cryptography.bindings``: This package contains bindings to low level
- cryptographic libraries. Our initial target will be OpenSSL.
-* ``cryptography.hazmat.primitives``: This packages contains low level
- algorithms, things like ``AES`` or ``SHA1``. This is implemented on top of
- ``cryptography.bindings``.
* ``cryptography``: This package contains higher level recipes, for example
"encrypt and then MAC". This is implemented on top of
``cryptography.hazmat.primitives``.
+* ``cryptography.hazmat.primitives``: This packages contains low level
+ algorithms, things like ``AES`` or ``SHA1``. This is implemented on top of
+ ``cryptography.hazmat.bindings``.
+* ``cryptography.hazmat.bindings``: This package contains bindings to low level
+ cryptographic libraries. Our initial target will be OpenSSL.
diff --git a/docs/bindings/index.rst b/docs/hazmat/bindings/index.rst
similarity index 100%
rename from docs/bindings/index.rst
rename to docs/hazmat/bindings/index.rst
diff --git a/docs/bindings/openssl.rst b/docs/hazmat/bindings/openssl.rst
similarity index 93%
rename from docs/bindings/openssl.rst
rename to docs/hazmat/bindings/openssl.rst
index e59b0c1..5a00395 100644
--- a/docs/bindings/openssl.rst
+++ b/docs/hazmat/bindings/openssl.rst
@@ -10,7 +10,7 @@
These are `CFFI`_ bindings to the `OpenSSL`_ C library.
-.. data:: cryptography.bindings.openssl.backend
+.. data:: cryptography.hazmat.bindings.openssl.backend
This is the exposed API for the OpenSSL bindings. It has two public
attributes:
diff --git a/docs/index.rst b/docs/index.rst
index 47418ab..b2420a8 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -31,7 +31,6 @@
:maxdepth: 2
architecture
- bindings/index
contributing
security
community
@@ -43,3 +42,4 @@
:maxdepth: 2
hazmat/primitives/index
+ hazmat/bindings/index
diff --git a/tests/conftest.py b/tests/conftest.py
index d2ba03d..fab40b1 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,5 @@
def pytest_generate_tests(metafunc):
- from cryptography.bindings import _ALL_BACKENDS
+ from cryptography.hazmat.bindings import _ALL_BACKENDS
if "backend" in metafunc.fixturenames:
metafunc.parametrize("backend", _ALL_BACKENDS)
diff --git a/tests/bindings/__init__.py b/tests/hazmat/bindings/__init__.py
similarity index 100%
rename from tests/bindings/__init__.py
rename to tests/hazmat/bindings/__init__.py
diff --git a/tests/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py
similarity index 95%
rename from tests/bindings/test_openssl.py
rename to tests/hazmat/bindings/test_openssl.py
index 69ab38d..9ce882e 100644
--- a/tests/bindings/test_openssl.py
+++ b/tests/hazmat/bindings/test_openssl.py
@@ -13,7 +13,7 @@
import pytest
-from cryptography.bindings.openssl.backend import backend
+from cryptography.hazmat.bindings.openssl.backend import backend
from cryptography.hazmat.primitives.block.ciphers import AES
from cryptography.hazmat.primitives.block.modes import CBC
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index 110ca4b..797fe4f 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -19,8 +19,7 @@
import six
-from cryptography.bindings import _default_backend
-
+from cryptography.hazmat.bindings import _default_backend
from cryptography.hazmat.primitives import hashes
from .utils import generate_base_hash_test
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index 79d0aba..fabdca0 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -3,7 +3,7 @@
import pytest
-from cryptography.bindings import _ALL_BACKENDS
+from cryptography.hazmat.bindings import _ALL_BACKENDS
from cryptography.hazmat.primitives.block import BlockCipher