Documentation ¶
Index ¶
- Constants
- func BuildUri(otpType, secret, accountName, issuerName, algorithm string, ...) string
- func IsSecretValid(secret string) bool
- func Itob(integer int64) []byte
- func RandomSecret(length int) string
- type HOTP
- type Hasher
- type OTP
- type TOTP
- func (t *TOTP) At(timestamp int64) string
- func (t *TOTP) AtTime(timestamp time.Time) string
- func (t *TOTP) Now() string
- func (t *TOTP) NowWithExpiration() (string, int64)
- func (t *TOTP) ProvisioningUri(accountName, issuerName string) string
- func (t *TOTP) Verify(otp string, timestamp int64) bool
- func (t *TOTP) VerifyTime(otp string, timestamp time.Time) bool
Constants ¶
const ( OtpTypeTotp = "totp" OtpTypeHotp = "hotp" )
Variables ¶
This section is empty.
Functions ¶
func BuildUri ¶
func BuildUri(otpType, secret, accountName, issuerName, algorithm string, initialCount, digits int, period int) string
Returns the provisioning URI for the OTP; works for either TOTP or HOTP. This can then be encoded in a QR Code and used to provision the Google Authenticator app. For module-internal use. See also:
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
params:
otpType: otp type, must in totp/hotp secret: the hotp/totp secret used to generate the URI accountName: name of the account issuerName: the name of the OTP issuer; this will be the organization title of the OTP entry in Authenticator algorithm: the algorithm used in the OTP generation initialCount: starting counter value. Only works for hotp digits: the length of the OTP generated code. period: the number of seconds the OTP generator is set to expire every code.
returns: provisioning uri
func IsSecretValid ¶
A non-panic way of seeing weather or not a given secret is valid
func RandomSecret ¶
RandomSecret generates a random secret of given length (number of bytes) returns empty string if something bad happened
Types ¶
type HOTP ¶
type HOTP struct {
OTP
}
HMAC-based OTP counters.
func NewDefaultHOTP ¶
func (*HOTP) ProvisioningUri ¶
Returns the provisioning URI for the OTP. This can then be encoded in a QR Code and used to provision an OTP app like Google Authenticator.
See also:
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
params:
accountName: name of the account issuerName: the name of the OTP issuer; this will be the organization title of the OTP entry in Authenticator initialCount: starting HMAC counter value
returns: provisioning URI
type TOTP ¶
type TOTP struct { OTP // contains filtered or unexported fields }
time-based OTP counters.
func NewDefaultTOTP ¶
func (*TOTP) NowWithExpiration ¶
Generate the current time OTP and expiration time
func (*TOTP) ProvisioningUri ¶
Returns the provisioning URI for the OTP. This can then be encoded in a QR Code and used to provision an OTP app like Google Authenticator.
See also:
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
params:
accountName: name of the account issuerName: the name of the OTP issuer; this will be the organization title of the OTP entry in Authenticator
returns: provisioning URI