Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

u2flib-host
=========

Provides library functionality for communicating with a U2F device over USB.

Two executables are provided, u2f-enroll and u2f-sign, which support the enroll
and sign commands of U2F v0, as well as v2, as defined in the 2014-02-09
draft specification, from: http://fidoalliance.org/specifications/download

==License==
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

==Installation==

u2flib-host is installable by running the following command:

$ python setup.py install

Under Linux you will need to add a Udev rule to be able to access the U2F
device, or run as root. For example, the Udev rule may contain the following:

# For Udev 188 and later
# /etc/udev/rules.d/70-gnubby.rules

ACTION!="add|change", GOTO="gnubby_end"

ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0211", \
ENV{ID_SECURITY_TOKEN}="1"

LABEL="gnubby_end"


# For older Udev versions
# /etc/udev/rules.d/70-gnubby.rules

ACTION=="add|change", SUBSYSTEM=="usb", \
ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0211", \
TEST=="/var/run/ConsoleKit/database", \
RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"

==Dependencies==

u2flib-host requires a PyUSB compatible backend, such as libusb.

The soft U2F device implementation requires M2Crypto.

==Examples==

===Library use===

from u2flib_host import winusb

#Enumerate available devices
devices = winusb.list_devices()

for device in devices:
#The with block ensures that the device is opened and closed.
with device as dev:
#Send a command to the device:
dev.call(cmd, data)

===Executable use===

The examples below use the soft U2F device to enroll and sign against the
u2f_server example server from the python-u2flib-server project. See that
project for more details.
The enroll step will create a new U2F key pair and store the credential in the
soft_device.json file. The sign step will use this credential to sign a
challenge given by the server.

====Enroll====
Enroll takes a registration request as input, registering the attached device
and returns the registration response as output.

$ u2f-enroll -s soft_device.json http://localhost:8081
Enter enrollment JSON data...
{"sessionId": "", "challenge": "K0aDxsacDNqrzlaGyLZoFYbXvCJcdIhq0SSaMz-lsV4", "version": "U2F_V2", "app_id": "http://localhost:8081/app-identity"}

Touch the U2F device you wish to enroll...
[{"bd": "eyJvcmlnaW4iOiAiaHR0cDovL2xvY2FsaG9zdDo4MDgxIiwgImNoYWxsZW5nZSI6ICJLMGFEeHNhY0ROcXJ6bGFHeUxab0ZZYlh2Q0pjZElocTBTU2FNei1sc1Y0IiwgInR5cCI6ICJuYXZpZ2F0b3IuaWQuZmluaXNoRW5yb2xsbWVudCJ9", "sessionId": "", "registrationData": "BQTGnJVILHhzuTKg2XClCM5TJjF2WeK4fp9i6fj3VywzOk3d-O1sNaapAUPh-1GxoVCMY6s_jimP-nKqnZT-MGOCQIGD9Hs4qBCXMbfOPfzuB5zhFcOD95ddve67HXV8QeyPDKPZS5zDogvWyl8l4Tv2XRWGo4_6cAPPM4dPZcMreagwggGHMIIBLqADAgECAgkAmb7osQyi7BwwCQYHKoZIzj0EATAhMR8wHQYDVQQDDBZZdWJpY28gVTJGIFNvZnQgRGV2aWNlMB4XDTEzMDcxNzE0MjEwM1oXDTE2MDcxNjE0MjEwM1owITEfMB0GA1UEAwwWWXViaWNvIFUyRiBTb2Z0IERldmljZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDvhl91zfpg9n7DeCedcQ8gGXUnemiXoi-JEAxz-EIhkVsMPAyzhtJZ4V3CqMZ-MOUgICt2aMxacMX9cIa8dgS2jUDBOMB0GA1UdDgQWBBQNqL-TV04iaO6mS5tjGE6ShfexnjAfBgNVHSMEGDAWgBQNqL-TV04iaO6mS5tjGE6ShfexnjAMBgNVHRMEBTADAQH_MAkGByqGSM49BAEDSAAwRQIgXJWZdbvOWdhVaG7IJtn44o21Kmi8EHsDk4cAfnZ0r38CIQD6ZPi3Pl4lXxbY7BXFyrpkiOvCpdyNdLLYbSTbvIBQOTBEAiBk3N3-gH2WPhR7EOq2-vEqrC1EZXgYs7fofhYTNk9jqwIgcAVRCeXfCLfLO7X71vKVeXaRQKCJgvmRZdB8PoPVdjw"}]

====Sign====
Sign takes an authentication request as input, and returns the
authentication response as output.

$ u2f-sign -s soft_device.json http://localhost:8081
Enter challenge JSON data...
{"key_handle": "gYP0ezioEJcxt849_O4HnOEVw4P3l1297rsddXxB7I8Mo9lLnMOiC9bKXyXhO_ZdFYajj_pwA88zh09lwyt5qA", "sessionId": "", "challenge": "zCfLJtWyaCk86Awi5VFtT7hhLk5yncYppYC0z2Q5xxo", "version": "U2F_V2", "app_id": "http://localhost:8081/app-identity"}

{"bd": "eyJvcmlnaW4iOiAiaHR0cDovL2xvY2FsaG9zdDo4MDgxIiwgImNoYWxsZW5nZSI6ICJ6Q2ZMSnRXeWFDazg2QXdpNVZGdFQ3aGhMazV5bmNZcHBZQzB6MlE1eHhvIiwgInR5cCI6ICJuYXZpZ2F0b3IuaWQuZ2V0QXNzZXJ0aW9uIn0", "challenge": "zCfLJtWyaCk86Awi5VFtT7hhLk5yncYppYC0z2Q5xxo", "app_id": "http://localhost:8081/app-identity", "sessionId": "", "sign": "AQAAAAEwRAIgK8HLGu8SQNPC3hI1700RsTtyXLlsn9_1sEcIcobhDi0CIFzduJ5IdGus-I-ieHTX1R-1xRCA0e29I9kChKbkkIzF"}

Metadata

Release files for python-u2flib-host 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-u2flib-host 1.0.0
File Size Uploaded Provenance Actions
python-u2flib-host-1.0.0.tar.gz 25.8 kB Without provenance Details for python-u2flib-host-1.0.0.tar.gz

Release files / python-u2flib-host-1.0.0.tar.gz

Download URL python-u2flib-host-1.0.0.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4c6f210ca0c540fe66341cb78fd1ca1add50946696b8b440559f7a461aecc8c4
BLAKE2b-256 checksum
How to use checksums
2ad602d1e495fc844147cc6716962c81ae4b93ebebf93ace4eca22f0564e9ab0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for python-u2flib-host 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page