forked from golang/crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes golang/go#17676 Change-Id: I96c51431b174898a6bc0f6bec7f4561d5d64819f
- Loading branch information
Showing
6 changed files
with
138 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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-256[email protected]", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96", | ||
} | ||
|
||
var supportedCompressions = []string{compressionNone} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import ( | |
|
||
type macMode struct { | ||
keySize int | ||
etm bool | ||
new func(key []byte) hash.Hash | ||
} | ||
|
||
|
@@ -45,13 +46,16 @@ func (t truncatingMAC) Size() int { | |
func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } | ||
|
||
var macModes = map[string]*macMode{ | ||
"hmac-sha2-256": {32, func(key []byte) hash.Hash { | ||
"hmac-sha2-256[email protected]": {32, true, func(key []byte) hash.Hash { | ||
return hmac.New(sha256.New, key) | ||
}}, | ||
"hmac-sha1": {20, func(key []byte) hash.Hash { | ||
"hmac-sha2-256": {32, false, func(key []byte) hash.Hash { | ||
return hmac.New(sha256.New, key) | ||
}}, | ||
"hmac-sha1": {20, false, func(key []byte) hash.Hash { | ||
return hmac.New(sha1.New, key) | ||
}}, | ||
"hmac-sha1-96": {20, func(key []byte) hash.Hash { | ||
"hmac-sha1-96": {20, false, func(key []byte) hash.Hash { | ||
return truncatingMAC{12, hmac.New(sha1.New, key)} | ||
}}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -320,6 +320,29 @@ func TestMACs(t *testing.T) { | |
} | ||
} | ||
|
||
func TestMACsEtM(t *testing.T) { | ||
var config ssh.Config | ||
config.SetDefaults() | ||
macOrder := []string{} | ||
for _, mac := range config.MACs { | ||
if len(mac) > 16 && mac[len(mac)-16:] == "[email protected]" { | ||
macOrder = append(macOrder, mac) | ||
} | ||
} | ||
|
||
for _, mac := range macOrder { | ||
server := newServer(t) | ||
defer server.Shutdown() | ||
conf := clientConfig() | ||
conf.MACs = []string{mac} | ||
if conn, err := server.TryDial(conf); err == nil { | ||
conn.Close() | ||
} else { | ||
t.Fatalf("failed for MAC %q", mac) | ||
} | ||
} | ||
} | ||
|
||
func TestKeyExchanges(t *testing.T) { | ||
var config ssh.Config | ||
config.SetDefaults() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters