diff --git a/python/http_ece/__init__.py b/python/http_ece/__init__.py index b1f1435..d28935e 100644 --- a/python/http_ece/__init__.py +++ b/python/http_ece/__init__.py @@ -104,7 +104,7 @@ def length_prefix(key): if dh is not None: if private_key is None: raise ECEException("DH requires a private_key") - (secret, context) = derive_dh( + secret, context = derive_dh( mode=mode, version=version, private_key=private_key, @@ -273,7 +273,7 @@ def unpad(data, last): content = content_header["content"] overhead += 16 - (key_, nonce_) = derive_key( + key_, nonce_ = derive_key( "decrypt", version=version, salt=salt, @@ -391,7 +391,7 @@ def compose_aes128gcm(salt, content, rs, keyid): if salt is None: salt = os.urandom(16) - (key_, nonce_) = derive_key( + key_, nonce_ = derive_key( "encrypt", version=version, salt=salt, diff --git a/python/http_ece/tests/test_ece.py b/python/http_ece/tests/test_ece.py index 0ed980e..3d9f713 100644 --- a/python/http_ece/tests/test_ece.py +++ b/python/http_ece/tests/test_ece.py @@ -428,8 +428,8 @@ def _run(self, mode): inp = "encrypted" outp = "input" - for data in self.legacy_data: - logmsg("{}: {}".format(mode, data["test"])) + for version, data in self.legacy_data.items(): + logmsg("{}: {}".format(mode, data.get("test"))) p = data["params"][mode] if "pad" in p and mode == "encrypt": @@ -438,8 +438,10 @@ def _run(self, mode): if "keys" in data: key = None - decode_pub = ec.EllipticCurvePublicNumbers.from_encoded_point - pubnum = decode_pub(ec.SECP256R1(), b64d(data["keys"][local]["public"])) + decode_pub = ec.EllipticCurvePublicKey.from_encoded_point + pubnum = decode_pub( + ec.SECP256R1(), b64d(data["keys"][local]["public"]) + ).public_numbers() d = 0 dbin = b64d(data["keys"][local]["private"]) for i in range(0, len(dbin), 4): @@ -468,7 +470,7 @@ def _run(self, mode): keyid=p.get("keyid"), private_key=private_key, rs=p.get("rs", 4096), - version=p["version"], + version=p.get("version") or version, ) assert b64d(data[outp]) == result diff --git a/python/pyproject.toml b/python/pyproject.toml index dd27d91..9f07f0a 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -6,9 +6,7 @@ build-backend = "setuptools.build_meta" name = "http_ece" version = "1.2.1" license = "MIT" -authors = [ - { name = "Martin Thomson", email = "martin.thomson@gmail.com" } -] +authors = [{ name = "Martin Thomson", email = "martin.thomson@gmail.com" }] keywords = ["crypto http"] classifiers = [ "Development Status :: 4 - Beta", @@ -21,13 +19,11 @@ classifiers = [ description = "Encrypted Content Encoding for HTTP" readme = { file = "README.rst", content-type = "text/x-rst" } requires-python = ">=3.10" -dependencies = [ - "cryptography>=45.0.1" -] +dependencies = ["cryptography>=46.0.1"] [project.optional-dependencies] dev = [ - "black==25.12.0", + "black>=26.3.1", "pytest", "pytest-cov", "ruff==0.14.10", @@ -50,21 +46,9 @@ log_format = "%(asctime)s,%(msecs)03d %(name)s: %(levelname)s: %(message)s" log_file_date_format = "%H:%M:%S" [tool.ruff] -lint.select = [ - "A", - "F", - "FURB", - "I", - "PERF", - "PT", - "PTH", - "RUF", - "S", - "UP", -] +lint.select = ["A", "F", "FURB", "I", "PERF", "PT", "PTH", "RUF", "S", "UP"] [tool.ruff.lint.extend-per-file-ignores] -"**/tests/**" = [ - "A001", - "A002", - "S101", -] +"**/tests/**" = ["A001", "A002", "S101"] + +[tool.setuptools] +packages = ["http_ece"]