Skip to content

Commit 2174a79

Browse files
committed
crypto/tls: use standard chacha20-poly1305 cipher suite names
The different chacha20-poly1305 cipher suites were renamed to include the _SHA256 suffix, which is the canonical naming convention. The occurrences of the old names were still not updated, which can lead to confusion when searching for the canonical names in the codebase. Change-Id: I4f90e9cbedc3552c3481c8b0c616b6f915ddd345 Reviewed-on: https://go-review.googlesource.com/c/go/+/689135 Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 8330fb4 commit 2174a79

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

src/crypto/tls/cipher_suites.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ type cipherSuite struct {
149149
}
150150

151151
var cipherSuites = []*cipherSuite{ // TODO: replace with a map, since the order doesn't matter.
152-
{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, 32, 0, 12, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadChaCha20Poly1305},
153-
{TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, 32, 0, 12, ecdheECDSAKA, suiteECDHE | suiteECSign | suiteTLS12, nil, nil, aeadChaCha20Poly1305},
152+
{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, 32, 0, 12, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadChaCha20Poly1305},
153+
{TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, 32, 0, 12, ecdheECDSAKA, suiteECDHE | suiteECSign | suiteTLS12, nil, nil, aeadChaCha20Poly1305},
154154
{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadAESGCM},
155155
{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECSign | suiteTLS12, nil, nil, aeadAESGCM},
156156
{TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
@@ -284,7 +284,7 @@ var cipherSuitesPreferenceOrder = []uint16{
284284
// AEADs w/ ECDHE
285285
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
286286
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
287-
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
287+
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
288288

289289
// CBC w/ ECDHE
290290
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
@@ -313,7 +313,7 @@ var cipherSuitesPreferenceOrder = []uint16{
313313

314314
var cipherSuitesPreferenceOrderNoAES = []uint16{
315315
// ChaCha20Poly1305
316-
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
316+
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
317317

318318
// AES-GCM w/ ECDHE
319319
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,

src/crypto/tls/handshake_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ func TestHandshakeClientHelloRetryRequest(t *testing.T) {
638638

639639
func TestHandshakeClientECDHERSAChaCha20(t *testing.T) {
640640
config := testConfig.Clone()
641-
config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305}
641+
config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}
642642

643643
test := &clientTest{
644644
name: "ECDHE-RSA-CHACHA20-POLY1305",
@@ -651,7 +651,7 @@ func TestHandshakeClientECDHERSAChaCha20(t *testing.T) {
651651

652652
func TestHandshakeClientECDHEECDSAChaCha20(t *testing.T) {
653653
config := testConfig.Clone()
654-
config.CipherSuites = []uint16{TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305}
654+
config.CipherSuites = []uint16{TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}
655655

656656
test := &clientTest{
657657
name: "ECDHE-ECDSA-CHACHA20-POLY1305",

src/crypto/tls/handshake_server_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,31 +1379,31 @@ func BenchmarkHandshakeServer(b *testing.B) {
13791379
})
13801380
b.Run("ECDHE-P256-RSA", func(b *testing.B) {
13811381
b.Run("TLSv13", func(b *testing.B) {
1382-
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1382+
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
13831383
CurveP256, testRSACertificate, testRSAPrivateKey)
13841384
})
13851385
b.Run("TLSv12", func(b *testing.B) {
1386-
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1386+
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
13871387
CurveP256, testRSACertificate, testRSAPrivateKey)
13881388
})
13891389
})
13901390
b.Run("ECDHE-P256-ECDSA-P256", func(b *testing.B) {
13911391
b.Run("TLSv13", func(b *testing.B) {
1392-
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
1392+
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
13931393
CurveP256, testP256Certificate, testP256PrivateKey)
13941394
})
13951395
b.Run("TLSv12", func(b *testing.B) {
1396-
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
1396+
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
13971397
CurveP256, testP256Certificate, testP256PrivateKey)
13981398
})
13991399
})
14001400
b.Run("ECDHE-X25519-ECDSA-P256", func(b *testing.B) {
14011401
b.Run("TLSv13", func(b *testing.B) {
1402-
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
1402+
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
14031403
X25519, testP256Certificate, testP256PrivateKey)
14041404
})
14051405
b.Run("TLSv12", func(b *testing.B) {
1406-
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
1406+
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
14071407
X25519, testP256Certificate, testP256PrivateKey)
14081408
})
14091409
})
@@ -1412,11 +1412,11 @@ func BenchmarkHandshakeServer(b *testing.B) {
14121412
b.Fatal("test ECDSA key doesn't use curve P-521")
14131413
}
14141414
b.Run("TLSv13", func(b *testing.B) {
1415-
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
1415+
benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
14161416
CurveP521, testECDSACertificate, testECDSAPrivateKey)
14171417
})
14181418
b.Run("TLSv12", func(b *testing.B) {
1419-
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
1419+
benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
14201420
CurveP521, testECDSACertificate, testECDSAPrivateKey)
14211421
})
14221422
})
@@ -1792,28 +1792,28 @@ func TestAESCipherReordering(t *testing.T) {
17921792
{
17931793
name: "server has hardware AES, client doesn't (pick ChaCha)",
17941794
clientCiphers: []uint16{
1795-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1795+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
17961796
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
17971797
TLS_RSA_WITH_AES_128_CBC_SHA,
17981798
},
17991799
serverHasAESGCM: true,
1800-
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1800+
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18011801
},
18021802
{
18031803
name: "client prefers AES-GCM, server doesn't have hardware AES (pick ChaCha)",
18041804
clientCiphers: []uint16{
18051805
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
1806-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1806+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18071807
TLS_RSA_WITH_AES_128_CBC_SHA,
18081808
},
18091809
serverHasAESGCM: false,
1810-
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1810+
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18111811
},
18121812
{
18131813
name: "client prefers AES-GCM, server has hardware AES (pick AES-GCM)",
18141814
clientCiphers: []uint16{
18151815
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
1816-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1816+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18171817
TLS_RSA_WITH_AES_128_CBC_SHA,
18181818
},
18191819
serverHasAESGCM: true,
@@ -1824,7 +1824,7 @@ func TestAESCipherReordering(t *testing.T) {
18241824
clientCiphers: []uint16{
18251825
0x0A0A, // GREASE value
18261826
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
1827-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1827+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18281828
TLS_RSA_WITH_AES_128_CBC_SHA,
18291829
},
18301830
serverHasAESGCM: true,
@@ -1845,27 +1845,27 @@ func TestAESCipherReordering(t *testing.T) {
18451845
clientCiphers: []uint16{
18461846
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
18471847
TLS_RSA_WITH_AES_128_CBC_SHA,
1848-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1848+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18491849
},
18501850
serverHasAESGCM: false,
1851-
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1851+
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18521852
},
18531853
{
18541854
name: "client prefers AES-GCM over ChaCha and sends GREASE, server doesn't have hardware AES (pick ChaCha)",
18551855
clientCiphers: []uint16{
18561856
0x0A0A, // GREASE value
18571857
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
1858-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1858+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18591859
TLS_RSA_WITH_AES_128_CBC_SHA,
18601860
},
18611861
serverHasAESGCM: false,
1862-
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1862+
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18631863
},
18641864
{
18651865
name: "client supports multiple AES-GCM, server doesn't have hardware AES and doesn't support ChaCha (AES-GCM)",
18661866
clientCiphers: []uint16{
18671867
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
1868-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1868+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18691869
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
18701870
},
18711871
serverHasAESGCM: false,
@@ -1879,14 +1879,14 @@ func TestAESCipherReordering(t *testing.T) {
18791879
name: "client prefers AES-GCM, server has hardware but doesn't support AES (pick ChaCha)",
18801880
clientCiphers: []uint16{
18811881
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
1882-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1882+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18831883
TLS_RSA_WITH_AES_128_CBC_SHA,
18841884
},
18851885
serverHasAESGCM: true,
18861886
serverCiphers: []uint16{
1887-
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1887+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18881888
},
1889-
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
1889+
expectedCipher: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
18901890
},
18911891
}
18921892

0 commit comments

Comments
 (0)