s2n_signature_scheme.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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_signature_scheme.h"
  16. #include "api/s2n.h"
  17. #include "crypto/s2n_ecc_evp.h"
  18. #include "crypto/s2n_hash.h"
  19. #include "crypto/s2n_signature.h"
  20. #include "tls/s2n_connection.h"
  21. #include "utils/s2n_safety.h"
  22. const struct s2n_signature_scheme s2n_null_sig_scheme = {
  23. .iana_value = 0,
  24. .hash_alg = S2N_HASH_NONE,
  25. .sig_alg = S2N_SIGNATURE_ANONYMOUS,
  26. .libcrypto_nid = 0,
  27. .signature_curve = NULL,
  28. .maximum_protocol_version = 0,
  29. };
  30. /* RSA PKCS1 */
  31. const struct s2n_signature_scheme s2n_rsa_pkcs1_md5_sha1 = {
  32. .iana_value = TLS_SIGNATURE_SCHEME_PRIVATE_INTERNAL_RSA_PKCS1_MD5_SHA1,
  33. .hash_alg = S2N_HASH_MD5_SHA1,
  34. .sig_alg = S2N_SIGNATURE_RSA,
  35. .libcrypto_nid = NID_md5_sha1,
  36. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  37. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 does not support pkcs1 or sha1 */
  38. };
  39. const struct s2n_signature_scheme s2n_rsa_pkcs1_sha1 = {
  40. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PKCS1_SHA1,
  41. .hash_alg = S2N_HASH_SHA1,
  42. .sig_alg = S2N_SIGNATURE_RSA,
  43. .libcrypto_nid = NID_sha1WithRSAEncryption,
  44. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  45. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 does not support pkcs1 or sha1 */
  46. };
  47. const struct s2n_signature_scheme s2n_rsa_pkcs1_sha224 = {
  48. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PKCS1_SHA224,
  49. .hash_alg = S2N_HASH_SHA224,
  50. .sig_alg = S2N_SIGNATURE_RSA,
  51. .libcrypto_nid = NID_sha224WithRSAEncryption,
  52. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  53. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 does not support pkcs1 */
  54. };
  55. const struct s2n_signature_scheme s2n_rsa_pkcs1_sha256 = {
  56. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PKCS1_SHA256,
  57. .hash_alg = S2N_HASH_SHA256,
  58. .sig_alg = S2N_SIGNATURE_RSA,
  59. .libcrypto_nid = NID_sha256WithRSAEncryption,
  60. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  61. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 does not support pkcs1 */
  62. };
  63. const struct s2n_signature_scheme s2n_rsa_pkcs1_sha384 = {
  64. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PKCS1_SHA384,
  65. .hash_alg = S2N_HASH_SHA384,
  66. .sig_alg = S2N_SIGNATURE_RSA,
  67. .libcrypto_nid = NID_sha384WithRSAEncryption,
  68. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  69. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 does not support pkcs1 */
  70. };
  71. const struct s2n_signature_scheme s2n_rsa_pkcs1_sha512 = {
  72. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PKCS1_SHA512,
  73. .hash_alg = S2N_HASH_SHA512,
  74. .sig_alg = S2N_SIGNATURE_RSA,
  75. .libcrypto_nid = NID_sha512WithRSAEncryption,
  76. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  77. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 does not support pkcs1 */
  78. };
  79. /* TLS 1.2 Compatible ECDSA Signature Schemes */
  80. const struct s2n_signature_scheme s2n_ecdsa_sha1 = {
  81. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SHA1,
  82. .hash_alg = S2N_HASH_SHA1,
  83. .sig_alg = S2N_SIGNATURE_ECDSA,
  84. .libcrypto_nid = NID_ecdsa_with_SHA1,
  85. .signature_curve = NULL, /* Decided by supported_groups Extension in TLS 1.2 and before */
  86. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 does not support sha1 and requires a signature curve */
  87. };
  88. const struct s2n_signature_scheme s2n_ecdsa_sha224 = {
  89. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SHA224,
  90. .hash_alg = S2N_HASH_SHA224,
  91. .sig_alg = S2N_SIGNATURE_ECDSA,
  92. .libcrypto_nid = NID_ecdsa_with_SHA224,
  93. .signature_curve = NULL, /* Decided by supported_groups Extension in TLS 1.2 and before */
  94. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 requires a signature curve */
  95. };
  96. const struct s2n_signature_scheme s2n_ecdsa_sha256 = {
  97. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SHA256,
  98. .hash_alg = S2N_HASH_SHA256,
  99. .sig_alg = S2N_SIGNATURE_ECDSA,
  100. .libcrypto_nid = NID_ecdsa_with_SHA256,
  101. .signature_curve = NULL, /* Decided by supported_groups Extension in TLS 1.2 and before */
  102. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 requires a signature curve */
  103. };
  104. const struct s2n_signature_scheme s2n_ecdsa_sha384 = {
  105. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SHA384,
  106. .hash_alg = S2N_HASH_SHA384,
  107. .sig_alg = S2N_SIGNATURE_ECDSA,
  108. .libcrypto_nid = NID_ecdsa_with_SHA384,
  109. .signature_curve = NULL, /* Decided by supported_groups Extension in TLS 1.2 and before */
  110. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 requires a signature curve */
  111. };
  112. const struct s2n_signature_scheme s2n_ecdsa_sha512 = {
  113. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SHA512,
  114. .hash_alg = S2N_HASH_SHA512,
  115. .sig_alg = S2N_SIGNATURE_ECDSA,
  116. .libcrypto_nid = NID_ecdsa_with_SHA512,
  117. .signature_curve = NULL, /* Decided by supported_groups Extension in TLS 1.2 and before */
  118. .maximum_protocol_version = S2N_TLS12, /* TLS1.3 requires a signature curve */
  119. };
  120. /* TLS 1.3 Compatible ECDSA Schemes */
  121. /* In TLS 1.3 the two byte IANA value also defines the Curve to use for signing */
  122. const struct s2n_signature_scheme s2n_ecdsa_secp256r1_sha256 = {
  123. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SECP256R1_SHA256,
  124. .hash_alg = S2N_HASH_SHA256,
  125. .sig_alg = S2N_SIGNATURE_ECDSA,
  126. .libcrypto_nid = NID_ecdsa_with_SHA256,
  127. .signature_curve = &s2n_ecc_curve_secp256r1, /* Hardcoded as of TLS 1.3 */
  128. .minimum_protocol_version = S2N_TLS13,
  129. };
  130. const struct s2n_signature_scheme s2n_ecdsa_secp384r1_sha384 = {
  131. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SECP384R1_SHA384,
  132. .hash_alg = S2N_HASH_SHA384,
  133. .sig_alg = S2N_SIGNATURE_ECDSA,
  134. .libcrypto_nid = NID_ecdsa_with_SHA384,
  135. .signature_curve = &s2n_ecc_curve_secp384r1, /* Hardcoded as of TLS 1.3 */
  136. .minimum_protocol_version = S2N_TLS13,
  137. };
  138. const struct s2n_signature_scheme s2n_ecdsa_secp521r1_sha512 = {
  139. .iana_value = TLS_SIGNATURE_SCHEME_ECDSA_SECP521R1_SHA512,
  140. .hash_alg = S2N_HASH_SHA512,
  141. .sig_alg = S2N_SIGNATURE_ECDSA,
  142. .libcrypto_nid = NID_ecdsa_with_SHA512,
  143. .signature_curve = &s2n_ecc_curve_secp521r1, /* Hardcoded as of TLS 1.3 */
  144. .minimum_protocol_version = S2N_TLS13,
  145. };
  146. /**
  147. * RSA-PSS-RSAE
  148. */
  149. const struct s2n_signature_scheme s2n_rsa_pss_rsae_sha256 = {
  150. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PSS_RSAE_SHA256,
  151. .hash_alg = S2N_HASH_SHA256,
  152. .sig_alg = S2N_SIGNATURE_RSA_PSS_RSAE,
  153. .libcrypto_nid = NID_rsassaPss,
  154. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  155. };
  156. const struct s2n_signature_scheme s2n_rsa_pss_rsae_sha384 = {
  157. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PSS_RSAE_SHA384,
  158. .hash_alg = S2N_HASH_SHA384,
  159. .sig_alg = S2N_SIGNATURE_RSA_PSS_RSAE,
  160. .libcrypto_nid = NID_rsassaPss,
  161. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  162. };
  163. const struct s2n_signature_scheme s2n_rsa_pss_rsae_sha512 = {
  164. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PSS_RSAE_SHA512,
  165. .hash_alg = S2N_HASH_SHA512,
  166. .sig_alg = S2N_SIGNATURE_RSA_PSS_RSAE,
  167. .libcrypto_nid = NID_rsassaPss,
  168. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  169. };
  170. /**
  171. * RSA-PSS-PSS
  172. */
  173. const struct s2n_signature_scheme s2n_rsa_pss_pss_sha256 = {
  174. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PSS_PSS_SHA256,
  175. .hash_alg = S2N_HASH_SHA256,
  176. .sig_alg = S2N_SIGNATURE_RSA_PSS_PSS,
  177. .libcrypto_nid = NID_rsassaPss,
  178. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  179. .minimum_protocol_version = S2N_TLS13,
  180. };
  181. const struct s2n_signature_scheme s2n_rsa_pss_pss_sha384 = {
  182. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PSS_PSS_SHA384,
  183. .hash_alg = S2N_HASH_SHA384,
  184. .sig_alg = S2N_SIGNATURE_RSA_PSS_PSS,
  185. .libcrypto_nid = NID_rsassaPss,
  186. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  187. .minimum_protocol_version = S2N_TLS13,
  188. };
  189. const struct s2n_signature_scheme s2n_rsa_pss_pss_sha512 = {
  190. .iana_value = TLS_SIGNATURE_SCHEME_RSA_PSS_PSS_SHA512,
  191. .hash_alg = S2N_HASH_SHA512,
  192. .sig_alg = S2N_SIGNATURE_RSA_PSS_PSS,
  193. .libcrypto_nid = NID_rsassaPss,
  194. .signature_curve = NULL, /* Elliptic Curve not needed for RSA */
  195. .minimum_protocol_version = S2N_TLS13,
  196. };
  197. /* All Supported SignatureSchemes. */
  198. /* No MD5 to avoid SLOTH Vulnerability */
  199. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_20140601[] = {
  200. /* RSA PKCS1 */
  201. &s2n_rsa_pkcs1_sha256,
  202. &s2n_rsa_pkcs1_sha384,
  203. &s2n_rsa_pkcs1_sha512,
  204. &s2n_rsa_pkcs1_sha224,
  205. /* ECDSA - TLS 1.2 */
  206. &s2n_ecdsa_sha256, /* same iana value as TLS 1.3 s2n_ecdsa_secp256r1_sha256 */
  207. &s2n_ecdsa_secp256r1_sha256,
  208. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  209. &s2n_ecdsa_secp384r1_sha384,
  210. &s2n_ecdsa_sha512,
  211. &s2n_ecdsa_sha224,
  212. /* SHA-1 Legacy */
  213. &s2n_rsa_pkcs1_sha1,
  214. &s2n_ecdsa_sha1,
  215. };
  216. /* The original preference list, but with rsa_pss supported. */
  217. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_20200207[] = {
  218. /* RSA PSS */
  219. &s2n_rsa_pss_pss_sha256,
  220. &s2n_rsa_pss_pss_sha384,
  221. &s2n_rsa_pss_pss_sha512,
  222. &s2n_rsa_pss_rsae_sha256,
  223. &s2n_rsa_pss_rsae_sha384,
  224. &s2n_rsa_pss_rsae_sha512,
  225. /* RSA PKCS1 */
  226. &s2n_rsa_pkcs1_sha256,
  227. &s2n_rsa_pkcs1_sha384,
  228. &s2n_rsa_pkcs1_sha512,
  229. &s2n_rsa_pkcs1_sha224,
  230. /* ECDSA - TLS 1.2 */
  231. &s2n_ecdsa_sha256, /* same iana value as TLS 1.3 s2n_ecdsa_secp256r1_sha256 */
  232. &s2n_ecdsa_secp256r1_sha256,
  233. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  234. &s2n_ecdsa_secp384r1_sha384,
  235. &s2n_ecdsa_sha512,
  236. &s2n_ecdsa_sha224,
  237. /* SHA-1 Legacy */
  238. &s2n_rsa_pkcs1_sha1,
  239. &s2n_ecdsa_sha1,
  240. };
  241. /*
  242. * These signature schemes were chosen based on the following specification:
  243. * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-52r2.pdf
  244. */
  245. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_default_fips[] = {
  246. /* RSA PKCS1 - TLS1.2 */
  247. &s2n_rsa_pkcs1_sha256,
  248. &s2n_rsa_pkcs1_sha384,
  249. &s2n_rsa_pkcs1_sha512,
  250. /* ECDSA - TLS 1.2 */
  251. &s2n_ecdsa_sha256, /* same iana value as TLS 1.3 s2n_ecdsa_secp256r1_sha256 */
  252. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  253. &s2n_ecdsa_sha512,
  254. &s2n_ecdsa_sha224,
  255. };
  256. const struct s2n_signature_preferences s2n_signature_preferences_default_fips = {
  257. .count = s2n_array_len(s2n_sig_scheme_pref_list_default_fips),
  258. .signature_schemes = s2n_sig_scheme_pref_list_default_fips,
  259. };
  260. /*
  261. * FIPS compliant.
  262. * Supports TLS1.3.
  263. * Prefers PSS over PKCS1.
  264. */
  265. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_20230317[] = {
  266. /* RSA */
  267. &s2n_rsa_pss_rsae_sha256,
  268. &s2n_rsa_pss_rsae_sha384,
  269. &s2n_rsa_pss_rsae_sha512,
  270. &s2n_rsa_pkcs1_sha256,
  271. &s2n_rsa_pkcs1_sha384,
  272. &s2n_rsa_pkcs1_sha512,
  273. /* TLS1.2 with ECDSA */
  274. &s2n_ecdsa_sha256, /* same iana value as TLS 1.3 s2n_ecdsa_secp256r1_sha256 */
  275. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  276. &s2n_ecdsa_sha512,
  277. /* TLS1.3 with ECDSA */
  278. &s2n_ecdsa_secp256r1_sha256,
  279. &s2n_ecdsa_secp384r1_sha384,
  280. &s2n_ecdsa_secp521r1_sha512,
  281. /* TLS1.3 with RSA-PSS */
  282. &s2n_rsa_pss_pss_sha256,
  283. &s2n_rsa_pss_pss_sha384,
  284. &s2n_rsa_pss_pss_sha512,
  285. };
  286. const struct s2n_signature_preferences s2n_signature_preferences_20230317 = {
  287. .count = s2n_array_len(s2n_sig_scheme_pref_list_20230317),
  288. .signature_schemes = s2n_sig_scheme_pref_list_20230317,
  289. };
  290. /* Add s2n_ecdsa_secp521r1_sha512 */
  291. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_20201021[] = {
  292. /* RSA PSS */
  293. &s2n_rsa_pss_pss_sha256,
  294. &s2n_rsa_pss_pss_sha384,
  295. &s2n_rsa_pss_pss_sha512,
  296. &s2n_rsa_pss_rsae_sha256,
  297. &s2n_rsa_pss_rsae_sha384,
  298. &s2n_rsa_pss_rsae_sha512,
  299. /* RSA PKCS1 */
  300. &s2n_rsa_pkcs1_sha256,
  301. &s2n_rsa_pkcs1_sha384,
  302. &s2n_rsa_pkcs1_sha512,
  303. &s2n_rsa_pkcs1_sha224,
  304. /* ECDSA - TLS 1.2 */
  305. &s2n_ecdsa_sha256, /* same iana value as TLS 1.3 s2n_ecdsa_secp256r1_sha256 */
  306. &s2n_ecdsa_secp256r1_sha256,
  307. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  308. &s2n_ecdsa_secp384r1_sha384,
  309. &s2n_ecdsa_sha512, /* same iana value as TLS 1.3 s2n_ecdsa_secp521r1_sha512 */
  310. &s2n_ecdsa_secp521r1_sha512,
  311. &s2n_ecdsa_sha224,
  312. /* SHA-1 Legacy */
  313. &s2n_rsa_pkcs1_sha1,
  314. &s2n_ecdsa_sha1,
  315. };
  316. const struct s2n_signature_preferences s2n_signature_preferences_20140601 = {
  317. .count = s2n_array_len(s2n_sig_scheme_pref_list_20140601),
  318. .signature_schemes = s2n_sig_scheme_pref_list_20140601,
  319. };
  320. const struct s2n_signature_preferences s2n_signature_preferences_20200207 = {
  321. .count = s2n_array_len(s2n_sig_scheme_pref_list_20200207),
  322. .signature_schemes = s2n_sig_scheme_pref_list_20200207,
  323. };
  324. const struct s2n_signature_preferences s2n_signature_preferences_20201021 = {
  325. .count = s2n_array_len(s2n_sig_scheme_pref_list_20201021),
  326. .signature_schemes = s2n_sig_scheme_pref_list_20201021,
  327. };
  328. const struct s2n_signature_preferences s2n_signature_preferences_null = {
  329. .count = 0,
  330. .signature_schemes = NULL,
  331. };
  332. /* TLS1.3 supported signature schemes, without SHA-1 legacy algorithms */
  333. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_20201110[] = {
  334. /* RSA PSS */
  335. &s2n_rsa_pss_pss_sha256,
  336. &s2n_rsa_pss_pss_sha384,
  337. &s2n_rsa_pss_pss_sha512,
  338. &s2n_rsa_pss_rsae_sha256,
  339. &s2n_rsa_pss_rsae_sha384,
  340. &s2n_rsa_pss_rsae_sha512,
  341. /* RSA PKCS1 */
  342. &s2n_rsa_pkcs1_sha256,
  343. &s2n_rsa_pkcs1_sha384,
  344. &s2n_rsa_pkcs1_sha512,
  345. &s2n_rsa_pkcs1_sha224,
  346. /* ECDSA - TLS 1.2 */
  347. &s2n_ecdsa_sha256, /* same iana value as TLS 1.3 s2n_ecdsa_secp256r1_sha256 */
  348. &s2n_ecdsa_secp256r1_sha256,
  349. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  350. &s2n_ecdsa_secp384r1_sha384,
  351. &s2n_ecdsa_sha512,
  352. &s2n_ecdsa_sha224,
  353. };
  354. const struct s2n_signature_preferences s2n_certificate_signature_preferences_20201110 = {
  355. .count = s2n_array_len(s2n_sig_scheme_pref_list_20201110),
  356. .signature_schemes = s2n_sig_scheme_pref_list_20201110,
  357. };
  358. /* Based on s2n_sig_scheme_pref_list_20140601 but with all hashes < SHA-384 removed */
  359. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_20210816[] = {
  360. /* RSA PKCS1 */
  361. &s2n_rsa_pkcs1_sha384,
  362. &s2n_rsa_pkcs1_sha512,
  363. /* ECDSA - TLS 1.2 */
  364. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  365. &s2n_ecdsa_sha512,
  366. };
  367. const struct s2n_signature_preferences s2n_signature_preferences_20210816 = {
  368. .count = s2n_array_len(s2n_sig_scheme_pref_list_20210816),
  369. .signature_schemes = s2n_sig_scheme_pref_list_20210816
  370. };
  371. const struct s2n_signature_scheme* const s2n_sig_scheme_pref_list_rfc9151[] = {
  372. /* ECDSA - TLS 1.3 */
  373. &s2n_ecdsa_secp384r1_sha384,
  374. /* RSA PSS - TLS 1.3 */
  375. &s2n_rsa_pss_pss_sha384,
  376. /* ECDSA - TLS 1.2 */
  377. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  378. /* RSA */
  379. &s2n_rsa_pss_rsae_sha384,
  380. &s2n_rsa_pkcs1_sha384,
  381. };
  382. const struct s2n_signature_scheme* const s2n_cert_sig_scheme_pref_list_rfc9151[] = {
  383. /* ECDSA - TLS 1.3 */
  384. &s2n_ecdsa_secp384r1_sha384,
  385. /* RSA PSS
  386. * https://github.com/aws/s2n-tls/issues/3435
  387. *
  388. * The Openssl function used to parse signatures off certificates does not differentiate
  389. * between any rsa pss signature schemes. Therefore a security policy with a certificate
  390. * signatures preference list must include all rsa_pss signature schemes.
  391. *
  392. * Since only sha384 is allowed by rfc9151, this certificate signing policy does not
  393. * support rsa_pss.
  394. */
  395. /* ECDSA - TLS 1.2 */
  396. &s2n_ecdsa_sha384, /* same iana value as TLS 1.3 s2n_ecdsa_secp384r1_sha384 */
  397. /* RSA */
  398. &s2n_rsa_pkcs1_sha384,
  399. };
  400. const struct s2n_signature_preferences s2n_signature_preferences_rfc9151 = {
  401. .count = s2n_array_len(s2n_sig_scheme_pref_list_rfc9151),
  402. .signature_schemes = s2n_sig_scheme_pref_list_rfc9151
  403. };
  404. const struct s2n_signature_preferences s2n_certificate_signature_preferences_rfc9151 = {
  405. .count = s2n_array_len(s2n_cert_sig_scheme_pref_list_rfc9151),
  406. .signature_schemes = s2n_cert_sig_scheme_pref_list_rfc9151
  407. };