package module
v0.0.0-...-22a356f Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 3 Imported by: 0


Table of Contents


make-all make-image make-test GoDoc

Go bindings for libyubikey so you can write Go to interact with your yubikeys. The C library lives at yubico/yubico-c.



Package yubikey provides Go bindings for libyubikey.



View Source
const (
	// BLOCKSIZE as defined in libyubikey/yubikey.h:44
	// KEYSIZE as defined in libyubikey/yubikey.h:45
	// UIDSIZE as defined in libyubikey/yubikey.h:46
	// OTPSIZE as defined in libyubikey/yubikey.h:47
	// MODHEXMAP as defined in libyubikey/yubikey.h:94
	MODHEXMAP = "cbdefghijklnrtuv"
	// CRCOKRESIDUE as defined in libyubikey/yubikey.h:122


This section is empty.


func AesDecrypt

func AesDecrypt(state []byte, key string)

AesDecrypt function as declared in libyubikey/yubikey.h:129

func AesEncrypt

func AesEncrypt(state []byte, key string)

AesEncrypt function as declared in libyubikey/yubikey.h:130

func Crc16

func Crc16(buf string, bufSize uint) uint16

Crc16 function as declared in libyubikey/yubikey.h:123

func Generate

func Generate(token *Token, key *[16]byte, out *[32]byte)

Generate function as declared in libyubikey/yubikey.h:81

func HexDecode

func HexDecode(dst []byte, src string, dstsize uint)

HexDecode function as declared in libyubikey/yubikey.h:111

func HexEncode

func HexEncode(dst []byte, src string, srcsize uint)

HexEncode function as declared in libyubikey/yubikey.h:110

func HexP

func HexP(str string) int32

HexP function as declared in libyubikey/yubikey.h:116

func ModhexDecode

func ModhexDecode(dst []byte, src string, dstsize uint)

ModhexDecode function as declared in libyubikey/yubikey.h:106

func ModhexEncode

func ModhexEncode(dst []byte, src string, srcsize uint)

ModhexEncode function as declared in libyubikey/yubikey.h:100

func ModhexP

func ModhexP(str string) int32

ModhexP function as declared in libyubikey/yubikey.h:115

func Parse

func Parse(token *[16]byte, key *[16]byte, out *Token)

Parse function as declared in libyubikey/yubikey.h:76


type Token

type Token struct {
	Uid   [6]byte
	Ctr   uint16
	Tstpl uint16
	Tstph byte
	Use   byte
	Rnd   uint16
	Crc   uint16
	// contains filtered or unexported fields

Token as declared in libyubikey/yubikey.h:68

func NewTokenRef

func NewTokenRef(ref unsafe.Pointer) *Token

NewTokenRef creates a new wrapper struct with underlying reference set to the original C object. Returns nil if the provided pointer to C object is nil too.

func (*Token) Deref

func (x *Token) Deref()

Deref uses the underlying reference to C object and fills the wrapping struct with values. Do not forget to call this method whether you get a struct for C object and want to read its values.

func (*Token) Free

func (x *Token) Free()

Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. Does nothing if struct is nil or has no allocation map.

func (*Token) PassRef

func (x *Token) PassRef() (*C.yubikey_token_st, *cgoAllocMap)

PassRef returns the underlying C object, otherwise it will allocate one and set its values from this wrapping struct, counting allocations into an allocation map.

func (Token) PassValue

func (x Token) PassValue() (C.yubikey_token_st, *cgoAllocMap)

PassValue does the same as PassRef except that it will try to dereference the returned pointer.

func (*Token) Ref

func (x *Token) Ref() *C.yubikey_token_st

Ref returns the underlying reference to C object or nil if struct is nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL