otp

package
v0.0.0-...-7690095 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefWindowSize     = 100
	DefTimeWindowSize = 2
	DefInterval       = 30
	DefDigits         = 6
)

Variables

View Source
var (
	ErrContainsColon = errors.New("issuer/account name cannot contain colon")
	ErrInvalidLen    = errors.New("password can only be 6 or 8 characters long")
)

Functions

func GenerateSecret

func GenerateSecret() string

Types

type HOTP

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

func NewHOTP

func NewHOTP(secret string) *HOTP

func NewHOTPAccount

func NewHOTPAccount(secret, issuer, account string) (hotp *HOTP)

func (*HOTP) AccountName

func (ho *HOTP) AccountName() string

func (*HOTP) Counter

func (ho *HOTP) Counter() uint64

func (*HOTP) Digits

func (ho *HOTP) Digits() int

func (*HOTP) HashFuncName

func (ho *HOTP) HashFuncName() string

func (*HOTP) IncCounter

func (ho *HOTP) IncCounter()

func (*HOTP) Interval

func (ho *HOTP) Interval() int

func (*HOTP) Issuer

func (ho *HOTP) Issuer() string

func (*HOTP) Password

func (ho *HOTP) Password() string

func (*HOTP) PasswordAt

func (ho *HOTP) PasswordAt(counter uint64) string

func (*HOTP) SetAccountName

func (ho *HOTP) SetAccountName(account string) error

func (*HOTP) SetCounter

func (ho *HOTP) SetCounter(c uint64)

func (*HOTP) SetDigits

func (ho *HOTP) SetDigits(d int) error

func (*HOTP) SetHashFunc

func (ho *HOTP) SetHashFunc(name string, h func() hash.Hash)

func (*HOTP) SetInterval

func (ho *HOTP) SetInterval(_ int)

func (*HOTP) SetIssuer

func (ho *HOTP) SetIssuer(issuer string) error

func (*HOTP) SetWindowSize

func (ho *HOTP) SetWindowSize(c int)

func (*HOTP) String

func (ho *HOTP) String() string

func (*HOTP) Type

func (ho *HOTP) Type() string

func (*HOTP) URI

func (ho *HOTP) URI() string

func (*HOTP) UseSHA1

func (ho *HOTP) UseSHA1()

func (*HOTP) UseSHA256

func (ho *HOTP) UseSHA256()

func (*HOTP) UseSHA512

func (ho *HOTP) UseSHA512()

func (*HOTP) Verify

func (ho *HOTP) Verify(password string) bool

func (*HOTP) VerifyAt

func (ho *HOTP) VerifyAt(password string, counter uint64) bool

func (*HOTP) WindowSize

func (ho *HOTP) WindowSize() int

type OTP

type OTP interface {
	Type() string
	SetIssuer(string) error
	Issuer() string
	SetAccountName(string) error
	AccountName() string
	SetHashFunc(string, func() hash.Hash)
	UseSHA1()
	UseSHA256()
	UseSHA512()
	HashFuncName() string
	SetDigits(int) error
	Digits() int
	SetCounter(uint64)
	Counter() uint64
	IncCounter()
	SetWindowSize(int)
	WindowSize() int
	VerifyAt(string, uint64) bool
	Verify(string) bool
	String() string
	URI() string
	PasswordAt(uint64) string
	Password() string
	SetInterval(int)
	Interval() int
}

func NewOTP

func NewOTP(uri string) (otp OTP)

type TOTP

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

func NewTOTP

func NewTOTP(secret string) *TOTP

func NewTOTPAccount

func NewTOTPAccount(secret, issuer, account string) (totp *TOTP)

func (*TOTP) Interval

func (to *TOTP) Interval() int

func (*TOTP) Password

func (to *TOTP) Password() string

func (*TOTP) PasswordAt

func (to *TOTP) PasswordAt(time uint64) string

func (*TOTP) SetInterval

func (to *TOTP) SetInterval(seconds int)

func (*TOTP) Type

func (to *TOTP) Type() string

func (*TOTP) URI

func (to *TOTP) URI() string

func (*TOTP) Verify

func (to *TOTP) Verify(password string) bool

func (*TOTP) VerifyAt

func (to *TOTP) VerifyAt(password string, time uint64) bool

Jump to

Keyboard shortcuts

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