mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 15:43:21 +00:00
use constant time comparison for sha1 password hash
This commit is contained in:
parent
46b020fd9e
commit
5a6ed2ffdf
1 changed files with 1 additions and 1 deletions
|
@ -254,7 +254,7 @@ func (h *HtpasswdFile) Validate(user string, password string) bool {
|
||||||
case shaRe.MatchString(realPassword):
|
case shaRe.MatchString(realPassword):
|
||||||
d := sha1.New()
|
d := sha1.New()
|
||||||
_, _ = d.Write([]byte(password))
|
_, _ = d.Write([]byte(password))
|
||||||
if realPassword[5:] == base64.StdEncoding.EncodeToString(d.Sum(nil)) {
|
if subtle.ConstantTimeCompare([]byte(realPassword[5:]), []byte(base64.StdEncoding.EncodeToString(d.Sum(nil)))) == 1 {
|
||||||
isValid = true
|
isValid = true
|
||||||
}
|
}
|
||||||
case bcrRe.MatchString(realPassword):
|
case bcrRe.MatchString(realPassword):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue