Skip to content

Commit db7d123

Browse files
ALTreehanwen
authored andcommitted
ssh/agent: remove len check in Unlock
Unlock compares the length of the passphrase with the given one before calling subtle.ConstantTimeCompare. This is redundant, since ConstantTimeCompare already perform a lengths check before doing anything. Remove the check from Unlock. Updates golang/go#25173 Change-Id: Ib5fec3a94392bddf2996f5c6bf5a414529e86f2f Reviewed-on: https://go-review.googlesource.com/110068 Run-TryBot: Alberto Donizetti <[email protected]> Reviewed-by: Han-Wen Nienhuys <[email protected]>
1 parent b49d69b commit db7d123

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ssh/agent/keyring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (r *keyring) Unlock(passphrase []byte) error {
102102
if !r.locked {
103103
return errors.New("agent: not locked")
104104
}
105-
if len(passphrase) != len(r.passphrase) || 1 != subtle.ConstantTimeCompare(passphrase, r.passphrase) {
105+
if 1 != subtle.ConstantTimeCompare(passphrase, r.passphrase) {
106106
return fmt.Errorf("agent: incorrect passphrase")
107107
}
108108

0 commit comments

Comments
 (0)