From 6d5ed302ebc16061b4e3629db28a6dfe26bff859 Mon Sep 17 00:00:00 2001 From: Felix Erkinger Date: Mon, 18 Jul 2022 14:21:13 +0200 Subject: [PATCH] Fix "make init" and "pip install" after upstream fido2 library change - https://github.com/solokeys/solo1-cli/issues/151 --- .SRCINFO | 4 ++- 152.patch | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ PKGBUILD | 15 ++++++-- 3 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 152.patch diff --git a/.SRCINFO b/.SRCINFO index 0fc6367..700aee5 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = solo1 pkgdesc = Python tool and library for SoloKeys Solo 1 pkgver = 0.1.1 - pkgrel = 2 + pkgrel = 3 url = https://github.com/solokeys/solo1-cli arch = any license = Apache @@ -21,6 +21,8 @@ pkgbase = solo1 conflicts = solo-python replaces = solo-python source = solo1-cli-0.1.1.tar.gz::https://github.com/solokeys/solo1-cli/archive/refs/tags/0.1.1.tar.gz + source = 152.patch sha256sums = 377f0c244ee0efc741f18b3370cc0e5dcaff852db90102eeb258201128643c84 + sha256sums = SKIP pkgname = solo1 diff --git a/152.patch b/152.patch new file mode 100644 index 0000000..b0e5808 --- /dev/null +++ b/152.patch @@ -0,0 +1,101 @@ +From 02bb791f3c32c8f93a3f5bc4d256a5a6c77d7528 Mon Sep 17 00:00:00 2001 +From: Kendrick Shaw +Date: Thu, 9 Jun 2022 23:16:43 +0000 +Subject: [PATCH] Update to fido2 library 1.0 API + +The fido2 library has changed the names of the CTAP1 class to Ctap1 and +the CTAP2 class to Ctap2; this commit updates the solo1-cli code to use +the new names. +--- + solo/devices/base.py | 10 +++++----- + solo/devices/solo_v1.py | 8 ++++---- + solo/solotool.py | 4 ++-- + 3 files changed, 11 insertions(+), 11 deletions(-) + +diff --git a/solo/devices/base.py b/solo/devices/base.py +index 2e030f4..6afe01a 100644 +--- a/solo/devices/base.py ++++ b/solo/devices/base.py +@@ -3,7 +3,7 @@ + from cryptography import x509 + from cryptography.hazmat.backends import default_backend + from fido2.attestation import Attestation +-from fido2.ctap2 import CTAP2, CredentialManagement ++from fido2.ctap2 import Ctap2, CredentialManagement + from fido2.hid import CTAPHID + from fido2.utils import hmac_sha256 + from fido2.webauthn import PublicKeyCredentialCreationOptions +@@ -76,7 +76,7 @@ def ping(self, data="pong"): + def reset( + self, + ): +- CTAP2(self.get_current_hid_device()).reset() ++ Ctap2(self.get_current_hid_device()).reset() + + def change_pin(self, old_pin, new_pin): + client = self.get_current_fido_client() +@@ -114,7 +114,7 @@ def make_credential(self, pin=None): + def cred_mgmt(self, pin): + client = self.get_current_fido_client() + token = client.client_pin.get_pin_token(pin) +- ctap2 = CTAP2(self.get_current_hid_device()) ++ ctap2 = Ctap2(self.get_current_hid_device()) + return CredentialManagement(ctap2, client.client_pin.protocol, token) + + def enter_solo_bootloader( +@@ -137,11 +137,11 @@ def is_solo_bootloader( + pass + + def program_kbd(self, cmd): +- ctap2 = CTAP2(self.get_current_hid_device()) ++ ctap2 = Ctap2(self.get_current_hid_device()) + return ctap2.send_cbor(0x51, cmd) + + def sign_hash(self, credential_id, dgst, pin): +- ctap2 = CTAP2(self.get_current_hid_device()) ++ ctap2 = Ctap2(self.get_current_hid_device()) + client = self.get_current_fido_client() + if pin: + pin_token = client.client_pin.get_pin_token(pin) +diff --git a/solo/devices/solo_v1.py b/solo/devices/solo_v1.py +index 0c4328f..fd64c22 100644 +--- a/solo/devices/solo_v1.py ++++ b/solo/devices/solo_v1.py +@@ -8,8 +8,8 @@ + + from fido2.client import Fido2Client + from fido2.ctap import CtapError +-from fido2.ctap1 import CTAP1 +-from fido2.ctap2 import CTAP2 ++from fido2.ctap1 import Ctap1 ++from fido2.ctap2 import Ctap2 + from fido2.hid import CTAPHID, CtapHidDevice + from intelhex import IntelHex + +@@ -64,9 +64,9 @@ def find_device(self, dev=None, solo_serial=None): + dev = devices[0] + self.dev = dev + +- self.ctap1 = CTAP1(dev) ++ self.ctap1 = Ctap1(dev) + try: +- self.ctap2 = CTAP2(dev) ++ self.ctap2 = Ctap2(dev) + except CtapError: + self.ctap2 = None + +diff --git a/solo/solotool.py b/solo/solotool.py +index ca01454..9c4cddb 100644 +--- a/solo/solotool.py ++++ b/solo/solotool.py +@@ -32,8 +32,8 @@ + from fido2.attestation import Attestation + from fido2.client import ClientError, Fido2Client + from fido2.ctap import CtapError +-from fido2.ctap1 import CTAP1, ApduError +-from fido2.ctap2 import CTAP2 ++from fido2.ctap1 import Ctap1, ApduError ++from fido2.ctap2 import Ctap2 + from fido2.hid import CTAPHID, CtapHidDevice + from intelhex import IntelHex + diff --git a/PKGBUILD b/PKGBUILD index 85ed53e..8b46caf 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,7 +5,7 @@ pkgname=solo1 _pkgname=solo1-cli pkgver=0.1.1 -pkgrel=2 +pkgrel=3 pkgdesc="Python tool and library for SoloKeys Solo 1" arch=('any') url="https://github.com/solokeys/${_pkgname}" @@ -17,8 +17,17 @@ makedepends=('python-pip' 'python-flit') replaces=('solo-python') conflicts=('solo-python') provides=('solo-python') -source=("${_pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz") -sha256sums=('377f0c244ee0efc741f18b3370cc0e5dcaff852db90102eeb258201128643c84') +source=("${_pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz" + '152.patch') +sha256sums=('377f0c244ee0efc741f18b3370cc0e5dcaff852db90102eeb258201128643c84' + 'SKIP') + +prepare() { + cd "${srcdir}/${_pkgname}-${pkgver}" + # patch api change in python-fido2 > 0.9 + # https://github.com/solokeys/solo1-cli/pull/152 + patch -Np1 -i "${srcdir}/152.patch" +} build() { cd "${srcdir}/${_pkgname}-${pkgver}"