Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rules for accessing HID devices with libusb #6

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 41-nitrokey.rules
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ ACTION!="add|change", GOTO="u2f_end"

# Nitrokey U2F
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="f1d0", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="f1d0", TAG+="uaccess"
# Nitrokey FIDO U2F
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="4287", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="4287", TAG+="uaccess"
# Nitrokey FIDO2
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42b1", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42b1", TAG+="uaccess"
# Nitrokey 3A Mini/3A NFC/3C NFC
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42b2", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42b2", TAG+="uaccess"
# Nitrokey 3A NFC Bootloader/3C NFC Bootloader
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42dd", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42dd", TAG+="uaccess"
# Nitrokey 3A Mini Bootloader
ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42e8", TAG+="uaccess"
# Nitrokey Passkey
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42f3", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42f3", TAG+="uaccess"
# Nitrokey Passkey Bootloader
ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="42f4", TAG+="uaccess"

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Remove symlink rule for the Nitrokey Storage. Users are advised to use
label- or UUID-based mounting or setup a a custom rule for their device
instead.
- Add rules for accessing HID devices with libusb.

## [v1.0.0][] (2024-01-29)

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ check:
.PHONY: fix
fix:
$(RUFF) check --fix
$(PYRIGHT) format
$(RUFF) format

.PHONY: generate
generate:
Expand Down
12 changes: 6 additions & 6 deletions devices.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
name = "Nitrokey U2F"
vid = 0x2581
pid = 0xf1d0
hidraw = true
hid = true

[[u2f]]
name = "Nitrokey FIDO U2F"
vid = 0x20a0
pid = 0x4287
hidraw = true
hid = true

[[u2f]]
name = "Nitrokey FIDO2"
vid = 0x20a0
pid = 0x42b1
hidraw = true
hid = true

[[u2f]]
name = "Nitrokey 3A Mini/3A NFC/3C NFC"
vid = 0x20a0
pid = 0x42b2
hidraw = true
hid = true

[[u2f]]
name = "Nitrokey 3A NFC Bootloader/3C NFC Bootloader"
vid = 0x20a0
pid = 0x42dd
hidraw = true
hid = true

[[u2f]]
name = "Nitrokey 3A Mini Bootloader"
Expand All @@ -38,7 +38,7 @@ all = true
name = "Nitrokey Passkey"
vid = 0x20a0
pid = 0x42f3
hidraw = true
hid = true

[[u2f]]
name = "Nitrokey Passkey Bootloader"
Expand Down
5 changes: 3 additions & 2 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Device:
name: str
vid: int
pid: int
hidraw: bool = False
hid: bool = False
gnupg: bool = False
all: bool = False

Expand All @@ -25,12 +25,13 @@ def generate(self) -> str:
("ATTRS{idProduct}", "==", f"{self.pid:04x}"),
]
uaccess = [("TAG", "+=", "uaccess")]
if self.hidraw:
if self.hid:
s += generate_rule(
[("KERNEL", "==", "hidraw*"), ("SUBSYSTEM", "==", "hidraw")]
+ attrs_vid_pid
+ uaccess
)
s += generate_rule([("SUBSYSTEMS", "==", "usb")] + attrs_vid_pid + uaccess)
if self.gnupg:
s += generate_rule(
attr_vid_pid
Expand Down
Loading