mirror of
https://github.com/restic/rest-server.git
synced 2025-12-06 17:15:45 -08:00
use constant time comparison for sha1 password hash
This commit is contained in:
committed by
Leo R. Lundgren
parent
46b020fd9e
commit
5a6ed2ffdf
@@ -254,7 +254,7 @@ func (h *HtpasswdFile) Validate(user string, password string) bool {
|
||||
case shaRe.MatchString(realPassword):
|
||||
d := sha1.New()
|
||||
_, _ = 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
|
||||
}
|
||||
case bcrRe.MatchString(realPassword):
|
||||
|
||||
Reference in New Issue
Block a user