Skip to content

Commit e3f150b

Browse files
datianshiagl
authored andcommitted
ssh: add hmac-sha2-256.
Fixes golang/go#10274 Change-Id: Id8386828ee92ccc6cba5197831cdb8b2ce0cd648 Reviewed-on: https://go-review.googlesource.com/8353 Reviewed-by: Adam Langley <[email protected]> Run-TryBot: Adam Langley <[email protected]>
1 parent 74f810a commit e3f150b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ssh/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var supportedHostKeyAlgos = []string{
5353
// This is based on RFC 4253, section 6.4, but with hmac-md5 variants removed
5454
// because they have reached the end of their useful life.
5555
var supportedMACs = []string{
56-
"hmac-sha1", "hmac-sha1-96",
56+
"hmac-sha2-256", "hmac-sha1", "hmac-sha1-96",
5757
}
5858

5959
var supportedCompressions = []string{compressionNone}

ssh/mac.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package ssh
99
import (
1010
"crypto/hmac"
1111
"crypto/sha1"
12+
"crypto/sha256"
1213
"hash"
1314
)
1415

@@ -44,6 +45,9 @@ func (t truncatingMAC) Size() int {
4445
func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() }
4546

4647
var macModes = map[string]*macMode{
48+
"hmac-sha2-256": {32, func(key []byte) hash.Hash {
49+
return hmac.New(sha256.New, key)
50+
}},
4751
"hmac-sha1": {20, func(key []byte) hash.Hash {
4852
return hmac.New(sha1.New, key)
4953
}},

0 commit comments

Comments
 (0)