diff --git a/DEVELOPERS b/DEVELOPERS index f10036f7f2..69e73636be 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1693,6 +1693,7 @@ F: package/perftest/ F: package/ptm2human/ F: package/python-distro/ F: package/python-gnupg/ +F: package/python-hkdf/ F: package/python-pyalsa/ F: package/rdma-core/ F: package/riscv-isa-sim/ @@ -1709,6 +1710,7 @@ F: support/testing/tests/package/test_ola.py F: support/testing/tests/package/test_ola/ F: support/testing/tests/package/test_perftest.py F: support/testing/tests/package/test_python_distro.py +F: support/testing/tests/package/test_python_hkdf.py F: support/testing/tests/package/test_python_gnupg.py F: support/testing/tests/package/test_python_pyalsa.py F: support/testing/tests/package/test_rdma_core.py diff --git a/package/Config.in b/package/Config.in index aa87f1305d..b28949500e 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1073,6 +1073,7 @@ menu "External python modules" source "package/python-h11/Config.in" source "package/python-h2/Config.in" source "package/python-hiredis/Config.in" + source "package/python-hkdf/Config.in" source "package/python-hpack/Config.in" source "package/python-html5lib/Config.in" source "package/python-httplib2/Config.in" diff --git a/package/python-hkdf/Config.in b/package/python-hkdf/Config.in new file mode 100644 index 0000000000..2add348ca2 --- /dev/null +++ b/package/python-hkdf/Config.in @@ -0,0 +1,7 @@ +config BR2_PACKAGE_PYTHON_HKDF + bool "python-hkdf" + help + HMAC-based Extract-and-Expand Key Derivation Function + (HKDF). + + https://github.com/casebeer/python-hkdf diff --git a/package/python-hkdf/python-hkdf.hash b/package/python-hkdf/python-hkdf.hash new file mode 100644 index 0000000000..87702b4582 --- /dev/null +++ b/package/python-hkdf/python-hkdf.hash @@ -0,0 +1,3 @@ +# md5, sha256 from https://pypi.org/pypi/hkdf/json +md5 d10471ad0ec891cdbe165d78282c943e hkdf-0.0.3.tar.gz +sha256 622a31c634bc185581530a4b44ffb731ed208acf4614f9c795bdd70e77991dca hkdf-0.0.3.tar.gz diff --git a/package/python-hkdf/python-hkdf.mk b/package/python-hkdf/python-hkdf.mk new file mode 100644 index 0000000000..8b68c5cc9f --- /dev/null +++ b/package/python-hkdf/python-hkdf.mk @@ -0,0 +1,17 @@ +################################################################################ +# +# python-hkdf +# +################################################################################ + +PYTHON_HKDF_VERSION = 0.0.3 +PYTHON_HKDF_SOURCE = hkdf-$(PYTHON_HKDF_VERSION).tar.gz +PYTHON_HKDF_SITE = https://files.pythonhosted.org/packages/c3/be/327e072850db181ce56afd51e26ec7aa5659b18466c709fa5ea2548c935f +PYTHON_HKDF_SETUP_TYPE = setuptools +# No license file in the tree, but +# https://github.com/casebeer/python-hkdf/blob/master/LICENSE shows +# it's BSD-2-Clause. Issue already reported upstream: +# https://github.com/casebeer/python-hkdf/issues/6 +PYTHON_HKDF_LICENSE = BSD-2-Clause + +$(eval $(python-package)) diff --git a/support/testing/tests/package/sample_python_hkdf.py b/support/testing/tests/package/sample_python_hkdf.py new file mode 100644 index 0000000000..a730c633e1 --- /dev/null +++ b/support/testing/tests/package/sample_python_hkdf.py @@ -0,0 +1,22 @@ +import hashlib +from binascii import hexlify, unhexlify + +from hkdf import Hkdf, hkdf_expand, hkdf_extract + +salt = b"ThisIsTheSalt." +key_in = b"ThisIsTheSecretKey" +key_info = b"KeyInfo1" +key_len = 16 +expected_key = unhexlify(b"b49d6cc9065b72f3a0859377d8bb7299") + +prk = hkdf_extract(salt, input_key_material=key_in, hash=hashlib.sha512) +key1 = hkdf_expand(prk, info=key_info, length=key_len) + +print("key1:", hexlify(key1)) +assert key1 == expected_key + +kdf = Hkdf(salt, input_key_material=key_in, hash=hashlib.sha512) +key2 = kdf.expand(info=key_info, length=key_len) + +print("key2:", hexlify(key2)) +assert key2 == expected_key diff --git a/support/testing/tests/package/test_python_hkdf.py b/support/testing/tests/package/test_python_hkdf.py new file mode 100644 index 0000000000..e93c24ff60 --- /dev/null +++ b/support/testing/tests/package/test_python_hkdf.py @@ -0,0 +1,11 @@ +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonPy3Hkdf(TestPythonPackageBase): + __test__ = True + config = TestPythonPackageBase.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_HKDF=y + """ + sample_scripts = ["tests/package/sample_python_hkdf.py"]