| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#pragma once |
| 17 |
|
| 18 |
#include <stdint.h> |
| 19 |
|
| 20 |
#include "tls/s2n_certificate_keys.h" |
| 21 |
#include "tls/s2n_cipher_preferences.h" |
| 22 |
#include "tls/s2n_ecc_preferences.h" |
| 23 |
#include "tls/s2n_kem_preferences.h" |
| 24 |
#include "tls/s2n_security_rules.h" |
| 25 |
#include "tls/s2n_signature_scheme.h" |
| 26 |
#include "tls/s2n_supported_group_preferences.h" |
| 27 |
|
| 28 |
|
| 29 |
#define NUM_RSA_PSS_SCHEMES 6 |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
struct s2n_security_policy { |
| 42 |
uint8_t minimum_protocol_version; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
const struct s2n_cipher_preferences *cipher_preferences; |
| 48 |
|
| 49 |
const struct s2n_kem_preferences *kem_preferences; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
const struct s2n_signature_preferences *signature_preferences; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
const struct s2n_signature_preferences *certificate_signature_preferences; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
const struct s2n_ecc_preferences *ecc_preferences; |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
const struct s2n_supported_group_preferences *strongly_preferred_groups; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
const struct s2n_certificate_key_preferences *certificate_key_preferences; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
bool certificate_preferences_apply_locally; |
| 92 |
bool rules[S2N_SECURITY_RULES_COUNT]; |
| 93 |
}; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
#define S2N_CIPHER_PREF_LIST(...) { __VA_ARGS__ } |
| 110 |
#define S2N_SIG_PREF_LIST(...) { __VA_ARGS__ } |
| 111 |
#define S2N_CURVE_PREF_LIST(...) { __VA_ARGS__ } |
| 112 |
#define S2N_KEM_PREF_LIST(...) { __VA_ARGS__ } |
| 113 |
|
| 114 |
#define S2N_INLINE_SECURITY_POLICY_V1(name, min_version, ciphers, signatures, curves, kems) \ |
| 115 |
struct s2n_cipher_suite *name##_cipher_list[] = ciphers; \ |
| 116 |
const struct s2n_cipher_preferences name##_cipher_prefs = { \ |
| 117 |
.count = s2n_array_len(name##_cipher_list), \ |
| 118 |
.suites = name##_cipher_list, \ |
| 119 |
.allow_chacha20_boosting = false, \ |
| 120 |
}; \ |
| 121 |
const struct s2n_signature_scheme *const name##_sig_list[] = signatures; \ |
| 122 |
const struct s2n_signature_preferences name##_sig_prefs = { \ |
| 123 |
.count = s2n_array_len(name##_sig_list), \ |
| 124 |
.signature_schemes = name##_sig_list, \ |
| 125 |
}; \ |
| 126 |
const struct s2n_ecc_named_curve *const name##_curve_list[] = curves; \ |
| 127 |
const struct s2n_ecc_preferences name##_ecc_prefs = { \ |
| 128 |
.count = s2n_array_len(name##_curve_list), \ |
| 129 |
.ecc_curves = name##_curve_list, \ |
| 130 |
}; \ |
| 131 |
const struct s2n_kem_group *name##_kem_group_list[] = kems; \ |
| 132 |
const struct s2n_kem_preferences name##_kem_prefs = { \ |
| 133 |
.tls13_kem_group_count = s2n_array_len(name##_kem_group_list), \ |
| 134 |
.tls13_kem_groups = name##_kem_group_list, \ |
| 135 |
.tls13_pq_hybrid_draft_revision = 5, \ |
| 136 |
}; \ |
| 137 |
const struct s2n_security_policy name = { \ |
| 138 |
.minimum_protocol_version = min_version, \ |
| 139 |
.cipher_preferences = &name##_cipher_prefs, \ |
| 140 |
.signature_preferences = &name##_sig_prefs, \ |
| 141 |
.certificate_signature_preferences = &name##_sig_prefs, \ |
| 142 |
.ecc_preferences = &name##_ecc_prefs, \ |
| 143 |
.kem_preferences = &name##_kem_prefs, \ |
| 144 |
} |
| 145 |
|
| 146 |
struct s2n_security_policy_selection { |
| 147 |
const char *version; |
| 148 |
const struct s2n_security_policy *security_policy; |
| 149 |
unsigned ecc_extension_required : 1; |
| 150 |
unsigned pq_kem_extension_required : 1; |
| 151 |
unsigned supports_tls13 : 1; |
| 152 |
}; |
| 153 |
|
| 154 |
extern struct s2n_security_policy_selection security_policy_selection[]; |
| 155 |
extern const char *deprecated_security_policies[]; |
| 156 |
extern const size_t deprecated_security_policies_len; |
| 157 |
|
| 158 |
|
| 159 |
extern const struct s2n_security_policy security_policy_20240501; |
| 160 |
extern const struct s2n_security_policy security_policy_20240502; |
| 161 |
extern const struct s2n_security_policy security_policy_20240503; |
| 162 |
|
| 163 |
extern const struct s2n_security_policy security_policy_20241106; |
| 164 |
extern const struct s2n_security_policy security_policy_20140601; |
| 165 |
extern const struct s2n_security_policy security_policy_20141001; |
| 166 |
extern const struct s2n_security_policy security_policy_20150202; |
| 167 |
extern const struct s2n_security_policy security_policy_20150214; |
| 168 |
extern const struct s2n_security_policy security_policy_20150306; |
| 169 |
extern const struct s2n_security_policy security_policy_20160411; |
| 170 |
extern const struct s2n_security_policy security_policy_20160804; |
| 171 |
extern const struct s2n_security_policy security_policy_20160824; |
| 172 |
extern const struct s2n_security_policy security_policy_20170210; |
| 173 |
extern const struct s2n_security_policy security_policy_20170328; |
| 174 |
extern const struct s2n_security_policy security_policy_20170328_gcm; |
| 175 |
extern const struct s2n_security_policy security_policy_20170405; |
| 176 |
extern const struct s2n_security_policy security_policy_20170405_gcm; |
| 177 |
extern const struct s2n_security_policy security_policy_20170718; |
| 178 |
extern const struct s2n_security_policy security_policy_20170718_gcm; |
| 179 |
extern const struct s2n_security_policy security_policy_20190214; |
| 180 |
extern const struct s2n_security_policy security_policy_20190214_gcm; |
| 181 |
extern const struct s2n_security_policy security_policy_20190801; |
| 182 |
extern const struct s2n_security_policy security_policy_20190802; |
| 183 |
extern const struct s2n_security_policy security_policy_20230317; |
| 184 |
extern const struct s2n_security_policy security_policy_20240331; |
| 185 |
extern const struct s2n_security_policy security_policy_20240417; |
| 186 |
extern const struct s2n_security_policy security_policy_20240416; |
| 187 |
extern const struct s2n_security_policy security_policy_20240603; |
| 188 |
extern const struct s2n_security_policy security_policy_20241001; |
| 189 |
extern const struct s2n_security_policy security_policy_20241001_pq_mixed; |
| 190 |
extern const struct s2n_security_policy security_policy_20250211; |
| 191 |
extern const struct s2n_security_policy security_policy_20250414; |
| 192 |
extern const struct s2n_security_policy security_policy_20250512; |
| 193 |
extern const struct s2n_security_policy security_policy_20250721; |
| 194 |
extern const struct s2n_security_policy security_policy_20251014; |
| 195 |
extern const struct s2n_security_policy security_policy_20251015; |
| 196 |
extern const struct s2n_security_policy security_policy_20251113; |
| 197 |
extern const struct s2n_security_policy security_policy_20251114; |
| 198 |
extern const struct s2n_security_policy security_policy_20251115; |
| 199 |
extern const struct s2n_security_policy security_policy_20251116; |
| 200 |
extern const struct s2n_security_policy security_policy_20251117; |
| 201 |
|
| 202 |
extern const struct s2n_security_policy security_policy_20250429; |
| 203 |
extern const struct s2n_security_policy security_policy_20251013; |
| 204 |
extern const struct s2n_security_policy security_policy_20260219; |
| 205 |
extern const struct s2n_security_policy security_policy_20260220; |
| 206 |
extern const struct s2n_security_policy security_policy_20260513; |
| 207 |
extern const struct s2n_security_policy security_policy_20260520; |
| 208 |
extern const struct s2n_security_policy security_policy_20260520_gcm; |
| 209 |
extern const struct s2n_security_policy security_policy_20260521; |
| 210 |
extern const struct s2n_security_policy security_policy_20260521_gcm; |
| 211 |
extern const struct s2n_security_policy security_policy_20260522; |
| 212 |
extern const struct s2n_security_policy security_policy_20260522_gcm; |
| 213 |
extern const struct s2n_security_policy security_policy_20260523; |
| 214 |
extern const struct s2n_security_policy security_policy_20260523_gcm; |
| 215 |
extern const struct s2n_security_policy security_policy_test_all; |
| 216 |
|
| 217 |
extern const struct s2n_security_policy security_policy_test_all_tls12; |
| 218 |
extern const struct s2n_security_policy security_policy_test_all_fips; |
| 219 |
extern const struct s2n_security_policy security_policy_test_all_ecdsa; |
| 220 |
extern const struct s2n_security_policy security_policy_test_ecdsa_priority; |
| 221 |
extern const struct s2n_security_policy security_policy_test_all_rsa_kex; |
| 222 |
extern const struct s2n_security_policy security_policy_test_all_tls13; |
| 223 |
|
| 224 |
|
| 225 |
extern const struct s2n_security_policy security_policy_elb_2015_04; |
| 226 |
extern const struct s2n_security_policy security_policy_elb_2016_08; |
| 227 |
extern const struct s2n_security_policy security_policy_elb_tls_1_2_2017_01; |
| 228 |
extern const struct s2n_security_policy security_policy_elb_tls_1_1_2017_01; |
| 229 |
extern const struct s2n_security_policy security_policy_elb_tls_1_2_ext_2018_06; |
| 230 |
extern const struct s2n_security_policy security_policy_elb_fs_2018_06; |
| 231 |
extern const struct s2n_security_policy security_policy_elb_fs_1_2_2019_08; |
| 232 |
extern const struct s2n_security_policy security_policy_elb_fs_1_1_2019_08; |
| 233 |
extern const struct s2n_security_policy security_policy_elb_fs_1_2_res_2019_08; |
| 234 |
|
| 235 |
extern const struct s2n_security_policy security_policy_aws_crt_sdk_ssl_v3; |
| 236 |
extern const struct s2n_security_policy security_policy_aws_crt_sdk_tls_10; |
| 237 |
extern const struct s2n_security_policy security_policy_aws_crt_sdk_tls_11; |
| 238 |
extern const struct s2n_security_policy security_policy_aws_crt_sdk_tls_12; |
| 239 |
extern const struct s2n_security_policy security_policy_aws_crt_sdk_tls_12_06_23; |
| 240 |
extern const struct s2n_security_policy security_policy_aws_crt_sdk_tls_12_06_23_pq; |
| 241 |
extern const struct s2n_security_policy security_policy_aws_crt_sdk_tls_13; |
| 242 |
|
| 243 |
extern const struct s2n_security_policy security_policy_pq_tls_1_2_2024_10_07; |
| 244 |
extern const struct s2n_security_policy security_policy_pq_tls_1_2_2024_10_08; |
| 245 |
extern const struct s2n_security_policy security_policy_pq_tls_1_2_2024_10_08_gcm; |
| 246 |
extern const struct s2n_security_policy security_policy_pq_tls_1_2_2024_10_09; |
| 247 |
|
| 248 |
extern const struct s2n_security_policy security_policy_cloudfront_upstream; |
| 249 |
extern const struct s2n_security_policy security_policy_cloudfront_upstream_tls10; |
| 250 |
extern const struct s2n_security_policy security_policy_cloudfront_upstream_tls11; |
| 251 |
extern const struct s2n_security_policy security_policy_cloudfront_upstream_tls12; |
| 252 |
|
| 253 |
extern const struct s2n_security_policy security_policy_cloudfront_ssl_v_3; |
| 254 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014; |
| 255 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014_sha256; |
| 256 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2016; |
| 257 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_1_2016; |
| 258 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2017; |
| 259 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2018_no_sha1; |
| 260 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2019_no_sha1; |
| 261 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2021_no_sha1; |
| 262 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2025; |
| 263 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_3_2025; |
| 264 |
|
| 265 |
extern const struct s2n_security_policy security_policy_cloudfront_ssl_v_3_no_pq; |
| 266 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014_no_pq; |
| 267 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014_sha256_no_pq; |
| 268 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2016_no_pq; |
| 269 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_1_2016_no_pq; |
| 270 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2017_no_pq; |
| 271 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2018_no_sha1_no_pq; |
| 272 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2019_no_sha1_no_pq; |
| 273 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2021_no_sha1_no_pq; |
| 274 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2025_no_pq; |
| 275 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_3_2025_no_pq; |
| 276 |
|
| 277 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014_pq_beta; |
| 278 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2021_no_sha1_pq_beta; |
| 279 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2018_beta; |
| 280 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2021_chacha20_boosted; |
| 281 |
|
| 282 |
extern const struct s2n_security_policy security_policy_cloudfront_ssl_v_3_legacy; |
| 283 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2014_legacy; |
| 284 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_0_2016_legacy; |
| 285 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_1_2016_legacy; |
| 286 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2018_legacy; |
| 287 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2019_legacy; |
| 288 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2018; |
| 289 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2019; |
| 290 |
extern const struct s2n_security_policy security_policy_cloudfront_tls_1_2_2021; |
| 291 |
|
| 292 |
extern const struct s2n_security_policy security_policy_kms_tls_1_0_2018_10; |
| 293 |
extern const struct s2n_security_policy security_policy_kms_tls_1_2_2023_06; |
| 294 |
extern const struct s2n_security_policy security_policy_kms_fips_tls_1_2_2018_10; |
| 295 |
extern const struct s2n_security_policy security_policy_kms_fips_tls_1_2_2024_10; |
| 296 |
|
| 297 |
extern const struct s2n_security_policy security_policy_20190120; |
| 298 |
extern const struct s2n_security_policy security_policy_20190121; |
| 299 |
extern const struct s2n_security_policy security_policy_20190122; |
| 300 |
|
| 301 |
extern const struct s2n_security_policy security_policy_null; |
| 302 |
|
| 303 |
int s2n_security_policies_init(); |
| 304 |
int s2n_config_set_cipher_preferences(struct s2n_config *config, const char *version); |
| 305 |
int s2n_connection_set_cipher_preferences(struct s2n_connection *conn, const char *version); |
| 306 |
bool s2n_ecc_is_extension_required(const struct s2n_security_policy *security_policy); |
| 307 |
bool s2n_pq_kem_is_extension_required(const struct s2n_security_policy *security_policy); |
| 308 |
bool s2n_security_policy_supports_tls13(const struct s2n_security_policy *security_policy); |
| 309 |
int s2n_find_security_policy_from_version(const char *version, const struct s2n_security_policy **security_policy); |
| 310 |
const char *s2n_find_version_from_security_policy(const struct s2n_security_policy *security_policy); |
| 311 |
int s2n_validate_kem_preferences(const struct s2n_kem_preferences *kem_preferences, bool pq_kem_extension_required); |
| 312 |
S2N_RESULT s2n_validate_certificate_signature_preferences(const struct s2n_signature_preferences *s2n_certificate_signature_preferences); |
| 313 |
S2N_RESULT s2n_security_policy_get_version(const struct s2n_security_policy *security_policy, |
| 314 |
const char **version); |
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
S2N_RESULT s2n_security_policy_validate_certificate_chain(const struct s2n_security_policy *security_policy, |
| 319 |
const struct s2n_cert_chain_and_key *cert_key_pair); |
| 320 |
S2N_RESULT s2n_security_policy_validate_cert_signature( |
| 321 |
const struct s2n_security_policy *security_policy, const struct s2n_cert_info *info, s2n_error error); |
| 322 |
S2N_RESULT s2n_security_policy_validate_cert_key( |
| 323 |
const struct s2n_security_policy *security_policy, const struct s2n_cert_info *info, s2n_error error); |