Skip to content

Commit

Permalink
Better password hashes error handling (thomiceli#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Oct 13, 2023
1 parent 7059d5c commit b1acea9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/web/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,16 @@ func (a Argon2ID) hash(plain string) (string, error) {
}

func (a Argon2ID) verify(plain, hash string) (bool, error) {
if hash == "" {
return false, nil
}

hashParts := strings.Split(hash, "$")

if len(hashParts) != 6 {
return false, errors.New("invalid hash")
}

_, err := fmt.Sscanf(hashParts[3], "m=%d,t=%d,p=%d", &a.memory, &a.time, &a.threads)
if err != nil {
return false, err
Expand Down

0 comments on commit b1acea9

Please sign in to comment.