nits
This commit is contained in:
@ -23,8 +23,8 @@ import (
|
|||||||
// IndexNow returns the current 30-second time step, and the number of seconds
|
// IndexNow returns the current 30-second time step, and the number of seconds
|
||||||
// remaining until it ends.
|
// remaining until it ends.
|
||||||
func IndexNow() (uint64, int) {
|
func IndexNow() (uint64, int) {
|
||||||
time := time.Now().Unix()
|
t := time.Now().Unix()
|
||||||
return uint64(time / 30), int(time % 30)
|
return uint64(t / 30), int(t % 30)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pickAlgorithm returns a constructor for the named hash function, or
|
// pickAlgorithm returns a constructor for the named hash function, or
|
||||||
@ -96,7 +96,7 @@ func LoadConfigFile(path string, getPass func() ([]byte, error)) ([]byte, error)
|
|||||||
salt := data[8:16]
|
salt := data[8:16]
|
||||||
rest := data[16:]
|
rest := data[16:]
|
||||||
salting := sha256.New()
|
salting := sha256.New()
|
||||||
salting.Write([]byte(passwd))
|
salting.Write(passwd)
|
||||||
salting.Write(salt)
|
salting.Write(salt)
|
||||||
sum := salting.Sum(nil)
|
sum := salting.Sum(nil)
|
||||||
key := sum[:16]
|
key := sum[:16]
|
||||||
@ -119,7 +119,7 @@ func LoadConfigFile(path string, getPass func() ([]byte, error)) ([]byte, error)
|
|||||||
return nil, errors.New("invalid block padding")
|
return nil, errors.New("invalid block padding")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rest[:len(rest)-int(pad)], nil
|
return rest[:len(rest)-pad], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseConfig parses the contents of data as a gauth configuration file. Each
|
// ParseConfig parses the contents of data as a gauth configuration file. Each
|
||||||
@ -155,7 +155,7 @@ func ParseConfig(data []byte) ([]*otpauth.URL, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy format (name:secret)
|
// Simple format (name:secret)
|
||||||
parts := strings.SplitN(trim, ":", 2)
|
parts := strings.SplitN(trim, ":", 2)
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
return nil, fmt.Errorf("line %d: invalid format (want name:secret)", ln+1)
|
return nil, fmt.Errorf("line %d: invalid format (want name:secret)", ln+1)
|
||||||
|
Reference in New Issue
Block a user