Skip to content

Commit

Permalink
ssh: add support for aes256-gcm@openssh.com
Browse files Browse the repository at this point in the history
  • Loading branch information
drakkan committed Feb 15, 2023
1 parent a9f661c commit 460b96d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions ssh/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var cipherModes = map[string]*cipherMode{

// AEAD ciphers
gcmCipherID: {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
7 changes: 4 additions & 3 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",
"aes128-gcm@openssh.com",
"aes128-gcm@openssh.com", 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{
"aes128-gcm@openssh.com",
"aes128-gcm@openssh.com", 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", gcmCipherID, gcm256CipherID, aes128cbcID:
return 16 * (1 << 32)

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

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

Expand Down
1 change: 1 addition & 0 deletions ssh/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const debugTransport = false

const (
gcmCipherID = "aes128-gcm@openssh.com"
gcm256CipherID = "aes256-gcm@openssh.com"
aes128cbcID = "aes128-cbc"
tripledescbcID = "3des-cbc"
)
Expand Down

0 comments on commit 460b96d

Please sign in to comment.