Case insensitive algorithm match
This commit is contained in:
7
totp.go
7
totp.go
@@ -123,12 +123,11 @@ func totpFromURL(u *url.URL) (*TOTP, string, error) {
|
||||
|
||||
var algo = crypto.SHA1
|
||||
if algorithm := v.Get("algorithm"); algorithm != "" {
|
||||
switch {
|
||||
case algorithm == "SHA256":
|
||||
if strings.EqualFold(algorithm, "SHA256") {
|
||||
algo = crypto.SHA256
|
||||
case algorithm == "SHA512":
|
||||
} else if strings.EqualFold(algorithm, "SHA512") {
|
||||
algo = crypto.SHA512
|
||||
case algorithm != "SHA1":
|
||||
} else if !strings.EqualFold(algorithm, "SHA1") {
|
||||
return nil, "", ErrInvalidAlgo
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user