Documentation ¶
Overview ¶
Example ¶
oath, err := New() if err != nil { log.Print(err) return } defer oath.Close() // Fix the clock oath.Clock = func() time.Time { return time.Unix(59, 0) } // Enable OATH for this session if _, err = oath.Select(); err != nil { log.Printf("Failed to select app: %v", err) return } // Add the testvector if err = oath.Put("testvector", HmacSha1, Totp, 8, []byte("12345678901234567890"), false); err != nil { log.Printf("Failed to put: %v", err) return } names, err := oath.List() if err != nil { log.Printf("Failed to list: %v", err) return } for _, name := range names { fmt.Printf("Name: %s\n", name) } otp, _ := oath.Calculate("testvector", nil) fmt.Printf("OTP: %s\n", otp)
Output: Name: testvector (HMAC-SHA1 TOTP) OTP: 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 ¶
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 )
Click to show internal directories.
Click to hide internal directories.