The package ykoath
implements the YubiKey YKOATH protocol for OATH-TOTP, OATH-HOTP and raw HMAC challenge-response.
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)
}
go-ykoath has been forked from yawn/ykoath at commit 201009e
Please have a look at the contact page: cunicu.li/docs/contact.
go-ykoath is licensed under the Apache 2.0 license.