From 6068a2e6cfdc895ce524b6d2bdc8ea0cea8ea0e8 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Wed, 2 Mar 2022 08:24:15 -0800 Subject: ssh: ignore MAC if AEAD ciphers negotiated If the server/client cipher chosen is one of the two AEAD ciphers that we support (aes128-gcm@openssh.com and chacha20-poly1305@openssh.com), don't attempt to find a common MAC algorithm in findAgreedAlgorithms. Similarly in newPacketCipher, don't attempt to generate a MAC key if we are using a AEAD cipher. Fixes golang/go#51406 Change-Id: Id48ae72f052cb0a0c597b32e9901a0f218e4161f Reviewed-on: https://go-review.googlesource.com/c/crypto/+/389214 Trust: Roland Shoemaker Run-TryBot: Roland Shoemaker TryBot-Result: Gopher Robot Reviewed-by: Filippo Valsorda --- ssh/handshake_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'ssh/handshake_test.go') diff --git a/ssh/handshake_test.go b/ssh/handshake_test.go index 02fbe83..46bfd6d 100644 --- a/ssh/handshake_test.go +++ b/ssh/handshake_test.go @@ -560,3 +560,26 @@ func TestHandshakeRekeyDefault(t *testing.T) { t.Errorf("got rekey after %dG write, want 64G", wgb) } } + +func TestHandshakeAEADCipherNoMAC(t *testing.T) { + for _, cipher := range []string{chacha20Poly1305ID, gcmCipherID} { + checker := &syncChecker{ + called: make(chan int, 1), + } + clientConf := &ClientConfig{ + Config: Config{ + Ciphers: []string{cipher}, + MACs: []string{}, + }, + HostKeyCallback: checker.Check, + } + trC, trS, err := handshakePair(clientConf, "addr", false) + if err != nil { + t.Fatalf("handshakePair: %v", err) + } + defer trC.Close() + defer trS.Close() + + <-checker.called + } +} -- cgit v1.3