aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/tls/handshake_server.go
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2020-12-01 21:15:51 -0500
committerDmitri Shuralyov <dmitshur@golang.org>2020-12-02 12:57:07 -0500
commit5934c434c1931f7227db4a97bb7e6dac6fc3b7a3 (patch)
tree60100a8de2a402544ee1cbfd2003420905ff0b22 /src/crypto/tls/handshake_server.go
parentdea96ada1742b45e383dcbb0c2ab4cd0d3fc92a8 (diff)
parent9f39a43e0d728721d5a9e2586ce47a57585591c5 (diff)
downloadgo-5934c434c1931f7227db4a97bb7e6dac6fc3b7a3.tar.xz
[dev.boringcrypto] all: merge master into dev.boringcrypto
Add BoringCrypto-specific test data to TestAESCipherReordering and TestAESCipherReordering13. Change-Id: Id1def4cf166d5059920741f045e3e61bb17c23c8
Diffstat (limited to 'src/crypto/tls/handshake_server.go')
-rw-r--r--src/crypto/tls/handshake_server.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/crypto/tls/handshake_server.go b/src/crypto/tls/handshake_server.go
index 8095ed1708..52bb4d6844 100644
--- a/src/crypto/tls/handshake_server.go
+++ b/src/crypto/tls/handshake_server.go
@@ -303,9 +303,24 @@ func (hs *serverHandshakeState) pickCipherSuite() error {
if c.config.PreferServerCipherSuites {
preferenceList = c.config.cipherSuites()
supportedList = hs.clientHello.cipherSuites
+
+ // If the client does not seem to have hardware support for AES-GCM,
+ // and the application did not specify a cipher suite preference order,
+ // prefer other AEAD ciphers even if we prioritized AES-GCM ciphers
+ // by default.
+ if c.config.CipherSuites == nil && !aesgcmPreferred(hs.clientHello.cipherSuites) {
+ preferenceList = deprioritizeAES(preferenceList)
+ }
} else {
preferenceList = hs.clientHello.cipherSuites
supportedList = c.config.cipherSuites()
+
+ // If we don't have hardware support for AES-GCM, prefer other AEAD
+ // ciphers even if the client prioritized AES-GCM.
+ // If BoringCrypto is enabled, always prioritize AES-GCM.
+ if !hasAESGCMHardwareSupport && !boringEnabled {
+ preferenceList = deprioritizeAES(preferenceList)
+ }
}
hs.suite = selectCipherSuite(preferenceList, supportedList, hs.cipherSuiteOk)