Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase default TOTP secret size to 20 bytes #30

Merged
merged 1 commit into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions totp/totp.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type GenerateOpts struct {
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 10 bytes.
// Size in size of the generated Secret. Defaults to 20 bytes.
SecretSize uint
// Digits to request. Defaults to 6.
Digits otp.Digits
Expand All @@ -160,7 +160,7 @@ func Generate(opts GenerateOpts) (*otp.Key, error) {
}

if opts.SecretSize == 0 {
opts.SecretSize = 10
opts.SecretSize = 20
}

if opts.Digits == 0 {
Expand Down
2 changes: 1 addition & 1 deletion totp/totp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestGenerate(t *testing.T) {
require.NoError(t, err, "generate basic TOTP")
require.Equal(t, "SnakeOil", k.Issuer(), "Extracting Issuer")
require.Equal(t, "[email protected]", k.AccountName(), "Extracting Account Name")
require.Equal(t, 16, len(k.Secret()), "Secret is 16 bytes long as base32.")
require.Equal(t, 32, len(k.Secret()), "Secret is 32 bytes long as base32.")

k, err = Generate(GenerateOpts{
Issuer: "SnakeOil",
Expand Down