rfc6238

package
v0.0.0-...-88ba0c5 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// default time step interval: 30 seconds
	TIMESTEP = 30
	// gmtime(0) or 1 Jan 1970. Unix Epoch
	EPOCH = 0
)

Variables

This section is empty.

Functions

func GoogleAuth

func GoogleAuth(key []byte, length int) string

Google Auth compliant TOTP generation function

key: array of base32-encoded key bytes length: length of the resulting totp token

func Totp

func Totp(key []byte, length int, timestep int, base32 bool, algorithm string) string

RFC6238 compliant TOTP generation function

key: array of key bytes length: length of the resulting totp token timestep: period of validity of the computed token (seconds)

Types

type TOTP

type TOTP struct {
	// contains filtered or unexported fields
}

totp token object

func NewTotp

func NewTotp(key []byte, timecounter int, timestep int, token_len int, is_base32 bool, algorithm string) TOTP

generate a new totp object

func (*TOTP) TokenToString

func (v *TOTP) TokenToString() string

return a string representation of the totp token integer value

totpToken: result of the TotpToken() function token_len: length of the computed Token

func (*TOTP) TotpToken

func (v *TOTP) TotpToken() error

generic TOTP compute function computes the TOTP token as per RFC 6238. returns an unsigned 32-bit integer representation of the TOTP token that can be used as is or otherwise converted into another formant (e.g. string)

key: byte array of the secret key to use during computation timecounter: point in time from epoch for which you wan to compute the TOTP (default is time.Now()) timestep: TOTP token period. default is 30 seconds (google-auth compatibility) token_len: length of the TOTP token in bytes (default is 6) is_base32: specifies whether the key array is base32 encoded or not (google-auth compatibility) digestFunc: HMAC function to use during computation

Jump to

Keyboard shortcuts

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