summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Duedal <[email protected]>2020-11-27 02:32:24 +0100
committerGitHub <[email protected]>2020-11-26 17:32:24 -0800
commit7497529f70862c140bc1c3b89e95919a48a9bf42 (patch)
treec29c5b4e00e4c5a1e083e7b137d2a255032831c3
parent2bd574b6bd75a044f526cf882161db08ac3cb633 (diff)
Expose GIT_CERT_SSH_SHA256 (#690)
Newer versions of libssh2 use SHA256 fingerprints
-rw-r--r--remote.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/remote.go b/remote.go
index 775c851..667408b 100644
--- a/remote.go
+++ b/remote.go
@@ -172,17 +172,18 @@ type Certificate struct {
type HostkeyKind uint
const (
- HostkeyMD5 HostkeyKind = C.GIT_CERT_SSH_MD5
- HostkeySHA1 HostkeyKind = C.GIT_CERT_SSH_SHA1
+ HostkeyMD5 HostkeyKind = C.GIT_CERT_SSH_MD5
+ HostkeySHA1 HostkeyKind = C.GIT_CERT_SSH_SHA1
+ HostkeySHA256 HostkeyKind = C.GIT_CERT_SSH_SHA256
)
-// Server host key information. If Kind is HostkeyMD5 the MD5 field
-// will be filled. If Kind is HostkeySHA1, then HashSHA1 will be
-// filled.
+// Server host key information. A bitmask containing the available fields.
+// Check for combinations of: HostkeyMD5, HostkeySHA1, HostkeySHA256.
type HostkeyCertificate struct {
- Kind HostkeyKind
- HashMD5 [16]byte
- HashSHA1 [20]byte
+ Kind HostkeyKind
+ HashMD5 [16]byte
+ HashSHA1 [20]byte
+ HashSHA256 [32]byte
}
type PushOptions struct {
@@ -318,6 +319,7 @@ func certificateCheckCallback(_cert *C.git_cert, _valid C.int, _host *C.char, da
cert.Hostkey.Kind = HostkeyKind(ccert._type)
C.memcpy(unsafe.Pointer(&cert.Hostkey.HashMD5[0]), unsafe.Pointer(&ccert.hash_md5[0]), C.size_t(len(cert.Hostkey.HashMD5)))
C.memcpy(unsafe.Pointer(&cert.Hostkey.HashSHA1[0]), unsafe.Pointer(&ccert.hash_sha1[0]), C.size_t(len(cert.Hostkey.HashSHA1)))
+ C.memcpy(unsafe.Pointer(&cert.Hostkey.HashSHA256[0]), unsafe.Pointer(&ccert.hash_sha256[0]), C.size_t(len(cert.Hostkey.HashSHA256)))
} else {
cstr := C.CString("Unsupported certificate type")
C.giterr_set_str(C.GITERR_NET, cstr)