Documentation
¶
Overview ¶
Package token2 provides transport-independent Token2 device information, response parsers and model identification.
Concrete device implementations live under transport. HID and PC/SC devices return DeviceInfo; CTAPHID devices return the partial identity encoded in ATR.
Index ¶
Constants ¶
const ( TransferTypeFIDODisabledMask byte = 0x01 TransferTypeHOTPKeystrokeDisabledMask byte = 0x02 TransferTypeCCIDDisabledMask byte = 0x04 DeviceConfigurationHOTPSuppressEnterMask byte = 0x01 DeviceConfigurationFIDOPINSetMask byte = 0x02 DeviceConfigurationHOTPMask byte = 0x04 DeviceConfigurationFingerprintSensorMask byte = 0x08 DeviceConfigurationNFCMask byte = 0x10 DeviceConfigurationHOTPLongPressMask byte = 0x20 DeviceConfigurationFIDOPINLockedMask byte = 0x40 DeviceConfigurationButtonHOTPConfiguredMask byte = 0x80 DeviceExtensionTOTPMask byte = 0x01 DeviceExtensionFIDO21Mask byte = 0x02 DeviceExtensionFingerprintRegistrationMask byte = 0x04 DeviceExtensionHOTPNumericKeypadMask byte = 0x08 DeviceExtensionCCIDMask byte = 0x10 DeviceExtensionButtonHOTPUnsupportedMask byte = 0x20 DeviceExtensionOTPRequiresFingerprintMask byte = 0x40 DeviceExtensionMandatoryFingerprintSupportMask byte = 0x80 )
Variables ¶
var ErrInvalidATR = errors.New("token2: invalid ATR")
ErrInvalidATR reports an ATR that does not contain the expected Token2 historical bytes.
var ErrInvalidConfiguration = errors.New("token2: invalid configuration")
ErrInvalidConfiguration reports malformed configuration data received from a Token2 device.
var ErrInvalidSerialResponse = errors.New("token2: invalid serial-number response")
ErrInvalidSerialResponse reports a malformed serial-number response received from a Token2 device.
Functions ¶
func ParseSerialNumber ¶
ParseSerialNumber parses the TAG-LENGTH-VALUE response returned by the Token2 serial-number command.
Types ¶
type ATR ¶
type ATR struct {
Raw []byte `json:"raw"`
ProductID uint16 `json:"productId"`
SerialSuffix string `json:"serialSuffix"`
}
ATR contains Token2 identity data encoded in a PC/SC answer-to-reset.
type Appearance ¶
type Appearance [4]byte
Appearance identifies the Token2 device appearance reported by its firmware.
type Configuration ¶
type Configuration struct {
Raw []byte `json:"raw"`
TransferType byte `json:"transferType"`
DeviceConfiguration byte `json:"deviceConfiguration"`
Appearance Appearance `json:"appearance"`
FIDOVersion FIDOVersion `json:"fidoVersion"`
DeviceExtension byte `json:"deviceExtension"`
}
Configuration describes the Token2 configuration response. Raw retains the complete response, including fields unknown to this version of the package. TransferType is an interface-state mask; DeviceConfiguration and DeviceExtension are capability and configuration masks.
func ParseConfiguration ¶
func ParseConfiguration(response []byte) (Configuration, error)
ParseConfiguration parses either a one-byte legacy response or a modern response of at least ten bytes. Additional bytes are retained in Raw.
type DeviceInfo ¶
type DeviceInfo struct {
SerialNumber string `json:"serialNumber"`
Release string `json:"release"`
FormFactor string `json:"formFactor"`
Branding string `json:"branding"`
ProductID uint16 `json:"productId,omitempty"`
Appearance *Appearance `json:"appearance,omitempty"`
FIDOVersion *FIDOVersion `json:"fidoVersion,omitempty"`
InterfaceStateKnown bool `json:"interfaceStateKnown"`
FIDOEnabled bool `json:"fidoEnabled"`
HOTPKeystrokeEnabled bool `json:"hotpKeystrokeEnabled"`
CCIDEnabled bool `json:"ccidEnabled"`
CapabilitiesKnown bool `json:"capabilitiesKnown"`
FIDOPINSet bool `json:"fidoPINSet"`
FIDOPINLocked bool `json:"fidoPINLocked"`
SupportsHOTP bool `json:"supportsHOTP"`
SupportsTOTP bool `json:"supportsTOTP"`
SupportsNFC bool `json:"supportsNFC"`
SupportsCCID bool `json:"supportsCCID"`
SupportsFIDO21 bool `json:"supportsFIDO21"`
HasFingerprintSensor bool `json:"hasFingerprintSensor"`
SupportsFingerprintRegistration bool `json:"supportsFingerprintRegistration"`
SupportsMandatoryFingerprint bool `json:"supportsMandatoryFingerprint"`
OTPRequiresFingerprint bool `json:"otpRequiresFingerprint"`
SupportsButtonHOTP bool `json:"supportsButtonHOTP"`
ButtonHOTPConfigured bool `json:"buttonHOTPConfigured"`
ButtonHOTPSendsEnter bool `json:"buttonHOTPSendsEnter"`
ButtonHOTPRequiresLongPress bool `json:"buttonHOTPRequiresLongPress"`
ButtonHOTPUsesNumericKeypad bool `json:"buttonHOTPUsesNumericKeypad"`
}
DeviceInfo contains normalized, transport-neutral information about a Token2 device. Interface state and capability fields are meaningful when their corresponding Known field is true.
func Identify ¶
func Identify(serialNumber string) (DeviceInfo, bool)
Identify returns device information derived from a full Token2 serial number. The boolean reports whether the model is in the built-in catalog.
func (DeviceInfo) ModelName ¶
func (info DeviceInfo) ModelName(fallback string) string
ModelName returns the canonical model name derived from the serial number. fallback is returned when the model is not in the built-in catalog.
type FIDOVersion ¶
type FIDOVersion struct {
Major byte `json:"major"`
Minor byte `json:"minor"`
Patch byte `json:"patch"`
}
FIDOVersion is the three-component FIDO version reported by a Token2 device.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
pcsc-serial-monitor
command
|
|
|
internal
|
|
|
protocol
Package protocol defines the Token2 commands shared by transport adapters.
|
Package protocol defines the Token2 commands shared by transport adapters. |
|
Package resolver correlates one FIDO attachment with Token2's auxiliary interfaces and returns transport-neutral device information.
|
Package resolver correlates one FIDO attachment with Token2's auxiliary interfaces and returns transport-neutral device information. |
|
transport
|
|
|
ctaphid
Package ctaphid accesses Token2 vendor commands over the CTAPHID protocol.
|
Package ctaphid accesses Token2 vendor commands over the CTAPHID protocol. |
|
hid
Package hid accesses Token2 devices through USB HID feature reports.
|
Package hid accesses Token2 devices through USB HID feature reports. |
|
pcsc
Package pcsc provides access to Token2 devices over PC/SC.
|
Package pcsc provides access to Token2 devices over PC/SC. |