cipher_suites.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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 qtls
  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. "hash"
  16. "golang.org/x/crypto/chacha20poly1305"
  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. // suiteECSign indicates that the cipher suite involves an ECDSA or
  40. // EdDSA signature and therefore may only be selected when the server's
  41. // certificate is ECDSA or EdDSA. If this is not set then the cipher suite
  42. // is RSA based.
  43. suiteECSign
  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 | suiteECSign | 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 | suiteECSign | 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 | suiteECSign | 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 | suiteECSign | suiteTLS12 | suiteDefaultOff, cipherAES, macSHA256, nil},
  80. {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECSign, 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 | suiteECSign, 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 | suiteECSign | 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. type CipherSuiteTLS13 struct {
  104. ID uint16
  105. KeyLen int
  106. Hash crypto.Hash
  107. AEAD func(key, fixedNonce []byte) cipher.AEAD
  108. }
  109. func (c *CipherSuiteTLS13) IVLen() int {
  110. return aeadNonceLength
  111. }
  112. var cipherSuitesTLS13 = []*cipherSuiteTLS13{
  113. {TLS_AES_128_GCM_SHA256, 16, aeadAESGCMTLS13, crypto.SHA256},
  114. {TLS_CHACHA20_POLY1305_SHA256, 32, aeadChaCha20Poly1305, crypto.SHA256},
  115. {TLS_AES_256_GCM_SHA384, 32, aeadAESGCMTLS13, crypto.SHA384},
  116. }
  117. func cipherRC4(key, iv []byte, isRead bool) interface{} {
  118. cipher, _ := rc4.NewCipher(key)
  119. return cipher
  120. }
  121. func cipher3DES(key, iv []byte, isRead bool) interface{} {
  122. block, _ := des.NewTripleDESCipher(key)
  123. if isRead {
  124. return cipher.NewCBCDecrypter(block, iv)
  125. }
  126. return cipher.NewCBCEncrypter(block, iv)
  127. }
  128. func cipherAES(key, iv []byte, isRead bool) interface{} {
  129. block, _ := aes.NewCipher(key)
  130. if isRead {
  131. return cipher.NewCBCDecrypter(block, iv)
  132. }
  133. return cipher.NewCBCEncrypter(block, iv)
  134. }
  135. // macSHA1 returns a macFunction for the given protocol version.
  136. func macSHA1(version uint16, key []byte) macFunction {
  137. if version == VersionSSL30 {
  138. mac := ssl30MAC{
  139. h: sha1.New(),
  140. key: make([]byte, len(key)),
  141. }
  142. copy(mac.key, key)
  143. return mac
  144. }
  145. return tls10MAC{h: hmac.New(newConstantTimeHash(sha1.New), key)}
  146. }
  147. // macSHA256 returns a SHA-256 based MAC. These are only supported in TLS 1.2
  148. // so the given version is ignored.
  149. func macSHA256(version uint16, key []byte) macFunction {
  150. return tls10MAC{h: hmac.New(sha256.New, key)}
  151. }
  152. type macFunction interface {
  153. // Size returns the length of the MAC.
  154. Size() int
  155. // MAC appends the MAC of (seq, header, data) to out. The extra data is fed
  156. // into the MAC after obtaining the result to normalize timing. The result
  157. // is only valid until the next invocation of MAC as the buffer is reused.
  158. MAC(seq, header, data, extra []byte) []byte
  159. }
  160. type aead interface {
  161. cipher.AEAD
  162. // explicitNonceLen returns the number of bytes of explicit nonce
  163. // included in each record. This is eight for older AEADs and
  164. // zero for modern ones.
  165. explicitNonceLen() int
  166. }
  167. const (
  168. aeadNonceLength = 12
  169. noncePrefixLength = 4
  170. )
  171. // prefixNonceAEAD wraps an AEAD and prefixes a fixed portion of the nonce to
  172. // each call.
  173. type prefixNonceAEAD struct {
  174. // nonce contains the fixed part of the nonce in the first four bytes.
  175. nonce [aeadNonceLength]byte
  176. aead cipher.AEAD
  177. }
  178. func (f *prefixNonceAEAD) NonceSize() int { return aeadNonceLength - noncePrefixLength }
  179. func (f *prefixNonceAEAD) Overhead() int { return f.aead.Overhead() }
  180. func (f *prefixNonceAEAD) explicitNonceLen() int { return f.NonceSize() }
  181. func (f *prefixNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte {
  182. copy(f.nonce[4:], nonce)
  183. return f.aead.Seal(out, f.nonce[:], plaintext, additionalData)
  184. }
  185. func (f *prefixNonceAEAD) Open(out, nonce, ciphertext, additionalData []byte) ([]byte, error) {
  186. copy(f.nonce[4:], nonce)
  187. return f.aead.Open(out, f.nonce[:], ciphertext, additionalData)
  188. }
  189. // xoredNonceAEAD wraps an AEAD by XORing in a fixed pattern to the nonce
  190. // before each call.
  191. type xorNonceAEAD struct {
  192. nonceMask [aeadNonceLength]byte
  193. aead cipher.AEAD
  194. }
  195. func (f *xorNonceAEAD) NonceSize() int { return 8 } // 64-bit sequence number
  196. func (f *xorNonceAEAD) Overhead() int { return f.aead.Overhead() }
  197. func (f *xorNonceAEAD) explicitNonceLen() int { return 0 }
  198. func (f *xorNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte {
  199. for i, b := range nonce {
  200. f.nonceMask[4+i] ^= b
  201. }
  202. result := f.aead.Seal(out, f.nonceMask[:], plaintext, additionalData)
  203. for i, b := range nonce {
  204. f.nonceMask[4+i] ^= b
  205. }
  206. return result
  207. }
  208. func (f *xorNonceAEAD) Open(out, nonce, ciphertext, additionalData []byte) ([]byte, error) {
  209. for i, b := range nonce {
  210. f.nonceMask[4+i] ^= b
  211. }
  212. result, err := f.aead.Open(out, f.nonceMask[:], ciphertext, additionalData)
  213. for i, b := range nonce {
  214. f.nonceMask[4+i] ^= b
  215. }
  216. return result, err
  217. }
  218. func aeadAESGCM(key, noncePrefix []byte) aead {
  219. if len(noncePrefix) != noncePrefixLength {
  220. panic("tls: internal error: wrong nonce length")
  221. }
  222. aes, err := aes.NewCipher(key)
  223. if err != nil {
  224. panic(err)
  225. }
  226. aead, err := cipher.NewGCM(aes)
  227. if err != nil {
  228. panic(err)
  229. }
  230. ret := &prefixNonceAEAD{aead: aead}
  231. copy(ret.nonce[:], noncePrefix)
  232. return ret
  233. }
  234. // AEADAESGCMTLS13 creates a new AES-GCM AEAD for TLS 1.3
  235. func AEADAESGCMTLS13(key, fixedNonce []byte) cipher.AEAD {
  236. return aeadAESGCMTLS13(key, fixedNonce)
  237. }
  238. func aeadAESGCMTLS13(key, nonceMask []byte) aead {
  239. if len(nonceMask) != aeadNonceLength {
  240. panic("tls: internal error: wrong nonce length")
  241. }
  242. aes, err := aes.NewCipher(key)
  243. if err != nil {
  244. panic(err)
  245. }
  246. aead, err := cipher.NewGCM(aes)
  247. if err != nil {
  248. panic(err)
  249. }
  250. ret := &xorNonceAEAD{aead: aead}
  251. copy(ret.nonceMask[:], nonceMask)
  252. return ret
  253. }
  254. func aeadChaCha20Poly1305(key, nonceMask []byte) aead {
  255. if len(nonceMask) != aeadNonceLength {
  256. panic("tls: internal error: wrong nonce length")
  257. }
  258. aead, err := chacha20poly1305.New(key)
  259. if err != nil {
  260. panic(err)
  261. }
  262. ret := &xorNonceAEAD{aead: aead}
  263. copy(ret.nonceMask[:], nonceMask)
  264. return ret
  265. }
  266. // ssl30MAC implements the SSLv3 MAC function, as defined in
  267. // www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt section 5.2.3.1
  268. type ssl30MAC struct {
  269. h hash.Hash
  270. key []byte
  271. buf []byte
  272. }
  273. func (s ssl30MAC) Size() int {
  274. return s.h.Size()
  275. }
  276. 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}
  277. 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}
  278. // MAC does not offer constant timing guarantees for SSL v3.0, since it's deemed
  279. // useless considering the similar, protocol-level POODLE vulnerability.
  280. func (s ssl30MAC) MAC(seq, header, data, extra []byte) []byte {
  281. padLength := 48
  282. if s.h.Size() == 20 {
  283. padLength = 40
  284. }
  285. s.h.Reset()
  286. s.h.Write(s.key)
  287. s.h.Write(ssl30Pad1[:padLength])
  288. s.h.Write(seq)
  289. s.h.Write(header[:1])
  290. s.h.Write(header[3:5])
  291. s.h.Write(data)
  292. s.buf = s.h.Sum(s.buf[:0])
  293. s.h.Reset()
  294. s.h.Write(s.key)
  295. s.h.Write(ssl30Pad2[:padLength])
  296. s.h.Write(s.buf)
  297. return s.h.Sum(s.buf[:0])
  298. }
  299. type constantTimeHash interface {
  300. hash.Hash
  301. ConstantTimeSum(b []byte) []byte
  302. }
  303. // cthWrapper wraps any hash.Hash that implements ConstantTimeSum, and replaces
  304. // with that all calls to Sum. It's used to obtain a ConstantTimeSum-based HMAC.
  305. type cthWrapper struct {
  306. h constantTimeHash
  307. }
  308. func (c *cthWrapper) Size() int { return c.h.Size() }
  309. func (c *cthWrapper) BlockSize() int { return c.h.BlockSize() }
  310. func (c *cthWrapper) Reset() { c.h.Reset() }
  311. func (c *cthWrapper) Write(p []byte) (int, error) { return c.h.Write(p) }
  312. func (c *cthWrapper) Sum(b []byte) []byte { return c.h.ConstantTimeSum(b) }
  313. func newConstantTimeHash(h func() hash.Hash) func() hash.Hash {
  314. return func() hash.Hash {
  315. return &cthWrapper{h().(constantTimeHash)}
  316. }
  317. }
  318. // tls10MAC implements the TLS 1.0 MAC function. RFC 2246, Section 6.2.3.
  319. type tls10MAC struct {
  320. h hash.Hash
  321. buf []byte
  322. }
  323. func (s tls10MAC) Size() int {
  324. return s.h.Size()
  325. }
  326. // MAC is guaranteed to take constant time, as long as
  327. // len(seq)+len(header)+len(data)+len(extra) is constant. extra is not fed into
  328. // the MAC, but is only provided to make the timing profile constant.
  329. func (s tls10MAC) MAC(seq, header, data, extra []byte) []byte {
  330. s.h.Reset()
  331. s.h.Write(seq)
  332. s.h.Write(header)
  333. s.h.Write(data)
  334. res := s.h.Sum(s.buf[:0])
  335. if extra != nil {
  336. s.h.Write(extra)
  337. }
  338. return res
  339. }
  340. func rsaKA(version uint16) keyAgreement {
  341. return rsaKeyAgreement{}
  342. }
  343. func ecdheECDSAKA(version uint16) keyAgreement {
  344. return &ecdheKeyAgreement{
  345. isRSA: false,
  346. version: version,
  347. }
  348. }
  349. func ecdheRSAKA(version uint16) keyAgreement {
  350. return &ecdheKeyAgreement{
  351. isRSA: true,
  352. version: version,
  353. }
  354. }
  355. // mutualCipherSuite returns a cipherSuite given a list of supported
  356. // ciphersuites and the id requested by the peer.
  357. func mutualCipherSuite(have []uint16, want uint16) *cipherSuite {
  358. for _, id := range have {
  359. if id == want {
  360. return cipherSuiteByID(id)
  361. }
  362. }
  363. return nil
  364. }
  365. func cipherSuiteByID(id uint16) *cipherSuite {
  366. for _, cipherSuite := range cipherSuites {
  367. if cipherSuite.id == id {
  368. return cipherSuite
  369. }
  370. }
  371. return nil
  372. }
  373. func mutualCipherSuiteTLS13(have []uint16, want uint16) *cipherSuiteTLS13 {
  374. for _, id := range have {
  375. if id == want {
  376. return cipherSuiteTLS13ByID(id)
  377. }
  378. }
  379. return nil
  380. }
  381. func cipherSuiteTLS13ByID(id uint16) *cipherSuiteTLS13 {
  382. for _, cipherSuite := range cipherSuitesTLS13 {
  383. if cipherSuite.id == id {
  384. return cipherSuite
  385. }
  386. }
  387. return nil
  388. }
  389. // A list of cipher suite IDs that are, or have been, implemented by this
  390. // package.
  391. //
  392. // Taken from https://www.iana.org/assignments/tls-parameters/tls-parameters.xml
  393. const (
  394. // TLS 1.0 - 1.2 cipher suites.
  395. TLS_RSA_WITH_RC4_128_SHA uint16 = 0x0005
  396. TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000a
  397. TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002f
  398. TLS_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0035
  399. TLS_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003c
  400. TLS_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009c
  401. TLS_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009d
  402. TLS_ECDHE_ECDSA_WITH_RC4_128_SHA uint16 = 0xc007
  403. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xc009
  404. TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xc00a
  405. TLS_ECDHE_RSA_WITH_RC4_128_SHA uint16 = 0xc011
  406. TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xc012
  407. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0xc013
  408. TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0xc014
  409. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16 = 0xc023
  410. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xc027
  411. TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02f
  412. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02b
  413. TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xc030
  414. TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 uint16 = 0xc02c
  415. TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 uint16 = 0xcca8
  416. TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 uint16 = 0xcca9
  417. // TLS 1.3 cipher suites.
  418. TLS_AES_128_GCM_SHA256 uint16 = 0x1301
  419. TLS_AES_256_GCM_SHA384 uint16 = 0x1302
  420. TLS_CHACHA20_POLY1305_SHA256 uint16 = 0x1303
  421. // TLS_FALLBACK_SCSV isn't a standard cipher suite but an indicator
  422. // that the client is doing version fallback. See RFC 7507.
  423. TLS_FALLBACK_SCSV uint16 = 0x5600
  424. )