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)
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) 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) Select() (*Select, 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 is a high-level function that first identifies all TOTP credentials that are configured and returns the matching one (if no touch is required) or fires the callback and then fetches the name again while blocking during the device awaiting touch
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 )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.