summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2022-12-20 21:44:47 -0500
committerGitHub <noreply@github.com>2022-12-21 09:44:47 +0700
commit7ff729ecf2ffeffc8442811a7ad5c8a9ab24351c (patch)
treed76a1971dcfa7ccf567bae9032799c475a955207
parent4868142f4193c441b4995f54c70caad7b06dc093 (diff)
downloadcryptography-7ff729ecf2ffeffc8442811a7ad5c8a9ab24351c.tar.gz
Switch from flake8 to ruff (#7920)
It's more than 60x faster.
-rw-r--r--.github/workflows/download_openssl.py1
-rw-r--r--docs/_ext/cryptography-docs.py1
-rw-r--r--docs/development/custom-vectors/arc4/generate_arc4.py1
-rw-r--r--docs/development/custom-vectors/rsa-oaep-sha2/generate_rsa_oaep_sha2.py1
-rw-r--r--docs/development/custom-vectors/secp256k1/generate_secp256k1.py1
-rw-r--r--docs/development/custom-vectors/secp256k1/verify_secp256k1.py1
-rw-r--r--docs/development/submitting-patches.rst2
-rw-r--r--pyproject.toml15
-rw-r--r--release.py1
-rw-r--r--setup.cfg10
-rw-r--r--src/_cffi_src/utils.py1
-rw-r--r--src/cryptography/__init__.py7
-rw-r--r--src/cryptography/hazmat/backends/openssl/__init__.py1
-rw-r--r--src/cryptography/hazmat/backends/openssl/aead.py1
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py17
-rw-r--r--src/cryptography/hazmat/backends/openssl/ciphers.py1
-rw-r--r--src/cryptography/hazmat/backends/openssl/cmac.py2
-rw-r--r--src/cryptography/hazmat/backends/openssl/dh.py1
-rw-r--r--src/cryptography/hazmat/backends/openssl/dsa.py7
-rw-r--r--src/cryptography/hazmat/backends/openssl/ed25519.py4
-rw-r--r--src/cryptography/hazmat/backends/openssl/hashes.py1
-rw-r--r--src/cryptography/hazmat/backends/openssl/hmac.py1
-rw-r--r--src/cryptography/hazmat/backends/openssl/poly1305.py1
-rw-r--r--src/cryptography/hazmat/backends/openssl/rsa.py9
-rw-r--r--src/cryptography/hazmat/bindings/_rust/__init__.pyi2
-rw-r--r--src/cryptography/hazmat/bindings/_rust/ocsp.pyi5
-rw-r--r--src/cryptography/hazmat/bindings/_rust/pkcs7.pyi2
-rw-r--r--src/cryptography/hazmat/bindings/_rust/x509.pyi1
-rw-r--r--src/cryptography/hazmat/primitives/_asymmetric.py1
-rw-r--r--src/cryptography/hazmat/primitives/_cipheralgorithm.py1
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/dh.py1
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/dsa.py4
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/ec.py4
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/ed25519.py1
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/rsa.py4
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/types.py1
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/utils.py1
-rw-r--r--src/cryptography/hazmat/primitives/ciphers/__init__.py1
-rw-r--r--src/cryptography/hazmat/primitives/ciphers/base.py1
-rw-r--r--src/cryptography/hazmat/primitives/cmac.py4
-rw-r--r--src/cryptography/hazmat/primitives/hashes.py4
-rw-r--r--src/cryptography/hazmat/primitives/hmac.py4
-rw-r--r--src/cryptography/hazmat/primitives/kdf/concatkdf.py5
-rw-r--r--src/cryptography/hazmat/primitives/kdf/hkdf.py5
-rw-r--r--src/cryptography/hazmat/primitives/kdf/scrypt.py1
-rw-r--r--src/cryptography/hazmat/primitives/kdf/x963kdf.py5
-rw-r--r--src/cryptography/hazmat/primitives/serialization/__init__.py1
-rw-r--r--src/cryptography/hazmat/primitives/serialization/pkcs12.py4
-rw-r--r--src/cryptography/hazmat/primitives/serialization/pkcs7.py3
-rw-r--r--src/cryptography/hazmat/primitives/twofactor/hotp.py1
-rw-r--r--src/cryptography/hazmat/primitives/twofactor/totp.py2
-rw-r--r--src/cryptography/x509/__init__.py15
-rw-r--r--src/cryptography/x509/base.py3
-rw-r--r--src/cryptography/x509/extensions.py8
-rw-r--r--src/cryptography/x509/general_name.py1
-rw-r--r--src/cryptography/x509/name.py4
-rw-r--r--src/cryptography/x509/ocsp.py3
-rw-r--r--src/cryptography/x509/oid.py5
-rw-r--r--tests/hazmat/backends/test_openssl.py2
-rw-r--r--tests/hazmat/backends/test_openssl_memleak.py1
-rw-r--r--tests/hazmat/primitives/fixtures_dsa.py1
-rw-r--r--tests/hazmat/primitives/fixtures_ec.py1
-rw-r--r--tests/hazmat/primitives/fixtures_rsa.py1
-rw-r--r--tests/hazmat/primitives/test_3des.py2
-rw-r--r--tests/hazmat/primitives/test_aead.py2
-rw-r--r--tests/hazmat/primitives/test_aes.py2
-rw-r--r--tests/hazmat/primitives/test_aes_gcm.py2
-rw-r--r--tests/hazmat/primitives/test_arc4.py2
-rw-r--r--tests/hazmat/primitives/test_block.py4
-rw-r--r--tests/hazmat/primitives/test_blowfish.py2
-rw-r--r--tests/hazmat/primitives/test_camellia.py2
-rw-r--r--tests/hazmat/primitives/test_cast5.py2
-rw-r--r--tests/hazmat/primitives/test_chacha20.py2
-rw-r--r--tests/hazmat/primitives/test_cmac.py11
-rw-r--r--tests/hazmat/primitives/test_concatkdf.py6
-rw-r--r--tests/hazmat/primitives/test_dh.py2
-rw-r--r--tests/hazmat/primitives/test_dsa.py4
-rw-r--r--tests/hazmat/primitives/test_ec.py4
-rw-r--r--tests/hazmat/primitives/test_hash_vectors.py2
-rw-r--r--tests/hazmat/primitives/test_hashes.py2
-rw-r--r--tests/hazmat/primitives/test_hkdf.py5
-rw-r--r--tests/hazmat/primitives/test_hkdf_vectors.py2
-rw-r--r--tests/hazmat/primitives/test_hmac.py2
-rw-r--r--tests/hazmat/primitives/test_hmac_vectors.py2
-rw-r--r--tests/hazmat/primitives/test_idea.py2
-rw-r--r--tests/hazmat/primitives/test_kbkdf.py2
-rw-r--r--tests/hazmat/primitives/test_kbkdf_vectors.py2
-rw-r--r--tests/hazmat/primitives/test_keywrap.py2
-rw-r--r--tests/hazmat/primitives/test_pbkdf2hmac_vectors.py2
-rw-r--r--tests/hazmat/primitives/test_rsa.py31
-rw-r--r--tests/hazmat/primitives/test_scrypt.py8
-rw-r--r--tests/hazmat/primitives/test_seed.py2
-rw-r--r--tests/hazmat/primitives/test_serialization.py10
-rw-r--r--tests/hazmat/primitives/test_sm4.py2
-rw-r--r--tests/hazmat/primitives/twofactor/test_hotp.py5
-rw-r--r--tests/hazmat/primitives/twofactor/test_totp.py5
-rw-r--r--tests/hazmat/primitives/utils.py2
-rw-r--r--tests/test_fernet.py5
-rw-r--r--tests/test_utils.py4
-rw-r--r--tests/utils.py4
-rw-r--r--tests/wycheproof/test_aes.py2
-rw-r--r--tests/wycheproof/test_chacha20poly1305.py2
-rw-r--r--tests/wycheproof/test_dsa.py1
-rw-r--r--tests/wycheproof/test_ecdh.py3
-rw-r--r--tests/wycheproof/test_ecdsa.py1
-rw-r--r--tests/wycheproof/test_hkdf.py1
-rw-r--r--tests/wycheproof/test_hmac.py1
-rw-r--r--tests/wycheproof/test_rsa.py1
-rw-r--r--tests/x509/test_ocsp.py2
-rw-r--r--tests/x509/test_x509.py1
-rw-r--r--tests/x509/test_x509_crlbuilder.py3
-rw-r--r--tests/x509/test_x509_ext.py3
-rw-r--r--tests/x509/test_x509_revokedcertbuilder.py1
-rw-r--r--tox.ini2
-rw-r--r--vectors/cryptography_vectors/__init__.py1
-rw-r--r--vectors/setup.py1
116 files changed, 133 insertions, 247 deletions
diff --git a/.github/workflows/download_openssl.py b/.github/workflows/download_openssl.py
index 0e6f66286..3be39084b 100644
--- a/.github/workflows/download_openssl.py
+++ b/.github/workflows/download_openssl.py
@@ -9,7 +9,6 @@ import time
import zipfile
import requests
-
from urllib3.util.retry import Retry
diff --git a/docs/_ext/cryptography-docs.py b/docs/_ext/cryptography-docs.py
index 1131f6a0e..43a9c6cb8 100644
--- a/docs/_ext/cryptography-docs.py
+++ b/docs/_ext/cryptography-docs.py
@@ -5,7 +5,6 @@
from docutils import nodes
from docutils.parsers.rst import Directive
-
DANGER_MESSAGE = """
This is a "Hazardous Materials" module. You should **ONLY** use it if you're
100% absolutely sure that you know what you're doing because this module is
diff --git a/docs/development/custom-vectors/arc4/generate_arc4.py b/docs/development/custom-vectors/arc4/generate_arc4.py
index 14a99d050..504d19643 100644
--- a/docs/development/custom-vectors/arc4/generate_arc4.py
+++ b/docs/development/custom-vectors/arc4/generate_arc4.py
@@ -7,7 +7,6 @@ import binascii
from cryptography.hazmat.primitives import ciphers
from cryptography.hazmat.primitives.ciphers import algorithms
-
_RFC6229_KEY_MATERIALS = [
(
True,
diff --git a/docs/development/custom-vectors/rsa-oaep-sha2/generate_rsa_oaep_sha2.py b/docs/development/custom-vectors/rsa-oaep-sha2/generate_rsa_oaep_sha2.py
index 009ba7fc7..6940f0400 100644
--- a/docs/development/custom-vectors/rsa-oaep-sha2/generate_rsa_oaep_sha2.py
+++ b/docs/development/custom-vectors/rsa-oaep-sha2/generate_rsa_oaep_sha2.py
@@ -8,7 +8,6 @@ import os
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding, rsa
-
from tests.utils import load_pkcs1_vectors, load_vectors_from_file
diff --git a/docs/development/custom-vectors/secp256k1/generate_secp256k1.py b/docs/development/custom-vectors/secp256k1/generate_secp256k1.py
index 2f1f69e94..ab616de7f 100644
--- a/docs/development/custom-vectors/secp256k1/generate_secp256k1.py
+++ b/docs/development/custom-vectors/secp256k1/generate_secp256k1.py
@@ -7,7 +7,6 @@ from ecdsa import SECP256k1, SigningKey
from ecdsa.util import sigdecode_der, sigencode_der
from cryptography_vectors import open_vector_file
-
from tests.utils import load_fips_ecdsa_signing_vectors, load_vectors_from_file
HASHLIB_HASH_TYPES = {
diff --git a/docs/development/custom-vectors/secp256k1/verify_secp256k1.py b/docs/development/custom-vectors/secp256k1/verify_secp256k1.py
index 3ba21c8d6..7949a74ee 100644
--- a/docs/development/custom-vectors/secp256k1/verify_secp256k1.py
+++ b/docs/development/custom-vectors/secp256k1/verify_secp256k1.py
@@ -5,7 +5,6 @@ from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.utils import (
encode_dss_signature,
)
-
from tests.utils import load_fips_ecdsa_signing_vectors, load_vectors_from_file
CRYPTOGRAPHY_HASH_TYPES = {
diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst
index 80a8bb496..4deaafe09 100644
--- a/docs/development/submitting-patches.rst
+++ b/docs/development/submitting-patches.rst
@@ -20,7 +20,7 @@ Code
When in doubt, refer to :pep:`8` for Python code. You can check if your code
meets our automated requirements by formatting it with ``black`` and running
-``flake8`` against it. If you've installed the development requirements this
+``ruff`` against it. If you've installed the development requirements this
will automatically use our configuration. You can also run the ``tox`` job with
``tox -e flake``.
diff --git a/pyproject.toml b/pyproject.toml
index 0fa34fb55..e099c2957 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -63,3 +63,18 @@ exclude_lines = [
"@typing.overload",
"if typing.TYPE_CHECKING",
]
+
+[tool.ruff]
+exclude = [
+ '.tox',
+ '*.egg',
+ '.git',
+ '_build',
+ '.hypothesis',
+]
+ignore = ['N818']
+select = ['E', 'F', 'I', 'N', 'W']
+line-length = 79
+
+[tool.ruff.isort]
+known-first-party = ["cryptography", "cryptography_vectors", "tests"]
diff --git a/release.py b/release.py
index e7445d951..5046daff1 100644
--- a/release.py
+++ b/release.py
@@ -10,7 +10,6 @@ import time
import zipfile
import click
-
import requests
diff --git a/setup.cfg b/setup.cfg
index d42e78930..07cce535b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -76,16 +76,8 @@ sdist =
setuptools_rust >= 0.11.4
pep8test =
black
- flake8
- flake8-import-order
- pep8-naming
+ ruff
# This extra is for OpenSSH private keys that use bcrypt KDF
# Versions: v3.1.3 - ignore_few_rounds, v3.1.5 - abi3
ssh =
bcrypt >= 3.1.5
-
-[flake8]
-ignore = E203,E211,W503,W504,N818
-exclude = .tox,*.egg,.git,_build,.hypothesis
-select = E,W,F,N,I
-application-import-names = cryptography,cryptography_vectors,tests
diff --git a/src/_cffi_src/utils.py b/src/_cffi_src/utils.py
index 5afc084a3..47d31b611 100644
--- a/src/_cffi_src/utils.py
+++ b/src/_cffi_src/utils.py
@@ -10,7 +10,6 @@ from distutils.dist import Distribution
from cffi import FFI
-
# Load the cryptography __about__ to get the current package version
base_src = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
about = {}
diff --git a/src/cryptography/__init__.py b/src/cryptography/__init__.py
index 6c0fd2a62..07c894ea3 100644
--- a/src/cryptography/__init__.py
+++ b/src/cryptography/__init__.py
@@ -5,14 +5,9 @@
import sys
import warnings
-from cryptography.__about__ import (
- __author__,
- __copyright__,
- __version__,
-)
+from cryptography.__about__ import __author__, __copyright__, __version__
from cryptography.utils import CryptographyDeprecationWarning
-
__all__ = [
"__version__",
"__author__",
diff --git a/src/cryptography/hazmat/backends/openssl/__init__.py b/src/cryptography/hazmat/backends/openssl/__init__.py
index 31fd17c3b..42c4539df 100644
--- a/src/cryptography/hazmat/backends/openssl/__init__.py
+++ b/src/cryptography/hazmat/backends/openssl/__init__.py
@@ -5,5 +5,4 @@
from cryptography.hazmat.backends.openssl.backend import backend
-
__all__ = ["backend"]
diff --git a/src/cryptography/hazmat/backends/openssl/aead.py b/src/cryptography/hazmat/backends/openssl/aead.py
index aa106fc3a..5b0fd2217 100644
--- a/src/cryptography/hazmat/backends/openssl/aead.py
+++ b/src/cryptography/hazmat/backends/openssl/aead.py
@@ -6,7 +6,6 @@ import typing
from cryptography.exceptions import InvalidTag
-
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.backend import Backend
from cryptography.hazmat.primitives.ciphers.aead import (
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index caa545824..5294e5d14 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -16,10 +16,10 @@ from cryptography.hazmat.backends.openssl import aead
from cryptography.hazmat.backends.openssl.ciphers import _CipherContext
from cryptography.hazmat.backends.openssl.cmac import _CMACContext
from cryptography.hazmat.backends.openssl.dh import (
+ _dh_params_dup,
_DHParameters,
_DHPrivateKey,
_DHPublicKey,
- _dh_params_dup,
)
from cryptography.hazmat.backends.openssl.dsa import (
_DSAParameters,
@@ -57,9 +57,7 @@ from cryptography.hazmat.backends.openssl.x448 import (
_X448PrivateKey,
_X448PublicKey,
)
-from cryptography.hazmat.bindings._rust import (
- x509 as rust_x509,
-)
+from cryptography.hazmat.bindings._rust import x509 as rust_x509
from cryptography.hazmat.bindings.openssl import binding
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives._asymmetric import AsymmetricPadding
@@ -76,8 +74,8 @@ from cryptography.hazmat.primitives.asymmetric import (
from cryptography.hazmat.primitives.asymmetric.padding import (
MGF1,
OAEP,
- PKCS1v15,
PSS,
+ PKCS1v15,
)
from cryptography.hazmat.primitives.asymmetric.types import (
CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES,
@@ -93,9 +91,9 @@ from cryptography.hazmat.primitives.ciphers.algorithms import (
AES128,
AES256,
ARC4,
+ SM4,
Camellia,
ChaCha20,
- SM4,
TripleDES,
_BlowfishInternal,
_CAST5Internal,
@@ -109,21 +107,20 @@ from cryptography.hazmat.primitives.ciphers.modes import (
CTR,
ECB,
GCM,
- Mode,
OFB,
XTS,
+ Mode,
)
from cryptography.hazmat.primitives.kdf import scrypt
from cryptography.hazmat.primitives.serialization import ssh
from cryptography.hazmat.primitives.serialization.pkcs12 import (
+ _ALLOWED_PKCS12_TYPES,
+ _PKCS12_CAS_TYPES,
PBES,
PKCS12Certificate,
PKCS12KeyAndCertificates,
- _ALLOWED_PKCS12_TYPES,
- _PKCS12_CAS_TYPES,
)
-
_MemoryBIO = collections.namedtuple("_MemoryBIO", ["bio", "char_ptr"])
diff --git a/src/cryptography/hazmat/backends/openssl/ciphers.py b/src/cryptography/hazmat/backends/openssl/ciphers.py
index 1058de9f1..fd2b6612f 100644
--- a/src/cryptography/hazmat/backends/openssl/ciphers.py
+++ b/src/cryptography/hazmat/backends/openssl/ciphers.py
@@ -8,7 +8,6 @@ from cryptography.exceptions import InvalidTag, UnsupportedAlgorithm, _Reasons
from cryptography.hazmat.primitives import ciphers
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.backend import Backend
diff --git a/src/cryptography/hazmat/backends/openssl/cmac.py b/src/cryptography/hazmat/backends/openssl/cmac.py
index 35f50c5c4..6f7363294 100644
--- a/src/cryptography/hazmat/backends/openssl/cmac.py
+++ b/src/cryptography/hazmat/backends/openssl/cmac.py
@@ -13,8 +13,8 @@ from cryptography.hazmat.primitives import constant_time
from cryptography.hazmat.primitives.ciphers.modes import CBC
if typing.TYPE_CHECKING:
- from cryptography.hazmat.primitives import ciphers
from cryptography.hazmat.backends.openssl.backend import Backend
+ from cryptography.hazmat.primitives import ciphers
class _CMACContext:
diff --git a/src/cryptography/hazmat/backends/openssl/dh.py b/src/cryptography/hazmat/backends/openssl/dh.py
index 33fed6a40..c429c0239 100644
--- a/src/cryptography/hazmat/backends/openssl/dh.py
+++ b/src/cryptography/hazmat/backends/openssl/dh.py
@@ -8,7 +8,6 @@ from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import dh
-
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.backend import Backend
diff --git a/src/cryptography/hazmat/backends/openssl/dsa.py b/src/cryptography/hazmat/backends/openssl/dsa.py
index 8634b7256..15bd84a7b 100644
--- a/src/cryptography/hazmat/backends/openssl/dsa.py
+++ b/src/cryptography/hazmat/backends/openssl/dsa.py
@@ -10,11 +10,8 @@ from cryptography.hazmat.backends.openssl.utils import (
_calculate_digest_and_algorithm,
)
from cryptography.hazmat.primitives import hashes, serialization
-from cryptography.hazmat.primitives.asymmetric import (
- dsa,
- utils as asym_utils,
-)
-
+from cryptography.hazmat.primitives.asymmetric import dsa
+from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.backend import Backend
diff --git a/src/cryptography/hazmat/backends/openssl/ed25519.py b/src/cryptography/hazmat/backends/openssl/ed25519.py
index 0ed69245a..6f393e5b6 100644
--- a/src/cryptography/hazmat/backends/openssl/ed25519.py
+++ b/src/cryptography/hazmat/backends/openssl/ed25519.py
@@ -7,10 +7,10 @@ import typing
from cryptography import exceptions
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import (
- Ed25519PrivateKey,
- Ed25519PublicKey,
_ED25519_KEY_SIZE,
_ED25519_SIG_SIZE,
+ Ed25519PrivateKey,
+ Ed25519PublicKey,
)
if typing.TYPE_CHECKING:
diff --git a/src/cryptography/hazmat/backends/openssl/hashes.py b/src/cryptography/hazmat/backends/openssl/hashes.py
index 278b3815d..52d4646a7 100644
--- a/src/cryptography/hazmat/backends/openssl/hashes.py
+++ b/src/cryptography/hazmat/backends/openssl/hashes.py
@@ -7,7 +7,6 @@ import typing
from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
from cryptography.hazmat.primitives import hashes
-
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.backend import Backend
diff --git a/src/cryptography/hazmat/backends/openssl/hmac.py b/src/cryptography/hazmat/backends/openssl/hmac.py
index 5fd540747..ba3dfb53f 100644
--- a/src/cryptography/hazmat/backends/openssl/hmac.py
+++ b/src/cryptography/hazmat/backends/openssl/hmac.py
@@ -11,7 +11,6 @@ from cryptography.exceptions import (
)
from cryptography.hazmat.primitives import constant_time, hashes
-
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.backend import Backend
diff --git a/src/cryptography/hazmat/backends/openssl/poly1305.py b/src/cryptography/hazmat/backends/openssl/poly1305.py
index dd6d376f0..d0d44f6fd 100644
--- a/src/cryptography/hazmat/backends/openssl/poly1305.py
+++ b/src/cryptography/hazmat/backends/openssl/poly1305.py
@@ -7,7 +7,6 @@ import typing
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import constant_time
-
_POLY1305_TAG_SIZE = 16
_POLY1305_KEY_SIZE = 32
diff --git a/src/cryptography/hazmat/backends/openssl/rsa.py b/src/cryptography/hazmat/backends/openssl/rsa.py
index 694829d2c..e18bab3ff 100644
--- a/src/cryptography/hazmat/backends/openssl/rsa.py
+++ b/src/cryptography/hazmat/backends/openssl/rsa.py
@@ -14,15 +14,13 @@ from cryptography.hazmat.backends.openssl.utils import (
_calculate_digest_and_algorithm,
)
from cryptography.hazmat.primitives import hashes, serialization
-from cryptography.hazmat.primitives.asymmetric import (
- utils as asym_utils,
-)
+from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
from cryptography.hazmat.primitives.asymmetric.padding import (
- AsymmetricPadding,
MGF1,
OAEP,
- PKCS1v15,
PSS,
+ AsymmetricPadding,
+ PKCS1v15,
_Auto,
_DigestLength,
_MaxLength,
@@ -35,7 +33,6 @@ from cryptography.hazmat.primitives.asymmetric.rsa import (
RSAPublicNumbers,
)
-
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.backend import Backend
diff --git a/src/cryptography/hazmat/bindings/_rust/__init__.pyi b/src/cryptography/hazmat/bindings/_rust/__init__.pyi
index 94a37a20a..d7642fcc4 100644
--- a/src/cryptography/hazmat/bindings/_rust/__init__.pyi
+++ b/src/cryptography/hazmat/bindings/_rust/__init__.pyi
@@ -22,7 +22,7 @@ class FixedPool(typing.Generic[T]):
self,
create: typing.Callable[[], T],
) -> None: ...
- def acquire(self) -> PoolAcquisition[T]: ...
+ def acquire(self) -> "PoolAcquisition[T]": ...
class PoolAcquisition(typing.Generic[T]):
def __enter__(self) -> T: ...
diff --git a/src/cryptography/hazmat/bindings/_rust/ocsp.pyi b/src/cryptography/hazmat/bindings/_rust/ocsp.pyi
index acdea3dd2..47a037ade 100644
--- a/src/cryptography/hazmat/bindings/_rust/ocsp.pyi
+++ b/src/cryptography/hazmat/bindings/_rust/ocsp.pyi
@@ -4,15 +4,14 @@
import typing
-from cryptography.hazmat.primitives.asymmetric.types import PRIVATE_KEY_TYPES
from cryptography.hazmat.primitives import hashes
-from cryptography.x509 import Extension
+from cryptography.hazmat.primitives.asymmetric.types import PRIVATE_KEY_TYPES
from cryptography.x509.ocsp import (
OCSPRequest,
OCSPRequestBuilder,
OCSPResponse,
- OCSPResponseStatus,
OCSPResponseBuilder,
+ OCSPResponseStatus,
)
def load_der_ocsp_request(data: bytes) -> OCSPRequest: ...
diff --git a/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi b/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi
index 6cbc0bcf7..66bd85098 100644
--- a/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi
+++ b/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi
@@ -1,8 +1,8 @@
import typing
+from cryptography import x509
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.serialization import pkcs7
-from cryptography import x509
def serialize_certificates(
certs: typing.List[x509.Certificate],
diff --git a/src/cryptography/hazmat/bindings/_rust/x509.pyi b/src/cryptography/hazmat/bindings/_rust/x509.pyi
index d92ea6c6a..1bbde8005 100644
--- a/src/cryptography/hazmat/bindings/_rust/x509.pyi
+++ b/src/cryptography/hazmat/bindings/_rust/x509.pyi
@@ -2,7 +2,6 @@
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
-import datetime
import typing
from cryptography import x509
diff --git a/src/cryptography/hazmat/primitives/_asymmetric.py b/src/cryptography/hazmat/primitives/_asymmetric.py
index cdadbdeff..c6862d931 100644
--- a/src/cryptography/hazmat/primitives/_asymmetric.py
+++ b/src/cryptography/hazmat/primitives/_asymmetric.py
@@ -4,7 +4,6 @@
import abc
-
# This exists to break an import cycle. It is normally accessible from the
# asymmetric padding module.
diff --git a/src/cryptography/hazmat/primitives/_cipheralgorithm.py b/src/cryptography/hazmat/primitives/_cipheralgorithm.py
index 7f322048d..6e6a79c11 100644
--- a/src/cryptography/hazmat/primitives/_cipheralgorithm.py
+++ b/src/cryptography/hazmat/primitives/_cipheralgorithm.py
@@ -5,7 +5,6 @@
import abc
import typing
-
# This exists to break an import cycle. It is normally accessible from the
# ciphers module.
diff --git a/src/cryptography/hazmat/primitives/asymmetric/dh.py b/src/cryptography/hazmat/primitives/asymmetric/dh.py
index 2093ad4a6..bbdd485cd 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/dh.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/dh.py
@@ -8,7 +8,6 @@ import typing
from cryptography.hazmat.primitives import _serialization
-
_MIN_MODULUS_SIZE = 512
diff --git a/src/cryptography/hazmat/primitives/asymmetric/dsa.py b/src/cryptography/hazmat/primitives/asymmetric/dsa.py
index 5e587097c..e013d6204 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/dsa.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/dsa.py
@@ -7,9 +7,7 @@ import abc
import typing
from cryptography.hazmat.primitives import _serialization, hashes
-from cryptography.hazmat.primitives.asymmetric import (
- utils as asym_utils,
-)
+from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
class DSAParameters(metaclass=abc.ABCMeta):
diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py
index 4d949da5e..062b33c34 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/ec.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py
@@ -9,9 +9,7 @@ import typing
from cryptography import utils
from cryptography.hazmat._oid import ObjectIdentifier
from cryptography.hazmat.primitives import _serialization, hashes
-from cryptography.hazmat.primitives.asymmetric import (
- utils as asym_utils,
-)
+from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
class EllipticCurveOID:
diff --git a/src/cryptography/hazmat/primitives/asymmetric/ed25519.py b/src/cryptography/hazmat/primitives/asymmetric/ed25519.py
index 432770283..220bf592c 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/ed25519.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/ed25519.py
@@ -8,7 +8,6 @@ import abc
from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
from cryptography.hazmat.primitives import _serialization
-
_ED25519_KEY_SIZE = 32
_ED25519_SIG_SIZE = 64
diff --git a/src/cryptography/hazmat/primitives/asymmetric/rsa.py b/src/cryptography/hazmat/primitives/asymmetric/rsa.py
index 36d360f22..433f925de 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/rsa.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/rsa.py
@@ -9,9 +9,7 @@ from math import gcd
from cryptography.hazmat.primitives import _serialization, hashes
from cryptography.hazmat.primitives._asymmetric import AsymmetricPadding
-from cryptography.hazmat.primitives.asymmetric import (
- utils as asym_utils,
-)
+from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
class RSAPrivateKey(metaclass=abc.ABCMeta):
diff --git a/src/cryptography/hazmat/primitives/asymmetric/types.py b/src/cryptography/hazmat/primitives/asymmetric/types.py
index d49781524..369fbf8f2 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/types.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/types.py
@@ -15,7 +15,6 @@ from cryptography.hazmat.primitives.asymmetric import (
x448,
)
-
# Every asymmetric key type
PUBLIC_KEY_TYPES = typing.Union[
dh.DHPublicKey,
diff --git a/src/cryptography/hazmat/primitives/asymmetric/utils.py b/src/cryptography/hazmat/primitives/asymmetric/utils.py
index 638ecb351..140ca1960 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/utils.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/utils.py
@@ -6,7 +6,6 @@
from cryptography.hazmat.bindings._rust import asn1
from cryptography.hazmat.primitives import hashes
-
decode_dss_signature = asn1.decode_dss_signature
encode_dss_signature = asn1.encode_dss_signature
diff --git a/src/cryptography/hazmat/primitives/ciphers/__init__.py b/src/cryptography/hazmat/primitives/ciphers/__init__.py
index 874dbd456..95f02842a 100644
--- a/src/cryptography/hazmat/primitives/ciphers/__init__.py
+++ b/src/cryptography/hazmat/primitives/ciphers/__init__.py
@@ -15,7 +15,6 @@ from cryptography.hazmat.primitives.ciphers.base import (
CipherContext,
)
-
__all__ = [
"Cipher",
"CipherAlgorithm",
diff --git a/src/cryptography/hazmat/primitives/ciphers/base.py b/src/cryptography/hazmat/primitives/ciphers/base.py
index 7af305249..886afa173 100644
--- a/src/cryptography/hazmat/primitives/ciphers/base.py
+++ b/src/cryptography/hazmat/primitives/ciphers/base.py
@@ -14,7 +14,6 @@ from cryptography.exceptions import (
from cryptography.hazmat.primitives._cipheralgorithm import CipherAlgorithm
from cryptography.hazmat.primitives.ciphers import modes
-
if typing.TYPE_CHECKING:
from cryptography.hazmat.backends.openssl.ciphers import (
_CipherContext as _BackendCipherContext,
diff --git a/src/cryptography/hazmat/primitives/cmac.py b/src/cryptography/hazmat/primitives/cmac.py
index 1ec756a8e..00c4bd11d 100644
--- a/src/cryptography/hazmat/primitives/cmac.py
+++ b/src/cryptography/hazmat/primitives/cmac.py
@@ -6,9 +6,7 @@
import typing
from cryptography import utils
-from cryptography.exceptions import (
- AlreadyFinalized,
-)
+from cryptography.exceptions import AlreadyFinalized
from cryptography.hazmat.primitives import ciphers
if typing.TYPE_CHECKING:
diff --git a/src/cryptography/hazmat/primitives/hashes.py b/src/cryptography/hazmat/primitives/hashes.py
index ba22a6646..440b1a3e9 100644
--- a/src/cryptography/hazmat/primitives/hashes.py
+++ b/src/cryptography/hazmat/primitives/hashes.py
@@ -6,9 +6,7 @@ import abc
import typing
from cryptography import utils
-from cryptography.exceptions import (
- AlreadyFinalized,
-)
+from cryptography.exceptions import AlreadyFinalized
class HashAlgorithm(metaclass=abc.ABCMeta):
diff --git a/src/cryptography/hazmat/primitives/hmac.py b/src/cryptography/hazmat/primitives/hmac.py
index 1577326c9..8f1c0eae6 100644
--- a/src/cryptography/hazmat/primitives/hmac.py
+++ b/src/cryptography/hazmat/primitives/hmac.py
@@ -6,9 +6,7 @@
import typing
from cryptography import utils
-from cryptography.exceptions import (
- AlreadyFinalized,
-)
+from cryptography.exceptions import AlreadyFinalized
from cryptography.hazmat.backends.openssl.hmac import _HMACContext
from cryptography.hazmat.primitives import hashes
diff --git a/src/cryptography/hazmat/primitives/kdf/concatkdf.py b/src/cryptography/hazmat/primitives/kdf/concatkdf.py
index 0b0262ebb..94312fec3 100644
--- a/src/cryptography/hazmat/primitives/kdf/concatkdf.py
+++ b/src/cryptography/hazmat/primitives/kdf/concatkdf.py
@@ -6,10 +6,7 @@
import typing
from cryptography import utils
-from cryptography.exceptions import (
- AlreadyFinalized,
- InvalidKey,
-)
+from cryptography.exceptions import AlreadyFinalized, InvalidKey
from cryptography.hazmat.primitives import constant_time, hashes, hmac
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
diff --git a/src/cryptography/hazmat/primitives/kdf/hkdf.py b/src/cryptography/hazmat/primitives/kdf/hkdf.py
index 44889b67b..2152ae220 100644
--- a/src/cryptography/hazmat/primitives/kdf/hkdf.py
+++ b/src/cryptography/hazmat/primitives/kdf/hkdf.py
@@ -6,10 +6,7 @@
import typing
from cryptography import utils
-from cryptography.exceptions import (
- AlreadyFinalized,
- InvalidKey,
-)
+from cryptography.exceptions import AlreadyFinalized, InvalidKey
from cryptography.hazmat.primitives import constant_time, hashes, hmac
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
diff --git a/src/cryptography/hazmat/primitives/kdf/scrypt.py b/src/cryptography/hazmat/primitives/kdf/scrypt.py
index ff81bbb1f..286f4388c 100644
--- a/src/cryptography/hazmat/primitives/kdf/scrypt.py
+++ b/src/cryptography/hazmat/primitives/kdf/scrypt.py
@@ -15,7 +15,6 @@ from cryptography.exceptions import (
from cryptography.hazmat.primitives import constant_time
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
-
# This is used by the scrypt tests to skip tests that require more memory
# than the MEM_LIMIT
_MEM_LIMIT = sys.maxsize // 2
diff --git a/src/cryptography/hazmat/primitives/kdf/x963kdf.py b/src/cryptography/hazmat/primitives/kdf/x963kdf.py
index aa6bcc1d1..651e691aa 100644
--- a/src/cryptography/hazmat/primitives/kdf/x963kdf.py
+++ b/src/cryptography/hazmat/primitives/kdf/x963kdf.py
@@ -6,10 +6,7 @@
import typing
from cryptography import utils
-from cryptography.exceptions import (
- AlreadyFinalized,
- InvalidKey,
-)
+from cryptography.exceptions import AlreadyFinalized, InvalidKey
from cryptography.hazmat.primitives import constant_time, hashes
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
diff --git a/src/cryptography/hazmat/primitives/serialization/__init__.py b/src/cryptography/hazmat/primitives/serialization/__init__.py
index 60241500c..af4112f39 100644
--- a/src/cryptography/hazmat/primitives/serialization/__init__.py
+++ b/src/cryptography/hazmat/primitives/serialization/__init__.py
@@ -26,7 +26,6 @@ from cryptography.hazmat.primitives.serialization.ssh import (
load_ssh_public_key,
)
-
__all__ = [
"load_der_parameters",
"load_der_private_key",
diff --git a/src/cryptography/hazmat/primitives/serialization/pkcs12.py b/src/cryptography/hazmat/primitives/serialization/pkcs12.py
index 662ea75af..b4d9a3436 100644
--- a/src/cryptography/hazmat/primitives/serialization/pkcs12.py
+++ b/src/cryptography/hazmat/primitives/serialization/pkcs12.py
@@ -14,9 +14,7 @@ from cryptography.hazmat.primitives.asymmetric import (
ed448,
rsa,
)
-from cryptography.hazmat.primitives.asymmetric.types import (
- PRIVATE_KEY_TYPES,
-)
+from cryptography.hazmat.primitives.asymmetric.types import PRIVATE_KEY_TYPES
__all__ = [
"PBES",
diff --git a/src/cryptography/hazmat/primitives/serialization/pkcs7.py b/src/cryptography/hazmat/primitives/serialization/pkcs7.py
index 5eaeab388..7e593e719 100644
--- a/src/cryptography/hazmat/primitives/serialization/pkcs7.py
+++ b/src/cryptography/hazmat/primitives/serialization/pkcs7.py
@@ -8,8 +8,7 @@ import email.message
import io
import typing
-from cryptography import utils
-from cryptography import x509
+from cryptography import utils, x509
from cryptography.hazmat.bindings._rust import pkcs7 as rust_pkcs7
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import ec, rsa
diff --git a/src/cryptography/hazmat/primitives/twofactor/hotp.py b/src/cryptography/hazmat/primitives/twofactor/hotp.py
index 9730af2b7..04c45bb8c 100644
--- a/src/cryptography/hazmat/primitives/twofactor/hotp.py
+++ b/src/cryptography/hazmat/primitives/twofactor/hotp.py
@@ -11,7 +11,6 @@ from cryptography.hazmat.primitives import constant_time, hmac
from cryptography.hazmat.primitives.hashes import SHA1, SHA256, SHA512
from cryptography.hazmat.primitives.twofactor import InvalidToken
-
_ALLOWED_HASH_TYPES = typing.Union[SHA1, SHA256, SHA512]
diff --git a/src/cryptography/hazmat/primitives/twofactor/totp.py b/src/cryptography/hazmat/primitives/twofactor/totp.py
index 317baba35..314dbef71 100644
--- a/src/cryptography/hazmat/primitives/twofactor/totp.py
+++ b/src/cryptography/hazmat/primitives/twofactor/totp.py
@@ -7,8 +7,8 @@ import typing
from cryptography.hazmat.primitives import constant_time
from cryptography.hazmat.primitives.twofactor import InvalidToken
from cryptography.hazmat.primitives.twofactor.hotp import (
- HOTP,
_ALLOWED_HASH_TYPES,
+ HOTP,
_generate_uri,
)
diff --git a/src/cryptography/x509/__init__.py b/src/cryptography/x509/__init__.py
index b3f6e608f..ad924ad42 100644
--- a/src/cryptography/x509/__init__.py
+++ b/src/cryptography/x509/__init__.py
@@ -32,19 +32,19 @@ from cryptography.x509.extensions import (
AuthorityInformationAccess,
AuthorityKeyIdentifier,
BasicConstraints,
+ CertificateIssuer,
+ CertificatePolicies,
CRLDistributionPoints,
CRLNumber,
CRLReason,
- CertificateIssuer,
- CertificatePolicies,
DeltaCRLIndicator,
DistributionPoint,
DuplicateExtension,
ExtendedKeyUsage,
Extension,
ExtensionNotFound,
- ExtensionType,
Extensions,
+ ExtensionType,
FreshestCRL,
GeneralNames,
InhibitAnyPolicy,
@@ -58,8 +58,8 @@ from cryptography.x509.extensions import (
OCSPNonce,
PolicyConstraints,
PolicyInformation,
- PrecertPoison,
PrecertificateSignedCertificateTimestamps,
+ PrecertPoison,
ReasonFlags,
SignedCertificateTimestamps,
SubjectAlternativeName,
@@ -71,13 +71,13 @@ from cryptography.x509.extensions import (
UserNotice,
)
from cryptography.x509.general_name import (
- DNSName,
DirectoryName,
+ DNSName,
GeneralName,
IPAddress,
OtherName,
- RFC822Name,
RegisteredID,
+ RFC822Name,
UniformResourceIdentifier,
UnsupportedGeneralNameType,
)
@@ -88,8 +88,8 @@ from cryptography.x509.name import (
)
from cryptography.x509.oid import (
AuthorityInformationAccessOID,
- CRLEntryExtensionOID,
CertificatePoliciesOID,
+ CRLEntryExtensionOID,
ExtendedKeyUsageOID,
ExtensionOID,
NameOID,
@@ -97,7 +97,6 @@ from cryptography.x509.oid import (
SignatureAlgorithmOID,
)
-
OID_AUTHORITY_INFORMATION_ACCESS = ExtensionOID.AUTHORITY_INFORMATION_ACCESS
OID_AUTHORITY_KEY_IDENTIFIER = ExtensionOID.AUTHORITY_KEY_IDENTIFIER
OID_BASIC_CONSTRAINTS = ExtensionOID.BASIC_CONSTRAINTS
diff --git a/src/cryptography/x509/base.py b/src/cryptography/x509/base.py
index 9c0aad530..49713f4c9 100644
--- a/src/cryptography/x509/base.py
+++ b/src/cryptography/x509/base.py
@@ -27,14 +27,13 @@ from cryptography.hazmat.primitives.asymmetric.types import (
)
from cryptography.x509.extensions import (
Extension,
- ExtensionType,
Extensions,
+ ExtensionType,
_make_sequence_methods,
)
from cryptography.x509.name import Name, _ASN1Type
from cryptography.x509.oid import ObjectIdentifier
-
_EARLIEST_UTC_TIME = datetime.datetime(1950, 1, 1)
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index 36be6f253..2012515f2 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -23,22 +23,22 @@ from cryptography.x509.certificate_transparency import (
SignedCertificateTimestamp,
)
from cryptography.x509.general_name import (
- DNSName,
+ _IPADDRESS_TYPES,
DirectoryName,
+ DNSName,
GeneralName,
IPAddress,
OtherName,
- RFC822Name,
RegisteredID,
+ RFC822Name,
UniformResourceIdentifier,
- _IPADDRESS_TYPES,
)
from cryptography.x509.name import Name, RelativeDistinguishedName
from cryptography.x509.oid import (
CRLEntryExtensionOID,
ExtensionOID,
- OCSPExtensionOID,
ObjectIdentifier,
+ OCSPExtensionOID,
)
ExtensionTypeVar = typing.TypeVar(
diff --git a/src/cryptography/x509/general_name.py b/src/cryptography/x509/general_name.py
index 9939233fe..a2f12b34b 100644
--- a/src/cryptography/x509/general_name.py
+++ b/src/cryptography/x509/general_name.py
@@ -11,7 +11,6 @@ from email.utils import parseaddr
from cryptography.x509.name import Name
from cryptography.x509.oid import ObjectIdentifier
-
_IPADDRESS_TYPES = typing.Union[
ipaddress.IPv4Address,
ipaddress.IPv6Address,
diff --git a/src/cryptography/x509/name.py b/src/cryptography/x509/name.py
index 702fb4b21..acd7c0f1e 100644
--- a/src/cryptography/x509/name.py
+++ b/src/cryptography/x509/name.py
@@ -9,9 +9,7 @@ import typing
import warnings
from cryptography import utils
-from cryptography.hazmat.bindings._rust import (
- x509 as rust_x509,
-)
+from cryptography.hazmat.bindings._rust import x509 as rust_x509
from cryptography.x509.oid import NameOID, ObjectIdentifier
diff --git a/src/cryptography/x509/ocsp.py b/src/cryptography/x509/ocsp.py
index 0e59fa4bc..4a08525a7 100644
--- a/src/cryptography/x509/ocsp.py
+++ b/src/cryptography/x509/ocsp.py
@@ -7,8 +7,7 @@ import abc
import datetime
import typing
-from cryptography import utils
-from cryptography import x509
+from cryptography import utils, x509
from cryptography.hazmat.bindings._rust import ocsp
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric.types import (
diff --git a/src/cryptography/x509/oid.py b/src/cryptography/x509/oid.py
index 9bfac75a4..0d91a5469 100644
--- a/src/cryptography/x509/oid.py
+++ b/src/cryptography/x509/oid.py
@@ -5,18 +5,17 @@
from cryptography.hazmat._oid import (
AttributeOID,
AuthorityInformationAccessOID,
- CRLEntryExtensionOID,
CertificatePoliciesOID,
+ CRLEntryExtensionOID,
ExtendedKeyUsageOID,
ExtensionOID,
NameOID,
- OCSPExtensionOID,
ObjectIdentifier,
+ OCSPExtensionOID,
SignatureAlgorithmOID,
SubjectInformationAccessOID,
)
-
__all__ = [
"AttributeOID",
"AuthorityInformationAccessOID",
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index a747f4d03..9879ca984 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -21,7 +21,6 @@ from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers.algorithms import AES
from cryptography.hazmat.primitives.ciphers.modes import CBC
-from ..primitives.fixtures_rsa import RSA_KEY_2048, RSA_KEY_512
from ...doubles import (
DummyAsymmetricPadding,
DummyBlockCipherAlgorithm,
@@ -34,6 +33,7 @@ from ...utils import (
load_vectors_from_file,
raises_unsupported_algorithm,
)
+from ..primitives.fixtures_rsa import RSA_KEY_2048, RSA_KEY_512
def skip_if_libre_ssl(openssl_version):
diff --git a/tests/hazmat/backends/test_openssl_memleak.py b/tests/hazmat/backends/test_openssl_memleak.py
index e23054a6e..ad5c4eb70 100644
--- a/tests/hazmat/backends/test_openssl_memleak.py
+++ b/tests/hazmat/backends/test_openssl_memleak.py
@@ -13,7 +13,6 @@ import pytest
from cryptography.hazmat.bindings.openssl.binding import Binding
-
MEMORY_LEAK_SCRIPT = """
import sys
diff --git a/tests/hazmat/primitives/fixtures_dsa.py b/tests/hazmat/primitives/fixtures_dsa.py
index eca0ec431..6675a2c10 100644
--- a/tests/hazmat/primitives/fixtures_dsa.py
+++ b/tests/hazmat/primitives/fixtures_dsa.py
@@ -9,7 +9,6 @@ from cryptography.hazmat.primitives.asymmetric.dsa import (
DSAPublicNumbers,
)
-
DSA_KEY_1024 = DSAPrivateNumbers(
public_numbers=DSAPublicNumbers(
parameter_numbers=DSAParameterNumbers(
diff --git a/tests/hazmat/primitives/fixtures_ec.py b/tests/hazmat/primitives/fixtures_ec.py
index 317c2ab24..fa671ac55 100644
--- a/tests/hazmat/primitives/fixtures_ec.py
+++ b/tests/hazmat/primitives/fixtures_ec.py
@@ -5,7 +5,6 @@
from cryptography.hazmat.primitives.asymmetric import ec
-
EC_KEY_SECT571R1 = ec.EllipticCurvePrivateNumbers(
private_value=int(
"213997069697108634621868251335076179190383272087548888968788698953"
diff --git a/tests/hazmat/primitives/fixtures_rsa.py b/tests/hazmat/primitives/fixtures_rsa.py
index f6b5c3b9f..09b32ab00 100644
--- a/tests/hazmat/primitives/fixtures_rsa.py
+++ b/tests/hazmat/primitives/fixtures_rsa.py
@@ -8,7 +8,6 @@ from cryptography.hazmat.primitives.asymmetric.rsa import (
RSAPublicNumbers,
)
-
RSA_KEY_512 = RSAPrivateNumbers(
p=int(
"d57846898d5c0de249c08467586cb458fa9bc417cdf297f73cfc52281b787cd9", 16
diff --git a/tests/hazmat/primitives/test_3des.py b/tests/hazmat/primitives/test_3des.py
index ea39a2102..007ecfe21 100644
--- a/tests/hazmat/primitives/test_3des.py
+++ b/tests/hazmat/primitives/test_3des.py
@@ -14,8 +14,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import generate_encrypt_test
from ...utils import load_nist_vectors
+from .utils import generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_aead.py b/tests/hazmat/primitives/test_aead.py
index b7a4aedf3..98ebae866 100644
--- a/tests/hazmat/primitives/test_aead.py
+++ b/tests/hazmat/primitives/test_aead.py
@@ -17,13 +17,13 @@ from cryptography.hazmat.primitives.ciphers.aead import (
ChaCha20Poly1305,
)
-from .utils import _load_all_params
from ...utils import (
load_nist_ccm_vectors,
load_nist_vectors,
load_vectors_from_file,
raises_unsupported_algorithm,
)
+from .utils import _load_all_params
class FakeData(bytes):
diff --git a/tests/hazmat/primitives/test_aes.py b/tests/hazmat/primitives/test_aes.py
index 9d68ef202..5798aefc6 100644
--- a/tests/hazmat/primitives/test_aes.py
+++ b/tests/hazmat/primitives/test_aes.py
@@ -10,9 +10,9 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, base, modes
-from .utils import _load_all_params, generate_encrypt_test
from ...doubles import DummyMode
from ...utils import load_nist_vectors
+from .utils import _load_all_params, generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_aes_gcm.py b/tests/hazmat/primitives/test_aes_gcm.py
index 9220e9e09..c1154a962 100644
--- a/tests/hazmat/primitives/test_aes_gcm.py
+++ b/tests/hazmat/primitives/test_aes_gcm.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, base, modes
-from .utils import generate_aead_test
from ...utils import load_nist_vectors
+from .utils import generate_aead_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_arc4.py b/tests/hazmat/primitives/test_arc4.py
index 5bc23f92e..b589518ad 100644
--- a/tests/hazmat/primitives/test_arc4.py
+++ b/tests/hazmat/primitives/test_arc4.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms
-from .utils import generate_stream_encryption_test
from ...utils import load_nist_vectors
+from .utils import generate_stream_encryption_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py
index fa2c4f52a..b831de176 100644
--- a/tests/hazmat/primitives/test_block.py
+++ b/tests/hazmat/primitives/test_block.py
@@ -15,12 +15,12 @@ from cryptography.hazmat.primitives.ciphers import (
modes,
)
+from ...doubles import DummyCipherAlgorithm, DummyMode
+from ...utils import raises_unsupported_algorithm
from .utils import (
generate_aead_exception_test,
generate_aead_tag_exception_test,
)
-from ...doubles import DummyCipherAlgorithm, DummyMode
-from ...utils import raises_unsupported_algorithm
class TestCipher:
diff --git a/tests/hazmat/primitives/test_blowfish.py b/tests/hazmat/primitives/test_blowfish.py
index 4ff8c1f2c..b8f34dfce 100644
--- a/tests/hazmat/primitives/test_blowfish.py
+++ b/tests/hazmat/primitives/test_blowfish.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import generate_encrypt_test
from ...utils import load_nist_vectors
+from .utils import generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_camellia.py b/tests/hazmat/primitives/test_camellia.py
index 8ec75510b..d6f1fca86 100644
--- a/tests/hazmat/primitives/test_camellia.py
+++ b/tests/hazmat/primitives/test_camellia.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import generate_encrypt_test
from ...utils import load_cryptrec_vectors, load_nist_vectors
+from .utils import generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_cast5.py b/tests/hazmat/primitives/test_cast5.py
index 6c6f0c884..a6f186a3c 100644
--- a/tests/hazmat/primitives/test_cast5.py
+++ b/tests/hazmat/primitives/test_cast5.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import generate_encrypt_test
from ...utils import load_nist_vectors
+from .utils import generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_chacha20.py b/tests/hazmat/primitives/test_chacha20.py
index 4dd1b08cd..5337465b9 100644
--- a/tests/hazmat/primitives/test_chacha20.py
+++ b/tests/hazmat/primitives/test_chacha20.py
@@ -11,8 +11,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms
-from .utils import _load_all_params
from ...utils import load_nist_vectors
+from .utils import _load_all_params
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_cmac.py b/tests/hazmat/primitives/test_cmac.py
index 9596705b1..c9e7fdd88 100644
--- a/tests/hazmat/primitives/test_cmac.py
+++ b/tests/hazmat/primitives/test_cmac.py
@@ -7,10 +7,7 @@ import binascii
import pytest
-from cryptography.exceptions import (
- AlreadyFinalized,
- InvalidSignature,
-)
+from cryptography.exceptions import AlreadyFinalized, InvalidSignature
from cryptography.hazmat.primitives.ciphers.algorithms import (
AES,
ARC4,
@@ -18,11 +15,7 @@ from cryptography.hazmat.primitives.ciphers.algorithms import (
)
from cryptography.hazmat.primitives.cmac import CMAC
-from ...utils import (
- load_nist_vectors,
- load_vectors_from_file,
-)
-
+from ...utils import load_nist_vectors, load_vectors_from_file
vectors_aes128 = load_vectors_from_file(
"CMAC/nist-800-38b-aes128.txt", load_nist_vectors
diff --git a/tests/hazmat/primitives/test_concatkdf.py b/tests/hazmat/primitives/test_concatkdf.py
index bd0117ce1..f0dd18828 100644
--- a/tests/hazmat/primitives/test_concatkdf.py
+++ b/tests/hazmat/primitives/test_concatkdf.py
@@ -9,8 +9,10 @@ import pytest
from cryptography.exceptions import AlreadyFinalized, InvalidKey
from cryptography.hazmat.primitives import hashes
-from cryptography.hazmat.primitives.kdf.concatkdf import ConcatKDFHMAC
-from cryptography.hazmat.primitives.kdf.concatkdf import ConcatKDFHash
+from cryptography.hazmat.primitives.kdf.concatkdf import (
+ ConcatKDFHash,
+ ConcatKDFHMAC,
+)
class TestConcatKDFHash:
diff --git a/tests/hazmat/primitives/test_dh.py b/tests/hazmat/primitives/test_dh.py
index 6e708676b..9a28d6114 100644
--- a/tests/hazmat/primitives/test_dh.py
+++ b/tests/hazmat/primitives/test_dh.py
@@ -13,9 +13,9 @@ import pytest
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import dh
-from .fixtures_dh import FFDH3072_P
from ...doubles import DummyKeySerializationEncryption
from ...utils import load_nist_vectors, load_vectors_from_file
+from .fixtures_dh import FFDH3072_P
# RFC 3526
P_1536 = int(
diff --git a/tests/hazmat/primitives/test_dsa.py b/tests/hazmat/primitives/test_dsa.py
index 424ffcee5..4ad4e9317 100644
--- a/tests/hazmat/primitives/test_dsa.py
+++ b/tests/hazmat/primitives/test_dsa.py
@@ -17,14 +17,14 @@ from cryptography.hazmat.primitives.asymmetric.utils import (
encode_dss_signature,
)
-from .fixtures_dsa import DSA_KEY_1024, DSA_KEY_2048, DSA_KEY_3072
-from .utils import skip_fips_traditional_openssl
from ...doubles import DummyHashAlgorithm, DummyKeySerializationEncryption
from ...utils import (
load_fips_dsa_key_pair_vectors,
load_fips_dsa_sig_vectors,
load_vectors_from_file,
)
+from .fixtures_dsa import DSA_KEY_1024, DSA_KEY_2048, DSA_KEY_3072
+from .utils import skip_fips_traditional_openssl
_ALGORITHMS_DICT: typing.Dict[str, hashes.HashAlgorithm] = {
"SHA1": hashes.SHA1(),
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py
index 3d488be17..142024459 100644
--- a/tests/hazmat/primitives/test_ec.py
+++ b/tests/hazmat/primitives/test_ec.py
@@ -20,8 +20,6 @@ from cryptography.hazmat.primitives.asymmetric.utils import (
encode_dss_signature,
)
-from .fixtures_ec import EC_KEY_SECP384R1
-from .utils import skip_fips_traditional_openssl
from ...doubles import DummyKeySerializationEncryption
from ...utils import (
load_fips_ecdsa_key_pair_vectors,
@@ -31,6 +29,8 @@ from ...utils import (
load_vectors_from_file,
raises_unsupported_algorithm,
)
+from .fixtures_ec import EC_KEY_SECP384R1
+from .utils import skip_fips_traditional_openssl
_HASH_TYPES: typing.Dict[str, typing.Type[hashes.HashAlgorithm]] = {
"SHA-1": hashes.SHA1,
diff --git a/tests/hazmat/primitives/test_hash_vectors.py b/tests/hazmat/primitives/test_hash_vectors.py
index d5916f061..bde811186 100644
--- a/tests/hazmat/primitives/test_hash_vectors.py
+++ b/tests/hazmat/primitives/test_hash_vectors.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives import hashes
-from .utils import _load_all_params, generate_hash_test
from ...utils import load_hash_vectors, load_nist_vectors
+from .utils import _load_all_params, generate_hash_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index 37744e745..1d096772a 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -10,9 +10,9 @@ import pytest
from cryptography.exceptions import AlreadyFinalized, _Reasons
from cryptography.hazmat.primitives import hashes
-from .utils import generate_base_hash_test
from ...doubles import DummyHashAlgorithm
from ...utils import raises_unsupported_algorithm
+from .utils import generate_base_hash_test
class TestHashContext:
diff --git a/tests/hazmat/primitives/test_hkdf.py b/tests/hazmat/primitives/test_hkdf.py
index cc001baf5..0bd5c97c4 100644
--- a/tests/hazmat/primitives/test_hkdf.py
+++ b/tests/hazmat/primitives/test_hkdf.py
@@ -12,10 +12,7 @@ from cryptography.exceptions import AlreadyFinalized, InvalidKey
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.hkdf import HKDF, HKDFExpand
-from ...utils import (
- load_nist_vectors,
- load_vectors_from_file,
-)
+from ...utils import load_nist_vectors, load_vectors_from_file
class TestHKDF:
diff --git a/tests/hazmat/primitives/test_hkdf_vectors.py b/tests/hazmat/primitives/test_hkdf_vectors.py
index 711d1b5ec..080aa1b5b 100644
--- a/tests/hazmat/primitives/test_hkdf_vectors.py
+++ b/tests/hazmat/primitives/test_hkdf_vectors.py
@@ -9,8 +9,8 @@ import pytest
from cryptography.hazmat.primitives import hashes
-from .utils import generate_hkdf_test
from ...utils import load_nist_vectors
+from .utils import generate_hkdf_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py
index 414385c5d..818ff2a7d 100644
--- a/tests/hazmat/primitives/test_hmac.py
+++ b/tests/hazmat/primitives/test_hmac.py
@@ -14,9 +14,9 @@ from cryptography.exceptions import (
)
from cryptography.hazmat.primitives import hashes, hmac
-from .utils import generate_base_hmac_test
from ...doubles import DummyHashAlgorithm
from ...utils import raises_unsupported_algorithm
+from .utils import generate_base_hmac_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_hmac_vectors.py b/tests/hazmat/primitives/test_hmac_vectors.py
index 703065a55..790993a34 100644
--- a/tests/hazmat/primitives/test_hmac_vectors.py
+++ b/tests/hazmat/primitives/test_hmac_vectors.py
@@ -9,8 +9,8 @@ import pytest
from cryptography.hazmat.primitives import hashes, hmac
-from .utils import generate_hmac_test
from ...utils import load_hash_vectors
+from .utils import generate_hmac_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_idea.py b/tests/hazmat/primitives/test_idea.py
index d591fe4e7..9817d5444 100644
--- a/tests/hazmat/primitives/test_idea.py
+++ b/tests/hazmat/primitives/test_idea.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import generate_encrypt_test
from ...utils import load_nist_vectors
+from .utils import generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_kbkdf.py b/tests/hazmat/primitives/test_kbkdf.py
index bb8ebea0d..4329e3df6 100644
--- a/tests/hazmat/primitives/test_kbkdf.py
+++ b/tests/hazmat/primitives/test_kbkdf.py
@@ -11,9 +11,9 @@ from cryptography.exceptions import AlreadyFinalized, InvalidKey, _Reasons
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.ciphers import algorithms
from cryptography.hazmat.primitives.kdf.kbkdf import (
- CounterLocation,
KBKDFCMAC,
KBKDFHMAC,
+ CounterLocation,
Mode,
)
diff --git a/tests/hazmat/primitives/test_kbkdf_vectors.py b/tests/hazmat/primitives/test_kbkdf_vectors.py
index fef75fe21..cab817bf4 100644
--- a/tests/hazmat/primitives/test_kbkdf_vectors.py
+++ b/tests/hazmat/primitives/test_kbkdf_vectors.py
@@ -5,8 +5,8 @@
import os
-from .utils import generate_kbkdf_counter_mode_test
from ...utils import load_nist_kbkdf_vectors
+from .utils import generate_kbkdf_counter_mode_test
class TestCounterKDFCounterMode:
diff --git a/tests/hazmat/primitives/test_keywrap.py b/tests/hazmat/primitives/test_keywrap.py
index b2fa05d74..7dfb80901 100644
--- a/tests/hazmat/primitives/test_keywrap.py
+++ b/tests/hazmat/primitives/test_keywrap.py
@@ -11,8 +11,8 @@ import pytest
from cryptography.hazmat.primitives import keywrap
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import _load_all_params
from ...utils import load_nist_vectors
+from .utils import _load_all_params
class TestAESKeyWrap:
diff --git a/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py b/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py
index f092894f5..60d2f864d 100644
--- a/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py
+++ b/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py
@@ -7,8 +7,8 @@ import pytest
from cryptography.hazmat.primitives import hashes
-from .utils import generate_pbkdf2_test
from ...utils import load_nist_vectors
+from .utils import generate_pbkdf2_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index 7a4b2f1e3..919331caf 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -15,16 +15,25 @@ from cryptography.exceptions import (
_Reasons,
)
from cryptography.hazmat.primitives import hashes, serialization
-from cryptography.hazmat.primitives.asymmetric import (
- padding,
- rsa,
- utils as asym_utils,
-)
+from cryptography.hazmat.primitives.asymmetric import padding, rsa
+from cryptography.hazmat.primitives.asymmetric import utils as asym_utils
from cryptography.hazmat.primitives.asymmetric.rsa import (
RSAPrivateNumbers,
RSAPublicNumbers,
)
+from ...doubles import (
+ DummyAsymmetricPadding,
+ DummyHashAlgorithm,
+ DummyKeySerializationEncryption,
+)
+from ...utils import (
+ load_nist_vectors,
+ load_pkcs1_vectors,
+ load_rsa_nist_vectors,
+ load_vectors_from_file,
+ raises_unsupported_algorithm,
+)
from .fixtures_rsa import (
RSA_KEY_1024,
RSA_KEY_1025,
@@ -48,18 +57,6 @@ from .utils import (
generate_rsa_verification_test,
skip_fips_traditional_openssl,
)
-from ...doubles import (
- DummyAsymmetricPadding,
- DummyHashAlgorithm,
- DummyKeySerializationEncryption,
-)
-from ...utils import (
- load_nist_vectors,
- load_pkcs1_vectors,
- load_rsa_nist_vectors,
- load_vectors_from_file,
- raises_unsupported_algorithm,
-)
class DummyMGF(padding.MGF):
diff --git a/tests/hazmat/primitives/test_scrypt.py b/tests/hazmat/primitives/test_scrypt.py
index 6e95a1f26..4b4641854 100644
--- a/tests/hazmat/primitives/test_scrypt.py
+++ b/tests/hazmat/primitives/test_scrypt.py
@@ -8,12 +8,8 @@ import os
import pytest
-from cryptography.exceptions import (
- AlreadyFinalized,
- InvalidKey,
-)
-from cryptography.hazmat.primitives.kdf.scrypt import Scrypt, _MEM_LIMIT
-
+from cryptography.exceptions import AlreadyFinalized, InvalidKey
+from cryptography.hazmat.primitives.kdf.scrypt import _MEM_LIMIT, Scrypt
from tests.utils import (
load_nist_vectors,
load_vectors_from_file,
diff --git a/tests/hazmat/primitives/test_seed.py b/tests/hazmat/primitives/test_seed.py
index eb0b88c2a..9f68bc3fb 100644
--- a/tests/hazmat/primitives/test_seed.py
+++ b/tests/hazmat/primitives/test_seed.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import generate_encrypt_test
from ...utils import load_nist_vectors
+from .utils import generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py
index 3a08d5570..3f1a55c23 100644
--- a/tests/hazmat/primitives/test_serialization.py
+++ b/tests/hazmat/primitives/test_serialization.py
@@ -39,15 +39,11 @@ from cryptography.hazmat.primitives.serialization import (
)
from cryptography.hazmat.primitives.serialization.pkcs12 import PBES
-
-from .fixtures_rsa import RSA_KEY_2048
-from .test_ec import _skip_curve_unsupported
-from .utils import (
- _check_dsa_private_numbers,
- _check_rsa_private_numbers,
-)
from ...doubles import DummyKeySerializationEncryption
from ...utils import load_vectors_from_file, raises_unsupported_algorithm
+from .fixtures_rsa import RSA_KEY_2048
+from .test_ec import _skip_curve_unsupported
+from .utils import _check_dsa_private_numbers, _check_rsa_private_numbers
def _skip_fips_format(key_path, password, backend):
diff --git a/tests/hazmat/primitives/test_sm4.py b/tests/hazmat/primitives/test_sm4.py
index 07b0cc7f7..13d9b5051 100644
--- a/tests/hazmat/primitives/test_sm4.py
+++ b/tests/hazmat/primitives/test_sm4.py
@@ -9,8 +9,8 @@ import pytest
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-from .utils import generate_encrypt_test
from ...utils import load_nist_vectors
+from .utils import generate_encrypt_test
@pytest.mark.supported(
diff --git a/tests/hazmat/primitives/twofactor/test_hotp.py b/tests/hazmat/primitives/twofactor/test_hotp.py
index d1c6cb530..31e01a495 100644
--- a/tests/hazmat/primitives/twofactor/test_hotp.py
+++ b/tests/hazmat/primitives/twofactor/test_hotp.py
@@ -12,10 +12,7 @@ from cryptography.hazmat.primitives.hashes import MD5, SHA1
from cryptography.hazmat.primitives.twofactor import InvalidToken
from cryptography.hazmat.primitives.twofactor.hotp import HOTP
-from ....utils import (
- load_nist_vectors,
- load_vectors_from_file,
-)
+from ....utils import load_nist_vectors, load_vectors_from_file
vectors = load_vectors_from_file("twofactor/rfc-4226.txt", load_nist_vectors)
diff --git a/tests/hazmat/primitives/twofactor/test_totp.py b/tests/hazmat/primitives/twofactor/test_totp.py
index 3c8d6b372..f68a8339c 100644
--- a/tests/hazmat/primitives/twofactor/test_totp.py
+++ b/tests/hazmat/primitives/twofactor/test_totp.py
@@ -9,10 +9,7 @@ from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.twofactor import InvalidToken
from cryptography.hazmat.primitives.twofactor.totp import TOTP
-from ....utils import (
- load_nist_vectors,
- load_vectors_from_file,
-)
+from ....utils import load_nist_vectors, load_vectors_from_file
vectors = load_vectors_from_file("twofactor/rfc-6238.txt", load_nist_vectors)
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index c8021cc2f..aac7296e6 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -26,9 +26,9 @@ from cryptography.hazmat.primitives.ciphers import (
from cryptography.hazmat.primitives.ciphers.modes import GCM
from cryptography.hazmat.primitives.kdf.hkdf import HKDF, HKDFExpand
from cryptography.hazmat.primitives.kdf.kbkdf import (
- CounterLocation,
KBKDFCMAC,
KBKDFHMAC,
+ CounterLocation,
Mode,
)
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
diff --git a/tests/test_fernet.py b/tests/test_fernet.py
index 58dd77296..d4b1561a0 100644
--- a/tests/test_fernet.py
+++ b/tests/test_fernet.py
@@ -10,16 +10,13 @@ import os
import time
import iso8601
-
import pretend
-
import pytest
+import cryptography_vectors
from cryptography.fernet import Fernet, InvalidToken, MultiFernet
from cryptography.hazmat.primitives.ciphers import algorithms, modes
-import cryptography_vectors
-
def json_parametrize(keys, filename):
vector_file = cryptography_vectors.open_vector_file(
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 8b07c91b0..9f6e27150 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -9,14 +9,12 @@ import os
import textwrap
import pretend
-
import pytest
import cryptography
import cryptography.utils
-from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
-
import cryptography_vectors
+from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
from . import deprecated_module
from .utils import (
diff --git a/tests/utils.py b/tests/utils.py
index 6119d3f4d..405cfbc78 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -13,10 +13,8 @@ from contextlib import contextmanager
import pytest
-from cryptography.exceptions import UnsupportedAlgorithm
-
import cryptography_vectors
-
+from cryptography.exceptions import UnsupportedAlgorithm
HashVector = collections.namedtuple("HashVector", ["message", "digest"])
KeyedHashVector = collections.namedtuple(
diff --git a/tests/wycheproof/test_aes.py b/tests/wycheproof/test_aes.py
index 891d8df43..ce83fe3c0 100644
--- a/tests/wycheproof/test_aes.py
+++ b/tests/wycheproof/test_aes.py
@@ -12,8 +12,8 @@ from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.ciphers.aead import AESCCM, AESGCM
-from .utils import wycheproof_tests
from ..hazmat.primitives.test_aead import _aead_supported
+from .utils import wycheproof_tests
@wycheproof_tests("aes_cbc_pkcs5_test.json")
diff --git a/tests/wycheproof/test_chacha20poly1305.py b/tests/wycheproof/test_chacha20poly1305.py
index 7cb8ff50f..06d6fc76a 100644
--- a/tests/wycheproof/test_chacha20poly1305.py
+++ b/tests/wycheproof/test_chacha20poly1305.py
@@ -10,8 +10,8 @@ import pytest
from cryptography.exceptions import InvalidTag
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
-from .utils import wycheproof_tests
from ..hazmat.primitives.test_aead import _aead_supported
+from .utils import wycheproof_tests
@pytest.mark.skipif(
diff --git a/tests/wycheproof/test_dsa.py b/tests/wycheproof/test_dsa.py
index 3d31ee170..b7da82dc3 100644
--- a/tests/wycheproof/test_dsa.py
+++ b/tests/wycheproof/test_dsa.py
@@ -13,7 +13,6 @@ from cryptography.hazmat.primitives.asymmetric import dsa
from .utils import wycheproof_tests
-
_DIGESTS = {
"SHA-1": hashes.SHA1(),
"SHA-224": hashes.SHA224(),
diff --git a/tests/wycheproof/test_ecdh.py b/tests/wycheproof/test_ecdh.py
index 672863fe7..1de26cb26 100644
--- a/tests/wycheproof/test_ecdh.py
+++ b/tests/wycheproof/test_ecdh.py
@@ -11,9 +11,8 @@ from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ec
-from .utils import wycheproof_tests
from ..hazmat.primitives.test_ec import _skip_exchange_algorithm_unsupported
-
+from .utils import wycheproof_tests
_CURVES = {
"secp224r1": ec.SECP224R1(),
diff --git a/tests/wycheproof/test_ecdsa.py b/tests/wycheproof/test_ecdsa.py
index b2ec9dfec..ffdfcc461 100644
--- a/tests/wycheproof/test_ecdsa.py
+++ b/tests/wycheproof/test_ecdsa.py
@@ -13,7 +13,6 @@ from cryptography.hazmat.primitives.asymmetric import ec
from .utils import wycheproof_tests
-
_DIGESTS = {
"SHA-1": hashes.SHA1(),
"SHA-224": hashes.SHA224(),
diff --git a/tests/wycheproof/test_hkdf.py b/tests/wycheproof/test_hkdf.py
index 4886be0fe..3d54e44ff 100644
--- a/tests/wycheproof/test_hkdf.py
+++ b/tests/wycheproof/test_hkdf.py
@@ -12,7 +12,6 @@ from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from .utils import wycheproof_tests
-
_HASH_ALGORITHMS = {
"HKDF-SHA-1": hashes.SHA1(),
"HKDF-SHA-256": hashes.SHA256(),
diff --git a/tests/wycheproof/test_hmac.py b/tests/wycheproof/test_hmac.py
index 84b0c19a0..49fe772cb 100644
--- a/tests/wycheproof/test_hmac.py
+++ b/tests/wycheproof/test_hmac.py
@@ -12,7 +12,6 @@ from cryptography.hazmat.primitives import hashes, hmac
from .utils import wycheproof_tests
-
_HMAC_ALGORITHMS = {
"HMACSHA1": hashes.SHA1(),
"HMACSHA224": hashes.SHA224(),
diff --git a/tests/wycheproof/test_rsa.py b/tests/wycheproof/test_rsa.py
index e2b8426fd..56ec21bc0 100644
--- a/tests/wycheproof/test_rsa.py
+++ b/tests/wycheproof/test_rsa.py
@@ -13,7 +13,6 @@ from cryptography.hazmat.primitives.asymmetric import padding, rsa
from .utils import wycheproof_tests
-
_DIGESTS = {
"SHA-1": hashes.SHA1(),
"SHA-224": hashes.SHA224(),
diff --git a/tests/x509/test_ocsp.py b/tests/x509/test_ocsp.py
index 9090e5205..ade916195 100644
--- a/tests/x509/test_ocsp.py
+++ b/tests/x509/test_ocsp.py
@@ -15,9 +15,9 @@ from cryptography.hazmat.primitives.asymmetric import ec, ed25519, ed448, rsa
from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15
from cryptography.x509 import ocsp
-from .test_x509 import DummyExtension, _load_cert
from ..hazmat.primitives.fixtures_ec import EC_KEY_SECP256R1
from ..utils import load_vectors_from_file, raises_unsupported_algorithm
+from .test_x509 import DummyExtension, _load_cert
def _load_data(filename, loader):
diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py
index 8a92c297c..1de0f6c45 100644
--- a/tests/x509/test_x509.py
+++ b/tests/x509/test_x509.py
@@ -12,7 +12,6 @@ import os
import typing
import pytest
-
import pytz
from cryptography import utils, x509
diff --git a/tests/x509/test_x509_crlbuilder.py b/tests/x509/test_x509_crlbuilder.py
index e3e34285d..5960cdd3b 100644
--- a/tests/x509/test_x509_crlbuilder.py
+++ b/tests/x509/test_x509_crlbuilder.py
@@ -6,7 +6,6 @@
import datetime
import pytest
-
import pytz
from cryptography import x509
@@ -18,11 +17,11 @@ from cryptography.x509.oid import (
SignatureAlgorithmOID,
)
-from .test_x509 import DummyExtension
from ..hazmat.primitives.fixtures_dsa import DSA_KEY_2048
from ..hazmat.primitives.fixtures_ec import EC_KEY_SECP256R1
from ..hazmat.primitives.fixtures_rsa import RSA_KEY_2048, RSA_KEY_512
from ..hazmat.primitives.test_ec import _skip_curve_unsupported
+from .test_x509 import DummyExtension
class TestCertificateRevocationListBuilder:
diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py
index 7284a73be..d3276b7cd 100644
--- a/tests/x509/test_x509_ext.py
+++ b/tests/x509/test_x509_ext.py
@@ -10,7 +10,6 @@ import os
import typing
import pretend
-
import pytest
from cryptography import x509
@@ -37,10 +36,10 @@ from cryptography.x509.oid import (
SubjectInformationAccessOID,
)
-from .test_x509 import _load_cert
from ..hazmat.primitives.fixtures_rsa import RSA_KEY_2048
from ..hazmat.primitives.test_ec import _skip_curve_unsupported
from ..utils import load_vectors_from_file
+from .test_x509 import _load_cert
def _make_certbuilder(private_key):
diff --git a/tests/x509/test_x509_revokedcertbuilder.py b/tests/x509/test_x509_revokedcertbuilder.py
index b2facfa51..83a71ff9b 100644
--- a/tests/x509/test_x509_revokedcertbuilder.py
+++ b/tests/x509/test_x509_revokedcertbuilder.py
@@ -6,7 +6,6 @@
import datetime
import pytest
-
import pytz
from cryptography import x509
diff --git a/tox.ini b/tox.ini
index 546c6cdd6..5159c5a1a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -64,7 +64,7 @@ deps =
types-pytz
check-manifest
commands =
- flake8 .
+ ruff .
black --check .
check-manifest
mypy src/cryptography/ vectors/cryptography_vectors/ tests/
diff --git a/vectors/cryptography_vectors/__init__.py b/vectors/cryptography_vectors/__init__.py
index 1fe176754..443357b28 100644
--- a/vectors/cryptography_vectors/__init__.py
+++ b/vectors/cryptography_vectors/__init__.py
@@ -7,7 +7,6 @@ import typing
from cryptography_vectors.__about__ import __version__
-
__all__ = [
"__version__",
]
diff --git a/vectors/setup.py b/vectors/setup.py
index 68ff1cd8a..88d88a75d 100644
--- a/vectors/setup.py
+++ b/vectors/setup.py
@@ -6,5 +6,4 @@
from setuptools import setup
-
setup()