[Buildroot] [PATCH next 3/7] package/python-spake2: new package
Julien Olivain
ju.o at free.fr
Sat Nov 19 22:42:21 UTC 2022
SPAKE2 password-authenticated key exchange (in pure python).
This library implements the SPAKE2 password-authenticated key
exchange ("PAKE") algorithm. This allows two parties, who share a
weak password, to safely derive a strong shared secret (and
therefore build an encrypted+authenticated channel).
https://github.com/warner/python-spake2
Signed-off-by: Julien Olivain <ju.o at free.fr>
---
DEVELOPERS | 3 +++
package/Config.in | 1 +
package/python-spake2/Config.in | 13 +++++++++++
package/python-spake2/python-spake2.hash | 5 +++++
package/python-spake2/python-spake2.mk | 14 ++++++++++++
.../tests/package/sample_python_spake2.py | 22 +++++++++++++++++++
.../tests/package/test_python_spake2.py | 11 ++++++++++
7 files changed, 69 insertions(+)
create mode 100644 package/python-spake2/Config.in
create mode 100644 package/python-spake2/python-spake2.hash
create mode 100644 package/python-spake2/python-spake2.mk
create mode 100644 support/testing/tests/package/sample_python_spake2.py
create mode 100644 support/testing/tests/package/test_python_spake2.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 1c08dbda48..ebbd0459b7 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1696,6 +1696,7 @@ F: package/python-distro/
F: package/python-gnupg/
F: package/python-hkdf/
F: package/python-pyalsa/
+F: package/python-spake2/
F: package/riscv-isa-sim/
F: package/tinycompress/
F: package/zynaddsubfx/
@@ -1703,6 +1704,7 @@ F: support/testing/tests/package/sample_python_distro.py
F: support/testing/tests/package/sample_python_hkdf.py
F: support/testing/tests/package/sample_python_gnupg.py
F: support/testing/tests/package/sample_python_pyalsa.py
+F: support/testing/tests/package/sample_python_spake2.py
F: support/testing/tests/package/test_hwloc.py
F: support/testing/tests/package/test_octave.py
F: support/testing/tests/package/test_ola.py
@@ -1711,6 +1713,7 @@ 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_python_spake2.py
N: Julien Viard de Galbert <julien at vdg.name>
F: package/dieharder/
diff --git a/package/Config.in b/package/Config.in
index ec7587a072..a1df1542c7 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1272,6 +1272,7 @@ menu "External python modules"
source "package/python-sockjs/Config.in"
source "package/python-sortedcontainers/Config.in"
source "package/python-soupsieve/Config.in"
+ source "package/python-spake2/Config.in"
source "package/python-spidev/Config.in"
source "package/python-sqlalchemy/Config.in"
source "package/python-sqliteschema/Config.in"
diff --git a/package/python-spake2/Config.in b/package/python-spake2/Config.in
new file mode 100644
index 0000000000..1c2e3a49af
--- /dev/null
+++ b/package/python-spake2/Config.in
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_PYTHON_SPAKE2
+ bool "python-spake2"
+ select BR2_PACKAGE_PYTHON_HKDF # runtime
+ help
+ SPAKE2 password-authenticated key exchange (in pure python).
+
+ This library implements the SPAKE2 password-authenticated
+ key exchange ("PAKE") algorithm. This allows two parties,
+ who share a weak password, to safely derive a strong shared
+ secret (and therefore build an encrypted+authenticated
+ channel).
+
+ https://github.com/warner/python-spake2
diff --git a/package/python-spake2/python-spake2.hash b/package/python-spake2/python-spake2.hash
new file mode 100644
index 0000000000..30052b1b36
--- /dev/null
+++ b/package/python-spake2/python-spake2.hash
@@ -0,0 +1,5 @@
+# md5, sha256 from https://pypi.org/pypi/spake2/json
+md5 0155bad518bb49c39994fe0b7d9fb32c spake2-0.8.tar.gz
+sha256 c17a614b29ee4126206e22181f70a406c618d3c6c62ca6d6779bce95e9c926f4 spake2-0.8.tar.gz
+# Locally computed sha256 checksums
+sha256 2a8a1200c3a2769d1815727f3b4439bd800f3bc88163118a36ff30b007d30031 LICENSE
diff --git a/package/python-spake2/python-spake2.mk b/package/python-spake2/python-spake2.mk
new file mode 100644
index 0000000000..99ce7dae13
--- /dev/null
+++ b/package/python-spake2/python-spake2.mk
@@ -0,0 +1,14 @@
+################################################################################
+#
+# python-spake2
+#
+################################################################################
+
+PYTHON_SPAKE2_VERSION = 0.8
+PYTHON_SPAKE2_SOURCE = spake2-$(PYTHON_SPAKE2_VERSION).tar.gz
+PYTHON_SPAKE2_SITE = https://files.pythonhosted.org/packages/60/0b/bb5eca8e18c38a10b1c207bbe6103df091e5cf7b3e5fdc0efbcad7b85b60
+PYTHON_SPAKE2_SETUP_TYPE = setuptools
+PYTHON_SPAKE2_LICENSE = MIT
+PYTHON_SPAKE2_LICENSE_FILES = LICENSE
+
+$(eval $(python-package))
diff --git a/support/testing/tests/package/sample_python_spake2.py b/support/testing/tests/package/sample_python_spake2.py
new file mode 100644
index 0000000000..49dd914ca8
--- /dev/null
+++ b/support/testing/tests/package/sample_python_spake2.py
@@ -0,0 +1,22 @@
+from binascii import hexlify
+
+from spake2 import SPAKE2_A, SPAKE2_B
+
+
+shared_password = b"This Is The Password!"
+
+alice = SPAKE2_A(shared_password)
+alice_msg = alice.start()
+
+bob = SPAKE2_B(shared_password)
+bob_msg = bob.start()
+
+# Alice and Bob exchange their messages...
+
+alice_key = alice.finish(bob_msg)
+bob_key = bob.finish(alice_msg)
+
+print("alice_key:", hexlify(alice_key))
+print(" bob_key:", hexlify(bob_key))
+
+assert alice_key == bob_key
diff --git a/support/testing/tests/package/test_python_spake2.py b/support/testing/tests/package/test_python_spake2.py
new file mode 100644
index 0000000000..fb47a0802c
--- /dev/null
+++ b/support/testing/tests/package/test_python_spake2.py
@@ -0,0 +1,11 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Spake2(TestPythonPackageBase):
+ __test__ = True
+ config = TestPythonPackageBase.config + \
+ """
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_SPAKE2=y
+ """
+ sample_scripts = ["tests/package/sample_python_spake2.py"]
--
2.38.1
More information about the buildroot
mailing list