From d4bc71791feba21fe6058ab3d35266e53ff9ef48 Mon Sep 17 00:00:00 2001 From: Cookie <136936422@qq.com> Date: Sat, 7 Jan 2023 06:35:27 +0000 Subject: [PATCH] add hmac-sha2-512. --- ssh/common.go | 2 +- ssh/mac.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ssh/common.go b/ssh/common.go index c7964275de..933e6238e7 100644 --- a/ssh/common.go +++ b/ssh/common.go @@ -85,7 +85,7 @@ var supportedHostKeyAlgos = []string{ // This is based on RFC 4253, section 6.4, but with hmac-md5 variants removed // because they have reached the end of their useful life. var supportedMACs = []string{ - "hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96", + "hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha2-512" ,"hmac-sha1", "hmac-sha1-96", } var supportedCompressions = []string{compressionNone} diff --git a/ssh/mac.go b/ssh/mac.go index c07a06285e..6341e3c4eb 100644 --- a/ssh/mac.go +++ b/ssh/mac.go @@ -10,6 +10,7 @@ import ( "crypto/hmac" "crypto/sha1" "crypto/sha256" + "crypto/sha512" "hash" ) @@ -52,6 +53,9 @@ var macModes = map[string]*macMode{ "hmac-sha2-256": {32, false, func(key []byte) hash.Hash { return hmac.New(sha256.New, key) }}, + "hmac-sha2-512": {64, false, func(key []byte) hash.Hash { + return hmac.New(sha512.New, key) + }}, "hmac-sha1": {20, false, func(key []byte) hash.Hash { return hmac.New(sha1.New, key) }},