Fix hash type switch statement

Signed-off-by: Philip Laine <philip.laine@gmail.com>
This commit is contained in:
Philip Laine 2021-02-12 08:43:40 +01:00
parent 6b3d96ef3b
commit f9ddeb06e1
1 changed files with 8 additions and 8 deletions

View File

@ -205,16 +205,16 @@ func (k knownKey) matches(host string, hostkey git2go.HostkeyCertificate) bool {
var fingerprint []byte var fingerprint []byte
var hasher hash.Hash var hasher hash.Hash
switch hostkey.Kind { switch {
case git2go.HostkeyMD5: case hostkey.Kind&git2go.HostkeySHA256 > 0:
fingerprint = hostkey.HashMD5[:]
hasher = md5.New()
case git2go.HostkeySHA1:
fingerprint = hostkey.HashSHA1[:]
hasher = sha1.New()
case git2go.HostkeySHA256:
fingerprint = hostkey.HashSHA256[:] fingerprint = hostkey.HashSHA256[:]
hasher = sha256.New() hasher = sha256.New()
case hostkey.Kind&git2go.HostkeySHA1 > 0:
fingerprint = hostkey.HashSHA1[:]
hasher = sha1.New()
case hostkey.Kind&git2go.HostkeyMD5 > 0:
fingerprint = hostkey.HashMD5[:]
hasher = md5.New()
default: default:
return false return false
} }