]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.boringcrypto] crypto/tls: use TLS-specific AES-GCM mode if available
authorRuss Cox <rsc@golang.org>
Tue, 15 Aug 2017 23:23:26 +0000 (19:23 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 17 Aug 2017 19:39:04 +0000 (19:39 +0000)
Change-Id: Ide00c40c0ca8d486f3bd8968e1d301c8b0ed6d05
Reviewed-on: https://go-review.googlesource.com/56011
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
src/crypto/tls/cipher_suites.go

index d39c6d3b66e1dfaddca186e6fcb5dc314c175952..1c5144ae9ea9a53b671cc2e31460a7fd09002e35 100644 (file)
@@ -220,12 +220,22 @@ func (f *xorNonceAEAD) Open(out, nonce, plaintext, additionalData []byte) ([]byt
        return result, err
 }
 
+type gcmtls interface {
+       NewGCMTLS() (cipher.AEAD, error)
+}
+
 func aeadAESGCM(key, fixedNonce []byte) cipher.AEAD {
        aes, err := aes.NewCipher(key)
        if err != nil {
                panic(err)
        }
-       aead, err := cipher.NewGCM(aes)
+       var aead cipher.AEAD
+       if aesTLS, ok := aes.(gcmtls); ok {
+               aead, err = aesTLS.NewGCMTLS()
+       } else {
+               boring.Unreachable()
+               aead, err = cipher.NewGCM(aes)
+       }
        if err != nil {
                panic(err)
        }