Merge pull request #188887 from wegank/yubikey-manager-darwin

authored by

Lassulus and committed by
GitHub
b90935e8 0f4f35c7

+52 -5
+11 -5
pkgs/tools/misc/yubikey-manager/default.nix
··· 1 - { python3Packages, fetchFromGitHub, lib, yubikey-personalization, libu2f-host, libusb1, procps }: 1 + { python3Packages, fetchFromGitHub, lib, yubikey-personalization, libu2f-host, libusb1, procps 2 + , stdenv, pyOpenSSLSupport ? !(stdenv.isDarwin && stdenv.isAarch64) }: 2 3 3 4 python3Packages.buildPythonPackage rec { 4 5 pname = "yubikey-manager"; ··· 12 13 sha256 = "sha256-MwM/b1QP6pkyBjz/r6oC4sW1mKC0CKMay45a0wCktk0="; 13 14 }; 14 15 16 + patches = lib.optionals (!pyOpenSSLSupport) [ 17 + ./remove-pyopenssl-tests.patch 18 + ]; 19 + 15 20 postPatch = '' 16 21 substituteInPlace pyproject.toml \ 17 22 --replace 'fido2 = ">=0.9, <1.0"' 'fido2 = ">*"' 18 23 substituteInPlace "ykman/pcsc/__init__.py" \ 19 - --replace 'pkill' '${procps}/bin/pkill' 24 + --replace 'pkill' '${if stdenv.isLinux then "${procps}" else "/usr"}/bin/pkill' 20 25 ''; 21 26 22 27 nativeBuildInputs = with python3Packages; [ poetry-core ]; 23 28 24 29 propagatedBuildInputs = 25 - with python3Packages; [ 30 + with python3Packages; ([ 26 31 click 27 32 cryptography 28 33 pyscard 29 34 pyusb 30 - pyopenssl 31 35 six 32 36 fido2 33 - ] ++ [ 37 + ] ++ lib.optionals pyOpenSSLSupport [ 38 + pyopenssl 39 + ]) ++ [ 34 40 libu2f-host 35 41 libusb1 36 42 yubikey-personalization
+41
pkgs/tools/misc/yubikey-manager/remove-pyopenssl-tests.patch
··· 1 + diff --git a/pyproject.toml b/pyproject.toml 2 + index 65a5943..e6932e0 100644 3 + --- a/pyproject.toml 4 + +++ b/pyproject.toml 5 + @@ -30,7 +30,6 @@ packages = [ 6 + python = "^3.6" 7 + dataclasses = {version = "^0.8", python = "<3.7"} 8 + cryptography = ">=2.1, <39" 9 + -pyOpenSSL = {version = ">=0.15.1", optional = true} 10 + pyscard = "^1.9 || ^2.0" 11 + fido2 = ">=0.9, <2.0" 12 + click = "^7.0 || ^8.0" 13 + diff --git a/tests/test_util.py b/tests/test_util.py 14 + index 6ccda6c..b4460e4 100644 15 + --- a/tests/test_util.py 16 + +++ b/tests/test_util.py 17 + @@ -8,7 +8,6 @@ from ykman.util import _parse_pkcs12_pyopenssl, _parse_pkcs12_cryptography 18 + from ykman.otp import format_oath_code, generate_static_pw, time_challenge 19 + from .util import open_file 20 + from cryptography.hazmat.primitives.serialization import pkcs12 21 + -from OpenSSL import crypto 22 + 23 + import unittest 24 + 25 + @@ -114,16 +113,6 @@ class TestUtilityFunctions(unittest.TestCase): 26 + ) as rsa_2048_key_cert_encrypted_pfx: 27 + self.assertTrue(is_pkcs12(rsa_2048_key_cert_encrypted_pfx.read())) 28 + 29 + - def test_parse_pkcs12(self): 30 + - with open_file("rsa_2048_key_cert.pfx") as rsa_2048_key_cert_pfx: 31 + - data = rsa_2048_key_cert_pfx.read() 32 + - 33 + - key1, certs1 = _parse_pkcs12_cryptography(pkcs12, data, None) 34 + - key2, certs2 = _parse_pkcs12_pyopenssl(crypto, data, None) 35 + - self.assertEqual(key1.private_numbers(), key2.private_numbers()) 36 + - self.assertEqual(1, len(certs1)) 37 + - self.assertEqual(certs1, certs2) 38 + - 39 + def test_is_pem(self): 40 + self.assertFalse(is_pem(b"just a byte string")) 41 + self.assertFalse(is_pem(None))