]> Cypherpunks repositories - gostls13.git/commit
crypto/tls: make cipher suite preference ordering automatic
authorFilippo Valsorda <filippo@golang.org>
Wed, 28 Apr 2021 05:37:09 +0000 (01:37 -0400)
committerFilippo Valsorda <filippo@golang.org>
Sat, 8 May 2021 05:15:48 +0000 (05:15 +0000)
commit9d0819b27ca248f9949e7cf6bf7cb9fe7cf574e8
treedc56e40409a868107d6234be12d8a1c1bfb0d30f
parent02ce4118219dc51a14680a0c5fa24cf6e73deeed
crypto/tls: make cipher suite preference ordering automatic

We now have a (well, two, depending on AES hardware support) universal
cipher suite preference order, based on their security and performance.
Peer and application lists are now treated as filters (and AES hardware
support hints) that are applied to this universal order.

This removes a complex and nuanced decision from the application's
responsibilities, one which we are better equipped to make and which
applications usually don't need to have an opinion about. It also lets
us worry less about what suites we support or enable, because we can be
confident that bad ones won't be selected over good ones.

This also moves 3DES suites to InsecureCipherSuites(), even if they are
not disabled by default. Just because we can keep them as a last resort
it doesn't mean they are secure. Thankfully we had not promised that
Insecure means disabled by default.

Notable test changes:

  - TestCipherSuiteCertPreferenceECDSA was testing that we'd pick the
    right certificate regardless of CipherSuite ordering, which is now
    completely ignored, as tested by TestCipherSuitePreference. Removed.

  - The openssl command of TestHandshakeServerExportKeyingMaterial was
    broken for TLS 1.0 in CL 262857, but its golden file was not
    regenerated, so the test kept passing. It now broke because the
    selected suite from the ones in the golden file changed.

  - In TestAESCipherReordering, "server strongly prefers AES-GCM" is
    removed because there is no way for a server to express a strong
    preference anymore; "client prefers AES-GCM and AES-CBC over ChaCha"
    switched to ChaCha20 when the server lacks AES hardware; and finally
    "client supports multiple AES-GCM" changed to always prefer AES-128
    per the universal preference list.

    * this is going back on an explicit decision from CL 262857, and
      while that client order is weird and does suggest a strong dislike
      for ChaCha20, we have a strong dislike for software AES, so it
      didn't feel worth making the logic more complex

  - All Client-* golden files had to be regenerated because the
    ClientHello cipher suites have changed.
    (Even when Config.CipherSuites was limited to one suite, the TLS 1.3
    default order changed.)

Fixes #45430
Fixes #41476 (as 3DES is now always the last resort)

Change-Id: If5f5d356c0f8d1f1c7542fb06644a478d6bad1e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/314609
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
68 files changed:
src/crypto/tls/cipher_suites.go
src/crypto/tls/common.go
src/crypto/tls/handshake_client.go
src/crypto/tls/handshake_server.go
src/crypto/tls/handshake_server_test.go
src/crypto/tls/handshake_server_tls13.go
src/crypto/tls/handshake_test.go
src/crypto/tls/key_agreement.go
src/crypto/tls/testdata/Client-TLSv10-ClientCert-ECDSA-ECDSA
src/crypto/tls/testdata/Client-TLSv10-ClientCert-ECDSA-RSA
src/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-ECDSA
src/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-RSA
src/crypto/tls/testdata/Client-TLSv10-ECDHE-ECDSA-AES
src/crypto/tls/testdata/Client-TLSv10-ECDHE-RSA-AES
src/crypto/tls/testdata/Client-TLSv10-ExportKeyingMaterial
src/crypto/tls/testdata/Client-TLSv10-RSA-RC4
src/crypto/tls/testdata/Client-TLSv11-ECDHE-ECDSA-AES
src/crypto/tls/testdata/Client-TLSv11-ECDHE-RSA-AES
src/crypto/tls/testdata/Client-TLSv11-RSA-RC4
src/crypto/tls/testdata/Client-TLSv12-AES128-GCM-SHA256
src/crypto/tls/testdata/Client-TLSv12-AES128-SHA256
src/crypto/tls/testdata/Client-TLSv12-AES256-GCM-SHA384
src/crypto/tls/testdata/Client-TLSv12-ALPN
src/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-ECDSA
src/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-RSA
src/crypto/tls/testdata/Client-TLSv12-ClientCert-Ed25519
src/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-AES256-GCM-SHA384
src/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-ECDSA
src/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSA
src/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPKCS1v15
src/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPSS
src/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES
src/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES-GCM
src/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES128-SHA256
src/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES256-GCM-SHA384
src/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-CHACHA20-POLY1305
src/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-AES
src/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-AES128-SHA256
src/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-CHACHA20-POLY1305
src/crypto/tls/testdata/Client-TLSv12-Ed25519
src/crypto/tls/testdata/Client-TLSv12-ExportKeyingMaterial
src/crypto/tls/testdata/Client-TLSv12-P256-ECDHE
src/crypto/tls/testdata/Client-TLSv12-RSA-RC4
src/crypto/tls/testdata/Client-TLSv12-RenegotiateOnce
src/crypto/tls/testdata/Client-TLSv12-RenegotiateTwice
src/crypto/tls/testdata/Client-TLSv12-RenegotiateTwiceRejected
src/crypto/tls/testdata/Client-TLSv12-RenegotiationRejected
src/crypto/tls/testdata/Client-TLSv12-SCT
src/crypto/tls/testdata/Client-TLSv12-X25519-ECDHE
src/crypto/tls/testdata/Client-TLSv13-AES128-SHA256
src/crypto/tls/testdata/Client-TLSv13-AES256-SHA384
src/crypto/tls/testdata/Client-TLSv13-ALPN
src/crypto/tls/testdata/Client-TLSv13-CHACHA20-SHA256
src/crypto/tls/testdata/Client-TLSv13-ClientCert-ECDSA-RSA
src/crypto/tls/testdata/Client-TLSv13-ClientCert-Ed25519
src/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-ECDSA
src/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-RSAPSS
src/crypto/tls/testdata/Client-TLSv13-ECDSA
src/crypto/tls/testdata/Client-TLSv13-Ed25519
src/crypto/tls/testdata/Client-TLSv13-ExportKeyingMaterial
src/crypto/tls/testdata/Client-TLSv13-HelloRetryRequest
src/crypto/tls/testdata/Client-TLSv13-KeyUpdate
src/crypto/tls/testdata/Client-TLSv13-P256-ECDHE
src/crypto/tls/testdata/Client-TLSv13-X25519-ECDHE
src/crypto/tls/testdata/Server-TLSv10-ExportKeyingMaterial
src/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceECDSA [deleted file]
src/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceRSA [deleted file]
src/crypto/tls/tls_test.go