您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

420 行
16 KiB

  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 main
  5. import (
  6. "crypto/aes"
  7. "crypto/cipher"
  8. "crypto/des"
  9. "crypto/hmac"
  10. "crypto/md5"
  11. "crypto/rc4"
  12. "crypto/sha1"
  13. "crypto/sha256"
  14. "crypto/sha512"
  15. "crypto/x509"
  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. // suiteNoDTLS indicates that the cipher suite cannot be used
  51. // in DTLS.
  52. suiteNoDTLS
  53. // suitePSK indicates that the cipher suite authenticates with
  54. // a pre-shared key rather than a server private key.
  55. suitePSK
  56. )
  57. type tlsAead struct {
  58. cipher.AEAD
  59. explicitNonce bool
  60. }
  61. // A cipherSuite is a specific combination of key agreement, cipher and MAC
  62. // function. All cipher suites currently assume RSA key agreement.
  63. type cipherSuite struct {
  64. id uint16
  65. // the lengths, in bytes, of the key material needed for each component.
  66. keyLen int
  67. macLen int
  68. ivLen int
  69. ka func(version uint16) keyAgreement
  70. // flags is a bitmask of the suite* values, above.
  71. flags int
  72. cipher func(key, iv []byte, isRead bool) interface{}
  73. mac func(version uint16, macKey []byte) macFunction
  74. aead func(key, fixedNonce []byte) *tlsAead
  75. }
  76. var cipherSuites = []*cipherSuite{
  77. // Ciphersuite order is chosen so that ECDHE comes before plain RSA
  78. // and RC4 comes before AES (because of the Lucky13 attack).
  79. {TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, 32, 0, 0, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, nil, nil, aeadCHACHA20POLY1305},
  80. {TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, 32, 0, 0, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadCHACHA20POLY1305},
  81. {TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadAESGCM},
  82. {TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, nil, nil, aeadAESGCM},
  83. {TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
  84. {TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
  85. {TLS_ECDHE_RSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheRSAKA, suiteECDHE | suiteNoDTLS, cipherRC4, macSHA1, nil},
  86. {TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteNoDTLS, cipherRC4, macSHA1, nil},
  87. {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheRSAKA, suiteECDHE | suiteTLS12, cipherAES, macSHA256, nil},
  88. {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, cipherAES, macSHA256, nil},
  89. {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
  90. {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
  91. {TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, 32, 48, 16, ecdheRSAKA, suiteECDHE | suiteTLS12 | suiteSHA384, cipherAES, macSHA384, nil},
  92. {TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, 32, 48, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12 | suiteSHA384, cipherAES, macSHA384, nil},
  93. {TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
  94. {TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
  95. {TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, 32, 0, 0, dheRSAKA, suiteTLS12, nil, nil, aeadCHACHA20POLY1305},
  96. {TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, dheRSAKA, suiteTLS12, nil, nil, aeadAESGCM},
  97. {TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, dheRSAKA, suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
  98. {TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, dheRSAKA, suiteTLS12, cipherAES, macSHA256, nil},
  99. {TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, 32, 32, 16, dheRSAKA, suiteTLS12, cipherAES, macSHA256, nil},
  100. {TLS_DHE_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, dheRSAKA, 0, cipherAES, macSHA1, nil},
  101. {TLS_DHE_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, dheRSAKA, 0, cipherAES, macSHA1, nil},
  102. {TLS_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, rsaKA, suiteTLS12, nil, nil, aeadAESGCM},
  103. {TLS_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, rsaKA, suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
  104. {TLS_RSA_WITH_RC4_128_SHA, 16, 20, 0, rsaKA, suiteNoDTLS, cipherRC4, macSHA1, nil},
  105. {TLS_RSA_WITH_RC4_128_MD5, 16, 16, 0, rsaKA, suiteNoDTLS, cipherRC4, macMD5, nil},
  106. {TLS_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, rsaKA, suiteTLS12, cipherAES, macSHA256, nil},
  107. {TLS_RSA_WITH_AES_256_CBC_SHA256, 32, 32, 16, rsaKA, suiteTLS12, cipherAES, macSHA256, nil},
  108. {TLS_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
  109. {TLS_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
  110. {TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, ecdheRSAKA, suiteECDHE, cipher3DES, macSHA1, nil},
  111. {TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, dheRSAKA, 0, cipher3DES, macSHA1, nil},
  112. {TLS_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, rsaKA, 0, cipher3DES, macSHA1, nil},
  113. {TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdhePSKKA, suiteECDHE | suiteTLS12 | suitePSK, nil, nil, aeadAESGCM},
  114. {TLS_PSK_WITH_RC4_128_SHA, 16, 20, 0, pskKA, suiteNoDTLS | suitePSK, cipherRC4, macSHA1, nil},
  115. {TLS_PSK_WITH_AES_128_CBC_SHA, 16, 20, 16, pskKA, suitePSK, cipherAES, macSHA1, nil},
  116. {TLS_PSK_WITH_AES_256_CBC_SHA, 32, 20, 16, pskKA, suitePSK, cipherAES, macSHA1, nil},
  117. {TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdhePSKKA, suiteECDHE | suitePSK, cipherAES, macSHA1, nil},
  118. {TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdhePSKKA, suiteECDHE | suitePSK, cipherAES, macSHA1, nil},
  119. }
  120. func cipherRC4(key, iv []byte, isRead bool) interface{} {
  121. cipher, _ := rc4.NewCipher(key)
  122. return cipher
  123. }
  124. func cipher3DES(key, iv []byte, isRead bool) interface{} {
  125. block, _ := des.NewTripleDESCipher(key)
  126. if isRead {
  127. return cipher.NewCBCDecrypter(block, iv)
  128. }
  129. return cipher.NewCBCEncrypter(block, iv)
  130. }
  131. func cipherAES(key, iv []byte, isRead bool) interface{} {
  132. block, _ := aes.NewCipher(key)
  133. if isRead {
  134. return cipher.NewCBCDecrypter(block, iv)
  135. }
  136. return cipher.NewCBCEncrypter(block, iv)
  137. }
  138. // macSHA1 returns a macFunction for the given protocol version.
  139. func macSHA1(version uint16, key []byte) macFunction {
  140. if version == VersionSSL30 {
  141. mac := ssl30MAC{
  142. h: sha1.New(),
  143. key: make([]byte, len(key)),
  144. }
  145. copy(mac.key, key)
  146. return mac
  147. }
  148. return tls10MAC{hmac.New(sha1.New, key)}
  149. }
  150. func macMD5(version uint16, key []byte) macFunction {
  151. if version == VersionSSL30 {
  152. mac := ssl30MAC{
  153. h: md5.New(),
  154. key: make([]byte, len(key)),
  155. }
  156. copy(mac.key, key)
  157. return mac
  158. }
  159. return tls10MAC{hmac.New(md5.New, key)}
  160. }
  161. func macSHA256(version uint16, key []byte) macFunction {
  162. if version == VersionSSL30 {
  163. mac := ssl30MAC{
  164. h: sha256.New(),
  165. key: make([]byte, len(key)),
  166. }
  167. copy(mac.key, key)
  168. return mac
  169. }
  170. return tls10MAC{hmac.New(sha256.New, key)}
  171. }
  172. func macSHA384(version uint16, key []byte) macFunction {
  173. if version == VersionSSL30 {
  174. mac := ssl30MAC{
  175. h: sha512.New384(),
  176. key: make([]byte, len(key)),
  177. }
  178. copy(mac.key, key)
  179. return mac
  180. }
  181. return tls10MAC{hmac.New(sha512.New384, key)}
  182. }
  183. type macFunction interface {
  184. Size() int
  185. MAC(digestBuf, seq, header, length, data []byte) []byte
  186. }
  187. // fixedNonceAEAD wraps an AEAD and prefixes a fixed portion of the nonce to
  188. // each call.
  189. type fixedNonceAEAD struct {
  190. // sealNonce and openNonce are buffers where the larger nonce will be
  191. // constructed. Since a seal and open operation may be running
  192. // concurrently, there is a separate buffer for each.
  193. sealNonce, openNonce []byte
  194. aead cipher.AEAD
  195. }
  196. func (f *fixedNonceAEAD) NonceSize() int { return 8 }
  197. func (f *fixedNonceAEAD) Overhead() int { return f.aead.Overhead() }
  198. func (f *fixedNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte {
  199. copy(f.sealNonce[len(f.sealNonce)-8:], nonce)
  200. return f.aead.Seal(out, f.sealNonce, plaintext, additionalData)
  201. }
  202. func (f *fixedNonceAEAD) Open(out, nonce, plaintext, additionalData []byte) ([]byte, error) {
  203. copy(f.openNonce[len(f.openNonce)-8:], nonce)
  204. return f.aead.Open(out, f.openNonce, plaintext, additionalData)
  205. }
  206. func aeadAESGCM(key, fixedNonce []byte) *tlsAead {
  207. aes, err := aes.NewCipher(key)
  208. if err != nil {
  209. panic(err)
  210. }
  211. aead, err := cipher.NewGCM(aes)
  212. if err != nil {
  213. panic(err)
  214. }
  215. nonce1, nonce2 := make([]byte, 12), make([]byte, 12)
  216. copy(nonce1, fixedNonce)
  217. copy(nonce2, fixedNonce)
  218. return &tlsAead{&fixedNonceAEAD{nonce1, nonce2, aead}, true}
  219. }
  220. func aeadCHACHA20POLY1305(key, fixedNonce []byte) *tlsAead {
  221. aead, err := newChaCha20Poly1305(key)
  222. if err != nil {
  223. panic(err)
  224. }
  225. return &tlsAead{aead, false}
  226. }
  227. // ssl30MAC implements the SSLv3 MAC function, as defined in
  228. // www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt section 5.2.3.1
  229. type ssl30MAC struct {
  230. h hash.Hash
  231. key []byte
  232. }
  233. func (s ssl30MAC) Size() int {
  234. return s.h.Size()
  235. }
  236. 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}
  237. 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}
  238. func (s ssl30MAC) MAC(digestBuf, seq, header, length, data []byte) []byte {
  239. padLength := 48
  240. if s.h.Size() == 20 {
  241. padLength = 40
  242. }
  243. s.h.Reset()
  244. s.h.Write(s.key)
  245. s.h.Write(ssl30Pad1[:padLength])
  246. s.h.Write(seq)
  247. s.h.Write(header[:1])
  248. s.h.Write(length)
  249. s.h.Write(data)
  250. digestBuf = s.h.Sum(digestBuf[:0])
  251. s.h.Reset()
  252. s.h.Write(s.key)
  253. s.h.Write(ssl30Pad2[:padLength])
  254. s.h.Write(digestBuf)
  255. return s.h.Sum(digestBuf[:0])
  256. }
  257. // tls10MAC implements the TLS 1.0 MAC function. RFC 2246, section 6.2.3.
  258. type tls10MAC struct {
  259. h hash.Hash
  260. }
  261. func (s tls10MAC) Size() int {
  262. return s.h.Size()
  263. }
  264. func (s tls10MAC) MAC(digestBuf, seq, header, length, data []byte) []byte {
  265. s.h.Reset()
  266. s.h.Write(seq)
  267. s.h.Write(header)
  268. s.h.Write(length)
  269. s.h.Write(data)
  270. return s.h.Sum(digestBuf[:0])
  271. }
  272. func rsaKA(version uint16) keyAgreement {
  273. return &rsaKeyAgreement{version: version}
  274. }
  275. func ecdheECDSAKA(version uint16) keyAgreement {
  276. return &ecdheKeyAgreement{
  277. auth: &signedKeyAgreement{
  278. sigType: signatureECDSA,
  279. version: version,
  280. },
  281. }
  282. }
  283. func ecdheRSAKA(version uint16) keyAgreement {
  284. return &ecdheKeyAgreement{
  285. auth: &signedKeyAgreement{
  286. sigType: signatureRSA,
  287. version: version,
  288. },
  289. }
  290. }
  291. func dheRSAKA(version uint16) keyAgreement {
  292. return &dheKeyAgreement{
  293. auth: &signedKeyAgreement{
  294. sigType: signatureRSA,
  295. version: version,
  296. },
  297. }
  298. }
  299. func pskKA(version uint16) keyAgreement {
  300. return &pskKeyAgreement{
  301. base: &nilKeyAgreement{},
  302. }
  303. }
  304. func ecdhePSKKA(version uint16) keyAgreement {
  305. return &pskKeyAgreement{
  306. base: &ecdheKeyAgreement{
  307. auth: &nilKeyAgreementAuthentication{},
  308. },
  309. }
  310. }
  311. // mutualCipherSuite returns a cipherSuite given a list of supported
  312. // ciphersuites and the id requested by the peer.
  313. func mutualCipherSuite(have []uint16, want uint16) *cipherSuite {
  314. for _, id := range have {
  315. if id == want {
  316. for _, suite := range cipherSuites {
  317. if suite.id == want {
  318. return suite
  319. }
  320. }
  321. return nil
  322. }
  323. }
  324. return nil
  325. }
  326. // A list of the possible cipher suite ids. Taken from
  327. // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml
  328. const (
  329. TLS_RSA_WITH_RC4_128_MD5 uint16 = 0x0004
  330. TLS_RSA_WITH_RC4_128_SHA uint16 = 0x0005
  331. TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000a
  332. TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x0016
  333. TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002f
  334. TLS_DHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0x0033
  335. TLS_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0035
  336. TLS_DHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0039
  337. TLS_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003c
  338. TLS_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x003d
  339. TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x0067
  340. TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x006b
  341. TLS_PSK_WITH_RC4_128_SHA uint16 = 0x008a
  342. TLS_PSK_WITH_AES_128_CBC_SHA uint16 = 0x008c
  343. TLS_PSK_WITH_AES_256_CBC_SHA uint16 = 0x008d
  344. TLS_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009c
  345. TLS_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009d
  346. TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009e
  347. TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009f
  348. TLS_ECDHE_ECDSA_WITH_RC4_128_SHA uint16 = 0xc007
  349. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xc009
  350. TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xc00a
  351. TLS_ECDHE_RSA_WITH_RC4_128_SHA uint16 = 0xc011
  352. TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xc012
  353. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0xc013
  354. TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0xc014
  355. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16 = 0xc023
  356. TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 uint16 = 0xc024
  357. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xc027
  358. TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 uint16 = 0xc028
  359. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02b
  360. TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 uint16 = 0xc02c
  361. TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02f
  362. TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xc030
  363. TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA uint16 = 0xc035
  364. TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA uint16 = 0xc036
  365. renegotiationSCSV uint16 = 0x00ff
  366. fallbackSCSV uint16 = 0x5600
  367. )
  368. // Additional cipher suite IDs, not IANA-assigned.
  369. const (
  370. TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256 uint16 = 0xcafe
  371. TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xcc13
  372. TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xcc14
  373. TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xcc15
  374. )