Case insensitive algorithm match

This commit is contained in:
Paul TREHIOU
2017-12-23 19:03:14 +01:00
committed by Kyle Isom
parent eaad1884d4
commit 2cf2c15def

View File

@@ -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
}
}