u2fhid

package
v0.0.0-...-ab65172 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: BSD-3-Clause Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (

	// VendorCommandFirst is the first admissible vendor command identifier.
	VendorCommandFirst = 0x80 | 0x40

	// VendorCommandLast is the last admissible vendor command identifier.
	VendorCommandLast = 0x80 | 0x7f
)

Variables

View Source
var DefaultReport = u2fHIDReport{
	0x06, 0xD0, 0xF1,
	0x09, 0x01,
	0xA1, 0x01,
	0x09, 0x20,
	0x15, 0x00,
	0x26, 0xFF, 0x00,
	0x75, 0x08,
	0x95, 0x40,
	0x81, 0x02,
	0x09, 0x21,
	0x15, 0x00,
	0x26, 0xFF, 0x00,
	0x75, 0x08,
	0x95, 0x40,
	0x91, 0x02,
	0xC0,
}

DefaultReport is the standard report descriptor for a USB HID FIDO2 token. https://chromium.googlesource.com/chromiumos/platform2/+/master/u2fd/u2fhid.cc

Functions

This section is empty.

Types

type CommandHandler

type CommandHandler func([]byte) []byte

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler holds methods for sending and receiving packets.

func NewHandler

func NewHandler(token Token) (*Handler, error)

NewHandler returns a new Handler instance with a given u2ftoken.Token. Token cannot be nil.

func (*Handler) AddMapping

func (h *Handler) AddMapping(command u2fHIDCommand, ch CommandHandler) error

AddMapping adds a new CommandHandler mapping for a given command. Returns error if there's already a mapping for command, or if it is not defined between VendorCommandFirst and VendorCommandLast. Each mapping will be handled like a cmdMsg, meaning that the input for ch will be the whole session data, while its output will be framed and sent over the wire.

func (*Handler) Rx

func (h *Handler) Rx(buf []byte, lastErr error) (res []byte, err error)

Rx handles data intake, parses messages and builds responses. res will always be nil.

func (*Handler) Tx

func (h *Handler) Tx(buf []byte, lastErr error) (res []byte, err error)

Tx handles USB endpoint data outtake. res will always not be nil.

type Token

type Token interface {
	// HandleMessage handles cmdMsg payloads, and return an appropriate response
	// for the underlying command.
	HandleMessage([]byte) []byte
}

Token represents a unit which can handle U2F messages.

Jump to

Keyboard shortcuts

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