Skip to content

Commit

Permalink
add support for lowercase digest algorithms (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
modiius authored Nov 23, 2024
1 parent c2fe096 commit 8f62119
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ type Options struct {

// CanDigest checks if the algorithm and qop are supported
func CanDigest(c *Challenge) bool {
switch c.Algorithm {
algorithm := strings.ToUpper(c.Algorithm)
switch algorithm {
case "", "MD5", "SHA-256", "SHA-512", "SHA-512-256":
default:
return false
Expand All @@ -60,7 +61,8 @@ func Digest(chal *Challenge, o Options) (*Credentials, error) {
}
// we re-use the same hash.Hash
var h hash.Hash
switch cred.Algorithm {
algorithm := strings.ToUpper(cred.Algorithm)
switch algorithm {
case "", "MD5":
h = md5.New()
case "SHA-256":
Expand Down

0 comments on commit 8f62119

Please sign in to comment.