From: Theo Buehler Subject: py3-fastecdsa 2.3.2: help wanted with tests To: ports@openbsd.org Date: Sat, 24 Feb 2024 13:53:31 +0100 With the update from 2.3.1 to 2.3.2, the github repo contains json files with the test vectors. This is good because we no longer need to work around the attempt at grabbing the tests from the internet. It is also bad because those .json files didn't make it to the assets on pypi for some reason. Now I had to add two stupid patches to fix test failures since they look for the json files in the wrong place. Is there a way to avoid by passing some magic to MODPY_PYTEST_ARGS? (I'm not looking for a sed or perl equivalent of these patches) ../../build/lib.openbsd-7.5-amd64-cpython-310/fastecdsa/tests/test_whycheproof_vectors.py:19: FileNotFoundError filename = 'fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha512_test.json' @staticmethod def _get_tests(filename): > with open(filename) as f: E FileNotFoundError: [Errno 2] No such file or directory: 'fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha512_test.json' ../../build/lib.openbsd-7.5-amd64-cpython-310/fastecdsa/tests/test_whycheproof_vectors.py:19: FileNotFoundError Index: Makefile =================================================================== RCS file: /cvs/ports/security/py-fastecdsa/Makefile,v diff -u -p -r1.14 Makefile --- Makefile 19 Sep 2023 21:48:23 -0000 1.14 +++ Makefile 24 Feb 2024 12:44:44 -0000 @@ -1,10 +1,12 @@ COMMENT = fast elliptic curve digital signatures -MODPY_EGG_VERSION = 2.3.1 +MODPY_EGG_VERSION = 2.3.2 -DISTNAME = fastecdsa-${MODPY_EGG_VERSION} -PKGNAME = py-${DISTNAME} -DISTFILES += ${DISTNAME}.tar.gz +GH_ACCOUNT = AntonKueltz +GH_PROJECT = fastecdsa +GH_TAGNAME = v${MODPY_EGG_VERSION} + +PKGNAME = py-fastecdsa-${MODPY_EGG_VERSION} CATEGORIES = security @@ -12,11 +14,6 @@ HOMEPAGE = https://github.com/AntonKuel MAINTAINER = Theo Buehler -# Avoid fetching test cases from the internet during 'make test' -SITES.ietf = https://tools.ietf.org/rfc/ -DISTFILES.ietf += rfc6979.txt -EXTRACT_CASES = *.txt) cp ${FULLDISTDIR}/$$archive ${MODPY_TEST_DIR};; - # Unlicense PERMIT_PACKAGE = Yes @@ -24,7 +21,6 @@ WANTLIB = gmp pthread MODULES = lang/python -MODPY_PI = Yes MODPY_PYBUILD = setuptools MODPY_TEST_DIR = ${WRKSRC}/fastecdsa/tests MODPY_PYTEST_ARGS = --pyargs fastecdsa @@ -35,10 +31,5 @@ FLAVOR = python3 CFLAGS += -I${LOCALBASE}/include LIB_DEPENDS = devel/gmp,-main - -TEST_DEPENDS = security/wycheproof-testvectors - -post-patch: - ${SUBST_CMD} ${WRKSRC}/fastecdsa/tests/test_whycheproof_vectors.py .include Index: distinfo =================================================================== RCS file: /cvs/ports/security/py-fastecdsa/distinfo,v diff -u -p -r1.6 distinfo --- distinfo 28 Dec 2022 15:34:26 -0000 1.6 +++ distinfo 24 Feb 2024 12:09:04 -0000 @@ -1,4 +1,2 @@ -SHA256 (fastecdsa-2.3.1.tar.gz) = 8ZjORPaUbKuwKYip9J0U78QQ26XiEemDIbqdhzeyP/g= -SHA256 (rfc6979.txt) = RW6PF1WP29IG+Wi5b8bxtKceozGrMK0X9xGrOtqn1wE= -SIZE (fastecdsa-2.3.1.tar.gz) = 49403 -SIZE (rfc6979.txt) = 140386 +SHA256 (fastecdsa-2.3.2.tar.gz) = 5uTavH+u3fTR9WGxgqVWCKwzLOTHtnRmT1t9NgGzL5U= +SIZE (fastecdsa-2.3.2.tar.gz) = 1001338 Index: patches/patch-fastecdsa_tests_test_rfc6979_ecdsa_py =================================================================== RCS file: /cvs/ports/security/py-fastecdsa/patches/patch-fastecdsa_tests_test_rfc6979_ecdsa_py,v diff -u -p -r1.2 patch-fastecdsa_tests_test_rfc6979_ecdsa_py --- patches/patch-fastecdsa_tests_test_rfc6979_ecdsa_py 11 Mar 2022 19:53:55 -0000 1.2 +++ patches/patch-fastecdsa_tests_test_rfc6979_ecdsa_py 24 Feb 2024 12:42:22 -0000 @@ -1,15 +1,25 @@ -Use extra distfile instead of reaching out to the internet. - Index: fastecdsa/tests/test_rfc6979_ecdsa.py --- fastecdsa/tests/test_rfc6979_ecdsa.py.orig +++ fastecdsa/tests/test_rfc6979_ecdsa.py -@@ -11,7 +11,8 @@ from ..util import RFC6979 - class TestRFC6979ECDSA(TestCase): - @classmethod - def setUpClass(cls): -- cls.rfc6979_text = urlopen('https://tools.ietf.org/rfc/rfc6979.txt').read().decode() -+ with open('rfc6979.txt') as f: -+ cls.rfc6979_text = f.read() - cls.hash_lookup = { - '1': sha1, - '224': sha224, +@@ -57,16 +57,16 @@ class TestRFC6979ECDSA(TestCase): + self.assertEqual((test.r, test.s), sign(test.m, test_data.x, curve=curve, hashfunc=test.h)) + + def test_p192_rfc6979_ecdsa(self): +- self._run_test("fastecdsa/tests/vectors/rfc6979/P192.json", P192) ++ self._run_test("../../fastecdsa/tests/vectors/rfc6979/P192.json", P192) + + def test_p224_rfc6979_ecdsa(self): +- self._run_test("fastecdsa/tests/vectors/rfc6979/P224.json", P224) ++ self._run_test("../../fastecdsa/tests/vectors/rfc6979/P224.json", P224) + + def test_p256_rfc6979_ecdsa(self): +- self._run_test("fastecdsa/tests/vectors/rfc6979/P256.json", P256) ++ self._run_test("../../fastecdsa/tests/vectors/rfc6979/P256.json", P256) + + def test_p384_rfc6979_ecdsa(self): +- self._run_test("fastecdsa/tests/vectors/rfc6979/P384.json", P384) ++ self._run_test("../../fastecdsa/tests/vectors/rfc6979/P384.json", P384) + + def test_p521_rfc6979_ecdsa(self): +- self._run_test("fastecdsa/tests/vectors/rfc6979/P521.json", P521) ++ self._run_test("../../fastecdsa/tests/vectors/rfc6979/P521.json", P521) Index: patches/patch-fastecdsa_tests_test_whycheproof_vectors_py =================================================================== RCS file: /cvs/ports/security/py-fastecdsa/patches/patch-fastecdsa_tests_test_whycheproof_vectors_py,v diff -u -p -r1.3 patch-fastecdsa_tests_test_whycheproof_vectors_py --- patches/patch-fastecdsa_tests_test_whycheproof_vectors_py 11 Mar 2022 19:53:55 -0000 1.3 +++ patches/patch-fastecdsa_tests_test_whycheproof_vectors_py 24 Feb 2024 12:42:25 -0000 @@ -1,17 +1,155 @@ -Use the JSON files from security/wycheproof-testvectors instead of fetching -them from GitHub. - Index: fastecdsa/tests/test_whycheproof_vectors.py --- fastecdsa/tests/test_whycheproof_vectors.py.orig +++ fastecdsa/tests/test_whycheproof_vectors.py -@@ -25,7 +25,9 @@ class TestWycheproofEcdsaVerify(TestCase): - @staticmethod - def _get_tests(url): - try: -- test_raw = urlopen(url).read() -+ url = url.replace('https://raw.githubusercontent.com/google/wycheproof/master/', '${LOCALBASE}/share/wycheproof/') -+ with open(url) as f: -+ test_raw = f.read() - test_json = loads(test_raw) - return test_json["testGroups"] - except (JSONDecodeError, URLError) as error: +@@ -39,126 +39,126 @@ class TestWycheproofEcdsaVerify(TestCase): + self.assertFalse(test["result"] == "valid", test) + + def test_brainpool224r1_sha224(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP224r1_sha224_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP224r1_sha224_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, brainpoolP224r1, sha224) + + def test_brainpoolP256r1_sha256(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP256r1_sha256_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP256r1_sha256_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, brainpoolP256r1, sha256) + + def test_brainpoolP320r1_sha384(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP320r1_sha384_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP320r1_sha384_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, brainpoolP320r1, sha384) + + def test_brainpoolP384r1_sha384(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP384r1_sha384_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP384r1_sha384_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, brainpoolP384r1, sha384) + + def test_brainpoolP512r1_sha512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP512r1_sha512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_brainpoolP512r1_sha512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, brainpoolP512r1, sha512) + + def test_p224_sha224(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha224_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha224_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P224, sha224) + + def test_p224_sha256(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha256_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha256_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P224, sha256) + + def test_p224_sha3_224(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha3_224_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha3_224_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P224, sha3_224) + + def test_p224_sha3_256(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha3_256_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha3_256_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P224, sha3_256) + + def test_p224_sha3_512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha3_512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha3_512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P224, sha3_512) + + def test_p224_sha512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp224r1_sha512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P224, sha512) + + def test_secp256k1_sha256(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha256_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha256_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, secp256k1, sha256) + + def test_secp256k1_sha3_256(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha3_256_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha3_256_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, secp256k1, sha3_256) + + def test_secp256k1_sha3_512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha3_512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha3_512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, secp256k1, sha3_512) + + def test_secp256k1_sha512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256k1_sha512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, secp256k1, sha512) + + def test_p256_sha256(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha256_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha256_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P256, sha256) + + def test_p256_sha3_256(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha3_256_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha3_256_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P256, sha3_256) + + def test_p256_sha3_512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha3_512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha3_512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P256, sha3_512) + + def test_p256_sha512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp256r1_sha512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P256, sha512) + + def test_p384_sha384(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha384_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha384_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P384, sha384) + + def test_p384_sha3_384(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha3_384_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha3_384_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P384, sha3_384) + + def test_p384_sha3_512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha3_512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha3_512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P384, sha3_512) + + def test_p384_sha512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp384r1_sha512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P384, sha512) + + def test_p521_sha3_512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp521r1_sha3_512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp521r1_sha3_512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P521, sha3_512) + + def test_p521_sha512(self): +- filename = "fastecdsa/tests/vectors/whycheproof/ecdsa_secp521r1_sha512_test.json" ++ filename = "../../fastecdsa/tests/vectors/whycheproof/ecdsa_secp521r1_sha512_test.json" + tests = self._get_tests(filename) + self._test_runner(tests, P521, sha512)