[Pcsclite-muscle] Support for file-descriptor based devices in pcsclite

Ludovic Rousseau ludovic.rousseau at gmail.com
Thu May 26 02:13:30 PDT 2022

Le jeu. 19 mai 2022 à 13:56, Wiktor Kwapisiewicz <wiktor at metacode.biz> a écrit :
> Hello,


Sorry for the delay. Your email was in my spam folder (gmail).

> I'm trying to use pcsclite on Android (via Termux) and found out that
> the Android OS exposes USB devices via file descriptors (instead of
> regular files). It seems libusb can interact via these devices using two
> functions introduced in 2018 [0]:
>      libusb_set_option(NULL, LIBUSB_OPTION_WEAK_AUTHORITY);
>      // ...
>      libusb_wrap_sys_device(context, (intptr_t) fd, &handle);
> Example from [1]. The option name is also called
> LIBUSB_OPTION_NO_DEVICE_DISCOVERY in newer versions of libusb [2].
> I did compile several small examples using libusb and
> libusb_wrap_sys_device and they worked fine with my tokens (Yubikeys).
> Now my question is whether support for
> LIBUSB_OPTION_WEAK_AUTHORITY/libusb_wrap_sys_device is something that
> could be considered for inclusion in pcsclite or is this out of scope?

Yes, I could consider something like that.

In fact I already have 2 issues opened for pcsc-lite and CCID with this idea.
"Open the device in pcscd and give the file descriptor to the driver"

"Use libusb_wrap_sys_device() and avoid rescanning the USB bus"

This scheme could also be used on a "normal" computer and not only for Android.

I am waiting for your first patches.
Good idea.

> The use-case I have in mind is using SSH and signing commits on Android
> phones. I'm already using pcsc-lite through openpgp-card crate for SSH
> and commit signing on my desktop and it works very well and I'm trying
> to replicate the setup on my tablet/phone.

What smart card reader do you plan to use with your Android phone?

> Thank you for your time and have a nice day!

You too.

 Dr. Ludovic Rousseau

More information about the pcsclite-muscle mailing list