Skip to content

Commit

Permalink
Merge pull request #30 from clarcharr/master
Browse files Browse the repository at this point in the history
Increase default TOTP secret size to 20 bytes
  • Loading branch information
pquerna authored Jun 21, 2018
2 parents 40d6240 + b34af48 commit 7b7d3c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 7b7d3c7

Please sign in to comment.