From 2f7b6a24772f2f6411c7d8d8c48dd78d4ee0c546 Mon Sep 17 00:00:00 2001 From: Franz Bettag Date: Tue, 23 Aug 2016 21:08:10 +0200 Subject: [PATCH] ssh: 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 2c72ab544b..6bd0582c8b 100644 --- a/ssh/common.go +++ b/ssh/common.go @@ -56,7 +56,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", "hmac-sha1", "hmac-sha1-96", + "hmac-sha2-512", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96", } var supportedCompressions = []string{compressionNone} diff --git a/ssh/mac.go b/ssh/mac.go index 07744ad671..cd09997d95 100644 --- a/ssh/mac.go +++ b/ssh/mac.go @@ -10,6 +10,7 @@ import ( "crypto/hmac" "crypto/sha1" "crypto/sha256" + "crypto/sha512" "hash" ) @@ -45,6 +46,9 @@ func (t truncatingMAC) Size() int { func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } var macModes = map[string]*macMode{ + "hmac-sha2-512": {64, func(key []byte) hash.Hash { + return hmac.New(sha512.New, key) + }}, "hmac-sha2-256": {32, func(key []byte) hash.Hash { return hmac.New(sha256.New, key) }},