Documentation ¶
Overview ¶
Example ¶
oath, _ := New() // fix the clock oath.Clock = func() time.Time { return time.Unix(59, 0) } defer oath.Close() // enable OATH for this session _, _ = oath.Select() // add the testvector _ = oath.Put("testvector", HmacSha1, Totp, 8, []byte("12345678901234567890"), false, false, 0) names, _ := oath.List() for _, name := range names { fmt.Println(name) } otp, _ := oath.Calculate("testvector", nil) fmt.Println(otp)
Output: testvector (HMAC-SHA1 TOTP) 94287082
Index ¶
- type Algorithm
- type Name
- type OATH
- func (o *OATH) Calculate(name string, touchRequiredCallback func(string) error) (string, error)
- func (o *OATH) CalculateAll() (map[string]string, error)
- func (o *OATH) Close() error
- func (o *OATH) Delete(name string) error
- func (o *OATH) List() ([]*Name, error)
- func (o *OATH) Put(name string, a Algorithm, t Type, digits uint8, key []byte, touch bool, ...) error
- func (o *OATH) Rename(oldName, newName string) error
- func (o *OATH) Select() (*Select, error)
- func (o *OATH) SetAsDefault(name string) error
- func (o *OATH) SetPassword(key []byte) (err error)
- func (o *OATH) Validate(chalFromSelect []byte, key []byte) (err error)
- type Select
- type Type
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm byte
Algorithm denotes the HMAc algorithm used for deriving the one-time passwords
type OATH ¶
type OATH struct { Clock func() time.Time Debug debugger // contains filtered or unexported fields }
OATH implements most parts of the TOTP portion of the YKOATH specification https://developers.yubico.com/OATH/YKOATH_Protocol.html
func (*OATH) Calculate ¶
Calculate implements the "CALCULATE" instruction to fetch a single truncated TOTP response
func (*OATH) CalculateAll ¶
CalculateAll implements the "CALCULATE ALL" instruction to fetch all TOTP tokens and their codes (or a constant indicating a touch requirement)
func (*OATH) Put ¶
func (o *OATH) Put(name string, a Algorithm, t Type, digits uint8, key []byte, touch bool, increasing bool, counter uint32) error
Put sends a "PUT" instruction, storing a new / overwriting an existing OATH credentials with an algorithm and type, 6 or 8 digits one-time password, shared secrets and touch-required bit
func (*OATH) Select ¶
Select sends a "SELECT" instruction, initializing the device for an OATH session
func (*OATH) SetAsDefault ¶
func (*OATH) SetPassword ¶ added in v1.4.0
type Type ¶
type Type byte
Type denotes the kind of derivation used for the one-time password
const ( // Hotp describes HMAC based one-time passwords (https://tools.ietf.org/html/rfc4226) Hotp Type = 0x10 // Totp describes time-based one-time passwords (https://tools.ietf.org/html/rfc6238) Totp Type = 0x20 )