From 46766a72f085d1a5a91b448491ef59016a7a2bbb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2020 21:03:12 -0800 Subject: [PATCH] Expose GIT_CERT_SSH_SHA256 (#690) (#694) Newer versions of libssh2 use SHA256 fingerprints (cherry picked from commit 7497529f70862c140bc1c3b89e95919a48a9bf42) Co-authored-by: Hans Duedal --- remote.go | 18 ++++++++++-------- 1 file 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)