Documentation ¶
Overview ¶
Package otp support generation of and validation of time synchronized one-time-pad codes. The conventions used by this package are the default ones used by the Google Authenticator application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid structure")
ErrInvalid indicates the id requested is unknown.
var ErrUnknown = errors.New("id unknown")
ErrUnknown indicates the id requested is unknown.
Functions ¶
This section is empty.
Types ¶
type KnownIDs ¶
type KnownIDs struct { // Issuer holds the OTP issuer name string. Issuer string // Map holds OTP secret information indexed by user ID. Map map[string]string // contains filtered or unexported fields }
KnownIDs holds access key material for a set of known IDs.
func NewKnownIDs ¶
NewKnownIDs returns a structure holding an issuer's list of secrets indexed by IDs.
func (*KnownIDs) AddKey ¶
AddKey adds a (replacement) issuer key for the specified id. The 80 bits of key material must be provided in valid base32 encoding.
func (*KnownIDs) TimeURI ¶
TimeURI returns a universal resource identifier for TOTP setup. Converting the returned string into a QR code, for example, will allow Google Authenticator to import the TOTP keys.
func (*KnownIDs) ValidateTimeCode ¶
ValidateTimeCode validates a numerical code as satisfying the TOTP criteria. If adjust is non-zero then that many time value indices adjacent to the current time are also checked and any of them are considered valid. No attempts are made to protect against a replay attack.