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

Event-based Transport/Token API / USB HID rewrite #324

Merged
merged 83 commits into from
Jul 10, 2023

Conversation

micolous
Copy link
Collaborator

@micolous micolous commented Jun 6, 2023

This rewrites most of the Transport/Token API to be event based (#214), and in the process, replaces hidapi with a homebrew implementation. The branch is called mozilla-hid because my original plan was to base it on authenticator-rs, but in the end I've rewritten most of that.

I'm only targetting Linux, macOS and Windows for now.

Main changes:

  • New USB HID API bindings (fido-hid-rs):

    • on Linux, this uses udev and the kernel hidraw interface
    • on macOS, this uses IOKit
    • on Windows, this uses the UWP HID API (available on Windows 10 and later); hidapi and authenticator-rs used the older Windows 2000 APIs which are not async friendly
  • Add event-based API for device enumeration (Transport::watch_tokens()), moved Bluetooth and NFC transports to it.

    This is now the only way to enumerate tokens for Bluetooth.

  • Started adding Bluetooth support to fido-key-manager. This is only really reliable on macOS at the moment.

  • NFC: work around a bug where macOS' login manager tries to access the PIV applet on tokens that we have an exclusive connection to, which causes some tokens to reset (if the command arrives after SELECT FIDO but before other commands).

  • Implement selection for CTAP 2.0/2.1-PRE authenticators

TODO list:


  • cargo test has been run and passes
  • documentation has been updated with relevant examples (if relevant)

@micolous micolous added the ctap2 Issues related to the CtapAuthenticator backend label Jun 6, 2023
@Firstyear
Copy link
Member

Looking really good <3

@Firstyear
Copy link
Member

This is getting pretty large, is there anything blocking it from merging? since we aren't planning to release just yet, did you want to rebase/commit and continue? What else do you think needs to be done?

@micolous
Copy link
Collaborator Author

I think this is pretty close to done, but there are still some broken things that I'm working through on the checklist. I'll probably split off some of the smaller things which aren't directly related to the rewrite into a separate PR; I just needed somewhere to stash notes for now.

@micolous micolous changed the title WIP: Event-based Transport/Token API / USB HID rewrite Event-based Transport/Token API / USB HID rewrite Jul 6, 2023
@micolous micolous marked this pull request as ready for review July 6, 2023 04:28
@micolous micolous merged commit 5a49ab5 into kanidm:master Jul 10, 2023
kikuomax pushed a commit to codemonger-io/webauthn-rs that referenced this pull request Nov 24, 2024
* WIP: windows usb hid

* basic windows HID works

* break things

* windows usb hotplug works!

* cleanup error handlers

* another stray error

* guard USB support

* document and tidy some things

* add platforms

* start macos support

* start wrapping types

* mac: hanging thread

* mac: needs a little more wires...

* event propagates

* mac: basics working, next is cleanup

* mac: unregister event handlers from correct thread

* mac: add synthetic enumeration_completed event

* mac: cleanup and improve tests

* more cleaning

* mac: more tidying, removed unneeded code...

* mac: reorganising functions

* mac: implement get_devices, remove debugging messages, more tidying

* mac: move IOHIDManager methods into impl

* mac: move methods into IOHIDHevice

* mac: replace enums

* mac: un-rename iohid symbols

* remove unused import

* start implementing linux

* rewrite descriptor parser to iterator model

* linux: update notes, remove unneeded code

* linux: implement device discovery

* linux: denoise

* use kernel definitions for types

* tidying, start rewriting fido-key-manager

* clean up some types, document linux behaviour

* nfc: start refactoring, add `info --watch` mode

* nfc: less noise

* fix up some NFC stuff, ignore silly readers

* nfc: improve enumeration

* start implementing bluetooth support again, fixing up a stupid macos PIV problem

* macos: clean up a bunch of imports and usage of std::thread

* delete a bunch of unused code

* split platform-specific USB HID code into its own library (WIP)

* tidy tidy

* exclude fido-hid-rs from first doc pass

* fixup linux issues, move errors into own file

* more tidying

* spawn_blocking on linux

* cleanup mac stuff

* clean up some dependency chains

* add dbus

* fix up clippy

* fake bluetooth events

* start migrating authenticate example

* WIP: macos broken, refactoring...

* refactor mac code to keep manager alive

* cleanup more mac stuff

* mac: delete more unneeded code

* typo

* fixup windows

* fixup linux

* docs updates, bluetooth tweaking

* fixup linux crosscompile

* linux again

* more linux

* Migrate NFC conformance test to new API

* tidy up conformance tests

* update cable_tunnel example for new API

* start implementing selection, roll back Transport name changes

* improve some windows things

* document selection

* type fun

* migrate more comands

* blah

* start openssl notes

* fido-key-manager: migrate fingerprints to new api

* add remaining fido-key-manager commands

* handle wine NFC stubs

* quiet clippy

* nfc stubs fix

* format code,

* fix up a bunch of broken

* cleanup more lint issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctap2 Issues related to the CtapAuthenticator backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants