Skip to content

Commit

Permalink
Add patches from upstream repository master branch
Browse files Browse the repository at this point in the history
There are a bunch of new devices added to the white list there.

Fixes QubesOS/qubes-issues#5400
  • Loading branch information
marmarek committed Jun 11, 2020
1 parent 3cf20ea commit 823d7a3
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 1 deletion.
46 changes: 46 additions & 0 deletions 0001-handing-write-failures-better.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From fbafa8fc169f64b4a55f1d110e12420ea6436840 Mon Sep 17 00:00:00 2001
From: Venkat Venkataraju <venkat.venkataraju@gmail.com>
Date: Thu, 16 Aug 2018 11:36:45 -0700
Subject: [PATCH 1/8] handing write failures better

---
u2flib_host/hid_transport.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/u2flib_host/hid_transport.py b/u2flib_host/hid_transport.py
index 2031405..ec97d06 100644
--- a/u2flib_host/hid_transport.py
+++ b/u2flib_host/hid_transport.py
@@ -159,6 +159,13 @@ class HIDDevice(U2FDevice):
def lock(self, lock_time=10):
self.call(CMD_LOCK, lock_time)

+ def _write_to_device(self, to_send):
+ expected = len(to_send)
+ actual = 0
+ while actual != expected:
+ actual = self.handle.write(to_send)
+ sleep(0.025)
+
def _send_req(self, cid, cmd, data):
size = len(data)
bc_l = int2byte(size & 0xff)
@@ -166,13 +173,13 @@ class HIDDevice(U2FDevice):
payload = cid + int2byte(TYPE_INIT | cmd) + bc_h + bc_l + \
data[:HID_RPT_SIZE - 7]
payload += b'\0' * (HID_RPT_SIZE - len(payload))
- self.handle.write([0] + [byte2int(c) for c in payload])
+ self._write_to_device([0] + [byte2int(c) for c in payload])
data = data[HID_RPT_SIZE - 7:]
seq = 0
while len(data) > 0:
payload = cid + int2byte(0x7f & seq) + data[:HID_RPT_SIZE - 5]
payload += b'\0' * (HID_RPT_SIZE - len(payload))
- self.handle.write([0] + [byte2int(c) for c in payload])
+ self._write_to_device([0] + [byte2int(c) for c in payload])
data = data[HID_RPT_SIZE - 5:]
seq += 1

--
2.21.3

49 changes: 49 additions & 0 deletions 0002-fix-test-for-test_init.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 59f98986a7ca52c2a9823db82c08bf73082c6268 Mon Sep 17 00:00:00 2001
From: Venkat Venkataraju <venkat.venkataraju@gmail.com>
Date: Fri, 17 Aug 2018 15:26:38 -0700
Subject: [PATCH 2/8] fix test for test_init

---
test/test_hid_transport.py | 1 +
u2flib_host/hid_transport.py | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/test_hid_transport.py b/test/test_hid_transport.py
index 26bc715..b31aeff 100644
--- a/test/test_hid_transport.py
+++ b/test/test_hid_transport.py
@@ -15,6 +15,7 @@ class TestHIDDevice(object):
self.cmd = payload[5] ^ hid_transport.TYPE_INIT
self.size = (payload[6] << 8) + payload[7]
self.data = list(map(int2byte, payload[8:(8 + self.size)]))
+ return len(payload)

def read(self, size):
self.response += [0] * (hid_transport.HID_RPT_SIZE - len(self.response) + 1)
diff --git a/u2flib_host/hid_transport.py b/u2flib_host/hid_transport.py
index ec97d06..e16eb20 100644
--- a/u2flib_host/hid_transport.py
+++ b/u2flib_host/hid_transport.py
@@ -159,13 +159,18 @@ class HIDDevice(U2FDevice):
def lock(self, lock_time=10):
self.call(CMD_LOCK, lock_time)

- def _write_to_device(self, to_send):
+ def _write_to_device(self, to_send, timeout=2.0):
expected = len(to_send)
actual = 0
+ stop_at = time() + timeout
while actual != expected:
+ if (time() > stop_at):
+ raise exc.DeviceError("Unable to send data to the device")
+
actual = self.handle.write(to_send)
sleep(0.025)

+
def _send_req(self, cid, cmd, data):
size = len(data)
bc_l = int2byte(size & 0xff)
--
2.21.3

25 changes: 25 additions & 0 deletions 0003-add-Google-Titan-Feitian-devices.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From bff89a63d567d6df8c941ad588b3b2cb92fff328 Mon Sep 17 00:00:00 2001
From: Devrandom <miron@basezero.com>
Date: Sun, 20 Oct 2019 04:17:16 +0200
Subject: [PATCH 3/8] add Google Titan (Feitian) devices

---
u2flib_host/hid_transport.py | 2 ++
1 file changed, 2 insertions(+)

diff --git a/u2flib_host/hid_transport.py b/u2flib_host/hid_transport.py
index e16eb20..20562b4 100644
--- a/u2flib_host/hid_transport.py
+++ b/u2flib_host/hid_transport.py
@@ -50,6 +50,8 @@ DEVICES = [
(0x1050, 0x0406), # YubiKey 4 U2F+CCID
(0x1050, 0x0407), # YubiKey 4 OTP+U2F+CCID
(0x2581, 0xf1d0), # Plug-Up U2F Security Key
+ (0x096e, 0x0858), # FT U2F
+ (0x096e, 0x085b), # FS ePass FIDO
]
HID_RPT_SIZE = 64

--
2.21.3

24 changes: 24 additions & 0 deletions 0004-Add-Feitian-Technologies-Inc.-ePass-FIDO-to-devices.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 111ed8a8fa0da001ef16c942d37edcef33f80805 Mon Sep 17 00:00:00 2001
From: Bryce Larson <blarson@saltstack.com>
Date: Wed, 23 Oct 2019 00:11:35 -0600
Subject: [PATCH 4/8] Add Feitian Technologies, Inc. ePass FIDO to devices

---
u2flib_host/hid_transport.py | 1 +
1 file changed, 1 insertion(+)

diff --git a/u2flib_host/hid_transport.py b/u2flib_host/hid_transport.py
index e16eb20..8b9a220 100644
--- a/u2flib_host/hid_transport.py
+++ b/u2flib_host/hid_transport.py
@@ -38,6 +38,7 @@ from u2flib_host.yubicommon.compat import byte2int, int2byte
from u2flib_host import exc

DEVICES = [
+ (0x096e, 0x0850), # Feitian Technologies, Inc. ePass FIDO
(0x1050, 0x0200), # Gnubby
(0x1050, 0x0113), # YubiKey NEO U2F
(0x1050, 0x0114), # YubiKey NEO OTP+U2F
--
2.21.3

36 changes: 36 additions & 0 deletions 0005-Add-Thetis-and-JaCarta-devices-close-36-close-39.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 91d0eb292ebf7490a1631dc7993d071401c48357 Mon Sep 17 00:00:00 2001
From: Dain Nilsson <dain@yubico.com>
Date: Wed, 6 Nov 2019 09:49:20 +0100
Subject: [PATCH 5/8] Add Thetis and JaCarta devices (close #36, close #39).

---
u2flib_host/hid_transport.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/u2flib_host/hid_transport.py b/u2flib_host/hid_transport.py
index adff200..eef954c 100644
--- a/u2flib_host/hid_transport.py
+++ b/u2flib_host/hid_transport.py
@@ -38,7 +38,6 @@ from u2flib_host.yubicommon.compat import byte2int, int2byte
from u2flib_host import exc

DEVICES = [
- (0x096e, 0x0850), # Feitian Technologies, Inc. ePass FIDO
(0x1050, 0x0200), # Gnubby
(0x1050, 0x0113), # YubiKey NEO U2F
(0x1050, 0x0114), # YubiKey NEO OTP+U2F
@@ -51,8 +50,11 @@ DEVICES = [
(0x1050, 0x0406), # YubiKey 4 U2F+CCID
(0x1050, 0x0407), # YubiKey 4 OTP+U2F+CCID
(0x2581, 0xf1d0), # Plug-Up U2F Security Key
+ (0x096e, 0x0850), # Feitian Technologies, Inc. ePass FIDO
(0x096e, 0x0858), # FT U2F
(0x096e, 0x085b), # FS ePass FIDO
+ (0x24dc, 0x0501), # JaCarta U2F
+ (0x1ea8, 0xf025), # Thetis U2F
]
HID_RPT_SIZE = 64

--
2.21.3

24 changes: 24 additions & 0 deletions 0006-Added-OnlyKey-device.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From e92c3cbd840b651ed4b9c50a9797393f6d3b0c70 Mon Sep 17 00:00:00 2001
From: Saswat Padhi <padhi@cs.ucla.edu>
Date: Sun, 24 Nov 2019 03:33:51 -0800
Subject: [PATCH 6/8] Added OnlyKey device

---
u2flib_host/hid_transport.py | 1 +
1 file changed, 1 insertion(+)

diff --git a/u2flib_host/hid_transport.py b/u2flib_host/hid_transport.py
index eef954c..4014aac 100644
--- a/u2flib_host/hid_transport.py
+++ b/u2flib_host/hid_transport.py
@@ -55,6 +55,7 @@ DEVICES = [
(0x096e, 0x085b), # FS ePass FIDO
(0x24dc, 0x0501), # JaCarta U2F
(0x1ea8, 0xf025), # Thetis U2F
+ (0x1d50, 0x60fc), # OnlyKey U2F
]
HID_RPT_SIZE = 64

--
2.21.3

24 changes: 24 additions & 0 deletions 0007-Add-Trezor-VID-PID-close-42.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 11ddd13557f0fe8bfa09d5b54e2427204dd58b8e Mon Sep 17 00:00:00 2001
From: Dain Nilsson <dain@yubico.com>
Date: Thu, 5 Dec 2019 13:24:46 +0100
Subject: [PATCH 7/8] Add Trezor VID/PID (close #42).

---
u2flib_host/hid_transport.py | 1 +
1 file changed, 1 insertion(+)

diff --git a/u2flib_host/hid_transport.py b/u2flib_host/hid_transport.py
index 4014aac..f7f71ca 100644
--- a/u2flib_host/hid_transport.py
+++ b/u2flib_host/hid_transport.py
@@ -56,6 +56,7 @@ DEVICES = [
(0x24dc, 0x0501), # JaCarta U2F
(0x1ea8, 0xf025), # Thetis U2F
(0x1d50, 0x60fc), # OnlyKey U2F
+ (0x1209, 0x53c1), # Trezor U2F/FIDO2
]
HID_RPT_SIZE = 64

--
2.21.3

36 changes: 36 additions & 0 deletions 0008-Add-reference-to-python-fido2-in-README.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 27dc866368f96f071c9edb3ba90bd628f14ad21c Mon Sep 17 00:00:00 2001
From: Dain Nilsson <dain@yubico.com>
Date: Thu, 5 Dec 2019 13:29:39 +0100
Subject: [PATCH 8/8] Add reference to python-fido2 in README.

---
README | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README b/README
index 56a02dd..478522c 100644
--- a/README
+++ b/README
@@ -1,6 +1,8 @@
== u2flib-host ==
Provides library functionality for communicating with a U2F device over USB.

+# NOTE: This project is superseded by https://github.com/Yubico/python-fido2
+
Two executables are provided, u2f-register and u2f-authenticate, which support
the register and authenticated commands of U2F as defined in the
http://fidoalliance.org/specifications/download[FIDO specifications].
@@ -58,8 +60,8 @@ for device in devices:

==== Executable use ====
The examples below use the soft U2F device to register and authenticate against
-the u2f_server example server from the
-http://developers.yubico.com/python-u2flib-server[python-u2flib-server] project.
+the u2f_server example server from the
+http://developers.yubico.com/python-u2flib-server[python-u2flib-server] project.
See that project for more details.
The register step will create a new U2F key pair and store the credential in
the soft_device.json file. The authenticate step will use this credential to
--
2.21.3

2 changes: 2 additions & 0 deletions Makefile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ source-debian-copy-in: SRC_FILE = $(ORIG_SRC)/python-u2flib-host-$(VERSION).tar
source-debian-copy-in:
cp -p $(SRC_FILE) $(ORIG_FILE)
tar xzf $(SRC_FILE) -C $(CHROOT_DIR)/$(DIST_SRC)/debian-pkg --strip-components=1
cp $(ORIG_SRC)/00*.patch $(CHROOT_DIR)/$(DIST_SRC)/debian-pkg/debian/patches/
cat $(ORIG_SRC)/debian-series.conf >> $(CHROOT_DIR)/$(DIST_SRC)/debian-pkg/debian/patches/series



Expand Down
8 changes: 8 additions & 0 deletions debian-series.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
0001-handing-write-failures-better.patch
0002-fix-test-for-test_init.patch
0003-add-Google-Titan-Feitian-devices.patch
0004-Add-Feitian-Technologies-Inc.-ePass-FIDO-to-devices.patch
0005-Add-Thetis-and-JaCarta-devices-close-36-close-39.patch
0006-Added-OnlyKey-device.patch
0007-Add-Trezor-VID-PID-close-42.patch
0008-Add-reference-to-python-fido2-in-README.patch
11 changes: 10 additions & 1 deletion python3-u2flib-host.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ License: None
URL: https://github.com/Yubico/python-u2flib-host
Source0: https://files.pythonhosted.org/packages/source/p/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch

Patch01: 0001-handing-write-failures-better.patch
Patch02: 0002-fix-test-for-test_init.patch
Patch03: 0003-add-Google-Titan-Feitian-devices.patch
Patch04: 0004-Add-Feitian-Technologies-Inc.-ePass-FIDO-to-devices.patch
Patch05: 0005-Add-Thetis-and-JaCarta-devices-close-36-close-39.patch
Patch06: 0006-Added-OnlyKey-device.patch
Patch07: 0007-Add-Trezor-VID-PID-close-42.patch
Patch08: 0008-Add-reference-to-python-fido2-in-README.patch

BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-cryptography >= 1.0
Expand All @@ -36,7 +45,7 @@ Pure Python implementation of U2F library for host, i.e. for communication
between client and token.

%prep
%autosetup -n %{pypi_name}-%{version}
%autosetup -n %{pypi_name}-%{version} -p1
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info

Expand Down

0 comments on commit 823d7a3

Please sign in to comment.