fido

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: BSD-3-Clause Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

fido

Opens a FIDO security key on macOS and hands it to go-authn/fido as a transport. Pure Go, CGO_ENABLED=0.

k, err := fido.Open(ctx)   // find the key, open it, handshake
defer k.Close()
fmt.Println(k)             // YubiKey FIDO (CTAPHID v2, firmware 5.7.4, wink, ctap2, ctap1)
err = k.Wink(ctx)          // the key blinks: which one is this?

The protocol is not here. Framing, the handshake, the commands and every command still to come are the same on every operating system and live in go-authn/fido. What is macOS about a security key is four calls to IOKit, which is what this is.

A FIDO authenticator publishes a HID interface on usage page 0xF1D0 with 64-byte reports. It opens with no entitlement and no user consent, so the whole path is reachable through go-macos/iokit's own IOKit binding: no framework, no driver, no cgo.

Several keys: list, then choose

Open and Transport take whichever key IOKit lists first, and that order is not promised. Anything that changes a key (a PIN, a fingerprint, a credential) must choose it:

devs, _ := fido.Devices()          // no key is opened, nothing is touched
for _, d := range devs { fmt.Println(d) }   // YubiKey Bio (1050:0407) at iokit:14100000
t, err := fido.OpenDevice(devs[i]) // matched by Path (and Serial), never by position
k, err := authn.Open(ctx, t)

Device has the same shape as go-gnulinux/fido's. Path is built from the USB location, so it is stable while the key stays in the same port; a key that was unplugged, or whose port another key took, is ErrGone, never a different key opened in its stead. Serial is empty for the many keys that publish none: go-authn/fido can tell keys apart by touch ([Select]) or by what they answer.

One reader, started once

A second hid.Stream opened on a device whose first was cancelled delivers nothing, silently — and the symptom is a key that answers the handshake and then never again. So one reader is started when the device is opened and never restarted.

It is registered on a run loop, so there is a moment between starting it and it being armed. Writing during that moment loses the reply: measured at one exchange in three. The wait is small and it is not optional — a test that removed it reproduced the fault immediately.

Documentation

Overview

Package fido opens a FIDO security key on macOS and hands it to github.com/go-authn/fido as a transport.

The protocol is not here. Framing, the handshake, the commands and every command still to come are the same on every operating system and live in go-authn/fido; what is macOS about a security key is four calls to IOKit, which is what this is.

A FIDO authenticator publishes a HID interface on usage page 0xF1D0 with 64-byte reports in both directions. It opens with no entitlement and no user consent, so the whole path is reachable in pure Go with CGO_ENABLED=0, through go-macos/iokit's own IOKit binding: no framework, no driver, no cgo.

t, err := fido.Transport()   // or fido.Open(ctx), which also handshakes
k, err := authn.Open(ctx, t)
defer k.Close()
fmt.Println(k)

Index

Constants

This section is empty.

Variables

View Source
var ErrGone = errors.New("fido: that security key is no longer attached")

ErrGone means a key that was listed is no longer attached (or no longer has the same serial number): it was unplugged, or another one took its place.

View Source
var ErrNoKey = errors.New("fido: no security key is attached")

ErrNoKey means no FIDO authenticator is attached.

View Source
var ErrUnsupported = errors.New("fido: only macOS is implemented here; see go-authn/fido for the protocol")

ErrUnsupported is returned off macOS. The protocol is portable and lives in go-authn/fido; only this transport is not.

Functions

func Open

func Open(context.Context) (*authn.Key, error)

Open reports ErrUnsupported.

func OpenDevice added in v0.6.0

func OpenDevice(Device) (authn.Transport, error)

OpenDevice reports ErrUnsupported.

func Transport

func Transport() (authn.Transport, error)

Transport reports ErrUnsupported.

Types

type Device added in v0.6.0

type Device struct {
	// Path identifies the key, e.g. "iokit:14200000". It is what OpenDevice
	// matches, and what a person can be shown and give back as --device.
	Path string
	// LocationID is the USB location the Path is made from.
	LocationID uint32
	// VendorID and ProductID identify the model.
	VendorID, ProductID uint16
	// Name is the product string, Manufacturer the manufacturer string.
	Name, Manufacturer string
	// Serial is the USB serial number string, empty when the key has none (most
	// do not publish one over HID).
	Serial string
}

Device is one attached security key, as Devices lists it. It has the same shape as go-gnulinux/fido's Device, so a program can treat both alike.

Opening is by Path, never by position: with two keys attached the order IOKit enumerates them in is not promised, so "the first" can be a different key on the next call. Path is built from the USB location, which is stable for as long as a key stays in the same port.

func Devices added in v0.6.0

func Devices() ([]Device, error)

Devices reports ErrUnsupported.

func (Device) String added in v0.6.0

func (d Device) String() string

String names the device the way a message a person reads should.

Directories

Path Synopsis
cmd
fidoprobe command
Command fidoprobe opens the attached security key and says what it is.
Command fidoprobe opens the attached security key and says what it is.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址