Skip to content

Commit

Permalink
ssh: add support for [email protected]
Browse files Browse the repository at this point in the history
Change-Id: I91caf3bda3dfd00c050f5ebf23c2a35a04c5762b
GitHub-Last-Rev: 6e71340
GitHub-Pull-Request: golang#127
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/223518
Auto-Submit: Filippo Valsorda <[email protected]>
Run-TryBot: Filippo Valsorda <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Roland Shoemaker <[email protected]>
Reviewed-by: Filippo Valsorda <[email protected]>
Reviewed-by: Han-Wen Nienhuys <[email protected]>
  • Loading branch information
drakkan authored and Maisem Ali committed Jul 11, 2023
1 parent b6debe4 commit 9dc6225
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ssh/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ var cipherModes = map[string]*cipherMode{
"arcfour": {16, 0, streamCipherMode(0, newRC4)},

// AEAD ciphers
gcmCipherID: {16, 12, newGCMCipher},
gcm128CipherID: {16, 12, newGCMCipher},
gcm256CipherID: {32, 12, newGCMCipher},
chacha20Poly1305ID: {64, 0, newChaCha20Cipher},

// CBC mode is insecure and so is not included in the default config.
Expand Down
2 changes: 1 addition & 1 deletion ssh/cipher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestCVE202143565(t *testing.T) {
constructPacket func(packetCipher) io.Reader
}{
{
cipher: gcmCipherID,
cipher: gcm128CipherID,
constructPacket: func(client packetCipher) io.Reader {
internalCipher := client.(*gcmCipher)
b := &bytes.Buffer{}
Expand Down
9 changes: 5 additions & 4 deletions ssh/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
// supportedCiphers lists ciphers we support but might not recommend.
var supportedCiphers = []string{
"aes128-ctr", "aes192-ctr", "aes256-ctr",
"[email protected]",
"[email protected]", gcm256CipherID,
chacha20Poly1305ID,
"arcfour256", "arcfour128", "arcfour",
aes128cbcID,
Expand All @@ -37,7 +37,7 @@ var supportedCiphers = []string{

// preferredCiphers specifies the default preference for ciphers.
var preferredCiphers = []string{
"[email protected]",
"[email protected]", gcm256CipherID,
chacha20Poly1305ID,
"aes128-ctr", "aes192-ctr", "aes256-ctr",
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func (a *directionAlgorithms) rekeyBytes() int64 {
// 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is
// 128.
switch a.Cipher {
case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcmCipherID, aes128cbcID:
case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcm128CipherID, gcm256CipherID, aes128cbcID:
return 16 * (1 << 32)

}
Expand All @@ -178,7 +178,8 @@ func (a *directionAlgorithms) rekeyBytes() int64 {
}

var aeadCiphers = map[string]bool{
gcmCipherID: true,
gcm128CipherID: true,
gcm256CipherID: true,
chacha20Poly1305ID: true,
}

Expand Down
2 changes: 1 addition & 1 deletion ssh/handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ func TestHandshakeRekeyDefault(t *testing.T) {
}

func TestHandshakeAEADCipherNoMAC(t *testing.T) {
for _, cipher := range []string{chacha20Poly1305ID, gcmCipherID} {
for _, cipher := range []string{chacha20Poly1305ID, gcm128CipherID} {
checker := &syncChecker{
called: make(chan int, 1),
}
Expand Down
3 changes: 2 additions & 1 deletion ssh/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
const debugTransport = false

const (
gcmCipherID = "[email protected]"
gcm128CipherID = "[email protected]"
gcm256CipherID = "[email protected]"
aes128cbcID = "aes128-cbc"
tripledescbcID = "3des-cbc"
)
Expand Down

0 comments on commit 9dc6225

Please sign in to comment.