yubico

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

go-ctap/yubico

Go Reference Go

Pure-Go support for Yubico-specific device information and identity.

[!WARNING] This module is under active development. Its public API may change during v0.x.

Packages

  • yubico contains transport-independent device-information models, response parsing and canonical model naming.
  • yubico/transport/ctaphid reads device information through Yubico's CTAPHID vendor command 0x42, using github.com/go-ctap/ctap.

The CTAPHID transport accepts an existing vendor-command channel and does not take ownership of it. It sends logical command 0x42; CTAPHID framing adds the init-packet bit, so the on-wire command byte is 0xc2.

Installation

go get github.com/go-ctap/yubico@latest

See go.mod for the required Go version.

Testing

go test ./...
go vet ./...

The test suite does not require hardware.

Documentation

Overview

Package yubico provides transport-independent Yubico device information, response parsing and identity naming.

CTAPHID access lives under transport/ctaphid.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDeviceInfo = errors.New("yubico: invalid device information")

Functions

This section is empty.

Types

type Capability

type Capability uint16

Capability is a bitmap of applications exposed by a YubiKey interface.

const (
	CapabilityOTP     Capability = 0x0001
	CapabilityU2F     Capability = 0x0002
	CapabilityCCID    Capability = 0x0004
	CapabilityOpenPGP Capability = 0x0008
	CapabilityPIV     Capability = 0x0010
	CapabilityOATH    Capability = 0x0020
	CapabilityHSMAuth Capability = 0x0100
	CapabilityCTAP2   Capability = 0x0200
)

func (Capability) String

func (i Capability) String() string

type DeviceInfo

type DeviceInfo struct {
	SupportedUSBCapabilities Capability
	Serial                   *uint32
	EnabledUSBCapabilities   Capability
	FormFactor               FormFactor
	IsFIPS                   bool
	IsSecurityKey            bool
	FirmwareVersion          FirmwareVersion
	VersionQualifier         *VersionQualifier
	AutoEjectTimeout         uint16
	ChallengeResponseTimeout byte
	DeviceFlags              byte
	Locked                   bool
	PartNumber               *string
	FIPSCapable              Capability
	FIPSApproved             Capability
	PinComplexity            bool
	NFCRestricted            bool
	ResetBlocked             Capability
	FPSVersion               *FirmwareVersion
	STMVersion               *FirmwareVersion
	SupportedNFCCapabilities *Capability
	EnabledNFCCapabilities   *Capability
	UnknownFields            map[byte][]byte
}

DeviceInfo is returned by Yubico's GET DEVICE INFORMATION command. UnknownFields preserves tags introduced by newer firmware.

func ParseDeviceInfo

func ParseDeviceInfo(data []byte) (DeviceInfo, error)

ParseDeviceInfo parses TOTAL-LENGTH followed by TAG-LENGTH-VALUE fields.

func ParseDeviceInfoPages

func ParseDeviceInfoPages(pages ...[]byte) (DeviceInfo, error)

ParseDeviceInfoPages parses and merges one or more paginated device-info responses. Fields from later pages replace fields with the same tag from earlier pages.

func (DeviceInfo) EffectiveFirmwareVersion

func (info DeviceInfo) EffectiveFirmwareVersion() FirmwareVersion

EffectiveFirmwareVersion returns the version used for behavioral checks. Alpha and beta firmware report this version through VersionQualifier.

func (DeviceInfo) HasNFC

func (info DeviceInfo) HasNFC() bool

HasNFC reports whether NFC capability data is valid for this form factor and firmware generation.

func (DeviceInfo) ModelName

func (info DeviceInfo) ModelName(fallback string) string

ModelName returns the canonical marketing name derived from Yubico device information. fallback is returned for firmware generations whose naming rules are not known.

type FirmwareVersion

type FirmwareVersion struct {
	Major byte
	Minor byte
	Build byte
}

FirmwareVersion is the major.minor.build version reported by the device.

func (FirmwareVersion) String

func (v FirmwareVersion) String() string

String formats a non-zero firmware version as major.minor.build.

type FormFactor

type FormFactor byte

FormFactor describes the physical shape and connector type of a YubiKey.

const (
	FormFactorUnknown               FormFactor = 0
	FormFactorUSBAKeychain          FormFactor = 1
	FormFactorUSBANano              FormFactor = 2
	FormFactorUSBCKeychain          FormFactor = 3
	FormFactorUSBCNano              FormFactor = 4
	FormFactorUSBCLightning         FormFactor = 5
	FormFactorUSBABiometricKeychain FormFactor = 6
	FormFactorUSBCBiometricKeychain FormFactor = 7
)

func (FormFactor) String

func (i FormFactor) String() string

type ReleaseType

type ReleaseType byte

ReleaseType identifies the release stage of qualified firmware.

const (
	ReleaseTypeAlpha ReleaseType = iota
	ReleaseTypeBeta
	ReleaseTypeFinal
)

type VersionQualifier

type VersionQualifier struct {
	Version     FirmwareVersion
	ReleaseType ReleaseType
	Iteration   uint32
}

VersionQualifier contains the behavioral firmware version reported by development firmware.

Directories

Path Synopsis
transport
ctaphid
Package ctaphid accesses Yubico vendor commands over the CTAPHID protocol.
Package ctaphid accesses Yubico vendor commands over the CTAPHID protocol.

Jump to

Keyboard shortcuts

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