s2n_security_policies.c 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. /*
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #include "tls/s2n_security_policies.h"
  16. #include "api/s2n.h"
  17. #include "tls/s2n_connection.h"
  18. #include "utils/s2n_safety.h"
  19. const struct s2n_security_policy security_policy_20170210 = {
  20. .minimum_protocol_version = S2N_TLS10,
  21. .cipher_preferences = &cipher_preferences_20170210,
  22. .kem_preferences = &kem_preferences_null,
  23. .signature_preferences = &s2n_signature_preferences_20140601,
  24. .ecc_preferences = &s2n_ecc_preferences_20140601,
  25. };
  26. const struct s2n_security_policy security_policy_default_tls13 = {
  27. .minimum_protocol_version = S2N_TLS10,
  28. .cipher_preferences = &cipher_preferences_20210831,
  29. .kem_preferences = &kem_preferences_null,
  30. .signature_preferences = &s2n_signature_preferences_20200207,
  31. .certificate_signature_preferences = &s2n_certificate_signature_preferences_20201110,
  32. .ecc_preferences = &s2n_ecc_preferences_20200310,
  33. };
  34. /*
  35. * This security policy is derived from the following specification:
  36. * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-52r2.pdf
  37. *
  38. * Supports TLS1.2
  39. */
  40. const struct s2n_security_policy security_policy_default_fips = {
  41. .minimum_protocol_version = S2N_TLS12,
  42. .cipher_preferences = &cipher_preferences_default_fips,
  43. .kem_preferences = &kem_preferences_null,
  44. .signature_preferences = &s2n_signature_preferences_default_fips,
  45. .certificate_signature_preferences = &s2n_signature_preferences_default_fips,
  46. .ecc_preferences = &s2n_ecc_preferences_default_fips,
  47. };
  48. const struct s2n_security_policy security_policy_20230317 = {
  49. .minimum_protocol_version = S2N_TLS12,
  50. .cipher_preferences = &cipher_preferences_20230317,
  51. .kem_preferences = &kem_preferences_null,
  52. .signature_preferences = &s2n_signature_preferences_20230317,
  53. .certificate_signature_preferences = &s2n_signature_preferences_20230317,
  54. .ecc_preferences = &s2n_ecc_preferences_20201021,
  55. };
  56. const struct s2n_security_policy security_policy_20190801 = {
  57. .minimum_protocol_version = S2N_TLS10,
  58. .cipher_preferences = &cipher_preferences_20190801,
  59. .kem_preferences = &kem_preferences_null,
  60. /* The discrepancy in the date exists because the signature preferences
  61. * were named when cipher preferences and signature preferences were
  62. * tracked separately, and we chose to keep the cipher preference
  63. * name because customers use it.
  64. */
  65. .signature_preferences = &s2n_signature_preferences_20200207,
  66. .ecc_preferences = &s2n_ecc_preferences_20200310,
  67. };
  68. const struct s2n_security_policy security_policy_20190802 = {
  69. .minimum_protocol_version = S2N_TLS10,
  70. .cipher_preferences = &cipher_preferences_20190801,
  71. .kem_preferences = &kem_preferences_null,
  72. /* The discrepancy in the date exists because the signature preferences
  73. * were named when cipher preferences and signature preferences were
  74. * tracked separately, and we chose to keep the cipher preference
  75. * name because customers use it.
  76. */
  77. .signature_preferences = &s2n_signature_preferences_20200207,
  78. .ecc_preferences = &s2n_ecc_preferences_20140601,
  79. };
  80. const struct s2n_security_policy security_policy_20170405 = {
  81. .minimum_protocol_version = S2N_TLS10,
  82. .cipher_preferences = &cipher_preferences_20170405,
  83. .kem_preferences = &kem_preferences_null,
  84. .signature_preferences = &s2n_signature_preferences_20140601,
  85. .ecc_preferences = &s2n_ecc_preferences_20140601,
  86. };
  87. const struct s2n_security_policy security_policy_20170405_gcm = {
  88. .minimum_protocol_version = S2N_TLS10,
  89. .cipher_preferences = &cipher_preferences_20170405_gcm,
  90. .kem_preferences = &kem_preferences_null,
  91. .signature_preferences = &s2n_signature_preferences_20140601,
  92. .ecc_preferences = &s2n_ecc_preferences_20140601,
  93. };
  94. const struct s2n_security_policy security_policy_elb_2015_04 = {
  95. .minimum_protocol_version = S2N_TLS10,
  96. .cipher_preferences = &elb_security_policy_2015_04,
  97. .kem_preferences = &kem_preferences_null,
  98. .signature_preferences = &s2n_signature_preferences_20140601,
  99. .ecc_preferences = &s2n_ecc_preferences_20140601,
  100. };
  101. const struct s2n_security_policy security_policy_elb_2016_08 = {
  102. .minimum_protocol_version = S2N_TLS10,
  103. .cipher_preferences = &elb_security_policy_2016_08,
  104. .kem_preferences = &kem_preferences_null,
  105. .signature_preferences = &s2n_signature_preferences_20140601,
  106. .ecc_preferences = &s2n_ecc_preferences_20140601,
  107. };
  108. const struct s2n_security_policy security_policy_elb_tls_1_1_2017_01 = {
  109. .minimum_protocol_version = S2N_TLS11,
  110. .cipher_preferences = &elb_security_policy_tls_1_1_2017_01,
  111. .kem_preferences = &kem_preferences_null,
  112. .signature_preferences = &s2n_signature_preferences_20140601,
  113. .ecc_preferences = &s2n_ecc_preferences_20140601,
  114. };
  115. const struct s2n_security_policy security_policy_elb_tls_1_2_2017_01 = {
  116. .minimum_protocol_version = S2N_TLS12,
  117. .cipher_preferences = &elb_security_policy_tls_1_2_2017_01,
  118. .kem_preferences = &kem_preferences_null,
  119. .signature_preferences = &s2n_signature_preferences_20140601,
  120. .ecc_preferences = &s2n_ecc_preferences_20140601,
  121. };
  122. const struct s2n_security_policy security_policy_elb_tls_1_2_ext_2018_06 = {
  123. .minimum_protocol_version = S2N_TLS12,
  124. .cipher_preferences = &elb_security_policy_tls_1_2_ext_2018_06,
  125. .kem_preferences = &kem_preferences_null,
  126. .signature_preferences = &s2n_signature_preferences_20140601,
  127. .ecc_preferences = &s2n_ecc_preferences_20140601,
  128. };
  129. const struct s2n_security_policy security_policy_elb_fs_2018_06 = {
  130. .minimum_protocol_version = S2N_TLS10,
  131. .cipher_preferences = &elb_security_policy_fs_2018_06,
  132. .kem_preferences = &kem_preferences_null,
  133. .signature_preferences = &s2n_signature_preferences_20140601,
  134. .ecc_preferences = &s2n_ecc_preferences_20140601,
  135. };
  136. const struct s2n_security_policy security_policy_elb_fs_1_2_2019_08 = {
  137. .minimum_protocol_version = S2N_TLS12,
  138. .cipher_preferences = &elb_security_policy_fs_1_2_2019_08,
  139. .kem_preferences = &kem_preferences_null,
  140. .signature_preferences = &s2n_signature_preferences_20140601,
  141. .ecc_preferences = &s2n_ecc_preferences_20140601,
  142. };
  143. const struct s2n_security_policy security_policy_elb_fs_1_1_2019_08 = {
  144. .minimum_protocol_version = S2N_TLS11,
  145. .cipher_preferences = &elb_security_policy_fs_1_1_2019_08,
  146. .kem_preferences = &kem_preferences_null,
  147. .signature_preferences = &s2n_signature_preferences_20140601,
  148. .ecc_preferences = &s2n_ecc_preferences_20140601,
  149. };
  150. const struct s2n_security_policy security_policy_elb_fs_1_2_Res_2019_08 = {
  151. .minimum_protocol_version = S2N_TLS12,
  152. .cipher_preferences = &elb_security_policy_fs_1_2_Res_2019_08,
  153. .kem_preferences = &kem_preferences_null,
  154. .signature_preferences = &s2n_signature_preferences_20140601,
  155. .ecc_preferences = &s2n_ecc_preferences_20140601,
  156. };
  157. /* CloudFront upstream */
  158. const struct s2n_security_policy security_policy_cloudfront_upstream = {
  159. .minimum_protocol_version = S2N_SSLv3,
  160. .cipher_preferences = &cipher_preferences_cloudfront_upstream,
  161. .kem_preferences = &kem_preferences_null,
  162. .signature_preferences = &s2n_signature_preferences_20140601,
  163. .ecc_preferences = &s2n_ecc_preferences_20140601,
  164. };
  165. const struct s2n_security_policy security_policy_cloudfront_upstream_tls10 = {
  166. .minimum_protocol_version = S2N_TLS10,
  167. .cipher_preferences = &cipher_preferences_cloudfront_upstream_tls10,
  168. .kem_preferences = &kem_preferences_null,
  169. .signature_preferences = &s2n_signature_preferences_20140601,
  170. .ecc_preferences = &s2n_ecc_preferences_20140601,
  171. };
  172. const struct s2n_security_policy security_policy_cloudfront_upstream_tls11 = {
  173. .minimum_protocol_version = S2N_TLS11,
  174. .cipher_preferences = &cipher_preferences_cloudfront_upstream_tls11,
  175. .kem_preferences = &kem_preferences_null,
  176. .signature_preferences = &s2n_signature_preferences_20140601,
  177. .ecc_preferences = &s2n_ecc_preferences_20140601,
  178. };
  179. const struct s2n_security_policy security_policy_cloudfront_upstream_tls12 = {
  180. .minimum_protocol_version = S2N_TLS12,
  181. .cipher_preferences = &cipher_preferences_cloudfront_upstream_tls12,
  182. .kem_preferences = &kem_preferences_null,
  183. .signature_preferences = &s2n_signature_preferences_20140601,
  184. .ecc_preferences = &s2n_ecc_preferences_20140601,
  185. };
  186. /* CloudFront viewer facing */
  187. const struct s2n_security_policy security_policy_cloudfront_ssl_v_3 = {
  188. .minimum_protocol_version = S2N_SSLv3,
  189. .cipher_preferences = &cipher_preferences_cloudfront_ssl_v_3,
  190. .kem_preferences = &kem_preferences_null,
  191. .signature_preferences = &s2n_signature_preferences_20200207,
  192. .ecc_preferences = &s2n_ecc_preferences_20200310,
  193. };
  194. const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014 = {
  195. .minimum_protocol_version = S2N_TLS10,
  196. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_0_2014,
  197. .kem_preferences = &kem_preferences_null,
  198. .signature_preferences = &s2n_signature_preferences_20200207,
  199. .ecc_preferences = &s2n_ecc_preferences_20200310,
  200. };
  201. const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2016 = {
  202. .minimum_protocol_version = S2N_TLS10,
  203. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_0_2016,
  204. .kem_preferences = &kem_preferences_null,
  205. .signature_preferences = &s2n_signature_preferences_20200207,
  206. .ecc_preferences = &s2n_ecc_preferences_20200310,
  207. };
  208. const struct s2n_security_policy security_policy_cloudfront_tls_1_1_2016 = {
  209. .minimum_protocol_version = S2N_TLS11,
  210. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_1_2016,
  211. .kem_preferences = &kem_preferences_null,
  212. .signature_preferences = &s2n_signature_preferences_20200207,
  213. .ecc_preferences = &s2n_ecc_preferences_20200310,
  214. };
  215. const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2017 = {
  216. .minimum_protocol_version = S2N_TLS12,
  217. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2017,
  218. .kem_preferences = &kem_preferences_null,
  219. .signature_preferences = &s2n_signature_preferences_20200207,
  220. .ecc_preferences = &s2n_ecc_preferences_20200310,
  221. };
  222. const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2018 = {
  223. .minimum_protocol_version = S2N_TLS12,
  224. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2018,
  225. .kem_preferences = &kem_preferences_null,
  226. .signature_preferences = &s2n_signature_preferences_20200207,
  227. .ecc_preferences = &s2n_ecc_preferences_20200310,
  228. };
  229. const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2019 = {
  230. .minimum_protocol_version = S2N_TLS12,
  231. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2019,
  232. .kem_preferences = &kem_preferences_null,
  233. .signature_preferences = &s2n_signature_preferences_20200207,
  234. .ecc_preferences = &s2n_ecc_preferences_20200310,
  235. };
  236. const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2021 = {
  237. .minimum_protocol_version = S2N_TLS12,
  238. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2021,
  239. .kem_preferences = &kem_preferences_null,
  240. .signature_preferences = &s2n_signature_preferences_20200207,
  241. .ecc_preferences = &s2n_ecc_preferences_20200310,
  242. };
  243. const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2021_chacha20_boosted = {
  244. .minimum_protocol_version = S2N_TLS12,
  245. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2021_chacha20_boosted,
  246. .kem_preferences = &kem_preferences_null,
  247. .signature_preferences = &s2n_signature_preferences_20200207,
  248. .ecc_preferences = &s2n_ecc_preferences_20200310,
  249. };
  250. /* CloudFront viewer facing legacy TLS 1.2 policies */
  251. const struct s2n_security_policy security_policy_cloudfront_ssl_v_3_legacy = {
  252. .minimum_protocol_version = S2N_SSLv3,
  253. .cipher_preferences = &cipher_preferences_cloudfront_ssl_v_3_legacy,
  254. .kem_preferences = &kem_preferences_null,
  255. .signature_preferences = &s2n_signature_preferences_20140601,
  256. .ecc_preferences = &s2n_ecc_preferences_20140601,
  257. };
  258. const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014_legacy = {
  259. .minimum_protocol_version = S2N_TLS10,
  260. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_0_2014_legacy,
  261. .kem_preferences = &kem_preferences_null,
  262. .signature_preferences = &s2n_signature_preferences_20140601,
  263. .ecc_preferences = &s2n_ecc_preferences_20140601,
  264. };
  265. const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2016_legacy = {
  266. .minimum_protocol_version = S2N_TLS10,
  267. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_0_2016_legacy,
  268. .kem_preferences = &kem_preferences_null,
  269. .signature_preferences = &s2n_signature_preferences_20140601,
  270. .ecc_preferences = &s2n_ecc_preferences_20140601,
  271. };
  272. const struct s2n_security_policy security_policy_cloudfront_tls_1_1_2016_legacy = {
  273. .minimum_protocol_version = S2N_TLS11,
  274. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_1_2016_legacy,
  275. .kem_preferences = &kem_preferences_null,
  276. .signature_preferences = &s2n_signature_preferences_20140601,
  277. .ecc_preferences = &s2n_ecc_preferences_20140601,
  278. };
  279. const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2018_legacy = {
  280. .minimum_protocol_version = S2N_TLS12,
  281. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2018_legacy,
  282. .kem_preferences = &kem_preferences_null,
  283. .signature_preferences = &s2n_signature_preferences_20140601,
  284. .ecc_preferences = &s2n_ecc_preferences_20140601,
  285. };
  286. const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2019_legacy = {
  287. .minimum_protocol_version = S2N_TLS12,
  288. .cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2019_legacy,
  289. .kem_preferences = &kem_preferences_null,
  290. .signature_preferences = &s2n_signature_preferences_20140601,
  291. .ecc_preferences = &s2n_ecc_preferences_20140601,
  292. };
  293. const struct s2n_security_policy security_policy_aws_crt_sdk_ssl_v3 = {
  294. .minimum_protocol_version = S2N_SSLv3,
  295. .cipher_preferences = &cipher_preferences_aws_crt_sdk_ssl_v3,
  296. .kem_preferences = &kem_preferences_null,
  297. .signature_preferences = &s2n_signature_preferences_20200207,
  298. .ecc_preferences = &s2n_ecc_preferences_20200310,
  299. };
  300. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_10 = {
  301. .minimum_protocol_version = S2N_TLS10,
  302. .cipher_preferences = &cipher_preferences_aws_crt_sdk_default,
  303. .kem_preferences = &kem_preferences_null,
  304. .signature_preferences = &s2n_signature_preferences_20200207,
  305. .ecc_preferences = &s2n_ecc_preferences_20200310,
  306. };
  307. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_11 = {
  308. .minimum_protocol_version = S2N_TLS11,
  309. .cipher_preferences = &cipher_preferences_aws_crt_sdk_default,
  310. .kem_preferences = &kem_preferences_null,
  311. .signature_preferences = &s2n_signature_preferences_20200207,
  312. .ecc_preferences = &s2n_ecc_preferences_20200310,
  313. };
  314. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_12 = {
  315. .minimum_protocol_version = S2N_TLS12,
  316. .cipher_preferences = &cipher_preferences_aws_crt_sdk_default,
  317. .kem_preferences = &kem_preferences_null,
  318. .signature_preferences = &s2n_signature_preferences_20200207,
  319. .ecc_preferences = &s2n_ecc_preferences_20200310,
  320. };
  321. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_13 = {
  322. .minimum_protocol_version = S2N_TLS13,
  323. .cipher_preferences = &cipher_preferences_aws_crt_sdk_tls_13,
  324. .kem_preferences = &kem_preferences_null,
  325. .signature_preferences = &s2n_signature_preferences_20200207,
  326. .ecc_preferences = &s2n_ecc_preferences_20200310,
  327. };
  328. const struct s2n_security_policy security_policy_aws_crt_sdk_ssl_v3_06_23 = {
  329. .minimum_protocol_version = S2N_SSLv3,
  330. .cipher_preferences = &cipher_preferences_aws_crt_sdk_ssl_v3,
  331. .kem_preferences = &kem_preferences_null,
  332. .signature_preferences = &s2n_signature_preferences_20200207,
  333. .ecc_preferences = &s2n_ecc_preferences_20230623,
  334. };
  335. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_10_06_23 = {
  336. .minimum_protocol_version = S2N_TLS10,
  337. .cipher_preferences = &cipher_preferences_aws_crt_sdk_default,
  338. .kem_preferences = &kem_preferences_null,
  339. .signature_preferences = &s2n_signature_preferences_20200207,
  340. .ecc_preferences = &s2n_ecc_preferences_20230623,
  341. };
  342. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_11_06_23 = {
  343. .minimum_protocol_version = S2N_TLS11,
  344. .cipher_preferences = &cipher_preferences_aws_crt_sdk_default,
  345. .kem_preferences = &kem_preferences_null,
  346. .signature_preferences = &s2n_signature_preferences_20200207,
  347. .ecc_preferences = &s2n_ecc_preferences_20230623,
  348. };
  349. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_12_06_23 = {
  350. .minimum_protocol_version = S2N_TLS12,
  351. .cipher_preferences = &cipher_preferences_aws_crt_sdk_default,
  352. .kem_preferences = &kem_preferences_null,
  353. .signature_preferences = &s2n_signature_preferences_20200207,
  354. .ecc_preferences = &s2n_ecc_preferences_20230623,
  355. };
  356. const struct s2n_security_policy security_policy_aws_crt_sdk_tls_13_06_23 = {
  357. .minimum_protocol_version = S2N_TLS13,
  358. .cipher_preferences = &cipher_preferences_aws_crt_sdk_tls_13,
  359. .kem_preferences = &kem_preferences_null,
  360. .signature_preferences = &s2n_signature_preferences_20200207,
  361. .ecc_preferences = &s2n_ecc_preferences_20230623,
  362. };
  363. const struct s2n_security_policy security_policy_kms_tls_1_0_2018_10 = {
  364. .minimum_protocol_version = S2N_TLS10,
  365. .cipher_preferences = &cipher_preferences_kms_tls_1_0_2018_10,
  366. .kem_preferences = &kem_preferences_null,
  367. .signature_preferences = &s2n_signature_preferences_20140601,
  368. .ecc_preferences = &s2n_ecc_preferences_20140601,
  369. };
  370. const struct s2n_security_policy security_policy_kms_tls_1_0_2021_08 = {
  371. .minimum_protocol_version = S2N_TLS10,
  372. .cipher_preferences = &cipher_preferences_kms_tls_1_0_2021_08,
  373. .kem_preferences = &kem_preferences_null,
  374. .signature_preferences = &s2n_signature_preferences_20200207,
  375. .ecc_preferences = &s2n_ecc_preferences_20200310,
  376. };
  377. const struct s2n_security_policy security_policy_kms_tls_1_2_2023_06 = {
  378. .minimum_protocol_version = S2N_TLS12,
  379. .cipher_preferences = &cipher_preferences_kms_tls_1_0_2021_08,
  380. .kem_preferences = &kem_preferences_null,
  381. .signature_preferences = &s2n_signature_preferences_20200207,
  382. .ecc_preferences = &s2n_ecc_preferences_20200310,
  383. };
  384. const struct s2n_security_policy security_policy_kms_pq_tls_1_0_2019_06 = {
  385. .minimum_protocol_version = S2N_TLS10,
  386. .cipher_preferences = &cipher_preferences_kms_pq_tls_1_0_2019_06,
  387. .kem_preferences = &kem_preferences_null,
  388. .signature_preferences = &s2n_signature_preferences_20140601,
  389. .ecc_preferences = &s2n_ecc_preferences_20140601,
  390. };
  391. const struct s2n_security_policy security_policy_kms_pq_tls_1_0_2020_02 = {
  392. .minimum_protocol_version = S2N_TLS10,
  393. .cipher_preferences = &cipher_preferences_kms_pq_tls_1_0_2020_02,
  394. .kem_preferences = &kem_preferences_null,
  395. .signature_preferences = &s2n_signature_preferences_20140601,
  396. .ecc_preferences = &s2n_ecc_preferences_20140601,
  397. };
  398. const struct s2n_security_policy security_policy_pq_sike_test_tls_1_0_2019_11 = {
  399. .minimum_protocol_version = S2N_TLS10,
  400. .cipher_preferences = &cipher_preferences_pq_sike_test_tls_1_0_2019_11,
  401. .kem_preferences = &kem_preferences_null,
  402. .signature_preferences = &s2n_signature_preferences_20140601,
  403. .ecc_preferences = &s2n_ecc_preferences_20140601,
  404. };
  405. const struct s2n_security_policy security_policy_pq_sike_test_tls_1_0_2020_02 = {
  406. .minimum_protocol_version = S2N_TLS10,
  407. .cipher_preferences = &cipher_preferences_pq_sike_test_tls_1_0_2020_02,
  408. .kem_preferences = &kem_preferences_null,
  409. .signature_preferences = &s2n_signature_preferences_20140601,
  410. .ecc_preferences = &s2n_ecc_preferences_20140601,
  411. };
  412. const struct s2n_security_policy security_policy_kms_pq_tls_1_0_2020_07 = {
  413. .minimum_protocol_version = S2N_TLS10,
  414. .cipher_preferences = &cipher_preferences_kms_pq_tls_1_0_2020_07,
  415. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  416. .signature_preferences = &s2n_signature_preferences_20140601,
  417. .ecc_preferences = &s2n_ecc_preferences_20140601,
  418. };
  419. const struct s2n_security_policy security_policy_pq_tls_1_0_2020_12 = {
  420. .minimum_protocol_version = S2N_TLS10,
  421. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2020_12,
  422. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  423. .signature_preferences = &s2n_signature_preferences_20200207,
  424. .ecc_preferences = &s2n_ecc_preferences_20200310,
  425. };
  426. const struct s2n_security_policy security_policy_pq_tls_1_1_2021_05_17 = {
  427. .minimum_protocol_version = S2N_TLS11,
  428. .cipher_preferences = &cipher_preferences_pq_tls_1_1_2021_05_17,
  429. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  430. .signature_preferences = &s2n_signature_preferences_20140601,
  431. .ecc_preferences = &s2n_ecc_preferences_20200310,
  432. };
  433. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_18 = {
  434. .minimum_protocol_version = S2N_TLS10,
  435. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_18,
  436. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  437. .signature_preferences = &s2n_signature_preferences_20140601,
  438. .ecc_preferences = &s2n_ecc_preferences_20200310,
  439. };
  440. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_19 = {
  441. .minimum_protocol_version = S2N_TLS10,
  442. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_19,
  443. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  444. .signature_preferences = &s2n_signature_preferences_20140601,
  445. .ecc_preferences = &s2n_ecc_preferences_20200310,
  446. };
  447. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_20 = {
  448. .minimum_protocol_version = S2N_TLS10,
  449. /* Yes, this is the same cipher_preferences as kms_pq_tls_1_0_2020_07. The difference between these policies is
  450. * the ecc_preferences, with this one adding support for x25519. */
  451. .cipher_preferences = &cipher_preferences_kms_pq_tls_1_0_2020_07,
  452. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  453. .signature_preferences = &s2n_signature_preferences_20140601,
  454. .ecc_preferences = &s2n_ecc_preferences_20200310,
  455. };
  456. const struct s2n_security_policy security_policy_pq_tls_1_1_2021_05_21 = {
  457. .minimum_protocol_version = S2N_TLS11,
  458. .cipher_preferences = &cipher_preferences_pq_tls_1_1_2021_05_21,
  459. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  460. .signature_preferences = &s2n_signature_preferences_20200207,
  461. .ecc_preferences = &s2n_ecc_preferences_20200310,
  462. };
  463. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_22 = {
  464. .minimum_protocol_version = S2N_TLS10,
  465. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_22,
  466. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  467. .signature_preferences = &s2n_signature_preferences_20200207,
  468. .ecc_preferences = &s2n_ecc_preferences_20200310,
  469. };
  470. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_23 = {
  471. .minimum_protocol_version = S2N_TLS10,
  472. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_23,
  473. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  474. .signature_preferences = &s2n_signature_preferences_20200207,
  475. .ecc_preferences = &s2n_ecc_preferences_20200310,
  476. };
  477. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_24 = {
  478. .minimum_protocol_version = S2N_TLS10,
  479. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_24,
  480. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  481. .signature_preferences = &s2n_signature_preferences_20200207,
  482. .ecc_preferences = &s2n_ecc_preferences_20200310,
  483. };
  484. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_25 = {
  485. .minimum_protocol_version = S2N_TLS10,
  486. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_25,
  487. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  488. .signature_preferences = &s2n_signature_preferences_20140601,
  489. .ecc_preferences = &s2n_ecc_preferences_20200310,
  490. };
  491. const struct s2n_security_policy security_policy_pq_tls_1_0_2021_05_26 = {
  492. .minimum_protocol_version = S2N_TLS10,
  493. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_26,
  494. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  495. .signature_preferences = &s2n_signature_preferences_20200207,
  496. .ecc_preferences = &s2n_ecc_preferences_20200310,
  497. };
  498. const struct s2n_security_policy security_policy_pq_tls_1_0_2023_01_24 = {
  499. .minimum_protocol_version = S2N_TLS10,
  500. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_24,
  501. .kem_preferences = &kem_preferences_pq_tls_1_0_2023_01,
  502. .signature_preferences = &s2n_signature_preferences_20200207,
  503. .ecc_preferences = &s2n_ecc_preferences_20200310,
  504. };
  505. /* Same as security_policy_pq_tls_1_1_2021_05_21, but with TLS 1.2 as minimum */
  506. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_04_07 = {
  507. .minimum_protocol_version = S2N_TLS12,
  508. .cipher_preferences = &cipher_preferences_pq_tls_1_1_2021_05_21,
  509. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  510. .signature_preferences = &s2n_signature_preferences_20200207,
  511. .ecc_preferences = &s2n_ecc_preferences_20200310,
  512. };
  513. /* Same as security_policy_pq_tls_1_0_2021_05_22, but with TLS 1.2 as minimum */
  514. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_04_08 = {
  515. .minimum_protocol_version = S2N_TLS12,
  516. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_22,
  517. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  518. .signature_preferences = &s2n_signature_preferences_20200207,
  519. .ecc_preferences = &s2n_ecc_preferences_20200310,
  520. };
  521. /* Same as security_policy_pq_tls_1_0_2021_05_24, but with TLS 1.2 as minimum */
  522. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_04_09 = {
  523. .minimum_protocol_version = S2N_TLS12,
  524. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_24,
  525. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  526. .signature_preferences = &s2n_signature_preferences_20200207,
  527. .ecc_preferences = &s2n_ecc_preferences_20200310,
  528. };
  529. /* Same as security_policy_pq_tls_1_0_2021_05_26, but with TLS 1.2 as minimum */
  530. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_04_10 = {
  531. .minimum_protocol_version = S2N_TLS12,
  532. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_26,
  533. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  534. .signature_preferences = &s2n_signature_preferences_20200207,
  535. .ecc_preferences = &s2n_ecc_preferences_20200310,
  536. };
  537. const struct s2n_security_policy security_policy_pq_tls_1_3_2023_06_01 = {
  538. .minimum_protocol_version = S2N_TLS12,
  539. .cipher_preferences = &cipher_preferences_pq_tls_1_3_2023_06_01,
  540. .kem_preferences = &kem_preferences_pq_tls_1_3_2023_06,
  541. .signature_preferences = &s2n_signature_preferences_20200207,
  542. .ecc_preferences = &s2n_ecc_preferences_20201021,
  543. };
  544. /* Same as security_policy_pq_tls_1_2_2023_04_07, but with updated KEM prefs */
  545. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_10_07 = {
  546. .minimum_protocol_version = S2N_TLS12,
  547. .cipher_preferences = &cipher_preferences_pq_tls_1_1_2021_05_21,
  548. .kem_preferences = &kem_preferences_pq_tls_1_3_2023_06,
  549. .signature_preferences = &s2n_signature_preferences_20200207,
  550. .ecc_preferences = &s2n_ecc_preferences_20200310,
  551. };
  552. /* Same as security_policy_pq_tls_1_2_2023_04_08, but with updated KEM prefs */
  553. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_10_08 = {
  554. .minimum_protocol_version = S2N_TLS12,
  555. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_22,
  556. .kem_preferences = &kem_preferences_pq_tls_1_3_2023_06,
  557. .signature_preferences = &s2n_signature_preferences_20200207,
  558. .ecc_preferences = &s2n_ecc_preferences_20200310,
  559. };
  560. /* Same as security_policy_pq_tls_1_2_2023_04_09, but with updated KEM prefs */
  561. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_10_09 = {
  562. .minimum_protocol_version = S2N_TLS12,
  563. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_24,
  564. .kem_preferences = &kem_preferences_pq_tls_1_3_2023_06,
  565. .signature_preferences = &s2n_signature_preferences_20200207,
  566. .ecc_preferences = &s2n_ecc_preferences_20200310,
  567. };
  568. /* Same as security_policy_pq_tls_1_2_2023_04_10, but with updated KEM prefs */
  569. const struct s2n_security_policy security_policy_pq_tls_1_2_2023_10_10 = {
  570. .minimum_protocol_version = S2N_TLS12,
  571. .cipher_preferences = &cipher_preferences_pq_tls_1_0_2021_05_26,
  572. .kem_preferences = &kem_preferences_pq_tls_1_3_2023_06,
  573. .signature_preferences = &s2n_signature_preferences_20200207,
  574. .ecc_preferences = &s2n_ecc_preferences_20200310,
  575. };
  576. const struct s2n_security_policy security_policy_kms_fips_tls_1_2_2018_10 = {
  577. .minimum_protocol_version = S2N_TLS12,
  578. .cipher_preferences = &cipher_preferences_kms_fips_tls_1_2_2018_10,
  579. .kem_preferences = &kem_preferences_null,
  580. .signature_preferences = &s2n_signature_preferences_20140601,
  581. .ecc_preferences = &s2n_ecc_preferences_20140601,
  582. };
  583. const struct s2n_security_policy security_policy_kms_fips_tls_1_2_2021_08 = {
  584. .minimum_protocol_version = S2N_TLS12,
  585. .cipher_preferences = &cipher_preferences_kms_fips_tls_1_2_2021_08,
  586. .kem_preferences = &kem_preferences_null,
  587. .signature_preferences = &s2n_signature_preferences_20200207,
  588. .ecc_preferences = &s2n_ecc_preferences_20140601,
  589. };
  590. const struct s2n_security_policy security_policy_20140601 = {
  591. .minimum_protocol_version = S2N_SSLv3,
  592. .cipher_preferences = &cipher_preferences_20140601,
  593. .kem_preferences = &kem_preferences_null,
  594. .signature_preferences = &s2n_signature_preferences_20140601,
  595. .ecc_preferences = &s2n_ecc_preferences_20140601,
  596. };
  597. const struct s2n_security_policy security_policy_20141001 = {
  598. .minimum_protocol_version = S2N_TLS10,
  599. .cipher_preferences = &cipher_preferences_20141001,
  600. .kem_preferences = &kem_preferences_null,
  601. .signature_preferences = &s2n_signature_preferences_20140601,
  602. .ecc_preferences = &s2n_ecc_preferences_20140601,
  603. };
  604. const struct s2n_security_policy security_policy_20150202 = {
  605. .minimum_protocol_version = S2N_TLS10,
  606. .cipher_preferences = &cipher_preferences_20150202,
  607. .kem_preferences = &kem_preferences_null,
  608. .signature_preferences = &s2n_signature_preferences_20140601,
  609. .ecc_preferences = &s2n_ecc_preferences_20140601,
  610. };
  611. const struct s2n_security_policy security_policy_20150214 = {
  612. .minimum_protocol_version = S2N_TLS10,
  613. .cipher_preferences = &cipher_preferences_20150214,
  614. .kem_preferences = &kem_preferences_null,
  615. .signature_preferences = &s2n_signature_preferences_20140601,
  616. .ecc_preferences = &s2n_ecc_preferences_20140601,
  617. };
  618. const struct s2n_security_policy security_policy_20160411 = {
  619. .minimum_protocol_version = S2N_TLS10,
  620. .cipher_preferences = &cipher_preferences_20160411,
  621. .kem_preferences = &kem_preferences_null,
  622. .signature_preferences = &s2n_signature_preferences_20140601,
  623. .ecc_preferences = &s2n_ecc_preferences_20140601,
  624. };
  625. const struct s2n_security_policy security_policy_20150306 = {
  626. .minimum_protocol_version = S2N_TLS10,
  627. .cipher_preferences = &cipher_preferences_20150306,
  628. .kem_preferences = &kem_preferences_null,
  629. .signature_preferences = &s2n_signature_preferences_20140601,
  630. .ecc_preferences = &s2n_ecc_preferences_20140601,
  631. };
  632. const struct s2n_security_policy security_policy_20160804 = {
  633. .minimum_protocol_version = S2N_TLS10,
  634. .cipher_preferences = &cipher_preferences_20160804,
  635. .kem_preferences = &kem_preferences_null,
  636. .signature_preferences = &s2n_signature_preferences_20140601,
  637. .ecc_preferences = &s2n_ecc_preferences_20140601,
  638. };
  639. const struct s2n_security_policy security_policy_20160824 = {
  640. .minimum_protocol_version = S2N_TLS10,
  641. .cipher_preferences = &cipher_preferences_20160824,
  642. .kem_preferences = &kem_preferences_null,
  643. .signature_preferences = &s2n_signature_preferences_20140601,
  644. .ecc_preferences = &s2n_ecc_preferences_20140601,
  645. };
  646. const struct s2n_security_policy security_policy_20190122 = {
  647. .minimum_protocol_version = S2N_TLS10,
  648. .cipher_preferences = &cipher_preferences_20190122,
  649. .kem_preferences = &kem_preferences_null,
  650. .signature_preferences = &s2n_signature_preferences_20140601,
  651. .ecc_preferences = &s2n_ecc_preferences_20140601,
  652. };
  653. const struct s2n_security_policy security_policy_20190121 = {
  654. .minimum_protocol_version = S2N_TLS10,
  655. .cipher_preferences = &cipher_preferences_20190121,
  656. .kem_preferences = &kem_preferences_null,
  657. .signature_preferences = &s2n_signature_preferences_20140601,
  658. .ecc_preferences = &s2n_ecc_preferences_20140601,
  659. };
  660. const struct s2n_security_policy security_policy_20190120 = {
  661. .minimum_protocol_version = S2N_TLS10,
  662. .cipher_preferences = &cipher_preferences_20190120,
  663. .kem_preferences = &kem_preferences_null,
  664. .signature_preferences = &s2n_signature_preferences_20140601,
  665. .ecc_preferences = &s2n_ecc_preferences_20140601,
  666. };
  667. const struct s2n_security_policy security_policy_20190214 = {
  668. .minimum_protocol_version = S2N_TLS10,
  669. .cipher_preferences = &cipher_preferences_20190214,
  670. .kem_preferences = &kem_preferences_null,
  671. .signature_preferences = &s2n_signature_preferences_20140601,
  672. .ecc_preferences = &s2n_ecc_preferences_20140601,
  673. };
  674. const struct s2n_security_policy security_policy_20190214_gcm = {
  675. .minimum_protocol_version = S2N_TLS10,
  676. .cipher_preferences = &cipher_preferences_20190214_gcm,
  677. .kem_preferences = &kem_preferences_null,
  678. .signature_preferences = &s2n_signature_preferences_20140601,
  679. .ecc_preferences = &s2n_ecc_preferences_20140601,
  680. };
  681. const struct s2n_security_policy security_policy_20210825 = {
  682. .minimum_protocol_version = S2N_TLS10,
  683. .cipher_preferences = &cipher_preferences_20210825,
  684. .kem_preferences = &kem_preferences_null,
  685. .signature_preferences = &s2n_signature_preferences_20200207,
  686. .ecc_preferences = &s2n_ecc_preferences_20200310,
  687. };
  688. const struct s2n_security_policy security_policy_20210825_gcm = {
  689. .minimum_protocol_version = S2N_TLS10,
  690. .cipher_preferences = &cipher_preferences_20210825_gcm,
  691. .kem_preferences = &kem_preferences_null,
  692. .signature_preferences = &s2n_signature_preferences_20200207,
  693. .ecc_preferences = &s2n_ecc_preferences_20200310,
  694. };
  695. const struct s2n_security_policy security_policy_20170328 = {
  696. .minimum_protocol_version = S2N_TLS10,
  697. .cipher_preferences = &cipher_preferences_20170328,
  698. .kem_preferences = &kem_preferences_null,
  699. .signature_preferences = &s2n_signature_preferences_20140601,
  700. .ecc_preferences = &s2n_ecc_preferences_20140601,
  701. };
  702. const struct s2n_security_policy security_policy_20170328_gcm = {
  703. .minimum_protocol_version = S2N_TLS10,
  704. .cipher_preferences = &cipher_preferences_20170328_gcm,
  705. .kem_preferences = &kem_preferences_null,
  706. .signature_preferences = &s2n_signature_preferences_20140601,
  707. .ecc_preferences = &s2n_ecc_preferences_20140601,
  708. };
  709. const struct s2n_security_policy security_policy_20170718 = {
  710. .minimum_protocol_version = S2N_TLS10,
  711. .cipher_preferences = &cipher_preferences_20170718,
  712. .kem_preferences = &kem_preferences_null,
  713. .signature_preferences = &s2n_signature_preferences_20140601,
  714. .ecc_preferences = &s2n_ecc_preferences_20140601,
  715. };
  716. const struct s2n_security_policy security_policy_20170718_gcm = {
  717. .minimum_protocol_version = S2N_TLS10,
  718. .cipher_preferences = &cipher_preferences_20170718_gcm,
  719. .kem_preferences = &kem_preferences_null,
  720. .signature_preferences = &s2n_signature_preferences_20140601,
  721. .ecc_preferences = &s2n_ecc_preferences_20140601,
  722. };
  723. const struct s2n_security_policy security_policy_20201021 = {
  724. .minimum_protocol_version = S2N_TLS10,
  725. .cipher_preferences = &cipher_preferences_20190122,
  726. .kem_preferences = &kem_preferences_null,
  727. .signature_preferences = &s2n_signature_preferences_20201021,
  728. .ecc_preferences = &s2n_ecc_preferences_20201021,
  729. };
  730. const struct s2n_security_policy security_policy_20210816 = {
  731. .minimum_protocol_version = S2N_TLS12,
  732. .cipher_preferences = &cipher_preferences_20210816,
  733. .kem_preferences = &kem_preferences_null,
  734. .signature_preferences = &s2n_signature_preferences_20210816,
  735. .ecc_preferences = &s2n_ecc_preferences_20210816,
  736. };
  737. const struct s2n_security_policy security_policy_20210816_gcm = {
  738. .minimum_protocol_version = S2N_TLS12,
  739. .cipher_preferences = &cipher_preferences_20210816_gcm,
  740. .kem_preferences = &kem_preferences_null,
  741. .signature_preferences = &s2n_signature_preferences_20210816,
  742. .ecc_preferences = &s2n_ecc_preferences_20210816,
  743. };
  744. /*
  745. * This security policy is derived from the following specification:
  746. * https://datatracker.ietf.org/doc/html/rfc9151
  747. */
  748. const struct s2n_security_policy security_policy_rfc9151 = {
  749. .minimum_protocol_version = S2N_TLS12,
  750. .cipher_preferences = &cipher_preferences_rfc9151,
  751. .kem_preferences = &kem_preferences_null,
  752. .signature_preferences = &s2n_signature_preferences_rfc9151,
  753. .certificate_signature_preferences = &s2n_certificate_signature_preferences_rfc9151,
  754. .ecc_preferences = &s2n_ecc_preferences_20210816,
  755. };
  756. const struct s2n_security_policy security_policy_test_all = {
  757. .minimum_protocol_version = S2N_SSLv3,
  758. .cipher_preferences = &cipher_preferences_test_all,
  759. .kem_preferences = &kem_preferences_all,
  760. .signature_preferences = &s2n_signature_preferences_20201021,
  761. .ecc_preferences = &s2n_ecc_preferences_test_all,
  762. };
  763. const struct s2n_security_policy security_policy_test_all_tls12 = {
  764. .minimum_protocol_version = S2N_SSLv3,
  765. .cipher_preferences = &cipher_preferences_test_all_tls12,
  766. .kem_preferences = &kem_preferences_pq_tls_1_0_2021_05,
  767. .signature_preferences = &s2n_signature_preferences_20201021,
  768. .ecc_preferences = &s2n_ecc_preferences_20201021,
  769. };
  770. const struct s2n_security_policy security_policy_test_all_fips = {
  771. .minimum_protocol_version = S2N_TLS10,
  772. .cipher_preferences = &cipher_preferences_test_all_fips,
  773. .kem_preferences = &kem_preferences_null,
  774. .signature_preferences = &s2n_signature_preferences_20201021,
  775. .ecc_preferences = &s2n_ecc_preferences_20201021,
  776. };
  777. const struct s2n_security_policy security_policy_test_all_ecdsa = {
  778. .minimum_protocol_version = S2N_TLS10,
  779. .cipher_preferences = &cipher_preferences_test_all_ecdsa,
  780. .kem_preferences = &kem_preferences_null,
  781. .signature_preferences = &s2n_signature_preferences_20201021,
  782. .ecc_preferences = &s2n_ecc_preferences_test_all,
  783. };
  784. const struct s2n_security_policy security_policy_test_all_rsa_kex = {
  785. .minimum_protocol_version = S2N_TLS10,
  786. .cipher_preferences = &cipher_preferences_test_all_rsa_kex,
  787. .kem_preferences = &kem_preferences_null,
  788. .signature_preferences = &s2n_signature_preferences_20140601,
  789. .ecc_preferences = &s2n_ecc_preferences_20140601,
  790. };
  791. const struct s2n_security_policy security_policy_test_all_tls13 = {
  792. .minimum_protocol_version = S2N_SSLv3,
  793. .cipher_preferences = &cipher_preferences_test_all_tls13,
  794. .kem_preferences = &kem_preferences_null,
  795. .signature_preferences = &s2n_signature_preferences_20201021,
  796. .ecc_preferences = &s2n_ecc_preferences_test_all,
  797. };
  798. const struct s2n_security_policy security_policy_test_ecdsa_priority = {
  799. .minimum_protocol_version = S2N_SSLv3,
  800. .cipher_preferences = &cipher_preferences_test_ecdsa_priority,
  801. .kem_preferences = &kem_preferences_null,
  802. .signature_preferences = &s2n_signature_preferences_20201021,
  803. .ecc_preferences = &s2n_ecc_preferences_test_all,
  804. };
  805. const struct s2n_security_policy security_policy_null = {
  806. .minimum_protocol_version = S2N_TLS10,
  807. .cipher_preferences = &cipher_preferences_null,
  808. .kem_preferences = &kem_preferences_null,
  809. .signature_preferences = &s2n_signature_preferences_null,
  810. .ecc_preferences = &s2n_ecc_preferences_null,
  811. };
  812. struct s2n_security_policy_selection security_policy_selection[] = {
  813. { .version = "default", .security_policy = &security_policy_20170210, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  814. { .version = "default_tls13", .security_policy = &security_policy_default_tls13, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  815. { .version = "default_fips", .security_policy = &security_policy_default_fips, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  816. { .version = "20230317", .security_policy = &security_policy_20230317, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  817. { .version = "ELBSecurityPolicy-TLS-1-0-2015-04", .security_policy = &security_policy_elb_2015_04, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  818. /* Not a mistake. TLS-1-0-2015-05 and 2016-08 are equivalent */
  819. { .version = "ELBSecurityPolicy-TLS-1-0-2015-05", .security_policy = &security_policy_elb_2016_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  820. { .version = "ELBSecurityPolicy-2016-08", .security_policy = &security_policy_elb_2016_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  821. { .version = "ELBSecurityPolicy-TLS-1-1-2017-01", .security_policy = &security_policy_elb_tls_1_1_2017_01, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  822. { .version = "ELBSecurityPolicy-TLS-1-2-2017-01", .security_policy = &security_policy_elb_tls_1_2_2017_01, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  823. { .version = "ELBSecurityPolicy-TLS-1-2-Ext-2018-06", .security_policy = &security_policy_elb_tls_1_2_ext_2018_06, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  824. { .version = "ELBSecurityPolicy-FS-2018-06", .security_policy = &security_policy_elb_fs_2018_06, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  825. { .version = "ELBSecurityPolicy-FS-1-2-2019-08", .security_policy = &security_policy_elb_fs_1_2_2019_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  826. { .version = "ELBSecurityPolicy-FS-1-1-2019-08", .security_policy = &security_policy_elb_fs_1_1_2019_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  827. { .version = "ELBSecurityPolicy-FS-1-2-Res-2019-08", .security_policy = &security_policy_elb_fs_1_2_Res_2019_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  828. { .version = "CloudFront-Upstream", .security_policy = &security_policy_cloudfront_upstream, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  829. { .version = "CloudFront-Upstream-TLS-1-0", .security_policy = &security_policy_cloudfront_upstream_tls10, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  830. { .version = "CloudFront-Upstream-TLS-1-1", .security_policy = &security_policy_cloudfront_upstream_tls11, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  831. { .version = "CloudFront-Upstream-TLS-1-2", .security_policy = &security_policy_cloudfront_upstream_tls12, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  832. /* CloudFront Viewer Facing */
  833. { .version = "CloudFront-SSL-v-3", .security_policy = &security_policy_cloudfront_ssl_v_3, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  834. { .version = "CloudFront-TLS-1-0-2014", .security_policy = &security_policy_cloudfront_tls_1_0_2014, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  835. { .version = "CloudFront-TLS-1-0-2016", .security_policy = &security_policy_cloudfront_tls_1_0_2016, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  836. { .version = "CloudFront-TLS-1-1-2016", .security_policy = &security_policy_cloudfront_tls_1_1_2016, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  837. { .version = "CloudFront-TLS-1-2-2017", .security_policy = &security_policy_cloudfront_tls_1_2_2017, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  838. { .version = "CloudFront-TLS-1-2-2018", .security_policy = &security_policy_cloudfront_tls_1_2_2018, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  839. { .version = "CloudFront-TLS-1-2-2019", .security_policy = &security_policy_cloudfront_tls_1_2_2019, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  840. { .version = "CloudFront-TLS-1-2-2021", .security_policy = &security_policy_cloudfront_tls_1_2_2021, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  841. { .version = "CloudFront-TLS-1-2-2021-Chacha20-Boosted", .security_policy = &security_policy_cloudfront_tls_1_2_2021_chacha20_boosted, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  842. /* CloudFront Legacy (TLS 1.2) policies */
  843. { .version = "CloudFront-SSL-v-3-Legacy", .security_policy = &security_policy_cloudfront_ssl_v_3_legacy, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  844. { .version = "CloudFront-TLS-1-0-2014-Legacy", .security_policy = &security_policy_cloudfront_tls_1_0_2014_legacy, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  845. { .version = "CloudFront-TLS-1-0-2016-Legacy", .security_policy = &security_policy_cloudfront_tls_1_0_2016_legacy, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  846. { .version = "CloudFront-TLS-1-1-2016-Legacy", .security_policy = &security_policy_cloudfront_tls_1_1_2016_legacy, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  847. { .version = "CloudFront-TLS-1-2-2018-Legacy", .security_policy = &security_policy_cloudfront_tls_1_2_2018_legacy, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  848. { .version = "CloudFront-TLS-1-2-2019-Legacy", .security_policy = &security_policy_cloudfront_tls_1_2_2019_legacy, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  849. /* CRT allows users to choose the minimal TLS protocol they want to negotiate with. This translates to 5 different security policies in s2n */
  850. { .version = "AWS-CRT-SDK-SSLv3.0", .security_policy = &security_policy_aws_crt_sdk_ssl_v3, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  851. { .version = "AWS-CRT-SDK-TLSv1.0", .security_policy = &security_policy_aws_crt_sdk_tls_10, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  852. { .version = "AWS-CRT-SDK-TLSv1.1", .security_policy = &security_policy_aws_crt_sdk_tls_11, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  853. { .version = "AWS-CRT-SDK-TLSv1.2", .security_policy = &security_policy_aws_crt_sdk_tls_12, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  854. { .version = "AWS-CRT-SDK-TLSv1.3", .security_policy = &security_policy_aws_crt_sdk_tls_13, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  855. { .version = "AWS-CRT-SDK-SSLv3.0-2023", .security_policy = &security_policy_aws_crt_sdk_ssl_v3_06_23, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  856. { .version = "AWS-CRT-SDK-TLSv1.0-2023", .security_policy = &security_policy_aws_crt_sdk_tls_10_06_23, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  857. { .version = "AWS-CRT-SDK-TLSv1.1-2023", .security_policy = &security_policy_aws_crt_sdk_tls_11_06_23, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  858. { .version = "AWS-CRT-SDK-TLSv1.2-2023", .security_policy = &security_policy_aws_crt_sdk_tls_12_06_23, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  859. { .version = "AWS-CRT-SDK-TLSv1.3-2023", .security_policy = &security_policy_aws_crt_sdk_tls_13_06_23, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  860. /* KMS TLS Policies*/
  861. { .version = "KMS-TLS-1-0-2018-10", .security_policy = &security_policy_kms_tls_1_0_2018_10, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  862. { .version = "KMS-TLS-1-0-2021-08", .security_policy = &security_policy_kms_tls_1_0_2021_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  863. { .version = "KMS-TLS-1-2-2023-06", .security_policy = &security_policy_kms_tls_1_2_2023_06, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  864. { .version = "KMS-FIPS-TLS-1-2-2018-10", .security_policy = &security_policy_kms_fips_tls_1_2_2018_10, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  865. { .version = "KMS-FIPS-TLS-1-2-2021-08", .security_policy = &security_policy_kms_fips_tls_1_2_2021_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  866. { .version = "KMS-PQ-TLS-1-0-2019-06", .security_policy = &security_policy_kms_pq_tls_1_0_2019_06, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  867. { .version = "KMS-PQ-TLS-1-0-2020-02", .security_policy = &security_policy_kms_pq_tls_1_0_2020_02, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  868. { .version = "KMS-PQ-TLS-1-0-2020-07", .security_policy = &security_policy_kms_pq_tls_1_0_2020_07, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  869. { .version = "PQ-SIKE-TEST-TLS-1-0-2019-11", .security_policy = &security_policy_pq_sike_test_tls_1_0_2019_11, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  870. { .version = "PQ-SIKE-TEST-TLS-1-0-2020-02", .security_policy = &security_policy_pq_sike_test_tls_1_0_2020_02, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  871. { .version = "PQ-TLS-1-0-2020-12", .security_policy = &security_policy_pq_tls_1_0_2020_12, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  872. { .version = "PQ-TLS-1-1-2021-05-17", .security_policy = &security_policy_pq_tls_1_1_2021_05_17, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  873. { .version = "PQ-TLS-1-0-2021-05-18", .security_policy = &security_policy_pq_tls_1_0_2021_05_18, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  874. { .version = "PQ-TLS-1-0-2021-05-19", .security_policy = &security_policy_pq_tls_1_0_2021_05_19, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  875. { .version = "PQ-TLS-1-0-2021-05-20", .security_policy = &security_policy_pq_tls_1_0_2021_05_20, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  876. { .version = "PQ-TLS-1-1-2021-05-21", .security_policy = &security_policy_pq_tls_1_1_2021_05_21, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  877. { .version = "PQ-TLS-1-0-2021-05-22", .security_policy = &security_policy_pq_tls_1_0_2021_05_22, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  878. { .version = "PQ-TLS-1-0-2021-05-23", .security_policy = &security_policy_pq_tls_1_0_2021_05_23, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  879. { .version = "PQ-TLS-1-0-2021-05-24", .security_policy = &security_policy_pq_tls_1_0_2021_05_24, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  880. { .version = "PQ-TLS-1-0-2021-05-25", .security_policy = &security_policy_pq_tls_1_0_2021_05_25, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  881. { .version = "PQ-TLS-1-0-2021-05-26", .security_policy = &security_policy_pq_tls_1_0_2021_05_26, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  882. { .version = "PQ-TLS-1-0-2023-01-24", .security_policy = &security_policy_pq_tls_1_0_2023_01_24, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  883. { .version = "PQ-TLS-1-2-2023-04-07", .security_policy = &security_policy_pq_tls_1_2_2023_04_07, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  884. { .version = "PQ-TLS-1-2-2023-04-08", .security_policy = &security_policy_pq_tls_1_2_2023_04_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  885. { .version = "PQ-TLS-1-2-2023-04-09", .security_policy = &security_policy_pq_tls_1_2_2023_04_09, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  886. { .version = "PQ-TLS-1-2-2023-04-10", .security_policy = &security_policy_pq_tls_1_2_2023_04_10, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  887. { .version = "PQ-TLS-1-3-2023-06-01", .security_policy = &security_policy_pq_tls_1_3_2023_06_01, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  888. { .version = "PQ-TLS-1-2-2023-10-07", .security_policy = &security_policy_pq_tls_1_2_2023_10_07, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  889. { .version = "PQ-TLS-1-2-2023-10-08", .security_policy = &security_policy_pq_tls_1_2_2023_10_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  890. { .version = "PQ-TLS-1-2-2023-10-09", .security_policy = &security_policy_pq_tls_1_2_2023_10_09, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  891. { .version = "PQ-TLS-1-2-2023-10-10", .security_policy = &security_policy_pq_tls_1_2_2023_10_10, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  892. { .version = "20140601", .security_policy = &security_policy_20140601, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  893. { .version = "20141001", .security_policy = &security_policy_20141001, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  894. { .version = "20150202", .security_policy = &security_policy_20150202, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  895. { .version = "20150214", .security_policy = &security_policy_20150214, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  896. { .version = "20150306", .security_policy = &security_policy_20150306, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  897. { .version = "20160411", .security_policy = &security_policy_20160411, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  898. { .version = "20160804", .security_policy = &security_policy_20160804, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  899. { .version = "20160824", .security_policy = &security_policy_20160824, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  900. { .version = "20170210", .security_policy = &security_policy_20170210, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  901. { .version = "20170328", .security_policy = &security_policy_20170328, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  902. { .version = "20170328_gcm", .security_policy = &security_policy_20170328_gcm, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  903. { .version = "20190214", .security_policy = &security_policy_20190214, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  904. { .version = "20190214_gcm", .security_policy = &security_policy_20190214_gcm, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  905. { .version = "20210825", .security_policy = &security_policy_20210825, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  906. { .version = "20210825_gcm", .security_policy = &security_policy_20210825_gcm, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  907. { .version = "20170405", .security_policy = &security_policy_20170405, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  908. { .version = "20170405_gcm", .security_policy = &security_policy_20170405_gcm, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  909. { .version = "20170718", .security_policy = &security_policy_20170718, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  910. { .version = "20170718_gcm", .security_policy = &security_policy_20170718_gcm, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  911. { .version = "20190120", .security_policy = &security_policy_20190120, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  912. { .version = "20190121", .security_policy = &security_policy_20190121, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  913. { .version = "20190122", .security_policy = &security_policy_20190122, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  914. { .version = "20190801", .security_policy = &security_policy_20190801, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  915. { .version = "20190802", .security_policy = &security_policy_20190802, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  916. { .version = "20200207", .security_policy = &security_policy_test_all_tls13, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  917. { .version = "20201021", .security_policy = &security_policy_20201021, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  918. { .version = "20210816", .security_policy = &security_policy_20210816, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  919. { .version = "20210816_GCM", .security_policy = &security_policy_20210816_gcm, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  920. { .version = "rfc9151", .security_policy = &security_policy_rfc9151, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  921. { .version = "test_all", .security_policy = &security_policy_test_all, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  922. { .version = "test_all_fips", .security_policy = &security_policy_test_all_fips, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  923. { .version = "test_all_ecdsa", .security_policy = &security_policy_test_all_ecdsa, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  924. { .version = "test_all_rsa_kex", .security_policy = &security_policy_test_all_rsa_kex, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  925. { .version = "test_ecdsa_priority", .security_policy = &security_policy_test_ecdsa_priority, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  926. { .version = "test_all_tls12", .security_policy = &security_policy_test_all_tls12, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  927. { .version = "test_all_tls13", .security_policy = &security_policy_test_all_tls13, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  928. { .version = "null", .security_policy = &security_policy_null, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
  929. { .version = NULL, .security_policy = NULL, .ecc_extension_required = 0, .pq_kem_extension_required = 0 }
  930. };
  931. int s2n_find_security_policy_from_version(const char *version, const struct s2n_security_policy **security_policy)
  932. {
  933. POSIX_ENSURE_REF(version);
  934. POSIX_ENSURE_REF(security_policy);
  935. for (int i = 0; security_policy_selection[i].version != NULL; i++) {
  936. if (!strcasecmp(version, security_policy_selection[i].version)) {
  937. *security_policy = security_policy_selection[i].security_policy;
  938. return 0;
  939. }
  940. }
  941. POSIX_BAIL(S2N_ERR_INVALID_SECURITY_POLICY);
  942. }
  943. int s2n_config_set_cipher_preferences(struct s2n_config *config, const char *version)
  944. {
  945. const struct s2n_security_policy *security_policy = NULL;
  946. POSIX_GUARD(s2n_find_security_policy_from_version(version, &security_policy));
  947. POSIX_ENSURE_REF(security_policy);
  948. POSIX_ENSURE_REF(security_policy->cipher_preferences);
  949. POSIX_ENSURE_REF(security_policy->kem_preferences);
  950. POSIX_ENSURE_REF(security_policy->signature_preferences);
  951. POSIX_ENSURE_REF(security_policy->ecc_preferences);
  952. /* If the security policy's minimum version is higher than what libcrypto supports, return an error. */
  953. POSIX_ENSURE((security_policy->minimum_protocol_version <= s2n_get_highest_fully_supported_tls_version()), S2N_ERR_PROTOCOL_VERSION_UNSUPPORTED);
  954. config->security_policy = security_policy;
  955. return 0;
  956. }
  957. int s2n_connection_set_cipher_preferences(struct s2n_connection *conn, const char *version)
  958. {
  959. const struct s2n_security_policy *security_policy = NULL;
  960. POSIX_GUARD(s2n_find_security_policy_from_version(version, &security_policy));
  961. POSIX_ENSURE_REF(security_policy);
  962. POSIX_ENSURE_REF(security_policy->cipher_preferences);
  963. POSIX_ENSURE_REF(security_policy->kem_preferences);
  964. POSIX_ENSURE_REF(security_policy->signature_preferences);
  965. POSIX_ENSURE_REF(security_policy->ecc_preferences);
  966. /* If the security policy's minimum version is higher than what libcrypto supports, return an error. */
  967. POSIX_ENSURE((security_policy->minimum_protocol_version <= s2n_get_highest_fully_supported_tls_version()), S2N_ERR_PROTOCOL_VERSION_UNSUPPORTED);
  968. conn->security_policy_override = security_policy;
  969. return 0;
  970. }
  971. int s2n_security_policies_init()
  972. {
  973. for (int i = 0; security_policy_selection[i].version != NULL; i++) {
  974. const struct s2n_security_policy *security_policy = security_policy_selection[i].security_policy;
  975. POSIX_ENSURE_REF(security_policy);
  976. const struct s2n_cipher_preferences *cipher_preference = security_policy->cipher_preferences;
  977. POSIX_ENSURE_REF(cipher_preference);
  978. const struct s2n_kem_preferences *kem_preference = security_policy->kem_preferences;
  979. POSIX_ENSURE_REF(kem_preference);
  980. const struct s2n_ecc_preferences *ecc_preference = security_policy->ecc_preferences;
  981. POSIX_ENSURE_REF(ecc_preference);
  982. POSIX_GUARD(s2n_check_ecc_preferences_curves_list(ecc_preference));
  983. const struct s2n_signature_preferences *certificate_signature_preference = security_policy->certificate_signature_preferences;
  984. if (certificate_signature_preference != NULL) {
  985. POSIX_GUARD_RESULT(s2n_validate_certificate_signature_preferences(certificate_signature_preference));
  986. }
  987. if (security_policy != &security_policy_null) {
  988. /* All policies must have at least one ecc curve configured. */
  989. S2N_ERROR_IF(ecc_preference->count == 0, S2N_ERR_INVALID_SECURITY_POLICY);
  990. }
  991. for (int j = 0; j < cipher_preference->count; j++) {
  992. struct s2n_cipher_suite *cipher = cipher_preference->suites[j];
  993. POSIX_ENSURE_REF(cipher);
  994. const uint8_t *iana = cipher->iana_value;
  995. if (cipher->minimum_required_tls_version >= S2N_TLS13) {
  996. security_policy_selection[i].supports_tls13 = 1;
  997. }
  998. /* Sanity check that valid tls13 has minimum tls version set correctly */
  999. S2N_ERROR_IF(s2n_is_valid_tls13_cipher(iana) ^ (cipher->minimum_required_tls_version >= S2N_TLS13),
  1000. S2N_ERR_INVALID_SECURITY_POLICY);
  1001. if (s2n_cipher_suite_requires_ecc_extension(cipher)) {
  1002. security_policy_selection[i].ecc_extension_required = 1;
  1003. }
  1004. if (s2n_cipher_suite_requires_pq_extension(cipher) && kem_preference->kem_count > 0) {
  1005. security_policy_selection[i].pq_kem_extension_required = 1;
  1006. }
  1007. }
  1008. POSIX_GUARD(s2n_validate_kem_preferences(kem_preference, security_policy_selection[i].pq_kem_extension_required));
  1009. }
  1010. return 0;
  1011. }
  1012. bool s2n_ecc_is_extension_required(const struct s2n_security_policy *security_policy)
  1013. {
  1014. if (security_policy == NULL) {
  1015. return false;
  1016. }
  1017. for (int i = 0; security_policy_selection[i].version != NULL; i++) {
  1018. if (security_policy_selection[i].security_policy == security_policy) {
  1019. return 1 == security_policy_selection[i].ecc_extension_required;
  1020. }
  1021. }
  1022. /* If cipher preference is not in the official list, compute the result */
  1023. const struct s2n_cipher_preferences *cipher_preferences = security_policy->cipher_preferences;
  1024. if (cipher_preferences == NULL) {
  1025. return false;
  1026. }
  1027. for (uint8_t i = 0; i < cipher_preferences->count; i++) {
  1028. if (s2n_cipher_suite_requires_ecc_extension(cipher_preferences->suites[i])) {
  1029. return true;
  1030. }
  1031. }
  1032. return false;
  1033. }
  1034. bool s2n_pq_kem_is_extension_required(const struct s2n_security_policy *security_policy)
  1035. {
  1036. if (security_policy == NULL) {
  1037. return false;
  1038. }
  1039. for (int i = 0; security_policy_selection[i].version != NULL; i++) {
  1040. if (security_policy_selection[i].security_policy == security_policy) {
  1041. return 1 == security_policy_selection[i].pq_kem_extension_required;
  1042. }
  1043. }
  1044. /* Preferences with no KEMs for the TLS 1.2 PQ KEM extension do not require that extension. */
  1045. if (security_policy->kem_preferences && security_policy->kem_preferences->kem_count == 0) {
  1046. return false;
  1047. }
  1048. /* If cipher preference is not in the official list, compute the result */
  1049. const struct s2n_cipher_preferences *cipher_preferences = security_policy->cipher_preferences;
  1050. if (cipher_preferences == NULL) {
  1051. return false;
  1052. }
  1053. for (uint8_t i = 0; i < cipher_preferences->count; i++) {
  1054. if (s2n_cipher_suite_requires_pq_extension(cipher_preferences->suites[i])) {
  1055. return true;
  1056. }
  1057. }
  1058. return false;
  1059. }
  1060. /* Checks whether cipher preference supports TLS 1.3 based on whether it is configured
  1061. * with TLS 1.3 ciphers. Returns true or false.
  1062. */
  1063. bool s2n_security_policy_supports_tls13(const struct s2n_security_policy *security_policy)
  1064. {
  1065. if (security_policy == NULL) {
  1066. return false;
  1067. }
  1068. for (uint8_t i = 0; security_policy_selection[i].version != NULL; i++) {
  1069. if (security_policy_selection[i].security_policy == security_policy) {
  1070. return security_policy_selection[i].supports_tls13 == 1;
  1071. }
  1072. }
  1073. /* if cipher preference is not in the official list, compute the result */
  1074. const struct s2n_cipher_preferences *cipher_preferences = security_policy->cipher_preferences;
  1075. if (cipher_preferences == NULL) {
  1076. return false;
  1077. }
  1078. for (uint8_t i = 0; i < cipher_preferences->count; i++) {
  1079. if (cipher_preferences->suites[i]->minimum_required_tls_version >= S2N_TLS13) {
  1080. return true;
  1081. }
  1082. }
  1083. return false;
  1084. }
  1085. int s2n_connection_is_valid_for_cipher_preferences(struct s2n_connection *conn, const char *version)
  1086. {
  1087. POSIX_ENSURE_REF(conn);
  1088. POSIX_ENSURE_REF(version);
  1089. POSIX_ENSURE_REF(conn->secure);
  1090. POSIX_ENSURE_REF(conn->secure->cipher_suite);
  1091. const struct s2n_security_policy *security_policy = NULL;
  1092. POSIX_GUARD(s2n_find_security_policy_from_version(version, &security_policy));
  1093. POSIX_ENSURE_REF(security_policy);
  1094. /* make sure we dont use a tls version lower than that configured by the version */
  1095. if (s2n_connection_get_actual_protocol_version(conn) < security_policy->minimum_protocol_version) {
  1096. return 0;
  1097. }
  1098. struct s2n_cipher_suite *cipher = conn->secure->cipher_suite;
  1099. POSIX_ENSURE_REF(cipher);
  1100. for (int i = 0; i < security_policy->cipher_preferences->count; ++i) {
  1101. if (0 == memcmp(security_policy->cipher_preferences->suites[i]->iana_value, cipher->iana_value, S2N_TLS_CIPHER_SUITE_LEN)) {
  1102. return 1;
  1103. }
  1104. }
  1105. return 0;
  1106. }
  1107. int s2n_validate_kem_preferences(const struct s2n_kem_preferences *kem_preferences, bool pq_kem_extension_required)
  1108. {
  1109. POSIX_ENSURE_REF(kem_preferences);
  1110. /* Basic sanity checks to assert that the count is 0 if and only if the associated list is NULL */
  1111. POSIX_ENSURE(S2N_IFF(kem_preferences->tls13_kem_group_count == 0, kem_preferences->tls13_kem_groups == NULL),
  1112. S2N_ERR_INVALID_SECURITY_POLICY);
  1113. POSIX_ENSURE(S2N_IFF(kem_preferences->kem_count == 0, kem_preferences->kems == NULL),
  1114. S2N_ERR_INVALID_SECURITY_POLICY);
  1115. POSIX_ENSURE(kem_preferences->tls13_kem_group_count <= S2N_SUPPORTED_KEM_GROUPS_COUNT, S2N_ERR_ARRAY_INDEX_OOB);
  1116. /* The PQ KEM extension is applicable only to TLS 1.2 */
  1117. if (pq_kem_extension_required) {
  1118. POSIX_ENSURE(kem_preferences->kem_count > 0, S2N_ERR_INVALID_SECURITY_POLICY);
  1119. POSIX_ENSURE(kem_preferences->kems != NULL, S2N_ERR_INVALID_SECURITY_POLICY);
  1120. } else {
  1121. POSIX_ENSURE(kem_preferences->kem_count == 0, S2N_ERR_INVALID_SECURITY_POLICY);
  1122. POSIX_ENSURE(kem_preferences->kems == NULL, S2N_ERR_INVALID_SECURITY_POLICY);
  1123. }
  1124. return S2N_SUCCESS;
  1125. }
  1126. S2N_RESULT s2n_validate_certificate_signature_preferences(const struct s2n_signature_preferences *certificate_signature_preferences)
  1127. {
  1128. RESULT_ENSURE_REF(certificate_signature_preferences);
  1129. size_t rsa_pss_scheme_count = 0;
  1130. for (size_t i = 0; i < certificate_signature_preferences->count; i++) {
  1131. if (certificate_signature_preferences->signature_schemes[i]->libcrypto_nid == NID_rsassaPss) {
  1132. rsa_pss_scheme_count++;
  1133. }
  1134. }
  1135. /*
  1136. * https://github.com/aws/s2n-tls/issues/3435
  1137. *
  1138. * The Openssl function used to parse signatures off certificates does not differentiate between any rsa pss
  1139. * signature schemes. Therefore a security policy with a certificate signatures preference list must include
  1140. * all rsa_pss signature schemes. */
  1141. RESULT_ENSURE(rsa_pss_scheme_count == NUM_RSA_PSS_SCHEMES || rsa_pss_scheme_count == 0, S2N_ERR_INVALID_SECURITY_POLICY);
  1142. return S2N_RESULT_OK;
  1143. }