cipher_suites.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. // Copyright 2010 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package tls
  5. import (
  6. "crypto"
  7. "crypto/aes"
  8. "crypto/cipher"
  9. "crypto/des"
  10. "crypto/hmac"
  11. "crypto/rc4"
  12. "crypto/sha1"
  13. "crypto/sha256"
  14. "crypto/x509"
  15. "golang.org/x/crypto/chacha20poly1305"
  16. "hash"
  17. )
  18. // a keyAgreement implements the client and server side of a TLS key agreement
  19. // protocol by generating and processing key exchange messages.
  20. type keyAgreement interface {
  21. // On the server side, the first two methods are called in order.
  22. // In the case that the key agreement protocol doesn't use a
  23. // ServerKeyExchange message, generateServerKeyExchange can return nil,
  24. // nil.
  25. generateServerKeyExchange(*Config, *Certificate, *clientHelloMsg, *serverHelloMsg) (*serverKeyExchangeMsg, error)
  26. processClientKeyExchange(*Config, *Certificate, *clientKeyExchangeMsg, uint16) ([]byte, error)
  27. // On the client side, the next two methods are called in order.
  28. // This method may not be called if the server doesn't send a
  29. // ServerKeyExchange message.
  30. processServerKeyExchange(*Config, *clientHelloMsg, *serverHelloMsg, *x509.Certificate, *serverKeyExchangeMsg) error
  31. generateClientKeyExchange(*Config, *clientHelloMsg, *x509.Certificate) ([]byte, *clientKeyExchangeMsg, error)
  32. }
  33. const (
  34. // suiteECDH indicates that the cipher suite involves elliptic curve
  35. // Diffie-Hellman. This means that it should only be selected when the
  36. // client indicates that it supports ECC with a curve and point format
  37. // that we're happy with.
  38. suiteECDHE = 1 << iota
  39. // suiteECDSA indicates that the cipher suite involves an ECDSA
  40. // signature and therefore may only be selected when the server's
  41. // certificate is ECDSA. If this is not set then the cipher suite is
  42. // RSA based.
  43. suiteECDSA
  44. // suiteTLS12 indicates that the cipher suite should only be advertised
  45. // and accepted when using TLS 1.2.
  46. suiteTLS12
  47. // suiteSHA384 indicates that the cipher suite uses SHA384 as the
  48. // handshake hash.
  49. suiteSHA384
  50. // suiteDefaultOff indicates that this cipher suite is not included by
  51. // default.
  52. suiteDefaultOff
  53. )
  54. // A cipherSuite is a specific combination of key agreement, cipher and MAC function.
  55. type cipherSuite struct {
  56. id uint16
  57. // the lengths, in bytes, of the key material needed for each component.
  58. keyLen int
  59. macLen int
  60. ivLen int
  61. ka func(version uint16) keyAgreement
  62. // flags is a bitmask of the suite* values, above.
  63. flags int
  64. cipher func(key, iv []byte, isRead bool) interface{}
  65. mac func(version uint16, macKey []byte) macFunction
  66. aead func(key, fixedNonce []byte) aead
  67. }
  68. var cipherSuites = []*cipherSuite{
  69. // Ciphersuite order is chosen so that ECDHE comes before plain RSA and
  70. // AEADs are the top preference.
  71. {TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, 32, 0, 12, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadChaCha20Poly1305},
  72. {TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, 32, 0, 12, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, nil, nil, aeadChaCha20Poly1305},
  73. {TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadAESGCM},
  74. {TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, nil, nil, aeadAESGCM},
  75. {TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
  76. {TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
  77. {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheRSAKA, suiteECDHE | suiteTLS12 | suiteDefaultOff, cipherAES, macSHA256, nil},
  78. {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
  79. {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12 | suiteDefaultOff, cipherAES, macSHA256, nil},
  80. {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
  81. {TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
  82. {TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
  83. {TLS_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, rsaKA, suiteTLS12, nil, nil, aeadAESGCM},
  84. {TLS_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, rsaKA, suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
  85. {TLS_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, rsaKA, suiteTLS12 | suiteDefaultOff, cipherAES, macSHA256, nil},
  86. {TLS_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
  87. {TLS_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
  88. {TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, ecdheRSAKA, suiteECDHE, cipher3DES, macSHA1, nil},
  89. {TLS_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, rsaKA, 0, cipher3DES, macSHA1, nil},
  90. // RC4-based cipher suites are disabled by default.
  91. {TLS_RSA_WITH_RC4_128_SHA, 16, 20, 0, rsaKA, suiteDefaultOff, cipherRC4, macSHA1, nil},
  92. {TLS_ECDHE_RSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheRSAKA, suiteECDHE | suiteDefaultOff, cipherRC4, macSHA1, nil},
  93. {TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteDefaultOff, cipherRC4, macSHA1, nil},
  94. }
  95. // A cipherSuiteTLS13 defines only the pair of the AEAD algorithm and hash
  96. // algorithm to be used with HKDF. See RFC 8446, Appendix B.4.
  97. type cipherSuiteTLS13 struct {
  98. id uint16
  99. keyLen int
  100. aead func(key, fixedNonce []byte) aead
  101. hash crypto.Hash
  102. }
  103. var cipherSuitesTLS13 = []*cipherSuiteTLS13{
  104. {TLS_AES_128_GCM_SHA256, 16, aeadAESGCMTLS13, crypto.SHA256},
  105. {TLS_CHACHA20_POLY1305_SHA256, 32, aeadChaCha20Poly1305, crypto.SHA256},
  106. {TLS_AES_256_GCM_SHA384, 32, aeadAESGCMTLS13, crypto.SHA384},
  107. }
  108. func cipherRC4(key, iv []byte, isRead bool) interface{} {
  109. cipher, _ := rc4.NewCipher(key)
  110. return cipher
  111. }
  112. func cipher3DES(key, iv []byte, isRead bool) interface{} {
  113. block, _ := des.NewTripleDESCipher(key)
  114. if isRead {
  115. return cipher.NewCBCDecrypter(block, iv)
  116. }
  117. return cipher.NewCBCEncrypter(block, iv)
  118. }
  119. func cipherAES(key, iv []byte, isRead bool) interface{} {
  120. block, _ := aes.NewCipher(key)
  121. if isRead {
  122. return cipher.NewCBCDecrypter(block, iv)
  123. }
  124. return cipher.NewCBCEncrypter(block, iv)
  125. }
  126. // macSHA1 returns a macFunction for the given protocol version.
  127. func macSHA1(version uint16, key []byte) macFunction {
  128. if version == VersionSSL30 {
  129. mac := ssl30MAC{
  130. h: sha1.New(),
  131. key: make([]byte, len(key)),
  132. }
  133. copy(mac.key, key)
  134. return mac
  135. }
  136. return tls10MAC{h: hmac.New(newConstantTimeHash(sha1.New), key)}
  137. }
  138. // macSHA256 returns a SHA-256 based MAC. These are only supported in TLS 1.2
  139. // so the given version is ignored.
  140. func macSHA256(version uint16, key []byte) macFunction {
  141. return tls10MAC{h: hmac.New(sha256.New, key)}
  142. }
  143. type macFunction interface {
  144. // Size returns the length of the MAC.
  145. Size() int
  146. // MAC appends the MAC of (seq, header, data) to out. The extra data is fed
  147. // into the MAC after obtaining the result to normalize timing. The result
  148. // is only valid until the next invocation of MAC as the buffer is reused.
  149. MAC(seq, header, data, extra []byte) []byte
  150. }
  151. type aead interface {
  152. cipher.AEAD
  153. // explicitNonceLen returns the number of bytes of explicit nonce
  154. // included in each record. This is eight for older AEADs and
  155. // zero for modern ones.
  156. explicitNonceLen() int
  157. }
  158. const (
  159. aeadNonceLength = 12
  160. noncePrefixLength = 4
  161. )
  162. // prefixNonceAEAD wraps an AEAD and prefixes a fixed portion of the nonce to
  163. // each call.
  164. type prefixNonceAEAD struct {
  165. // nonce contains the fixed part of the nonce in the first four bytes.
  166. nonce [aeadNonceLength]byte
  167. aead cipher.AEAD
  168. }
  169. func (f *prefixNonceAEAD) NonceSize() int { return aeadNonceLength - noncePrefixLength }
  170. func (f *prefixNonceAEAD) Overhead() int { return f.aead.Overhead() }
  171. func (f *prefixNonceAEAD) explicitNonceLen() int { return f.NonceSize() }
  172. func (f *prefixNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte {
  173. copy(f.nonce[4:], nonce)
  174. return f.aead.Seal(out, f.nonce[:], plaintext, additionalData)
  175. }
  176. func (f *prefixNonceAEAD) Open(out, nonce, ciphertext, additionalData []byte) ([]byte, error) {
  177. copy(f.nonce[4:], nonce)
  178. return f.aead.Open(out, f.nonce[:], ciphertext, additionalData)
  179. }
  180. // xoredNonceAEAD wraps an AEAD by XORing in a fixed pattern to the nonce
  181. // before each call.
  182. type xorNonceAEAD struct {
  183. nonceMask [aeadNonceLength]byte
  184. aead cipher.AEAD
  185. }
  186. func (f *xorNonceAEAD) NonceSize() int { return 8 } // 64-bit sequence number
  187. func (f *xorNonceAEAD) Overhead() int { return f.aead.Overhead() }
  188. func (f *xorNonceAEAD) explicitNonceLen() int { return 0 }
  189. func (f *xorNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte {
  190. for i, b := range nonce {
  191. f.nonceMask[4+i] ^= b
  192. }
  193. result := f.aead.Seal(out, f.nonceMask[:], plaintext, additionalData)
  194. for i, b := range nonce {
  195. f.nonceMask[4+i] ^= b
  196. }
  197. return result
  198. }
  199. func (f *xorNonceAEAD) Open(out, nonce, ciphertext, additionalData []byte) ([]byte, error) {
  200. for i, b := range nonce {
  201. f.nonceMask[4+i] ^= b
  202. }
  203. result, err := f.aead.Open(out, f.nonceMask[:], ciphertext, additionalData)
  204. for i, b := range nonce {
  205. f.nonceMask[4+i] ^= b
  206. }
  207. return result, err
  208. }
  209. func aeadAESGCM(key, noncePrefix []byte) aead {
  210. if len(noncePrefix) != noncePrefixLength {
  211. panic("tls: internal error: wrong nonce length")
  212. }
  213. aes, err := aes.NewCipher(key)
  214. if err != nil {
  215. panic(err)
  216. }
  217. aead, err := cipher.NewGCM(aes)
  218. if err != nil {
  219. panic(err)
  220. }
  221. ret := &prefixNonceAEAD{aead: aead}
  222. copy(ret.nonce[:], noncePrefix)
  223. return ret
  224. }
  225. func aeadAESGCMTLS13(key, nonceMask []byte) aead {
  226. if len(nonceMask) != aeadNonceLength {
  227. panic("tls: internal error: wrong nonce length")
  228. }
  229. aes, err := aes.NewCipher(key)
  230. if err != nil {
  231. panic(err)
  232. }
  233. aead, err := cipher.NewGCM(aes)
  234. if err != nil {
  235. panic(err)
  236. }
  237. ret := &xorNonceAEAD{aead: aead}
  238. copy(ret.nonceMask[:], nonceMask)
  239. return ret
  240. }
  241. func aeadChaCha20Poly1305(key, nonceMask []byte) aead {
  242. if len(nonceMask) != aeadNonceLength {
  243. panic("tls: internal error: wrong nonce length")
  244. }
  245. aead, err := chacha20poly1305.New(key)
  246. if err != nil {
  247. panic(err)
  248. }
  249. ret := &xorNonceAEAD{aead: aead}
  250. copy(ret.nonceMask[:], nonceMask)
  251. return ret
  252. }
  253. // ssl30MAC implements the SSLv3 MAC function, as defined in
  254. // www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt section 5.2.3.1
  255. type ssl30MAC struct {
  256. h hash.Hash
  257. key []byte
  258. buf []byte
  259. }
  260. func (s ssl30MAC) Size() int {
  261. return s.h.Size()
  262. }
  263. var ssl30Pad1 = [48]byte{0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}
  264. var ssl30Pad2 = [48]byte{0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c}
  265. // MAC does not offer constant timing guarantees for SSL v3.0, since it's deemed
  266. // useless considering the similar, protocol-level POODLE vulnerability.
  267. func (s ssl30MAC) MAC(seq, header, data, extra []byte) []byte {
  268. padLength := 48
  269. if s.h.Size() == 20 {
  270. padLength = 40
  271. }
  272. s.h.Reset()
  273. s.h.Write(s.key)
  274. s.h.Write(ssl30Pad1[:padLength])
  275. s.h.Write(seq)
  276. s.h.Write(header[:1])
  277. s.h.Write(header[3:5])
  278. s.h.Write(data)
  279. s.buf = s.h.Sum(s.buf[:0])
  280. s.h.Reset()
  281. s.h.Write(s.key)
  282. s.h.Write(ssl30Pad2[:padLength])
  283. s.h.Write(s.buf)
  284. return s.h.Sum(s.buf[:0])
  285. }
  286. type constantTimeHash interface {
  287. hash.Hash
  288. ConstantTimeSum(b []byte) []byte
  289. }
  290. // cthWrapper wraps any hash.Hash that implements ConstantTimeSum, and replaces
  291. // with that all calls to Sum. It's used to obtain a ConstantTimeSum-based HMAC.
  292. type cthWrapper struct {
  293. h constantTimeHash
  294. }
  295. func (c *cthWrapper) Size() int { return c.h.Size() }
  296. func (c *cthWrapper) BlockSize() int { return c.h.BlockSize() }
  297. func (c *cthWrapper) Reset() { c.h.Reset() }
  298. func (c *cthWrapper) Write(p []byte) (int, error) { return c.h.Write(p) }
  299. func (c *cthWrapper) Sum(b []byte) []byte { return c.h.ConstantTimeSum(b) }
  300. func newConstantTimeHash(h func() hash.Hash) func() hash.Hash {
  301. return func() hash.Hash {
  302. return &cthWrapper{h().(constantTimeHash)}
  303. }
  304. }
  305. // tls10MAC implements the TLS 1.0 MAC function. RFC 2246, Section 6.2.3.
  306. type tls10MAC struct {
  307. h hash.Hash
  308. buf []byte
  309. }
  310. func (s tls10MAC) Size() int {
  311. return s.h.Size()
  312. }
  313. // MAC is guaranteed to take constant time, as long as
  314. // len(seq)+len(header)+len(data)+len(extra) is constant. extra is not fed into
  315. // the MAC, but is only provided to make the timing profile constant.
  316. func (s tls10MAC) MAC(seq, header, data, extra []byte) []byte {
  317. s.h.Reset()
  318. s.h.Write(seq)
  319. s.h.Write(header)
  320. s.h.Write(data)
  321. res := s.h.Sum(s.buf[:0])
  322. if extra != nil {
  323. s.h.Write(extra)
  324. }
  325. return res
  326. }
  327. func rsaKA(version uint16) keyAgreement {
  328. return rsaKeyAgreement{}
  329. }
  330. func ecdheECDSAKA(version uint16) keyAgreement {
  331. return &ecdheKeyAgreement{
  332. isRSA: false,
  333. version: version,
  334. }
  335. }
  336. func ecdheRSAKA(version uint16) keyAgreement {
  337. return &ecdheKeyAgreement{
  338. isRSA: true,
  339. version: version,
  340. }
  341. }
  342. // mutualCipherSuite returns a cipherSuite given a list of supported
  343. // ciphersuites and the id requested by the peer.
  344. func mutualCipherSuite(have []uint16, want uint16) *cipherSuite {
  345. for _, id := range have {
  346. if id == want {
  347. return cipherSuiteByID(id)
  348. }
  349. }
  350. return nil
  351. }
  352. func cipherSuiteByID(id uint16) *cipherSuite {
  353. for _, cipherSuite := range utlsSupportedCipherSuites {
  354. if cipherSuite.id == id {
  355. return cipherSuite
  356. }
  357. }
  358. return nil
  359. }
  360. func mutualCipherSuiteTLS13(have []uint16, want uint16) *cipherSuiteTLS13 {
  361. for _, id := range have {
  362. if id == want {
  363. return cipherSuiteTLS13ByID(id)
  364. }
  365. }
  366. return nil
  367. }
  368. func cipherSuiteTLS13ByID(id uint16) *cipherSuiteTLS13 {
  369. for _, cipherSuite := range cipherSuitesTLS13 {
  370. if cipherSuite.id == id {
  371. return cipherSuite
  372. }
  373. }
  374. return nil
  375. }
  376. // A list of cipher suite IDs that are, or have been, implemented by this
  377. // package.
  378. //
  379. // Taken from https://www.iana.org/assignments/tls-parameters/tls-parameters.xml
  380. const (
  381. // TLS 1.0 - 1.2 cipher suites.
  382. TLS_RSA_WITH_RC4_128_SHA uint16 = 0x0005
  383. TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000a
  384. TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002f
  385. TLS_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0035
  386. TLS_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003c
  387. TLS_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009c
  388. TLS_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009d
  389. TLS_ECDHE_ECDSA_WITH_RC4_128_SHA uint16 = 0xc007
  390. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xc009
  391. TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xc00a
  392. TLS_ECDHE_RSA_WITH_RC4_128_SHA uint16 = 0xc011
  393. TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xc012
  394. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0xc013
  395. TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0xc014
  396. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16 = 0xc023
  397. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xc027
  398. TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02f
  399. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02b
  400. TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xc030
  401. TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 uint16 = 0xc02c
  402. TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 uint16 = 0xcca8
  403. TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 uint16 = 0xcca9
  404. // TLS 1.3 cipher suites.
  405. TLS_AES_128_GCM_SHA256 uint16 = 0x1301
  406. TLS_AES_256_GCM_SHA384 uint16 = 0x1302
  407. TLS_CHACHA20_POLY1305_SHA256 uint16 = 0x1303
  408. // TLS_FALLBACK_SCSV isn't a standard cipher suite but an indicator
  409. // that the client is doing version fallback. See RFC 7507.
  410. TLS_FALLBACK_SCSV uint16 = 0x5600
  411. )