File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ typedef enum {
7878 GIT_CERT_SSH_MD5 = (1 << 0 ),
7979 /** SHA-1 is available */
8080 GIT_CERT_SSH_SHA1 = (1 << 1 ),
81+ /** SHA-256 is available */
82+ GIT_CERT_SSH_SHA256 = (1 << 2 ),
8183} git_cert_ssh_t ;
8284
8385/**
@@ -103,6 +105,12 @@ typedef struct {
103105 * have the SHA-1 hash of the hostkey.
104106 */
105107 unsigned char hash_sha1 [20 ];
108+
109+ /**
110+ * Hostkey hash. If type has `GIT_CERT_SSH_SHA256` set, this will
111+ * have the SHA-256 hash of the hostkey.
112+ */
113+ unsigned char hash_sha256 [32 ];
106114} git_cert_hostkey ;
107115
108116/**
Original file line number Diff line number Diff line change @@ -566,6 +566,14 @@ static int _git_ssh_setup_conn(
566566
567567 cert .parent .cert_type = GIT_CERT_HOSTKEY_LIBSSH2 ;
568568
569+ #ifdef LIBSSH2_HOSTKEY_HASH_SHA256
570+ key = libssh2_hostkey_hash (session , LIBSSH2_HOSTKEY_HASH_SHA256 );
571+ if (key != NULL ) {
572+ cert .type |= GIT_CERT_SSH_SHA256 ;
573+ memcpy (& cert .hash_sha256 , key , 32 );
574+ }
575+ #endif
576+
569577 key = libssh2_hostkey_hash (session , LIBSSH2_HOSTKEY_HASH_SHA1 );
570578 if (key != NULL ) {
571579 cert .type |= GIT_CERT_SSH_SHA1 ;
You can’t perform that action at this time.
0 commit comments