bindings.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. """
  2. This module uses ctypes to bind a whole bunch of functions and constants from
  3. SecureTransport. The goal here is to provide the low-level API to
  4. SecureTransport. These are essentially the C-level functions and constants, and
  5. they're pretty gross to work with.
  6. This code is a bastardised version of the code found in Will Bond's oscrypto
  7. library. An enormous debt is owed to him for blazing this trail for us. For
  8. that reason, this code should be considered to be covered both by urllib3's
  9. license and by oscrypto's:
  10. Copyright (c) 2015-2016 Will Bond <will@wbond.net>
  11. Permission is hereby granted, free of charge, to any person obtaining a
  12. copy of this software and associated documentation files (the "Software"),
  13. to deal in the Software without restriction, including without limitation
  14. the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. and/or sell copies of the Software, and to permit persons to whom the
  16. Software is furnished to do so, subject to the following conditions:
  17. The above copyright notice and this permission notice shall be included in
  18. all copies or substantial portions of the Software.
  19. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. DEALINGS IN THE SOFTWARE.
  26. """
  27. from __future__ import absolute_import
  28. import platform
  29. from ctypes import (
  30. CDLL,
  31. CFUNCTYPE,
  32. POINTER,
  33. c_bool,
  34. c_byte,
  35. c_char_p,
  36. c_int32,
  37. c_long,
  38. c_size_t,
  39. c_uint32,
  40. c_ulong,
  41. c_void_p,
  42. )
  43. from ctypes.util import find_library
  44. from ...packages.six import raise_from
  45. if platform.system() != "Darwin":
  46. raise ImportError("Only macOS is supported")
  47. version = platform.mac_ver()[0]
  48. version_info = tuple(map(int, version.split(".")))
  49. if version_info < (10, 8):
  50. raise OSError(
  51. "Only OS X 10.8 and newer are supported, not %s.%s"
  52. % (version_info[0], version_info[1])
  53. )
  54. def load_cdll(name, macos10_16_path):
  55. """Loads a CDLL by name, falling back to known path on 10.16+"""
  56. try:
  57. # Big Sur is technically 11 but we use 10.16 due to the Big Sur
  58. # beta being labeled as 10.16.
  59. if version_info >= (10, 16):
  60. path = macos10_16_path
  61. else:
  62. path = find_library(name)
  63. if not path:
  64. raise OSError # Caught and reraised as 'ImportError'
  65. return CDLL(path, use_errno=True)
  66. except OSError:
  67. raise_from(ImportError("The library %s failed to load" % name), None)
  68. Security = load_cdll(
  69. "Security", "/System/Library/Frameworks/Security.framework/Security"
  70. )
  71. CoreFoundation = load_cdll(
  72. "CoreFoundation",
  73. "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation",
  74. )
  75. Boolean = c_bool
  76. CFIndex = c_long
  77. CFStringEncoding = c_uint32
  78. CFData = c_void_p
  79. CFString = c_void_p
  80. CFArray = c_void_p
  81. CFMutableArray = c_void_p
  82. CFDictionary = c_void_p
  83. CFError = c_void_p
  84. CFType = c_void_p
  85. CFTypeID = c_ulong
  86. CFTypeRef = POINTER(CFType)
  87. CFAllocatorRef = c_void_p
  88. OSStatus = c_int32
  89. CFDataRef = POINTER(CFData)
  90. CFStringRef = POINTER(CFString)
  91. CFArrayRef = POINTER(CFArray)
  92. CFMutableArrayRef = POINTER(CFMutableArray)
  93. CFDictionaryRef = POINTER(CFDictionary)
  94. CFArrayCallBacks = c_void_p
  95. CFDictionaryKeyCallBacks = c_void_p
  96. CFDictionaryValueCallBacks = c_void_p
  97. SecCertificateRef = POINTER(c_void_p)
  98. SecExternalFormat = c_uint32
  99. SecExternalItemType = c_uint32
  100. SecIdentityRef = POINTER(c_void_p)
  101. SecItemImportExportFlags = c_uint32
  102. SecItemImportExportKeyParameters = c_void_p
  103. SecKeychainRef = POINTER(c_void_p)
  104. SSLProtocol = c_uint32
  105. SSLCipherSuite = c_uint32
  106. SSLContextRef = POINTER(c_void_p)
  107. SecTrustRef = POINTER(c_void_p)
  108. SSLConnectionRef = c_uint32
  109. SecTrustResultType = c_uint32
  110. SecTrustOptionFlags = c_uint32
  111. SSLProtocolSide = c_uint32
  112. SSLConnectionType = c_uint32
  113. SSLSessionOption = c_uint32
  114. try:
  115. Security.SecItemImport.argtypes = [
  116. CFDataRef,
  117. CFStringRef,
  118. POINTER(SecExternalFormat),
  119. POINTER(SecExternalItemType),
  120. SecItemImportExportFlags,
  121. POINTER(SecItemImportExportKeyParameters),
  122. SecKeychainRef,
  123. POINTER(CFArrayRef),
  124. ]
  125. Security.SecItemImport.restype = OSStatus
  126. Security.SecCertificateGetTypeID.argtypes = []
  127. Security.SecCertificateGetTypeID.restype = CFTypeID
  128. Security.SecIdentityGetTypeID.argtypes = []
  129. Security.SecIdentityGetTypeID.restype = CFTypeID
  130. Security.SecKeyGetTypeID.argtypes = []
  131. Security.SecKeyGetTypeID.restype = CFTypeID
  132. Security.SecCertificateCreateWithData.argtypes = [CFAllocatorRef, CFDataRef]
  133. Security.SecCertificateCreateWithData.restype = SecCertificateRef
  134. Security.SecCertificateCopyData.argtypes = [SecCertificateRef]
  135. Security.SecCertificateCopyData.restype = CFDataRef
  136. Security.SecCopyErrorMessageString.argtypes = [OSStatus, c_void_p]
  137. Security.SecCopyErrorMessageString.restype = CFStringRef
  138. Security.SecIdentityCreateWithCertificate.argtypes = [
  139. CFTypeRef,
  140. SecCertificateRef,
  141. POINTER(SecIdentityRef),
  142. ]
  143. Security.SecIdentityCreateWithCertificate.restype = OSStatus
  144. Security.SecKeychainCreate.argtypes = [
  145. c_char_p,
  146. c_uint32,
  147. c_void_p,
  148. Boolean,
  149. c_void_p,
  150. POINTER(SecKeychainRef),
  151. ]
  152. Security.SecKeychainCreate.restype = OSStatus
  153. Security.SecKeychainDelete.argtypes = [SecKeychainRef]
  154. Security.SecKeychainDelete.restype = OSStatus
  155. Security.SecPKCS12Import.argtypes = [
  156. CFDataRef,
  157. CFDictionaryRef,
  158. POINTER(CFArrayRef),
  159. ]
  160. Security.SecPKCS12Import.restype = OSStatus
  161. SSLReadFunc = CFUNCTYPE(OSStatus, SSLConnectionRef, c_void_p, POINTER(c_size_t))
  162. SSLWriteFunc = CFUNCTYPE(
  163. OSStatus, SSLConnectionRef, POINTER(c_byte), POINTER(c_size_t)
  164. )
  165. Security.SSLSetIOFuncs.argtypes = [SSLContextRef, SSLReadFunc, SSLWriteFunc]
  166. Security.SSLSetIOFuncs.restype = OSStatus
  167. Security.SSLSetPeerID.argtypes = [SSLContextRef, c_char_p, c_size_t]
  168. Security.SSLSetPeerID.restype = OSStatus
  169. Security.SSLSetCertificate.argtypes = [SSLContextRef, CFArrayRef]
  170. Security.SSLSetCertificate.restype = OSStatus
  171. Security.SSLSetCertificateAuthorities.argtypes = [SSLContextRef, CFTypeRef, Boolean]
  172. Security.SSLSetCertificateAuthorities.restype = OSStatus
  173. Security.SSLSetConnection.argtypes = [SSLContextRef, SSLConnectionRef]
  174. Security.SSLSetConnection.restype = OSStatus
  175. Security.SSLSetPeerDomainName.argtypes = [SSLContextRef, c_char_p, c_size_t]
  176. Security.SSLSetPeerDomainName.restype = OSStatus
  177. Security.SSLHandshake.argtypes = [SSLContextRef]
  178. Security.SSLHandshake.restype = OSStatus
  179. Security.SSLRead.argtypes = [SSLContextRef, c_char_p, c_size_t, POINTER(c_size_t)]
  180. Security.SSLRead.restype = OSStatus
  181. Security.SSLWrite.argtypes = [SSLContextRef, c_char_p, c_size_t, POINTER(c_size_t)]
  182. Security.SSLWrite.restype = OSStatus
  183. Security.SSLClose.argtypes = [SSLContextRef]
  184. Security.SSLClose.restype = OSStatus
  185. Security.SSLGetNumberSupportedCiphers.argtypes = [SSLContextRef, POINTER(c_size_t)]
  186. Security.SSLGetNumberSupportedCiphers.restype = OSStatus
  187. Security.SSLGetSupportedCiphers.argtypes = [
  188. SSLContextRef,
  189. POINTER(SSLCipherSuite),
  190. POINTER(c_size_t),
  191. ]
  192. Security.SSLGetSupportedCiphers.restype = OSStatus
  193. Security.SSLSetEnabledCiphers.argtypes = [
  194. SSLContextRef,
  195. POINTER(SSLCipherSuite),
  196. c_size_t,
  197. ]
  198. Security.SSLSetEnabledCiphers.restype = OSStatus
  199. Security.SSLGetNumberEnabledCiphers.argtype = [SSLContextRef, POINTER(c_size_t)]
  200. Security.SSLGetNumberEnabledCiphers.restype = OSStatus
  201. Security.SSLGetEnabledCiphers.argtypes = [
  202. SSLContextRef,
  203. POINTER(SSLCipherSuite),
  204. POINTER(c_size_t),
  205. ]
  206. Security.SSLGetEnabledCiphers.restype = OSStatus
  207. Security.SSLGetNegotiatedCipher.argtypes = [SSLContextRef, POINTER(SSLCipherSuite)]
  208. Security.SSLGetNegotiatedCipher.restype = OSStatus
  209. Security.SSLGetNegotiatedProtocolVersion.argtypes = [
  210. SSLContextRef,
  211. POINTER(SSLProtocol),
  212. ]
  213. Security.SSLGetNegotiatedProtocolVersion.restype = OSStatus
  214. Security.SSLCopyPeerTrust.argtypes = [SSLContextRef, POINTER(SecTrustRef)]
  215. Security.SSLCopyPeerTrust.restype = OSStatus
  216. Security.SecTrustSetAnchorCertificates.argtypes = [SecTrustRef, CFArrayRef]
  217. Security.SecTrustSetAnchorCertificates.restype = OSStatus
  218. Security.SecTrustSetAnchorCertificatesOnly.argstypes = [SecTrustRef, Boolean]
  219. Security.SecTrustSetAnchorCertificatesOnly.restype = OSStatus
  220. Security.SecTrustEvaluate.argtypes = [SecTrustRef, POINTER(SecTrustResultType)]
  221. Security.SecTrustEvaluate.restype = OSStatus
  222. Security.SecTrustGetCertificateCount.argtypes = [SecTrustRef]
  223. Security.SecTrustGetCertificateCount.restype = CFIndex
  224. Security.SecTrustGetCertificateAtIndex.argtypes = [SecTrustRef, CFIndex]
  225. Security.SecTrustGetCertificateAtIndex.restype = SecCertificateRef
  226. Security.SSLCreateContext.argtypes = [
  227. CFAllocatorRef,
  228. SSLProtocolSide,
  229. SSLConnectionType,
  230. ]
  231. Security.SSLCreateContext.restype = SSLContextRef
  232. Security.SSLSetSessionOption.argtypes = [SSLContextRef, SSLSessionOption, Boolean]
  233. Security.SSLSetSessionOption.restype = OSStatus
  234. Security.SSLSetProtocolVersionMin.argtypes = [SSLContextRef, SSLProtocol]
  235. Security.SSLSetProtocolVersionMin.restype = OSStatus
  236. Security.SSLSetProtocolVersionMax.argtypes = [SSLContextRef, SSLProtocol]
  237. Security.SSLSetProtocolVersionMax.restype = OSStatus
  238. try:
  239. Security.SSLSetALPNProtocols.argtypes = [SSLContextRef, CFArrayRef]
  240. Security.SSLSetALPNProtocols.restype = OSStatus
  241. except AttributeError:
  242. # Supported only in 10.12+
  243. pass
  244. Security.SecCopyErrorMessageString.argtypes = [OSStatus, c_void_p]
  245. Security.SecCopyErrorMessageString.restype = CFStringRef
  246. Security.SSLReadFunc = SSLReadFunc
  247. Security.SSLWriteFunc = SSLWriteFunc
  248. Security.SSLContextRef = SSLContextRef
  249. Security.SSLProtocol = SSLProtocol
  250. Security.SSLCipherSuite = SSLCipherSuite
  251. Security.SecIdentityRef = SecIdentityRef
  252. Security.SecKeychainRef = SecKeychainRef
  253. Security.SecTrustRef = SecTrustRef
  254. Security.SecTrustResultType = SecTrustResultType
  255. Security.SecExternalFormat = SecExternalFormat
  256. Security.OSStatus = OSStatus
  257. Security.kSecImportExportPassphrase = CFStringRef.in_dll(
  258. Security, "kSecImportExportPassphrase"
  259. )
  260. Security.kSecImportItemIdentity = CFStringRef.in_dll(
  261. Security, "kSecImportItemIdentity"
  262. )
  263. # CoreFoundation time!
  264. CoreFoundation.CFRetain.argtypes = [CFTypeRef]
  265. CoreFoundation.CFRetain.restype = CFTypeRef
  266. CoreFoundation.CFRelease.argtypes = [CFTypeRef]
  267. CoreFoundation.CFRelease.restype = None
  268. CoreFoundation.CFGetTypeID.argtypes = [CFTypeRef]
  269. CoreFoundation.CFGetTypeID.restype = CFTypeID
  270. CoreFoundation.CFStringCreateWithCString.argtypes = [
  271. CFAllocatorRef,
  272. c_char_p,
  273. CFStringEncoding,
  274. ]
  275. CoreFoundation.CFStringCreateWithCString.restype = CFStringRef
  276. CoreFoundation.CFStringGetCStringPtr.argtypes = [CFStringRef, CFStringEncoding]
  277. CoreFoundation.CFStringGetCStringPtr.restype = c_char_p
  278. CoreFoundation.CFStringGetCString.argtypes = [
  279. CFStringRef,
  280. c_char_p,
  281. CFIndex,
  282. CFStringEncoding,
  283. ]
  284. CoreFoundation.CFStringGetCString.restype = c_bool
  285. CoreFoundation.CFDataCreate.argtypes = [CFAllocatorRef, c_char_p, CFIndex]
  286. CoreFoundation.CFDataCreate.restype = CFDataRef
  287. CoreFoundation.CFDataGetLength.argtypes = [CFDataRef]
  288. CoreFoundation.CFDataGetLength.restype = CFIndex
  289. CoreFoundation.CFDataGetBytePtr.argtypes = [CFDataRef]
  290. CoreFoundation.CFDataGetBytePtr.restype = c_void_p
  291. CoreFoundation.CFDictionaryCreate.argtypes = [
  292. CFAllocatorRef,
  293. POINTER(CFTypeRef),
  294. POINTER(CFTypeRef),
  295. CFIndex,
  296. CFDictionaryKeyCallBacks,
  297. CFDictionaryValueCallBacks,
  298. ]
  299. CoreFoundation.CFDictionaryCreate.restype = CFDictionaryRef
  300. CoreFoundation.CFDictionaryGetValue.argtypes = [CFDictionaryRef, CFTypeRef]
  301. CoreFoundation.CFDictionaryGetValue.restype = CFTypeRef
  302. CoreFoundation.CFArrayCreate.argtypes = [
  303. CFAllocatorRef,
  304. POINTER(CFTypeRef),
  305. CFIndex,
  306. CFArrayCallBacks,
  307. ]
  308. CoreFoundation.CFArrayCreate.restype = CFArrayRef
  309. CoreFoundation.CFArrayCreateMutable.argtypes = [
  310. CFAllocatorRef,
  311. CFIndex,
  312. CFArrayCallBacks,
  313. ]
  314. CoreFoundation.CFArrayCreateMutable.restype = CFMutableArrayRef
  315. CoreFoundation.CFArrayAppendValue.argtypes = [CFMutableArrayRef, c_void_p]
  316. CoreFoundation.CFArrayAppendValue.restype = None
  317. CoreFoundation.CFArrayGetCount.argtypes = [CFArrayRef]
  318. CoreFoundation.CFArrayGetCount.restype = CFIndex
  319. CoreFoundation.CFArrayGetValueAtIndex.argtypes = [CFArrayRef, CFIndex]
  320. CoreFoundation.CFArrayGetValueAtIndex.restype = c_void_p
  321. CoreFoundation.kCFAllocatorDefault = CFAllocatorRef.in_dll(
  322. CoreFoundation, "kCFAllocatorDefault"
  323. )
  324. CoreFoundation.kCFTypeArrayCallBacks = c_void_p.in_dll(
  325. CoreFoundation, "kCFTypeArrayCallBacks"
  326. )
  327. CoreFoundation.kCFTypeDictionaryKeyCallBacks = c_void_p.in_dll(
  328. CoreFoundation, "kCFTypeDictionaryKeyCallBacks"
  329. )
  330. CoreFoundation.kCFTypeDictionaryValueCallBacks = c_void_p.in_dll(
  331. CoreFoundation, "kCFTypeDictionaryValueCallBacks"
  332. )
  333. CoreFoundation.CFTypeRef = CFTypeRef
  334. CoreFoundation.CFArrayRef = CFArrayRef
  335. CoreFoundation.CFStringRef = CFStringRef
  336. CoreFoundation.CFDictionaryRef = CFDictionaryRef
  337. except (AttributeError):
  338. raise ImportError("Error initializing ctypes")
  339. class CFConst(object):
  340. """
  341. A class object that acts as essentially a namespace for CoreFoundation
  342. constants.
  343. """
  344. kCFStringEncodingUTF8 = CFStringEncoding(0x08000100)
  345. class SecurityConst(object):
  346. """
  347. A class object that acts as essentially a namespace for Security constants.
  348. """
  349. kSSLSessionOptionBreakOnServerAuth = 0
  350. kSSLProtocol2 = 1
  351. kSSLProtocol3 = 2
  352. kTLSProtocol1 = 4
  353. kTLSProtocol11 = 7
  354. kTLSProtocol12 = 8
  355. # SecureTransport does not support TLS 1.3 even if there's a constant for it
  356. kTLSProtocol13 = 10
  357. kTLSProtocolMaxSupported = 999
  358. kSSLClientSide = 1
  359. kSSLStreamType = 0
  360. kSecFormatPEMSequence = 10
  361. kSecTrustResultInvalid = 0
  362. kSecTrustResultProceed = 1
  363. # This gap is present on purpose: this was kSecTrustResultConfirm, which
  364. # is deprecated.
  365. kSecTrustResultDeny = 3
  366. kSecTrustResultUnspecified = 4
  367. kSecTrustResultRecoverableTrustFailure = 5
  368. kSecTrustResultFatalTrustFailure = 6
  369. kSecTrustResultOtherError = 7
  370. errSSLProtocol = -9800
  371. errSSLWouldBlock = -9803
  372. errSSLClosedGraceful = -9805
  373. errSSLClosedNoNotify = -9816
  374. errSSLClosedAbort = -9806
  375. errSSLXCertChainInvalid = -9807
  376. errSSLCrypto = -9809
  377. errSSLInternal = -9810
  378. errSSLCertExpired = -9814
  379. errSSLCertNotYetValid = -9815
  380. errSSLUnknownRootCert = -9812
  381. errSSLNoRootCert = -9813
  382. errSSLHostNameMismatch = -9843
  383. errSSLPeerHandshakeFail = -9824
  384. errSSLPeerUserCancelled = -9839
  385. errSSLWeakPeerEphemeralDHKey = -9850
  386. errSSLServerAuthCompleted = -9841
  387. errSSLRecordOverflow = -9847
  388. errSecVerifyFailed = -67808
  389. errSecNoTrustSettings = -25263
  390. errSecItemNotFound = -25300
  391. errSecInvalidTrustSettings = -25262
  392. # Cipher suites. We only pick the ones our default cipher string allows.
  393. # Source: https://developer.apple.com/documentation/security/1550981-ssl_cipher_suite_values
  394. TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xC02C
  395. TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xC030
  396. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xC02B
  397. TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xC02F
  398. TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = 0xCCA9
  399. TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = 0xCCA8
  400. TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = 0x009F
  401. TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = 0x009E
  402. TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = 0xC024
  403. TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = 0xC028
  404. TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xC00A
  405. TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014
  406. TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x006B
  407. TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x0039
  408. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 0xC023
  409. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 0xC027
  410. TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0xC009
  411. TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xC013
  412. TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x0067
  413. TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x0033
  414. TLS_RSA_WITH_AES_256_GCM_SHA384 = 0x009D
  415. TLS_RSA_WITH_AES_128_GCM_SHA256 = 0x009C
  416. TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x003D
  417. TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x003C
  418. TLS_RSA_WITH_AES_256_CBC_SHA = 0x0035
  419. TLS_RSA_WITH_AES_128_CBC_SHA = 0x002F
  420. TLS_AES_128_GCM_SHA256 = 0x1301
  421. TLS_AES_256_GCM_SHA384 = 0x1302
  422. TLS_AES_128_CCM_8_SHA256 = 0x1305
  423. TLS_AES_128_CCM_SHA256 = 0x1304