unit3205.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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 "curlcheck.h"
  25. #include "vtls/cipher_suite.h"
  26. static CURLcode unit_setup(void)
  27. {
  28. return CURLE_OK;
  29. }
  30. static void unit_stop(void)
  31. {
  32. }
  33. #if defined(USE_MBEDTLS) || defined(USE_BEARSSL)
  34. struct test_cs_entry {
  35. uint16_t id;
  36. const char *rfc;
  37. const char *openssl;
  38. };
  39. static const struct test_cs_entry test_cs_list[] = {
  40. { 0x002F, "TLS_RSA_WITH_AES_128_CBC_SHA",
  41. "AES128-SHA" },
  42. { 0x0035, "TLS_RSA_WITH_AES_256_CBC_SHA",
  43. "AES256-SHA" },
  44. { 0x003C, "TLS_RSA_WITH_AES_128_CBC_SHA256",
  45. "AES128-SHA256" },
  46. { 0x003D, "TLS_RSA_WITH_AES_256_CBC_SHA256",
  47. "AES256-SHA256" },
  48. { 0x009C, "TLS_RSA_WITH_AES_128_GCM_SHA256",
  49. "AES128-GCM-SHA256" },
  50. { 0x009D, "TLS_RSA_WITH_AES_256_GCM_SHA384",
  51. "AES256-GCM-SHA384" },
  52. { 0xC004, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
  53. "ECDH-ECDSA-AES128-SHA" },
  54. { 0xC005, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
  55. "ECDH-ECDSA-AES256-SHA" },
  56. { 0xC009, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
  57. "ECDHE-ECDSA-AES128-SHA" },
  58. { 0xC00A, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
  59. "ECDHE-ECDSA-AES256-SHA" },
  60. { 0xC00E, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
  61. "ECDH-RSA-AES128-SHA" },
  62. { 0xC00F, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
  63. "ECDH-RSA-AES256-SHA" },
  64. { 0xC013, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
  65. "ECDHE-RSA-AES128-SHA" },
  66. { 0xC014, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
  67. "ECDHE-RSA-AES256-SHA" },
  68. { 0xC023, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
  69. "ECDHE-ECDSA-AES128-SHA256" },
  70. { 0xC024, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
  71. "ECDHE-ECDSA-AES256-SHA384" },
  72. { 0xC025, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
  73. "ECDH-ECDSA-AES128-SHA256" },
  74. { 0xC026, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
  75. "ECDH-ECDSA-AES256-SHA384" },
  76. { 0xC027, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
  77. "ECDHE-RSA-AES128-SHA256" },
  78. { 0xC028, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
  79. "ECDHE-RSA-AES256-SHA384" },
  80. { 0xC029, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
  81. "ECDH-RSA-AES128-SHA256" },
  82. { 0xC02A, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
  83. "ECDH-RSA-AES256-SHA384" },
  84. { 0xC02B, "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
  85. "ECDHE-ECDSA-AES128-GCM-SHA256" },
  86. { 0xC02C, "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
  87. "ECDHE-ECDSA-AES256-GCM-SHA384" },
  88. { 0xC02D, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
  89. "ECDH-ECDSA-AES128-GCM-SHA256" },
  90. { 0xC02E, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
  91. "ECDH-ECDSA-AES256-GCM-SHA384" },
  92. { 0xC02F, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
  93. "ECDHE-RSA-AES128-GCM-SHA256" },
  94. { 0xC030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
  95. "ECDHE-RSA-AES256-GCM-SHA384" },
  96. { 0xC031, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
  97. "ECDH-RSA-AES128-GCM-SHA256" },
  98. { 0xC032, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",
  99. "ECDH-RSA-AES256-GCM-SHA384" },
  100. { 0xCCA8, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
  101. "ECDHE-RSA-CHACHA20-POLY1305" },
  102. { 0xCCA9, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
  103. "ECDHE-ECDSA-CHACHA20-POLY1305" },
  104. #if defined(USE_MBEDTLS)
  105. { 0x0001, "TLS_RSA_WITH_NULL_MD5",
  106. "NULL-MD5" },
  107. { 0x0002, "TLS_RSA_WITH_NULL_SHA",
  108. "NULL-SHA" },
  109. { 0x002C, "TLS_PSK_WITH_NULL_SHA",
  110. "PSK-NULL-SHA" },
  111. { 0x002D, "TLS_DHE_PSK_WITH_NULL_SHA",
  112. "DHE-PSK-NULL-SHA" },
  113. { 0x002E, "TLS_RSA_PSK_WITH_NULL_SHA",
  114. "RSA-PSK-NULL-SHA" },
  115. { 0x0033, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
  116. "DHE-RSA-AES128-SHA" },
  117. { 0x0039, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
  118. "DHE-RSA-AES256-SHA" },
  119. { 0x003B, "TLS_RSA_WITH_NULL_SHA256",
  120. "NULL-SHA256" },
  121. { 0x0067, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
  122. "DHE-RSA-AES128-SHA256" },
  123. { 0x006B, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
  124. "DHE-RSA-AES256-SHA256" },
  125. { 0x008C, "TLS_PSK_WITH_AES_128_CBC_SHA",
  126. "PSK-AES128-CBC-SHA" },
  127. { 0x008D, "TLS_PSK_WITH_AES_256_CBC_SHA",
  128. "PSK-AES256-CBC-SHA" },
  129. { 0x0090, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA",
  130. "DHE-PSK-AES128-CBC-SHA" },
  131. { 0x0091, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA",
  132. "DHE-PSK-AES256-CBC-SHA" },
  133. { 0x0094, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA",
  134. "RSA-PSK-AES128-CBC-SHA" },
  135. { 0x0095, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA",
  136. "RSA-PSK-AES256-CBC-SHA" },
  137. { 0x009E, "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
  138. "DHE-RSA-AES128-GCM-SHA256" },
  139. { 0x009F, "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
  140. "DHE-RSA-AES256-GCM-SHA384" },
  141. { 0x00A8, "TLS_PSK_WITH_AES_128_GCM_SHA256",
  142. "PSK-AES128-GCM-SHA256" },
  143. { 0x00A9, "TLS_PSK_WITH_AES_256_GCM_SHA384",
  144. "PSK-AES256-GCM-SHA384" },
  145. { 0x00AA, "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256",
  146. "DHE-PSK-AES128-GCM-SHA256" },
  147. { 0x00AB, "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384",
  148. "DHE-PSK-AES256-GCM-SHA384" },
  149. { 0x00AC, "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256",
  150. "RSA-PSK-AES128-GCM-SHA256" },
  151. { 0x00AD, "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384",
  152. "RSA-PSK-AES256-GCM-SHA384" },
  153. { 0x00AE, "TLS_PSK_WITH_AES_128_CBC_SHA256",
  154. "PSK-AES128-CBC-SHA256" },
  155. { 0x00AF, "TLS_PSK_WITH_AES_256_CBC_SHA384",
  156. "PSK-AES256-CBC-SHA384" },
  157. { 0x00B0, "TLS_PSK_WITH_NULL_SHA256",
  158. "PSK-NULL-SHA256" },
  159. { 0x00B1, "TLS_PSK_WITH_NULL_SHA384",
  160. "PSK-NULL-SHA384" },
  161. { 0x00B2, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256",
  162. "DHE-PSK-AES128-CBC-SHA256" },
  163. { 0x00B3, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384",
  164. "DHE-PSK-AES256-CBC-SHA384" },
  165. { 0x00B4, "TLS_DHE_PSK_WITH_NULL_SHA256",
  166. "DHE-PSK-NULL-SHA256" },
  167. { 0x00B5, "TLS_DHE_PSK_WITH_NULL_SHA384",
  168. "DHE-PSK-NULL-SHA384" },
  169. { 0x00B6, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256",
  170. "RSA-PSK-AES128-CBC-SHA256" },
  171. { 0x00B7, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384",
  172. "RSA-PSK-AES256-CBC-SHA384" },
  173. { 0x00B8, "TLS_RSA_PSK_WITH_NULL_SHA256",
  174. "RSA-PSK-NULL-SHA256" },
  175. { 0x00B9, "TLS_RSA_PSK_WITH_NULL_SHA384",
  176. "RSA-PSK-NULL-SHA384" },
  177. { 0x1301, "TLS_AES_128_GCM_SHA256",
  178. NULL },
  179. { 0x1302, "TLS_AES_256_GCM_SHA384",
  180. NULL },
  181. { 0x1303, "TLS_CHACHA20_POLY1305_SHA256",
  182. NULL },
  183. { 0x1304, "TLS_AES_128_CCM_SHA256",
  184. NULL },
  185. { 0x1305, "TLS_AES_128_CCM_8_SHA256",
  186. NULL },
  187. { 0xC001, "TLS_ECDH_ECDSA_WITH_NULL_SHA",
  188. "ECDH-ECDSA-NULL-SHA" },
  189. { 0xC006, "TLS_ECDHE_ECDSA_WITH_NULL_SHA",
  190. "ECDHE-ECDSA-NULL-SHA" },
  191. { 0xC00B, "TLS_ECDH_RSA_WITH_NULL_SHA",
  192. "ECDH-RSA-NULL-SHA" },
  193. { 0xC010, "TLS_ECDHE_RSA_WITH_NULL_SHA",
  194. "ECDHE-RSA-NULL-SHA" },
  195. { 0xC035, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA",
  196. "ECDHE-PSK-AES128-CBC-SHA" },
  197. { 0xC036, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA",
  198. "ECDHE-PSK-AES256-CBC-SHA" },
  199. { 0xCCAB, "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256",
  200. "PSK-CHACHA20-POLY1305" },
  201. #endif
  202. #if defined(USE_BEARSSL)
  203. { 0x000A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA",
  204. "DES-CBC3-SHA" },
  205. { 0xC003, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA",
  206. "ECDH-ECDSA-DES-CBC3-SHA" },
  207. { 0xC008, "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
  208. "ECDHE-ECDSA-DES-CBC3-SHA" },
  209. { 0xC00D, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA",
  210. "ECDH-RSA-DES-CBC3-SHA" },
  211. { 0xC012, "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
  212. "ECDHE-RSA-DES-CBC3-SHA" },
  213. #endif
  214. { 0xC09C, "TLS_RSA_WITH_AES_128_CCM",
  215. "AES128-CCM" },
  216. { 0xC09D, "TLS_RSA_WITH_AES_256_CCM",
  217. "AES256-CCM" },
  218. { 0xC0A0, "TLS_RSA_WITH_AES_128_CCM_8",
  219. "AES128-CCM8" },
  220. { 0xC0A1, "TLS_RSA_WITH_AES_256_CCM_8",
  221. "AES256-CCM8" },
  222. { 0xC0AC, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM",
  223. "ECDHE-ECDSA-AES128-CCM" },
  224. { 0xC0AD, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM",
  225. "ECDHE-ECDSA-AES256-CCM" },
  226. { 0xC0AE, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8",
  227. "ECDHE-ECDSA-AES128-CCM8" },
  228. { 0xC0AF, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8",
  229. "ECDHE-ECDSA-AES256-CCM8" },
  230. #if defined(USE_MBEDTLS)
  231. /* entries marked ns are non-"standard", they are not in openssl */
  232. { 0x0041, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA",
  233. "CAMELLIA128-SHA" },
  234. { 0x0045, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA",
  235. "DHE-RSA-CAMELLIA128-SHA" },
  236. { 0x0084, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA",
  237. "CAMELLIA256-SHA" },
  238. { 0x0088, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA",
  239. "DHE-RSA-CAMELLIA256-SHA" },
  240. { 0x00BA, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256",
  241. "CAMELLIA128-SHA256" },
  242. { 0x00BE, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256",
  243. "DHE-RSA-CAMELLIA128-SHA256" },
  244. { 0x00C0, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256",
  245. "CAMELLIA256-SHA256" },
  246. { 0x00C4, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256",
  247. "DHE-RSA-CAMELLIA256-SHA256" },
  248. { 0xC037, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256",
  249. "ECDHE-PSK-AES128-CBC-SHA256" },
  250. { 0xC038, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384",
  251. "ECDHE-PSK-AES256-CBC-SHA384" },
  252. { 0xC039, "TLS_ECDHE_PSK_WITH_NULL_SHA",
  253. "ECDHE-PSK-NULL-SHA" },
  254. { 0xC03A, "TLS_ECDHE_PSK_WITH_NULL_SHA256",
  255. "ECDHE-PSK-NULL-SHA256" },
  256. { 0xC03B, "TLS_ECDHE_PSK_WITH_NULL_SHA384",
  257. "ECDHE-PSK-NULL-SHA384" },
  258. { 0xC03C, "TLS_RSA_WITH_ARIA_128_CBC_SHA256",
  259. "ARIA128-SHA256" /* ns */ },
  260. { 0xC03D, "TLS_RSA_WITH_ARIA_256_CBC_SHA384",
  261. "ARIA256-SHA384" /* ns */ },
  262. { 0xC044, "TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256",
  263. "DHE-RSA-ARIA128-SHA256" /* ns */ },
  264. { 0xC045, "TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384",
  265. "DHE-RSA-ARIA256-SHA384" /* ns */ },
  266. { 0xC048, "TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256",
  267. "ECDHE-ECDSA-ARIA128-SHA256" /* ns */ },
  268. { 0xC049, "TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384",
  269. "ECDHE-ECDSA-ARIA256-SHA384" /* ns */ },
  270. { 0xC04A, "TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256",
  271. "ECDH-ECDSA-ARIA128-SHA256" /* ns */ },
  272. { 0xC04B, "TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384",
  273. "ECDH-ECDSA-ARIA256-SHA384" /* ns */ },
  274. { 0xC04C, "TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256",
  275. "ECDHE-ARIA128-SHA256" /* ns */ },
  276. { 0xC04D, "TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384",
  277. "ECDHE-ARIA256-SHA384" /* ns */ },
  278. { 0xC04E, "TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256",
  279. "ECDH-ARIA128-SHA256" /* ns */ },
  280. { 0xC04F, "TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384",
  281. "ECDH-ARIA256-SHA384" /* ns */ },
  282. { 0xC050, "TLS_RSA_WITH_ARIA_128_GCM_SHA256",
  283. "ARIA128-GCM-SHA256" },
  284. { 0xC051, "TLS_RSA_WITH_ARIA_256_GCM_SHA384",
  285. "ARIA256-GCM-SHA384" },
  286. { 0xC052, "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256",
  287. "DHE-RSA-ARIA128-GCM-SHA256" },
  288. { 0xC053, "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384",
  289. "DHE-RSA-ARIA256-GCM-SHA384" },
  290. { 0xC05C, "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256",
  291. "ECDHE-ECDSA-ARIA128-GCM-SHA256" },
  292. { 0xC05D, "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384",
  293. "ECDHE-ECDSA-ARIA256-GCM-SHA384" },
  294. { 0xC05E, "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256",
  295. "ECDH-ECDSA-ARIA128-GCM-SHA256" /* ns */ },
  296. { 0xC05F, "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384",
  297. "ECDH-ECDSA-ARIA256-GCM-SHA384" /* ns */ },
  298. { 0xC060, "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256",
  299. "ECDHE-ARIA128-GCM-SHA256" },
  300. { 0xC061, "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384",
  301. "ECDHE-ARIA256-GCM-SHA384" },
  302. { 0xC062, "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256",
  303. "ECDH-ARIA128-GCM-SHA256" /* ns */ },
  304. { 0xC063, "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384",
  305. "ECDH-ARIA256-GCM-SHA384" /* ns */ },
  306. { 0xC064, "TLS_PSK_WITH_ARIA_128_CBC_SHA256",
  307. "PSK-ARIA128-SHA256" /* ns */ },
  308. { 0xC065, "TLS_PSK_WITH_ARIA_256_CBC_SHA384",
  309. "PSK-ARIA256-SHA384" /* ns */ },
  310. { 0xC066, "TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256",
  311. "DHE-PSK-ARIA128-SHA256" /* ns */ },
  312. { 0xC067, "TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384",
  313. "DHE-PSK-ARIA256-SHA384" /* ns */ },
  314. { 0xC068, "TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256",
  315. "RSA-PSK-ARIA128-SHA256" /* ns */ },
  316. { 0xC069, "TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384",
  317. "RSA-PSK-ARIA256-SHA384" /* ns */ },
  318. { 0xC06A, "TLS_PSK_WITH_ARIA_128_GCM_SHA256",
  319. "PSK-ARIA128-GCM-SHA256" },
  320. { 0xC06B, "TLS_PSK_WITH_ARIA_256_GCM_SHA384",
  321. "PSK-ARIA256-GCM-SHA384" },
  322. { 0xC06C, "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256",
  323. "DHE-PSK-ARIA128-GCM-SHA256" },
  324. { 0xC06D, "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384",
  325. "DHE-PSK-ARIA256-GCM-SHA384" },
  326. { 0xC06E, "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256",
  327. "RSA-PSK-ARIA128-GCM-SHA256" },
  328. { 0xC06F, "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384",
  329. "RSA-PSK-ARIA256-GCM-SHA384" },
  330. { 0xC070, "TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256",
  331. "ECDHE-PSK-ARIA128-SHA256" /* ns */ },
  332. { 0xC071, "TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384",
  333. "ECDHE-PSK-ARIA256-SHA384" /* ns */ },
  334. { 0xC072, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256",
  335. "ECDHE-ECDSA-CAMELLIA128-SHA256" },
  336. { 0xC073, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384",
  337. "ECDHE-ECDSA-CAMELLIA256-SHA384" },
  338. { 0xC074, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256",
  339. "ECDH-ECDSA-CAMELLIA128-SHA256" /* ns */ },
  340. { 0xC075, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384",
  341. "ECDH-ECDSA-CAMELLIA256-SHA384" /* ns */ },
  342. { 0xC076, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256",
  343. "ECDHE-RSA-CAMELLIA128-SHA256" },
  344. { 0xC077, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384",
  345. "ECDHE-RSA-CAMELLIA256-SHA384" },
  346. { 0xC078, "TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256",
  347. "ECDH-CAMELLIA128-SHA256" /* ns */ },
  348. { 0xC079, "TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384",
  349. "ECDH-CAMELLIA256-SHA384" /* ns */ },
  350. { 0xC07A, "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256",
  351. "CAMELLIA128-GCM-SHA256" /* ns */ },
  352. { 0xC07B, "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384",
  353. "CAMELLIA256-GCM-SHA384" /* ns */ },
  354. { 0xC07C, "TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256",
  355. "DHE-RSA-CAMELLIA128-GCM-SHA256" /* ns */ },
  356. { 0xC07D, "TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384",
  357. "DHE-RSA-CAMELLIA256-GCM-SHA384" /* ns */ },
  358. { 0xC086, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256",
  359. "ECDHE-ECDSA-CAMELLIA128-GCM-SHA256" /* ns */ },
  360. { 0xC087, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384",
  361. "ECDHE-ECDSA-CAMELLIA256-GCM-SHA384" /* ns */ },
  362. { 0xC088, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256",
  363. "ECDH-ECDSA-CAMELLIA128-GCM-SHA256" /* ns */ },
  364. { 0xC089, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384",
  365. "ECDH-ECDSA-CAMELLIA256-GCM-SHA384" /* ns */ },
  366. { 0xC08A, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256",
  367. "ECDHE-CAMELLIA128-GCM-SHA256" /* ns */ },
  368. { 0xC08B, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384",
  369. "ECDHE-CAMELLIA256-GCM-SHA384" /* ns */ },
  370. { 0xC08C, "TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256",
  371. "ECDH-CAMELLIA128-GCM-SHA256" /* ns */ },
  372. { 0xC08D, "TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384",
  373. "ECDH-CAMELLIA256-GCM-SHA384" /* ns */ },
  374. { 0xC08E, "TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256",
  375. "PSK-CAMELLIA128-GCM-SHA256" /* ns */ },
  376. { 0xC08F, "TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384",
  377. "PSK-CAMELLIA256-GCM-SHA384" /* ns */ },
  378. { 0xC090, "TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256",
  379. "DHE-PSK-CAMELLIA128-GCM-SHA256" /* ns */ },
  380. { 0xC091, "TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384",
  381. "DHE-PSK-CAMELLIA256-GCM-SHA384" /* ns */ },
  382. { 0xC092, "TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256",
  383. "RSA-PSK-CAMELLIA128-GCM-SHA256" /* ns */ },
  384. { 0xC093, "TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384",
  385. "RSA-PSK-CAMELLIA256-GCM-SHA384" /* ns */ },
  386. { 0xC094, "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256",
  387. "PSK-CAMELLIA128-SHA256" },
  388. { 0xC095, "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384",
  389. "PSK-CAMELLIA256-SHA384" },
  390. { 0xC096, "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256",
  391. "DHE-PSK-CAMELLIA128-SHA256" },
  392. { 0xC097, "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384",
  393. "DHE-PSK-CAMELLIA256-SHA384" },
  394. { 0xC098, "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256",
  395. "RSA-PSK-CAMELLIA128-SHA256" },
  396. { 0xC099, "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384",
  397. "RSA-PSK-CAMELLIA256-SHA384" },
  398. { 0xC09A, "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256",
  399. "ECDHE-PSK-CAMELLIA128-SHA256" },
  400. { 0xC09B, "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384",
  401. "ECDHE-PSK-CAMELLIA256-SHA384" },
  402. { 0xC09E, "TLS_DHE_RSA_WITH_AES_128_CCM",
  403. "DHE-RSA-AES128-CCM" },
  404. { 0xC09F, "TLS_DHE_RSA_WITH_AES_256_CCM",
  405. "DHE-RSA-AES256-CCM" },
  406. { 0xC0A2, "TLS_DHE_RSA_WITH_AES_128_CCM_8",
  407. "DHE-RSA-AES128-CCM8" },
  408. { 0xC0A3, "TLS_DHE_RSA_WITH_AES_256_CCM_8",
  409. "DHE-RSA-AES256-CCM8" },
  410. { 0xC0A4, "TLS_PSK_WITH_AES_128_CCM",
  411. "PSK-AES128-CCM" },
  412. { 0xC0A5, "TLS_PSK_WITH_AES_256_CCM",
  413. "PSK-AES256-CCM" },
  414. { 0xC0A6, "TLS_DHE_PSK_WITH_AES_128_CCM",
  415. "DHE-PSK-AES128-CCM" },
  416. { 0xC0A7, "TLS_DHE_PSK_WITH_AES_256_CCM",
  417. "DHE-PSK-AES256-CCM" },
  418. { 0xC0A8, "TLS_PSK_WITH_AES_128_CCM_8",
  419. "PSK-AES128-CCM8" },
  420. { 0xC0A9, "TLS_PSK_WITH_AES_256_CCM_8",
  421. "PSK-AES256-CCM8" },
  422. { 0xC0AA, "TLS_PSK_DHE_WITH_AES_128_CCM_8",
  423. "DHE-PSK-AES128-CCM8" },
  424. { 0xC0AB, "TLS_PSK_DHE_WITH_AES_256_CCM_8",
  425. "DHE-PSK-AES256-CCM8" },
  426. { 0xCCAA, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
  427. "DHE-RSA-CHACHA20-POLY1305" },
  428. { 0xCCAC, "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256",
  429. "ECDHE-PSK-CHACHA20-POLY1305" },
  430. { 0xCCAD, "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256",
  431. "DHE-PSK-CHACHA20-POLY1305" },
  432. { 0xCCAE, "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256",
  433. "RSA-PSK-CHACHA20-POLY1305" },
  434. #endif
  435. };
  436. #define TEST_CS_LIST_LEN (sizeof(test_cs_list) / sizeof(test_cs_list[0]))
  437. static const char *cs_test_string =
  438. "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:"
  439. "TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:"
  440. "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:"
  441. "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:"
  442. "ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:"
  443. "DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:"
  444. "ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:"
  445. "ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:"
  446. "ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:"
  447. "DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:"
  448. "AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:"
  449. "DES-CBC3-SHA:"
  450. ":: GIBBERISH ::"
  451. ;
  452. struct test_str_entry {
  453. uint16_t id;
  454. const char *str;
  455. };
  456. static const struct test_str_entry test_str_list[] = {
  457. #if defined(USE_MBEDTLS)
  458. { 0x1301, "TLS_AES_128_GCM_SHA256"},
  459. { 0x1302, "TLS_AES_256_GCM_SHA384"},
  460. { 0x1303, "TLS_CHACHA20_POLY1305_SHA256"},
  461. #else
  462. { 0x0000, "TLS_AES_128_GCM_SHA256"},
  463. { 0x0000, "TLS_AES_256_GCM_SHA384"},
  464. { 0x0000, "TLS_CHACHA20_POLY1305_SHA256"},
  465. #endif
  466. { 0xC02B, "ECDHE-ECDSA-AES128-GCM-SHA256"},
  467. { 0xC02F, "ECDHE-RSA-AES128-GCM-SHA256"},
  468. { 0xC02C, "ECDHE-ECDSA-AES256-GCM-SHA384"},
  469. { 0xC030, "ECDHE-RSA-AES256-GCM-SHA384"},
  470. { 0xCCA9, "ECDHE-ECDSA-CHACHA20-POLY1305"},
  471. { 0xCCA8, "ECDHE-RSA-CHACHA20-POLY1305"},
  472. #if defined(USE_MBEDTLS)
  473. { 0x009E, "DHE-RSA-AES128-GCM-SHA256"},
  474. { 0x009F, "DHE-RSA-AES256-GCM-SHA384"},
  475. { 0xCCAA, "DHE-RSA-CHACHA20-POLY1305"},
  476. #else
  477. { 0x0000, "DHE-RSA-AES128-GCM-SHA256"},
  478. { 0x0000, "DHE-RSA-AES256-GCM-SHA384"},
  479. { 0x0000, "DHE-RSA-CHACHA20-POLY1305"},
  480. #endif
  481. { 0xC023, "ECDHE-ECDSA-AES128-SHA256" },
  482. { 0xC027, "ECDHE-RSA-AES128-SHA256" },
  483. { 0xC009, "ECDHE-ECDSA-AES128-SHA" },
  484. { 0xC013, "ECDHE-RSA-AES128-SHA" },
  485. { 0xC024, "ECDHE-ECDSA-AES256-SHA384" },
  486. { 0xC028, "ECDHE-RSA-AES256-SHA384" },
  487. { 0xC00A, "ECDHE-ECDSA-AES256-SHA" },
  488. { 0xC014, "ECDHE-RSA-AES256-SHA" },
  489. #if defined(USE_MBEDTLS)
  490. { 0x0067, "DHE-RSA-AES128-SHA256" },
  491. { 0x006B, "DHE-RSA-AES256-SHA256" },
  492. #else
  493. { 0x0000, "DHE-RSA-AES128-SHA256" },
  494. { 0x0000, "DHE-RSA-AES256-SHA256" },
  495. #endif
  496. { 0x009C, "AES128-GCM-SHA256" },
  497. { 0x009D, "AES256-GCM-SHA384" },
  498. { 0x003C, "AES128-SHA256" },
  499. { 0x003D, "AES256-SHA256" },
  500. { 0x002F, "AES128-SHA" },
  501. { 0x0035, "AES256-SHA" },
  502. #if defined(USE_BEARSSL)
  503. { 0x000A, "DES-CBC3-SHA" },
  504. #else
  505. { 0x0000, "DES-CBC3-SHA" },
  506. #endif
  507. { 0x0000, "GIBBERISH" },
  508. { 0x0000, "" },
  509. };
  510. #define TEST_STR_LIST_LEN (sizeof(test_str_list) / sizeof(test_str_list[0]))
  511. UNITTEST_START
  512. {
  513. for(size_t i = 0; i < TEST_CS_LIST_LEN; i++) {
  514. const struct test_cs_entry *test = &test_cs_list[i];
  515. const char *expect;
  516. char buf[64] = "";
  517. uint16_t id;
  518. /* test Curl_cipher_suite_lookup_id() for rfc name */
  519. if(test->rfc) {
  520. id = Curl_cipher_suite_lookup_id(test->rfc, strlen(test->rfc));
  521. if(id != test->id) {
  522. fprintf(stderr, "Curl_cipher_suite_lookup_id FAILED for \"%s\", "
  523. "result = 0x%04x, expected = 0x%04x\n",
  524. test->rfc, id, test->id);
  525. unitfail++;
  526. }
  527. }
  528. /* test Curl_cipher_suite_lookup_id() for openssl name */
  529. if(test->openssl) {
  530. id = Curl_cipher_suite_lookup_id(test->openssl, strlen(test->openssl));
  531. if(id != test->id) {
  532. fprintf(stderr, "Curl_cipher_suite_lookup_id FAILED for \"%s\", "
  533. "result = 0x%04x, expected = 0x%04x\n",
  534. test->openssl, id, test->id);
  535. unitfail++;
  536. }
  537. }
  538. /* test Curl_cipher_suite_get_str() prefer rfc name */
  539. buf[0] = '\0';
  540. expect = test->rfc ? test->rfc : test->openssl;
  541. Curl_cipher_suite_get_str(test->id, buf, sizeof(buf), true);
  542. if(strcmp(buf, expect) != 0) {
  543. fprintf(stderr, "Curl_cipher_suite_get_str FAILED for 0x%04x, "
  544. "result = \"%s\", expected = \"%s\"\n",
  545. test->id, buf, expect);
  546. unitfail++;
  547. }
  548. /* test Curl_cipher_suite_get_str() prefer openssl name */
  549. buf[0] = '\0';
  550. expect = test->openssl ? test->openssl : test->rfc;
  551. Curl_cipher_suite_get_str(test->id, buf, sizeof(buf), false);
  552. if(strcmp(buf, expect) != 0) {
  553. fprintf(stderr, "Curl_cipher_suite_get_str FAILED for 0x%04x, "
  554. "result = \"%s\", expected = \"%s\"\n",
  555. test->id, buf, expect);
  556. unitfail++;
  557. }
  558. }
  559. /* test Curl_cipher_suite_walk_str() */
  560. {
  561. const char *ptr, *end = cs_test_string;
  562. int i = 0;
  563. uint16_t id;
  564. size_t len;
  565. for(ptr = cs_test_string; ptr[0] != '\0'; ptr = end) {
  566. const struct test_str_entry *test = &test_str_list[i];
  567. abort_if(i == TEST_STR_LIST_LEN, "should have been done");
  568. id = Curl_cipher_suite_walk_str(&ptr, &end);
  569. len = end - ptr;
  570. if(id != test->id) {
  571. fprintf(stderr, "Curl_cipher_suite_walk_str FAILED for \"%s\" "
  572. "unexpected cipher, "
  573. "result = 0x%04x, expected = 0x%04x\n",
  574. test->str, id, test->id);
  575. unitfail++;
  576. }
  577. if(len > 64 || strncmp(ptr, test->str, len) != 0) {
  578. fprintf(stderr, "Curl_cipher_suite_walk_str ABORT for \"%s\" "
  579. "unexpected pointers\n",
  580. test->str);
  581. unitfail++;
  582. goto unit_test_abort;
  583. }
  584. i++;
  585. }
  586. }
  587. }
  588. UNITTEST_STOP
  589. #else /* defined(USE_MBEDTLS) || defined(USE_BEARSSL) */
  590. UNITTEST_START
  591. UNITTEST_STOP
  592. #endif /* defined(USE_MBEDTLS) || defined(USE_BEARSSL) */