Skip to content

A Go implementation of Yubico's YKOATH protocol

License

Notifications You must be signed in to change notification settings

cunicu/go-ykoath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-ykoath

GitHub Workflow Status goreportcard Codecov branch License GitHub go.mod Go version Go Reference

The package ykoath implements the YubiKey YKOATH protocol for OATH-TOTP, OATH-HOTP and raw HMAC challenge-response.

Usage

c, err := ykoath.New()
if err != nil {
    log.Fatal(err)
}

defer c.Close()

if _, err = c.Select(); err != nil {
    log.Fatalf("Failed to select app: %v", err)
}

names, err := c.List()
if err != nil {
    log.Fatal("Failed to list slots: %v", err)
}

for _, name := range names {
    calc, err := c.Calculate(name.Name, func(name string) error {
        log.Printf("*** Please touch your YubiKey to unlock slot: %q ***", name)
        return nil
    })
    if err != nil {
        log.Fatal("Failed to calculate code for slot %q: %v", name.Name, err)
    }

    log.Printf("Got one-time-password %s for slot %q", calc, name)
}

if err := c.Put("test", ykoath.HmacSha1, ykoath.Totp, 6, []byte("open sesame"), true); err != nil {
    log.Fatal(err)
}

if err := c.Put("test2", ykoath.HmacSha1, ykoath.Totp, 6, []byte("open sesame"), true); err != nil {
    log.Fatal(err)
}

Authors

go-ykoath has been forked from yawn/ykoath at commit 201009e

Contact

Please have a look at the contact page: cunicu.li/docs/contact.

License

go-ykoath is licensed under the Apache 2.0 license.