yubikey

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package yubikey implements basic support for getting status and details about YubiKey tokens.

Index

Constants

View Source
const (
	TagCapsSupportedUSB tlv.Tag = 0x01
	TagSerialNumber     tlv.Tag = 0x02
	TagCapsEnabledUSB   tlv.Tag = 0x03
	TagFormFactor       tlv.Tag = 0x04
	TagFirmwareVersion  tlv.Tag = 0x05
	TagAutoEjectTimeout tlv.Tag = 0x06
	TagChalRespTimeout  tlv.Tag = 0x07
	TagDeviceFlags      tlv.Tag = 0x08
	TagAppVersions      tlv.Tag = 0x09
	TagConfigLock       tlv.Tag = 0x0a
	TagUnlock           tlv.Tag = 0x0b
	TagReboot           tlv.Tag = 0x0c
	TagCapsSupportedNFC tlv.Tag = 0x0d
	TagCapsEnabledNFC   tlv.Tag = 0x0e
)
View Source
const (
	// https://docs.yubico.com/yesdk/users-manual/application-otp/otp-commands.html
	InsOTP        iso.Instruction = 0x01 // Most commands of the OTP applet use this value
	InsReadStatus iso.Instruction = 0x03
)

Variables

View Source
var (
	IsFIPS = withDeviceInfo(func(di *DeviceInfo) bool {
		return di.IsFIPS
	})
	IsLocked = withDeviceInfo(func(di *DeviceInfo) bool {
		return di.IsLocked
	})
)
View Source
var ErrInvalidResponseLength = errors.New("invalid response length")

Functions

func GetFIPSMode

func GetFIPSMode(card *iso.Card) (bool, error)

GetFIPSMode returns returns the FIPS compliancy state of the YubiKey token.

func GetSerialNumber

func GetSerialNumber(card *iso.Card) (uint32, error)

GetSerialNumber returns the serial number of the YubiKey token.

func HasFIDO2

func HasFIDO2(reader string, card *iso.Card) (bool, error)

HasFIDO2 is a filter which checks if the YubiKey has the FIDO2 applet enabled.

func HasFormFactor

func HasFormFactor(ff FormFactor) filter.Filter

HasFormFactor returns a filter which checks if the YubiKey has a given form factor.

func HasHSMAuth

func HasHSMAuth(reader string, card *iso.Card) (bool, error)

HasHSMAuth is a filter which checks if the YubiKey has the HSM authentication applet enabled.

func HasOATH

func HasOATH(reader string, card *iso.Card) (bool, error)

HasOATH is a filter which checks if the YubiKey has the OATH applet enabled.

func HasOTP

func HasOTP(reader string, card *iso.Card) (bool, error)

HasOTP is a filter which checks if the YubiKey has the OTP applet enabled.

func HasOpenPGP

func HasOpenPGP(reader string, card *iso.Card) (bool, error)

HasOpenPGP is a filter which checks if the YubiKey has the OpenPGP applet enabled.

func HasPIV

func HasPIV(reader string, card *iso.Card) (bool, error)

HasPIV is a filter which checks if the YubiKey has the PIV applet enabled.

func HasU2F

func HasU2F(reader string, card *iso.Card) (bool, error)

HasU2F is a filter which checks if the YubiKey has the U2F applet enabled.

func HasVersion added in v0.2.0

func HasVersion(v iso.Version) filter.Filter

HasVersion checks that the card has a firmware version equal or higher than the given one.

func HasVersionStr added in v0.2.0

func HasVersionStr(s string) filter.Filter

func IsSerialNumber

func IsSerialNumber(sno uint32) filter.Filter

func Metadata added in v0.5.0

func Metadata(card *iso.Card) (meta map[string]any)

Types

type Capability

type Capability int
const (
	CapOTP     Capability = 0x01
	CapU2F     Capability = 0x02
	CapFIDO2   Capability = 0x200
	CapOATH    Capability = 0x20
	CapPIV     Capability = 0x10
	CapOpenPGP Capability = 0x08
	CapHSMAUTH Capability = 0x100
)

type DeviceFlag

type DeviceFlag byte
const (
	DeviceFlagRemoteWakeup DeviceFlag = 0x40
	DeviceFlagEject        DeviceFlag = 0x80
)

type DeviceInfo

type DeviceInfo struct {
	Flags            DeviceFlag
	CapsSupportedUSB Capability
	CapsEnabledUSB   Capability
	CapsSupportedNFC Capability
	CapsEnabledNFC   Capability
	SerialNumber     uint32
	FirmwareVersion  iso.Version
	FormFactor       FormFactor
	AutoEjectTimeout time.Duration
	ChalRespTimeout  time.Duration
	IsLocked         bool
	IsSky            bool
	IsFIPS           bool
}

func GetDeviceInfo

func GetDeviceInfo(card *iso.Card) (*DeviceInfo, error)

GetDeviceInfo returns device information about the YubiKey token.

func (*DeviceInfo) Unmarshal

func (di *DeviceInfo) Unmarshal(b []byte) error

nolint: gocognit

type FormFactor

type FormFactor byte
const (
	FormFactorUnknown       FormFactor = 0x00
	FormFactorUSBAKeychain  FormFactor = 0x01
	FormFactorUSBANano      FormFactor = 0x02
	FormFactorUSBCKeychain  FormFactor = 0x03
	FormFactorUSBCNano      FormFactor = 0x04
	FormFactorUSBCLightning FormFactor = 0x05
	FormFactorUSBABio       FormFactor = 0x06
	FormFactorUSBCBio       FormFactor = 0x07
)

type Status

type Status struct {
	Version    iso.Version
	Sequence   uint8
	TouchLevel uint16
}

func GetStatus

func GetStatus(card *iso.Card) (*Status, error)

GetStatus returns the status of the YubiKey token.

func (*Status) Unmarshal

func (s *Status) Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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