Documentation ¶
Index ¶
Constants ¶
View Source
const ( DigitsSix Digits = 6 DigitsEight Digits = 8 DefaultPeriod uint = 30 DefaultDigits Digits = DigitsSix DefaultAlgorithm Algorithm = AlgorithmSHA1 DefaultSecretLength uint = 20 )
Variables ¶
View Source
var B32NoPadding = base32.StdEncoding.WithPadding(base32.NoPadding)
View Source
var ErrGenerateMissingAccountName = errors.New("AccountName must be set")
When generating a Key, the Account Name must be set.
View Source
var ErrGenerateMissingIssuer = errors.New("Issuer must be set")
When generating a Key, the Issuer must be set.
View Source
var ErrValidateInputInvalidLength = errors.New("Input length unexpected")
The user provided passcode length was not expected.
View Source
var ErrValidateSecretInvalidBase32 = errors.New("Decoding of secret as base32 failed.")
Error when attempting to convert the secret from base32 to raw bytes.
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm int
const ( // AlgorithmSHA1 should be used for compatibility with Google Authenticator. // // See https://github.com/pquerna/otp/issues/55 for additional details. AlgorithmSHA1 Algorithm = iota AlgorithmSHA256 AlgorithmSHA512 AlgorithmMD5 )
type Digits ¶
type Digits int
Digits represents the number of digits present in the user's OTP passcode. Six and Eight are the most common values.
type GenerateOpts ¶
type GenerateOpts struct { // Name of the issuing Organization/Company. Issuer string // Name of the User's Account (eg, email address) AccountName string // Number of seconds a TOTP hash is valid for. Defaults to 30 seconds. Period uint // Size in size of the generated Secret. Defaults to 20 bytes. SecretSize uint // Secret to store. Defaults to a randomly generated secret of SecretSize. You should generally leave this empty. Secret []byte // Digits to request. Defaults to 6. Digits Digits // Algorithm to use for HMAC. Defaults to SHA1. Algorithm Algorithm // Reader to use for generating TOTP Key. Rand io.Reader }
GenerateOpts provides options for Generate(). The default values are compatible with Google-Authenticator.
type ValidateOpts ¶
type ValidateOpts struct { // Number of seconds a TOTP hash is valid for. Defaults to 30 seconds. Period uint // Periods before or after the current time to allow. Value of 1 allows up to Period // of either side of the specified time. Defaults to 0 allowed skews. Values greater // than 1 are likely sketchy. Skew uint // Digits as part of the input. Defaults to 6. Digits Digits // Algorithm to use for HMAC. Defaults to SHA1. Algorithm Algorithm }
ValidateOpts provides options for ValidateCustom().
Click to show internal directories.
Click to hide internal directories.