2
0

cipher_suite.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) Jan Venekamp, <jan@venekamp.net>
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #if defined(USE_MBEDTLS) || defined(USE_BEARSSL)
  26. #include "cipher_suite.h"
  27. #include "curl_printf.h"
  28. #include "strcase.h"
  29. #include <string.h>
  30. /*
  31. * To support the CURLOPT_SSL_CIPHER_LIST option on SSL backends
  32. * that do not support it natively, but do support setting a list of
  33. * IANA ids, we need a list of all supported cipher suite names
  34. * (openssl and IANA) to be able to look up the IANA ids.
  35. *
  36. * To keep the binary size of this list down we compress each entry
  37. * down to 2 + 6 bytes using the C preprocessor.
  38. */
  39. /*
  40. * mbedTLS NOTE: mbedTLS has mbedtls_ssl_get_ciphersuite_id() to
  41. * convert a string representation to an IANA id, we do not use that
  42. * because it does not support "standard" openssl cipher suite
  43. * names, nor IANA names.
  44. */
  45. /* NOTE: also see tests/unit/unit3205.c */
  46. /* Text for cipher suite parts (max 64 entries),
  47. keep indexes below in sync with this! */
  48. static const char *cs_txt =
  49. "\0"
  50. "TLS" "\0"
  51. "WITH" "\0"
  52. "128" "\0"
  53. "256" "\0"
  54. "3DES" "\0"
  55. "8" "\0"
  56. "AES" "\0"
  57. "AES128" "\0"
  58. "AES256" "\0"
  59. "CBC" "\0"
  60. "CBC3" "\0"
  61. "CCM" "\0"
  62. "CCM8" "\0"
  63. "CHACHA20" "\0"
  64. "DES" "\0"
  65. "DHE" "\0"
  66. "ECDH" "\0"
  67. "ECDHE" "\0"
  68. "ECDSA" "\0"
  69. "EDE" "\0"
  70. "GCM" "\0"
  71. "MD5" "\0"
  72. "NULL" "\0"
  73. "POLY1305" "\0"
  74. "PSK" "\0"
  75. "RSA" "\0"
  76. "SHA" "\0"
  77. "SHA256" "\0"
  78. "SHA384" "\0"
  79. #if defined(USE_MBEDTLS)
  80. "ARIA" "\0"
  81. "ARIA128" "\0"
  82. "ARIA256" "\0"
  83. "CAMELLIA" "\0"
  84. "CAMELLIA128" "\0"
  85. "CAMELLIA256" "\0"
  86. #endif
  87. ;
  88. /* Indexes of above cs_txt */
  89. enum {
  90. CS_TXT_IDX_,
  91. CS_TXT_IDX_TLS,
  92. CS_TXT_IDX_WITH,
  93. CS_TXT_IDX_128,
  94. CS_TXT_IDX_256,
  95. CS_TXT_IDX_3DES,
  96. CS_TXT_IDX_8,
  97. CS_TXT_IDX_AES,
  98. CS_TXT_IDX_AES128,
  99. CS_TXT_IDX_AES256,
  100. CS_TXT_IDX_CBC,
  101. CS_TXT_IDX_CBC3,
  102. CS_TXT_IDX_CCM,
  103. CS_TXT_IDX_CCM8,
  104. CS_TXT_IDX_CHACHA20,
  105. CS_TXT_IDX_DES,
  106. CS_TXT_IDX_DHE,
  107. CS_TXT_IDX_ECDH,
  108. CS_TXT_IDX_ECDHE,
  109. CS_TXT_IDX_ECDSA,
  110. CS_TXT_IDX_EDE,
  111. CS_TXT_IDX_GCM,
  112. CS_TXT_IDX_MD5,
  113. CS_TXT_IDX_NULL,
  114. CS_TXT_IDX_POLY1305,
  115. CS_TXT_IDX_PSK,
  116. CS_TXT_IDX_RSA,
  117. CS_TXT_IDX_SHA,
  118. CS_TXT_IDX_SHA256,
  119. CS_TXT_IDX_SHA384,
  120. #if defined(USE_MBEDTLS)
  121. CS_TXT_IDX_ARIA,
  122. CS_TXT_IDX_ARIA128,
  123. CS_TXT_IDX_ARIA256,
  124. CS_TXT_IDX_CAMELLIA,
  125. CS_TXT_IDX_CAMELLIA128,
  126. CS_TXT_IDX_CAMELLIA256,
  127. #endif
  128. CS_TXT_LEN,
  129. };
  130. #define CS_ZIP_IDX(a, b, c, d, e, f, g, h) \
  131. { \
  132. (uint8_t) ((a) << 2 | ((b) & 0x3F) >> 4), \
  133. (uint8_t) ((b) << 4 | ((c) & 0x3F) >> 2), \
  134. (uint8_t) ((c) << 6 | ((d) & 0x3F)), \
  135. (uint8_t) ((e) << 2 | ((f) & 0x3F) >> 4), \
  136. (uint8_t) ((f) << 4 | ((g) & 0x3F) >> 2), \
  137. (uint8_t) ((g) << 6 | ((h) & 0x3F)) \
  138. }
  139. #define CS_ENTRY(id, a, b, c, d, e, f, g, h) \
  140. { \
  141. id, \
  142. CS_ZIP_IDX( \
  143. CS_TXT_IDX_ ## a, CS_TXT_IDX_ ## b, \
  144. CS_TXT_IDX_ ## c, CS_TXT_IDX_ ## d, \
  145. CS_TXT_IDX_ ## e, CS_TXT_IDX_ ## f, \
  146. CS_TXT_IDX_ ## g, CS_TXT_IDX_ ## h \
  147. ) \
  148. }
  149. struct cs_entry {
  150. uint16_t id;
  151. uint8_t zip[6];
  152. };
  153. /* !checksrc! disable COMMANOSPACE all */
  154. static const struct cs_entry cs_list [] = {
  155. CS_ENTRY(0x002F, TLS,RSA,WITH,AES,128,CBC,SHA,),
  156. CS_ENTRY(0x002F, AES128,SHA,,,,,,),
  157. CS_ENTRY(0x0035, TLS,RSA,WITH,AES,256,CBC,SHA,),
  158. CS_ENTRY(0x0035, AES256,SHA,,,,,,),
  159. CS_ENTRY(0x003C, TLS,RSA,WITH,AES,128,CBC,SHA256,),
  160. CS_ENTRY(0x003C, AES128,SHA256,,,,,,),
  161. CS_ENTRY(0x003D, TLS,RSA,WITH,AES,256,CBC,SHA256,),
  162. CS_ENTRY(0x003D, AES256,SHA256,,,,,,),
  163. CS_ENTRY(0x009C, TLS,RSA,WITH,AES,128,GCM,SHA256,),
  164. CS_ENTRY(0x009C, AES128,GCM,SHA256,,,,,),
  165. CS_ENTRY(0x009D, TLS,RSA,WITH,AES,256,GCM,SHA384,),
  166. CS_ENTRY(0x009D, AES256,GCM,SHA384,,,,,),
  167. CS_ENTRY(0xC004, TLS,ECDH,ECDSA,WITH,AES,128,CBC,SHA),
  168. CS_ENTRY(0xC004, ECDH,ECDSA,AES128,SHA,,,,),
  169. CS_ENTRY(0xC005, TLS,ECDH,ECDSA,WITH,AES,256,CBC,SHA),
  170. CS_ENTRY(0xC005, ECDH,ECDSA,AES256,SHA,,,,),
  171. CS_ENTRY(0xC009, TLS,ECDHE,ECDSA,WITH,AES,128,CBC,SHA),
  172. CS_ENTRY(0xC009, ECDHE,ECDSA,AES128,SHA,,,,),
  173. CS_ENTRY(0xC00A, TLS,ECDHE,ECDSA,WITH,AES,256,CBC,SHA),
  174. CS_ENTRY(0xC00A, ECDHE,ECDSA,AES256,SHA,,,,),
  175. CS_ENTRY(0xC00E, TLS,ECDH,RSA,WITH,AES,128,CBC,SHA),
  176. CS_ENTRY(0xC00E, ECDH,RSA,AES128,SHA,,,,),
  177. CS_ENTRY(0xC00F, TLS,ECDH,RSA,WITH,AES,256,CBC,SHA),
  178. CS_ENTRY(0xC00F, ECDH,RSA,AES256,SHA,,,,),
  179. CS_ENTRY(0xC013, TLS,ECDHE,RSA,WITH,AES,128,CBC,SHA),
  180. CS_ENTRY(0xC013, ECDHE,RSA,AES128,SHA,,,,),
  181. CS_ENTRY(0xC014, TLS,ECDHE,RSA,WITH,AES,256,CBC,SHA),
  182. CS_ENTRY(0xC014, ECDHE,RSA,AES256,SHA,,,,),
  183. CS_ENTRY(0xC023, TLS,ECDHE,ECDSA,WITH,AES,128,CBC,SHA256),
  184. CS_ENTRY(0xC023, ECDHE,ECDSA,AES128,SHA256,,,,),
  185. CS_ENTRY(0xC024, TLS,ECDHE,ECDSA,WITH,AES,256,CBC,SHA384),
  186. CS_ENTRY(0xC024, ECDHE,ECDSA,AES256,SHA384,,,,),
  187. CS_ENTRY(0xC025, TLS,ECDH,ECDSA,WITH,AES,128,CBC,SHA256),
  188. CS_ENTRY(0xC025, ECDH,ECDSA,AES128,SHA256,,,,),
  189. CS_ENTRY(0xC026, TLS,ECDH,ECDSA,WITH,AES,256,CBC,SHA384),
  190. CS_ENTRY(0xC026, ECDH,ECDSA,AES256,SHA384,,,,),
  191. CS_ENTRY(0xC027, TLS,ECDHE,RSA,WITH,AES,128,CBC,SHA256),
  192. CS_ENTRY(0xC027, ECDHE,RSA,AES128,SHA256,,,,),
  193. CS_ENTRY(0xC028, TLS,ECDHE,RSA,WITH,AES,256,CBC,SHA384),
  194. CS_ENTRY(0xC028, ECDHE,RSA,AES256,SHA384,,,,),
  195. CS_ENTRY(0xC029, TLS,ECDH,RSA,WITH,AES,128,CBC,SHA256),
  196. CS_ENTRY(0xC029, ECDH,RSA,AES128,SHA256,,,,),
  197. CS_ENTRY(0xC02A, TLS,ECDH,RSA,WITH,AES,256,CBC,SHA384),
  198. CS_ENTRY(0xC02A, ECDH,RSA,AES256,SHA384,,,,),
  199. CS_ENTRY(0xC02B, TLS,ECDHE,ECDSA,WITH,AES,128,GCM,SHA256),
  200. CS_ENTRY(0xC02B, ECDHE,ECDSA,AES128,GCM,SHA256,,,),
  201. CS_ENTRY(0xC02C, TLS,ECDHE,ECDSA,WITH,AES,256,GCM,SHA384),
  202. CS_ENTRY(0xC02C, ECDHE,ECDSA,AES256,GCM,SHA384,,,),
  203. CS_ENTRY(0xC02D, TLS,ECDH,ECDSA,WITH,AES,128,GCM,SHA256),
  204. CS_ENTRY(0xC02D, ECDH,ECDSA,AES128,GCM,SHA256,,,),
  205. CS_ENTRY(0xC02E, TLS,ECDH,ECDSA,WITH,AES,256,GCM,SHA384),
  206. CS_ENTRY(0xC02E, ECDH,ECDSA,AES256,GCM,SHA384,,,),
  207. CS_ENTRY(0xC02F, TLS,ECDHE,RSA,WITH,AES,128,GCM,SHA256),
  208. CS_ENTRY(0xC02F, ECDHE,RSA,AES128,GCM,SHA256,,,),
  209. CS_ENTRY(0xC030, TLS,ECDHE,RSA,WITH,AES,256,GCM,SHA384),
  210. CS_ENTRY(0xC030, ECDHE,RSA,AES256,GCM,SHA384,,,),
  211. CS_ENTRY(0xC031, TLS,ECDH,RSA,WITH,AES,128,GCM,SHA256),
  212. CS_ENTRY(0xC031, ECDH,RSA,AES128,GCM,SHA256,,,),
  213. CS_ENTRY(0xC032, TLS,ECDH,RSA,WITH,AES,256,GCM,SHA384),
  214. CS_ENTRY(0xC032, ECDH,RSA,AES256,GCM,SHA384,,,),
  215. CS_ENTRY(0xCCA8, TLS,ECDHE,RSA,WITH,CHACHA20,POLY1305,SHA256,),
  216. CS_ENTRY(0xCCA8, ECDHE,RSA,CHACHA20,POLY1305,,,,),
  217. CS_ENTRY(0xCCA9, TLS,ECDHE,ECDSA,WITH,CHACHA20,POLY1305,SHA256,),
  218. CS_ENTRY(0xCCA9, ECDHE,ECDSA,CHACHA20,POLY1305,,,,),
  219. #if defined(USE_MBEDTLS)
  220. CS_ENTRY(0x0001, TLS,RSA,WITH,NULL,MD5,,,),
  221. CS_ENTRY(0x0001, NULL,MD5,,,,,,),
  222. CS_ENTRY(0x0002, TLS,RSA,WITH,NULL,SHA,,,),
  223. CS_ENTRY(0x0002, NULL,SHA,,,,,,),
  224. CS_ENTRY(0x002C, TLS,PSK,WITH,NULL,SHA,,,),
  225. CS_ENTRY(0x002C, PSK,NULL,SHA,,,,,),
  226. CS_ENTRY(0x002D, TLS,DHE,PSK,WITH,NULL,SHA,,),
  227. CS_ENTRY(0x002D, DHE,PSK,NULL,SHA,,,,),
  228. CS_ENTRY(0x002E, TLS,RSA,PSK,WITH,NULL,SHA,,),
  229. CS_ENTRY(0x002E, RSA,PSK,NULL,SHA,,,,),
  230. CS_ENTRY(0x0033, TLS,DHE,RSA,WITH,AES,128,CBC,SHA),
  231. CS_ENTRY(0x0033, DHE,RSA,AES128,SHA,,,,),
  232. CS_ENTRY(0x0039, TLS,DHE,RSA,WITH,AES,256,CBC,SHA),
  233. CS_ENTRY(0x0039, DHE,RSA,AES256,SHA,,,,),
  234. CS_ENTRY(0x003B, TLS,RSA,WITH,NULL,SHA256,,,),
  235. CS_ENTRY(0x003B, NULL,SHA256,,,,,,),
  236. CS_ENTRY(0x0067, TLS,DHE,RSA,WITH,AES,128,CBC,SHA256),
  237. CS_ENTRY(0x0067, DHE,RSA,AES128,SHA256,,,,),
  238. CS_ENTRY(0x006B, TLS,DHE,RSA,WITH,AES,256,CBC,SHA256),
  239. CS_ENTRY(0x006B, DHE,RSA,AES256,SHA256,,,,),
  240. CS_ENTRY(0x008C, TLS,PSK,WITH,AES,128,CBC,SHA,),
  241. CS_ENTRY(0x008C, PSK,AES128,CBC,SHA,,,,),
  242. CS_ENTRY(0x008D, TLS,PSK,WITH,AES,256,CBC,SHA,),
  243. CS_ENTRY(0x008D, PSK,AES256,CBC,SHA,,,,),
  244. CS_ENTRY(0x0090, TLS,DHE,PSK,WITH,AES,128,CBC,SHA),
  245. CS_ENTRY(0x0090, DHE,PSK,AES128,CBC,SHA,,,),
  246. CS_ENTRY(0x0091, TLS,DHE,PSK,WITH,AES,256,CBC,SHA),
  247. CS_ENTRY(0x0091, DHE,PSK,AES256,CBC,SHA,,,),
  248. CS_ENTRY(0x0094, TLS,RSA,PSK,WITH,AES,128,CBC,SHA),
  249. CS_ENTRY(0x0094, RSA,PSK,AES128,CBC,SHA,,,),
  250. CS_ENTRY(0x0095, TLS,RSA,PSK,WITH,AES,256,CBC,SHA),
  251. CS_ENTRY(0x0095, RSA,PSK,AES256,CBC,SHA,,,),
  252. CS_ENTRY(0x009E, TLS,DHE,RSA,WITH,AES,128,GCM,SHA256),
  253. CS_ENTRY(0x009E, DHE,RSA,AES128,GCM,SHA256,,,),
  254. CS_ENTRY(0x009F, TLS,DHE,RSA,WITH,AES,256,GCM,SHA384),
  255. CS_ENTRY(0x009F, DHE,RSA,AES256,GCM,SHA384,,,),
  256. CS_ENTRY(0x00A8, TLS,PSK,WITH,AES,128,GCM,SHA256,),
  257. CS_ENTRY(0x00A8, PSK,AES128,GCM,SHA256,,,,),
  258. CS_ENTRY(0x00A9, TLS,PSK,WITH,AES,256,GCM,SHA384,),
  259. CS_ENTRY(0x00A9, PSK,AES256,GCM,SHA384,,,,),
  260. CS_ENTRY(0x00AA, TLS,DHE,PSK,WITH,AES,128,GCM,SHA256),
  261. CS_ENTRY(0x00AA, DHE,PSK,AES128,GCM,SHA256,,,),
  262. CS_ENTRY(0x00AB, TLS,DHE,PSK,WITH,AES,256,GCM,SHA384),
  263. CS_ENTRY(0x00AB, DHE,PSK,AES256,GCM,SHA384,,,),
  264. CS_ENTRY(0x00AC, TLS,RSA,PSK,WITH,AES,128,GCM,SHA256),
  265. CS_ENTRY(0x00AC, RSA,PSK,AES128,GCM,SHA256,,,),
  266. CS_ENTRY(0x00AD, TLS,RSA,PSK,WITH,AES,256,GCM,SHA384),
  267. CS_ENTRY(0x00AD, RSA,PSK,AES256,GCM,SHA384,,,),
  268. CS_ENTRY(0x00AE, TLS,PSK,WITH,AES,128,CBC,SHA256,),
  269. CS_ENTRY(0x00AE, PSK,AES128,CBC,SHA256,,,,),
  270. CS_ENTRY(0x00AF, TLS,PSK,WITH,AES,256,CBC,SHA384,),
  271. CS_ENTRY(0x00AF, PSK,AES256,CBC,SHA384,,,,),
  272. CS_ENTRY(0x00B0, TLS,PSK,WITH,NULL,SHA256,,,),
  273. CS_ENTRY(0x00B0, PSK,NULL,SHA256,,,,,),
  274. CS_ENTRY(0x00B1, TLS,PSK,WITH,NULL,SHA384,,,),
  275. CS_ENTRY(0x00B1, PSK,NULL,SHA384,,,,,),
  276. CS_ENTRY(0x00B2, TLS,DHE,PSK,WITH,AES,128,CBC,SHA256),
  277. CS_ENTRY(0x00B2, DHE,PSK,AES128,CBC,SHA256,,,),
  278. CS_ENTRY(0x00B3, TLS,DHE,PSK,WITH,AES,256,CBC,SHA384),
  279. CS_ENTRY(0x00B3, DHE,PSK,AES256,CBC,SHA384,,,),
  280. CS_ENTRY(0x00B4, TLS,DHE,PSK,WITH,NULL,SHA256,,),
  281. CS_ENTRY(0x00B4, DHE,PSK,NULL,SHA256,,,,),
  282. CS_ENTRY(0x00B5, TLS,DHE,PSK,WITH,NULL,SHA384,,),
  283. CS_ENTRY(0x00B5, DHE,PSK,NULL,SHA384,,,,),
  284. CS_ENTRY(0x00B6, TLS,RSA,PSK,WITH,AES,128,CBC,SHA256),
  285. CS_ENTRY(0x00B6, RSA,PSK,AES128,CBC,SHA256,,,),
  286. CS_ENTRY(0x00B7, TLS,RSA,PSK,WITH,AES,256,CBC,SHA384),
  287. CS_ENTRY(0x00B7, RSA,PSK,AES256,CBC,SHA384,,,),
  288. CS_ENTRY(0x00B8, TLS,RSA,PSK,WITH,NULL,SHA256,,),
  289. CS_ENTRY(0x00B8, RSA,PSK,NULL,SHA256,,,,),
  290. CS_ENTRY(0x00B9, TLS,RSA,PSK,WITH,NULL,SHA384,,),
  291. CS_ENTRY(0x00B9, RSA,PSK,NULL,SHA384,,,,),
  292. CS_ENTRY(0x1301, TLS,AES,128,GCM,SHA256,,,),
  293. CS_ENTRY(0x1302, TLS,AES,256,GCM,SHA384,,,),
  294. CS_ENTRY(0x1303, TLS,CHACHA20,POLY1305,SHA256,,,,),
  295. CS_ENTRY(0x1304, TLS,AES,128,CCM,SHA256,,,),
  296. CS_ENTRY(0x1305, TLS,AES,128,CCM,8,SHA256,,),
  297. CS_ENTRY(0xC001, TLS,ECDH,ECDSA,WITH,NULL,SHA,,),
  298. CS_ENTRY(0xC001, ECDH,ECDSA,NULL,SHA,,,,),
  299. CS_ENTRY(0xC006, TLS,ECDHE,ECDSA,WITH,NULL,SHA,,),
  300. CS_ENTRY(0xC006, ECDHE,ECDSA,NULL,SHA,,,,),
  301. CS_ENTRY(0xC00B, TLS,ECDH,RSA,WITH,NULL,SHA,,),
  302. CS_ENTRY(0xC00B, ECDH,RSA,NULL,SHA,,,,),
  303. CS_ENTRY(0xC010, TLS,ECDHE,RSA,WITH,NULL,SHA,,),
  304. CS_ENTRY(0xC010, ECDHE,RSA,NULL,SHA,,,,),
  305. CS_ENTRY(0xC035, TLS,ECDHE,PSK,WITH,AES,128,CBC,SHA),
  306. CS_ENTRY(0xC035, ECDHE,PSK,AES128,CBC,SHA,,,),
  307. CS_ENTRY(0xC036, TLS,ECDHE,PSK,WITH,AES,256,CBC,SHA),
  308. CS_ENTRY(0xC036, ECDHE,PSK,AES256,CBC,SHA,,,),
  309. CS_ENTRY(0xCCAB, TLS,PSK,WITH,CHACHA20,POLY1305,SHA256,,),
  310. CS_ENTRY(0xCCAB, PSK,CHACHA20,POLY1305,,,,,),
  311. #endif
  312. #if defined(USE_BEARSSL)
  313. CS_ENTRY(0x000A, TLS,RSA,WITH,3DES,EDE,CBC,SHA,),
  314. CS_ENTRY(0x000A, DES,CBC3,SHA,,,,,),
  315. CS_ENTRY(0xC003, TLS,ECDH,ECDSA,WITH,3DES,EDE,CBC,SHA),
  316. CS_ENTRY(0xC003, ECDH,ECDSA,DES,CBC3,SHA,,,),
  317. CS_ENTRY(0xC008, TLS,ECDHE,ECDSA,WITH,3DES,EDE,CBC,SHA),
  318. CS_ENTRY(0xC008, ECDHE,ECDSA,DES,CBC3,SHA,,,),
  319. CS_ENTRY(0xC00D, TLS,ECDH,RSA,WITH,3DES,EDE,CBC,SHA),
  320. CS_ENTRY(0xC00D, ECDH,RSA,DES,CBC3,SHA,,,),
  321. CS_ENTRY(0xC012, TLS,ECDHE,RSA,WITH,3DES,EDE,CBC,SHA),
  322. CS_ENTRY(0xC012, ECDHE,RSA,DES,CBC3,SHA,,,),
  323. #endif
  324. CS_ENTRY(0xC09C, TLS,RSA,WITH,AES,128,CCM,,),
  325. CS_ENTRY(0xC09C, AES128,CCM,,,,,,),
  326. CS_ENTRY(0xC09D, TLS,RSA,WITH,AES,256,CCM,,),
  327. CS_ENTRY(0xC09D, AES256,CCM,,,,,,),
  328. CS_ENTRY(0xC0A0, TLS,RSA,WITH,AES,128,CCM,8,),
  329. CS_ENTRY(0xC0A0, AES128,CCM8,,,,,,),
  330. CS_ENTRY(0xC0A1, TLS,RSA,WITH,AES,256,CCM,8,),
  331. CS_ENTRY(0xC0A1, AES256,CCM8,,,,,,),
  332. CS_ENTRY(0xC0AC, TLS,ECDHE,ECDSA,WITH,AES,128,CCM,),
  333. CS_ENTRY(0xC0AC, ECDHE,ECDSA,AES128,CCM,,,,),
  334. CS_ENTRY(0xC0AD, TLS,ECDHE,ECDSA,WITH,AES,256,CCM,),
  335. CS_ENTRY(0xC0AD, ECDHE,ECDSA,AES256,CCM,,,,),
  336. CS_ENTRY(0xC0AE, TLS,ECDHE,ECDSA,WITH,AES,128,CCM,8),
  337. CS_ENTRY(0xC0AE, ECDHE,ECDSA,AES128,CCM8,,,,),
  338. CS_ENTRY(0xC0AF, TLS,ECDHE,ECDSA,WITH,AES,256,CCM,8),
  339. CS_ENTRY(0xC0AF, ECDHE,ECDSA,AES256,CCM8,,,,),
  340. #if defined(USE_MBEDTLS)
  341. /* entries marked ns are "non-standard", they are not in openssl */
  342. CS_ENTRY(0x0041, TLS,RSA,WITH,CAMELLIA,128,CBC,SHA,),
  343. CS_ENTRY(0x0041, CAMELLIA128,SHA,,,,,,),
  344. CS_ENTRY(0x0045, TLS,DHE,RSA,WITH,CAMELLIA,128,CBC,SHA),
  345. CS_ENTRY(0x0045, DHE,RSA,CAMELLIA128,SHA,,,,),
  346. CS_ENTRY(0x0084, TLS,RSA,WITH,CAMELLIA,256,CBC,SHA,),
  347. CS_ENTRY(0x0084, CAMELLIA256,SHA,,,,,,),
  348. CS_ENTRY(0x0088, TLS,DHE,RSA,WITH,CAMELLIA,256,CBC,SHA),
  349. CS_ENTRY(0x0088, DHE,RSA,CAMELLIA256,SHA,,,,),
  350. CS_ENTRY(0x00BA, TLS,RSA,WITH,CAMELLIA,128,CBC,SHA256,),
  351. CS_ENTRY(0x00BA, CAMELLIA128,SHA256,,,,,,),
  352. CS_ENTRY(0x00BE, TLS,DHE,RSA,WITH,CAMELLIA,128,CBC,SHA256),
  353. CS_ENTRY(0x00BE, DHE,RSA,CAMELLIA128,SHA256,,,,),
  354. CS_ENTRY(0x00C0, TLS,RSA,WITH,CAMELLIA,256,CBC,SHA256,),
  355. CS_ENTRY(0x00C0, CAMELLIA256,SHA256,,,,,,),
  356. CS_ENTRY(0x00C4, TLS,DHE,RSA,WITH,CAMELLIA,256,CBC,SHA256),
  357. CS_ENTRY(0x00C4, DHE,RSA,CAMELLIA256,SHA256,,,,),
  358. CS_ENTRY(0xC037, TLS,ECDHE,PSK,WITH,AES,128,CBC,SHA256),
  359. CS_ENTRY(0xC037, ECDHE,PSK,AES128,CBC,SHA256,,,),
  360. CS_ENTRY(0xC038, TLS,ECDHE,PSK,WITH,AES,256,CBC,SHA384),
  361. CS_ENTRY(0xC038, ECDHE,PSK,AES256,CBC,SHA384,,,),
  362. CS_ENTRY(0xC039, TLS,ECDHE,PSK,WITH,NULL,SHA,,),
  363. CS_ENTRY(0xC039, ECDHE,PSK,NULL,SHA,,,,),
  364. CS_ENTRY(0xC03A, TLS,ECDHE,PSK,WITH,NULL,SHA256,,),
  365. CS_ENTRY(0xC03A, ECDHE,PSK,NULL,SHA256,,,,),
  366. CS_ENTRY(0xC03B, TLS,ECDHE,PSK,WITH,NULL,SHA384,,),
  367. CS_ENTRY(0xC03B, ECDHE,PSK,NULL,SHA384,,,,),
  368. CS_ENTRY(0xC03C, TLS,RSA,WITH,ARIA,128,CBC,SHA256,),
  369. CS_ENTRY(0xC03C, ARIA128,SHA256,,,,,,), /* ns */
  370. CS_ENTRY(0xC03D, TLS,RSA,WITH,ARIA,256,CBC,SHA384,),
  371. CS_ENTRY(0xC03D, ARIA256,SHA384,,,,,,), /* ns */
  372. CS_ENTRY(0xC044, TLS,DHE,RSA,WITH,ARIA,128,CBC,SHA256),
  373. CS_ENTRY(0xC044, DHE,RSA,ARIA128,SHA256,,,,), /* ns */
  374. CS_ENTRY(0xC045, TLS,DHE,RSA,WITH,ARIA,256,CBC,SHA384),
  375. CS_ENTRY(0xC045, DHE,RSA,ARIA256,SHA384,,,,), /* ns */
  376. CS_ENTRY(0xC048, TLS,ECDHE,ECDSA,WITH,ARIA,128,CBC,SHA256),
  377. CS_ENTRY(0xC048, ECDHE,ECDSA,ARIA128,SHA256,,,,), /* ns */
  378. CS_ENTRY(0xC049, TLS,ECDHE,ECDSA,WITH,ARIA,256,CBC,SHA384),
  379. CS_ENTRY(0xC049, ECDHE,ECDSA,ARIA256,SHA384,,,,), /* ns */
  380. CS_ENTRY(0xC04A, TLS,ECDH,ECDSA,WITH,ARIA,128,CBC,SHA256),
  381. CS_ENTRY(0xC04A, ECDH,ECDSA,ARIA128,SHA256,,,,), /* ns */
  382. CS_ENTRY(0xC04B, TLS,ECDH,ECDSA,WITH,ARIA,256,CBC,SHA384),
  383. CS_ENTRY(0xC04B, ECDH,ECDSA,ARIA256,SHA384,,,,), /* ns */
  384. CS_ENTRY(0xC04C, TLS,ECDHE,RSA,WITH,ARIA,128,CBC,SHA256),
  385. CS_ENTRY(0xC04C, ECDHE,ARIA128,SHA256,,,,,), /* ns */
  386. CS_ENTRY(0xC04D, TLS,ECDHE,RSA,WITH,ARIA,256,CBC,SHA384),
  387. CS_ENTRY(0xC04D, ECDHE,ARIA256,SHA384,,,,,), /* ns */
  388. CS_ENTRY(0xC04E, TLS,ECDH,RSA,WITH,ARIA,128,CBC,SHA256),
  389. CS_ENTRY(0xC04E, ECDH,ARIA128,SHA256,,,,,), /* ns */
  390. CS_ENTRY(0xC04F, TLS,ECDH,RSA,WITH,ARIA,256,CBC,SHA384),
  391. CS_ENTRY(0xC04F, ECDH,ARIA256,SHA384,,,,,), /* ns */
  392. CS_ENTRY(0xC050, TLS,RSA,WITH,ARIA,128,GCM,SHA256,),
  393. CS_ENTRY(0xC050, ARIA128,GCM,SHA256,,,,,),
  394. CS_ENTRY(0xC051, TLS,RSA,WITH,ARIA,256,GCM,SHA384,),
  395. CS_ENTRY(0xC051, ARIA256,GCM,SHA384,,,,,),
  396. CS_ENTRY(0xC052, TLS,DHE,RSA,WITH,ARIA,128,GCM,SHA256),
  397. CS_ENTRY(0xC052, DHE,RSA,ARIA128,GCM,SHA256,,,),
  398. CS_ENTRY(0xC053, TLS,DHE,RSA,WITH,ARIA,256,GCM,SHA384),
  399. CS_ENTRY(0xC053, DHE,RSA,ARIA256,GCM,SHA384,,,),
  400. CS_ENTRY(0xC05C, TLS,ECDHE,ECDSA,WITH,ARIA,128,GCM,SHA256),
  401. CS_ENTRY(0xC05C, ECDHE,ECDSA,ARIA128,GCM,SHA256,,,),
  402. CS_ENTRY(0xC05D, TLS,ECDHE,ECDSA,WITH,ARIA,256,GCM,SHA384),
  403. CS_ENTRY(0xC05D, ECDHE,ECDSA,ARIA256,GCM,SHA384,,,),
  404. CS_ENTRY(0xC05E, TLS,ECDH,ECDSA,WITH,ARIA,128,GCM,SHA256),
  405. CS_ENTRY(0xC05E, ECDH,ECDSA,ARIA128,GCM,SHA256,,,), /* ns */
  406. CS_ENTRY(0xC05F, TLS,ECDH,ECDSA,WITH,ARIA,256,GCM,SHA384),
  407. CS_ENTRY(0xC05F, ECDH,ECDSA,ARIA256,GCM,SHA384,,,), /* ns */
  408. CS_ENTRY(0xC060, TLS,ECDHE,RSA,WITH,ARIA,128,GCM,SHA256),
  409. CS_ENTRY(0xC060, ECDHE,ARIA128,GCM,SHA256,,,,),
  410. CS_ENTRY(0xC061, TLS,ECDHE,RSA,WITH,ARIA,256,GCM,SHA384),
  411. CS_ENTRY(0xC061, ECDHE,ARIA256,GCM,SHA384,,,,),
  412. CS_ENTRY(0xC062, TLS,ECDH,RSA,WITH,ARIA,128,GCM,SHA256),
  413. CS_ENTRY(0xC062, ECDH,ARIA128,GCM,SHA256,,,,), /* ns */
  414. CS_ENTRY(0xC063, TLS,ECDH,RSA,WITH,ARIA,256,GCM,SHA384),
  415. CS_ENTRY(0xC063, ECDH,ARIA256,GCM,SHA384,,,,), /* ns */
  416. CS_ENTRY(0xC064, TLS,PSK,WITH,ARIA,128,CBC,SHA256,),
  417. CS_ENTRY(0xC064, PSK,ARIA128,SHA256,,,,,), /* ns */
  418. CS_ENTRY(0xC065, TLS,PSK,WITH,ARIA,256,CBC,SHA384,),
  419. CS_ENTRY(0xC065, PSK,ARIA256,SHA384,,,,,), /* ns */
  420. CS_ENTRY(0xC066, TLS,DHE,PSK,WITH,ARIA,128,CBC,SHA256),
  421. CS_ENTRY(0xC066, DHE,PSK,ARIA128,SHA256,,,,), /* ns */
  422. CS_ENTRY(0xC067, TLS,DHE,PSK,WITH,ARIA,256,CBC,SHA384),
  423. CS_ENTRY(0xC067, DHE,PSK,ARIA256,SHA384,,,,), /* ns */
  424. CS_ENTRY(0xC068, TLS,RSA,PSK,WITH,ARIA,128,CBC,SHA256),
  425. CS_ENTRY(0xC068, RSA,PSK,ARIA128,SHA256,,,,), /* ns */
  426. CS_ENTRY(0xC069, TLS,RSA,PSK,WITH,ARIA,256,CBC,SHA384),
  427. CS_ENTRY(0xC069, RSA,PSK,ARIA256,SHA384,,,,), /* ns */
  428. CS_ENTRY(0xC06A, TLS,PSK,WITH,ARIA,128,GCM,SHA256,),
  429. CS_ENTRY(0xC06A, PSK,ARIA128,GCM,SHA256,,,,),
  430. CS_ENTRY(0xC06B, TLS,PSK,WITH,ARIA,256,GCM,SHA384,),
  431. CS_ENTRY(0xC06B, PSK,ARIA256,GCM,SHA384,,,,),
  432. CS_ENTRY(0xC06C, TLS,DHE,PSK,WITH,ARIA,128,GCM,SHA256),
  433. CS_ENTRY(0xC06C, DHE,PSK,ARIA128,GCM,SHA256,,,),
  434. CS_ENTRY(0xC06D, TLS,DHE,PSK,WITH,ARIA,256,GCM,SHA384),
  435. CS_ENTRY(0xC06D, DHE,PSK,ARIA256,GCM,SHA384,,,),
  436. CS_ENTRY(0xC06E, TLS,RSA,PSK,WITH,ARIA,128,GCM,SHA256),
  437. CS_ENTRY(0xC06E, RSA,PSK,ARIA128,GCM,SHA256,,,),
  438. CS_ENTRY(0xC06F, TLS,RSA,PSK,WITH,ARIA,256,GCM,SHA384),
  439. CS_ENTRY(0xC06F, RSA,PSK,ARIA256,GCM,SHA384,,,),
  440. CS_ENTRY(0xC070, TLS,ECDHE,PSK,WITH,ARIA,128,CBC,SHA256),
  441. CS_ENTRY(0xC070, ECDHE,PSK,ARIA128,SHA256,,,,), /* ns */
  442. CS_ENTRY(0xC071, TLS,ECDHE,PSK,WITH,ARIA,256,CBC,SHA384),
  443. CS_ENTRY(0xC071, ECDHE,PSK,ARIA256,SHA384,,,,), /* ns */
  444. CS_ENTRY(0xC072, TLS,ECDHE,ECDSA,WITH,CAMELLIA,128,CBC,SHA256),
  445. CS_ENTRY(0xC072, ECDHE,ECDSA,CAMELLIA128,SHA256,,,,),
  446. CS_ENTRY(0xC073, TLS,ECDHE,ECDSA,WITH,CAMELLIA,256,CBC,SHA384),
  447. CS_ENTRY(0xC073, ECDHE,ECDSA,CAMELLIA256,SHA384,,,,),
  448. CS_ENTRY(0xC074, TLS,ECDH,ECDSA,WITH,CAMELLIA,128,CBC,SHA256),
  449. CS_ENTRY(0xC074, ECDH,ECDSA,CAMELLIA128,SHA256,,,,), /* ns */
  450. CS_ENTRY(0xC075, TLS,ECDH,ECDSA,WITH,CAMELLIA,256,CBC,SHA384),
  451. CS_ENTRY(0xC075, ECDH,ECDSA,CAMELLIA256,SHA384,,,,), /* ns */
  452. CS_ENTRY(0xC076, TLS,ECDHE,RSA,WITH,CAMELLIA,128,CBC,SHA256),
  453. CS_ENTRY(0xC076, ECDHE,RSA,CAMELLIA128,SHA256,,,,),
  454. CS_ENTRY(0xC077, TLS,ECDHE,RSA,WITH,CAMELLIA,256,CBC,SHA384),
  455. CS_ENTRY(0xC077, ECDHE,RSA,CAMELLIA256,SHA384,,,,),
  456. CS_ENTRY(0xC078, TLS,ECDH,RSA,WITH,CAMELLIA,128,CBC,SHA256),
  457. CS_ENTRY(0xC078, ECDH,CAMELLIA128,SHA256,,,,,), /* ns */
  458. CS_ENTRY(0xC079, TLS,ECDH,RSA,WITH,CAMELLIA,256,CBC,SHA384),
  459. CS_ENTRY(0xC079, ECDH,CAMELLIA256,SHA384,,,,,), /* ns */
  460. CS_ENTRY(0xC07A, TLS,RSA,WITH,CAMELLIA,128,GCM,SHA256,),
  461. CS_ENTRY(0xC07A, CAMELLIA128,GCM,SHA256,,,,,), /* ns */
  462. CS_ENTRY(0xC07B, TLS,RSA,WITH,CAMELLIA,256,GCM,SHA384,),
  463. CS_ENTRY(0xC07B, CAMELLIA256,GCM,SHA384,,,,,), /* ns */
  464. CS_ENTRY(0xC07C, TLS,DHE,RSA,WITH,CAMELLIA,128,GCM,SHA256),
  465. CS_ENTRY(0xC07C, DHE,RSA,CAMELLIA128,GCM,SHA256,,,), /* ns */
  466. CS_ENTRY(0xC07D, TLS,DHE,RSA,WITH,CAMELLIA,256,GCM,SHA384),
  467. CS_ENTRY(0xC07D, DHE,RSA,CAMELLIA256,GCM,SHA384,,,), /* ns */
  468. CS_ENTRY(0xC086, TLS,ECDHE,ECDSA,WITH,CAMELLIA,128,GCM,SHA256),
  469. CS_ENTRY(0xC086, ECDHE,ECDSA,CAMELLIA128,GCM,SHA256,,,), /* ns */
  470. CS_ENTRY(0xC087, TLS,ECDHE,ECDSA,WITH,CAMELLIA,256,GCM,SHA384),
  471. CS_ENTRY(0xC087, ECDHE,ECDSA,CAMELLIA256,GCM,SHA384,,,), /* ns */
  472. CS_ENTRY(0xC088, TLS,ECDH,ECDSA,WITH,CAMELLIA,128,GCM,SHA256),
  473. CS_ENTRY(0xC088, ECDH,ECDSA,CAMELLIA128,GCM,SHA256,,,), /* ns */
  474. CS_ENTRY(0xC089, TLS,ECDH,ECDSA,WITH,CAMELLIA,256,GCM,SHA384),
  475. CS_ENTRY(0xC089, ECDH,ECDSA,CAMELLIA256,GCM,SHA384,,,), /* ns */
  476. CS_ENTRY(0xC08A, TLS,ECDHE,RSA,WITH,CAMELLIA,128,GCM,SHA256),
  477. CS_ENTRY(0xC08A, ECDHE,CAMELLIA128,GCM,SHA256,,,,), /* ns */
  478. CS_ENTRY(0xC08B, TLS,ECDHE,RSA,WITH,CAMELLIA,256,GCM,SHA384),
  479. CS_ENTRY(0xC08B, ECDHE,CAMELLIA256,GCM,SHA384,,,,), /* ns */
  480. CS_ENTRY(0xC08C, TLS,ECDH,RSA,WITH,CAMELLIA,128,GCM,SHA256),
  481. CS_ENTRY(0xC08C, ECDH,CAMELLIA128,GCM,SHA256,,,,), /* ns */
  482. CS_ENTRY(0xC08D, TLS,ECDH,RSA,WITH,CAMELLIA,256,GCM,SHA384),
  483. CS_ENTRY(0xC08D, ECDH,CAMELLIA256,GCM,SHA384,,,,), /* ns */
  484. CS_ENTRY(0xC08E, TLS,PSK,WITH,CAMELLIA,128,GCM,SHA256,),
  485. CS_ENTRY(0xC08E, PSK,CAMELLIA128,GCM,SHA256,,,,), /* ns */
  486. CS_ENTRY(0xC08F, TLS,PSK,WITH,CAMELLIA,256,GCM,SHA384,),
  487. CS_ENTRY(0xC08F, PSK,CAMELLIA256,GCM,SHA384,,,,), /* ns */
  488. CS_ENTRY(0xC090, TLS,DHE,PSK,WITH,CAMELLIA,128,GCM,SHA256),
  489. CS_ENTRY(0xC090, DHE,PSK,CAMELLIA128,GCM,SHA256,,,), /* ns */
  490. CS_ENTRY(0xC091, TLS,DHE,PSK,WITH,CAMELLIA,256,GCM,SHA384),
  491. CS_ENTRY(0xC091, DHE,PSK,CAMELLIA256,GCM,SHA384,,,), /* ns */
  492. CS_ENTRY(0xC092, TLS,RSA,PSK,WITH,CAMELLIA,128,GCM,SHA256),
  493. CS_ENTRY(0xC092, RSA,PSK,CAMELLIA128,GCM,SHA256,,,), /* ns */
  494. CS_ENTRY(0xC093, TLS,RSA,PSK,WITH,CAMELLIA,256,GCM,SHA384),
  495. CS_ENTRY(0xC093, RSA,PSK,CAMELLIA256,GCM,SHA384,,,), /* ns */
  496. CS_ENTRY(0xC094, TLS,PSK,WITH,CAMELLIA,128,CBC,SHA256,),
  497. CS_ENTRY(0xC094, PSK,CAMELLIA128,SHA256,,,,,),
  498. CS_ENTRY(0xC095, TLS,PSK,WITH,CAMELLIA,256,CBC,SHA384,),
  499. CS_ENTRY(0xC095, PSK,CAMELLIA256,SHA384,,,,,),
  500. CS_ENTRY(0xC096, TLS,DHE,PSK,WITH,CAMELLIA,128,CBC,SHA256),
  501. CS_ENTRY(0xC096, DHE,PSK,CAMELLIA128,SHA256,,,,),
  502. CS_ENTRY(0xC097, TLS,DHE,PSK,WITH,CAMELLIA,256,CBC,SHA384),
  503. CS_ENTRY(0xC097, DHE,PSK,CAMELLIA256,SHA384,,,,),
  504. CS_ENTRY(0xC098, TLS,RSA,PSK,WITH,CAMELLIA,128,CBC,SHA256),
  505. CS_ENTRY(0xC098, RSA,PSK,CAMELLIA128,SHA256,,,,),
  506. CS_ENTRY(0xC099, TLS,RSA,PSK,WITH,CAMELLIA,256,CBC,SHA384),
  507. CS_ENTRY(0xC099, RSA,PSK,CAMELLIA256,SHA384,,,,),
  508. CS_ENTRY(0xC09A, TLS,ECDHE,PSK,WITH,CAMELLIA,128,CBC,SHA256),
  509. CS_ENTRY(0xC09A, ECDHE,PSK,CAMELLIA128,SHA256,,,,),
  510. CS_ENTRY(0xC09B, TLS,ECDHE,PSK,WITH,CAMELLIA,256,CBC,SHA384),
  511. CS_ENTRY(0xC09B, ECDHE,PSK,CAMELLIA256,SHA384,,,,),
  512. CS_ENTRY(0xC09E, TLS,DHE,RSA,WITH,AES,128,CCM,),
  513. CS_ENTRY(0xC09E, DHE,RSA,AES128,CCM,,,,),
  514. CS_ENTRY(0xC09F, TLS,DHE,RSA,WITH,AES,256,CCM,),
  515. CS_ENTRY(0xC09F, DHE,RSA,AES256,CCM,,,,),
  516. CS_ENTRY(0xC0A2, TLS,DHE,RSA,WITH,AES,128,CCM,8),
  517. CS_ENTRY(0xC0A2, DHE,RSA,AES128,CCM8,,,,),
  518. CS_ENTRY(0xC0A3, TLS,DHE,RSA,WITH,AES,256,CCM,8),
  519. CS_ENTRY(0xC0A3, DHE,RSA,AES256,CCM8,,,,),
  520. CS_ENTRY(0xC0A4, TLS,PSK,WITH,AES,128,CCM,,),
  521. CS_ENTRY(0xC0A4, PSK,AES128,CCM,,,,,),
  522. CS_ENTRY(0xC0A5, TLS,PSK,WITH,AES,256,CCM,,),
  523. CS_ENTRY(0xC0A5, PSK,AES256,CCM,,,,,),
  524. CS_ENTRY(0xC0A6, TLS,DHE,PSK,WITH,AES,128,CCM,),
  525. CS_ENTRY(0xC0A6, DHE,PSK,AES128,CCM,,,,),
  526. CS_ENTRY(0xC0A7, TLS,DHE,PSK,WITH,AES,256,CCM,),
  527. CS_ENTRY(0xC0A7, DHE,PSK,AES256,CCM,,,,),
  528. CS_ENTRY(0xC0A8, TLS,PSK,WITH,AES,128,CCM,8,),
  529. CS_ENTRY(0xC0A8, PSK,AES128,CCM8,,,,,),
  530. CS_ENTRY(0xC0A9, TLS,PSK,WITH,AES,256,CCM,8,),
  531. CS_ENTRY(0xC0A9, PSK,AES256,CCM8,,,,,),
  532. CS_ENTRY(0xC0AA, TLS,PSK,DHE,WITH,AES,128,CCM,8),
  533. CS_ENTRY(0xC0AA, DHE,PSK,AES128,CCM8,,,,),
  534. CS_ENTRY(0xC0AB, TLS,PSK,DHE,WITH,AES,256,CCM,8),
  535. CS_ENTRY(0xC0AB, DHE,PSK,AES256,CCM8,,,,),
  536. CS_ENTRY(0xCCAA, TLS,DHE,RSA,WITH,CHACHA20,POLY1305,SHA256,),
  537. CS_ENTRY(0xCCAA, DHE,RSA,CHACHA20,POLY1305,,,,),
  538. CS_ENTRY(0xCCAC, TLS,ECDHE,PSK,WITH,CHACHA20,POLY1305,SHA256,),
  539. CS_ENTRY(0xCCAC, ECDHE,PSK,CHACHA20,POLY1305,,,,),
  540. CS_ENTRY(0xCCAD, TLS,DHE,PSK,WITH,CHACHA20,POLY1305,SHA256,),
  541. CS_ENTRY(0xCCAD, DHE,PSK,CHACHA20,POLY1305,,,,),
  542. CS_ENTRY(0xCCAE, TLS,RSA,PSK,WITH,CHACHA20,POLY1305,SHA256,),
  543. CS_ENTRY(0xCCAE, RSA,PSK,CHACHA20,POLY1305,,,,),
  544. #endif
  545. };
  546. #define CS_LIST_LEN (sizeof(cs_list) / sizeof(cs_list[0]))
  547. static int cs_str_to_zip(const char *cs_str, size_t cs_len,
  548. uint8_t zip[6])
  549. {
  550. uint8_t indexes[8] = {0};
  551. const char *entry, *cur;
  552. const char *nxt = cs_str;
  553. const char *end = cs_str + cs_len;
  554. char separator = '-';
  555. int idx, i = 0;
  556. size_t len;
  557. /* split the cipher string by '-' or '_' */
  558. if(strncasecompare(cs_str, "TLS", 3))
  559. separator = '_';
  560. do {
  561. if(i == 8)
  562. return -1;
  563. /* determine the length of the part */
  564. cur = nxt;
  565. for(; nxt < end && *nxt != '\0' && *nxt != separator; nxt++);
  566. len = nxt - cur;
  567. /* lookup index for the part (skip empty string at 0) */
  568. for(idx = 1, entry = cs_txt + 1; idx < CS_TXT_LEN; idx++) {
  569. size_t elen = strlen(entry);
  570. if(elen == len && strncasecompare(entry, cur, len))
  571. break;
  572. entry += elen + 1;
  573. }
  574. if(idx == CS_TXT_LEN)
  575. return -1;
  576. indexes[i++] = (uint8_t) idx;
  577. } while(nxt < end && *(nxt++) != '\0');
  578. /* zip the 8 indexes into 48 bits */
  579. zip[0] = (uint8_t) (indexes[0] << 2 | (indexes[1] & 0x3F) >> 4);
  580. zip[1] = (uint8_t) (indexes[1] << 4 | (indexes[2] & 0x3F) >> 2);
  581. zip[2] = (uint8_t) (indexes[2] << 6 | (indexes[3] & 0x3F));
  582. zip[3] = (uint8_t) (indexes[4] << 2 | (indexes[5] & 0x3F) >> 4);
  583. zip[4] = (uint8_t) (indexes[5] << 4 | (indexes[6] & 0x3F) >> 2);
  584. zip[5] = (uint8_t) (indexes[6] << 6 | (indexes[7] & 0x3F));
  585. return 0;
  586. }
  587. static int cs_zip_to_str(const uint8_t zip[6],
  588. char *buf, size_t buf_size)
  589. {
  590. uint8_t indexes[8] = {0};
  591. const char *entry;
  592. char separator = '-';
  593. int idx, i, r;
  594. size_t len = 0;
  595. /* unzip the 8 indexes */
  596. indexes[0] = zip[0] >> 2;
  597. indexes[1] = ((zip[0] << 4) & 0x3F) | zip[1] >> 4;
  598. indexes[2] = ((zip[1] << 2) & 0x3F) | zip[2] >> 6;
  599. indexes[3] = ((zip[2] << 0) & 0x3F);
  600. indexes[4] = zip[3] >> 2;
  601. indexes[5] = ((zip[3] << 4) & 0x3F) | zip[4] >> 4;
  602. indexes[6] = ((zip[4] << 2) & 0x3F) | zip[5] >> 6;
  603. indexes[7] = ((zip[5] << 0) & 0x3F);
  604. if(indexes[0] == CS_TXT_IDX_TLS)
  605. separator = '_';
  606. for(i = 0; i < 8 && indexes[i] != 0 && len < buf_size; i++) {
  607. if(indexes[i] >= CS_TXT_LEN)
  608. return -1;
  609. /* lookup the part string for the index (skip empty string at 0) */
  610. for(idx = 1, entry = cs_txt + 1; idx < indexes[i]; idx++) {
  611. size_t elen = strlen(entry);
  612. entry += elen + 1;
  613. }
  614. /* append the part string to the buffer */
  615. if(i > 0)
  616. r = msnprintf(&buf[len], buf_size - len, "%c%s", separator, entry);
  617. else
  618. r = msnprintf(&buf[len], buf_size - len, "%s", entry);
  619. if(r < 0)
  620. return -1;
  621. len += r;
  622. }
  623. return 0;
  624. }
  625. uint16_t Curl_cipher_suite_lookup_id(const char *cs_str, size_t cs_len)
  626. {
  627. size_t i;
  628. uint8_t zip[6];
  629. if(cs_len > 0 && cs_str_to_zip(cs_str, cs_len, zip) == 0) {
  630. for(i = 0; i < CS_LIST_LEN; i++) {
  631. if(memcmp(cs_list[i].zip, zip, sizeof(zip)) == 0)
  632. return cs_list[i].id;
  633. }
  634. }
  635. return 0;
  636. }
  637. static bool cs_is_separator(char c)
  638. {
  639. switch(c) {
  640. case ' ':
  641. case '\t':
  642. case ':':
  643. case ',':
  644. case ';':
  645. return true;
  646. default:;
  647. }
  648. return false;
  649. }
  650. uint16_t Curl_cipher_suite_walk_str(const char **str, const char **end)
  651. {
  652. /* move string pointer to first non-separator or end of string */
  653. for(; cs_is_separator(*str[0]); (*str)++);
  654. /* move end pointer to next separator or end of string */
  655. for(*end = *str; *end[0] != '\0' && !cs_is_separator(*end[0]); (*end)++);
  656. return Curl_cipher_suite_lookup_id(*str, *end - *str);
  657. }
  658. int Curl_cipher_suite_get_str(uint16_t id, char *buf, size_t buf_size,
  659. bool prefer_rfc)
  660. {
  661. size_t i, j = CS_LIST_LEN;
  662. int r = -1;
  663. for(i = 0; i < CS_LIST_LEN; i++) {
  664. if(cs_list[i].id != id)
  665. continue;
  666. if((cs_list[i].zip[0] >> 2 != CS_TXT_IDX_TLS) == !prefer_rfc) {
  667. j = i;
  668. break;
  669. }
  670. if(j == CS_LIST_LEN)
  671. j = i;
  672. }
  673. if(j < CS_LIST_LEN)
  674. r = cs_zip_to_str(cs_list[j].zip, buf, buf_size);
  675. if(r < 0)
  676. msnprintf(buf, buf_size, "TLS_UNKNOWN_0x%04x", id);
  677. return r;
  678. }
  679. #endif /* defined(USE_MBEDTLS) || defined(USE_BEARSSL) */