-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathtls.rs
More file actions
130 lines (115 loc) · 3.95 KB
/
Copy pathtls.rs
File metadata and controls
130 lines (115 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
use super::*;
macro_rules! tls_options {
(@build $builder:expr) => {
$builder.build().into()
};
(1) => {
tls_options!(@build ChromeTlsConfig::builder())
};
(2) => {
tls_options!(@build ChromeTlsConfig::builder().enable_ech_grease(true))
};
(3) => {
tls_options!(@build ChromeTlsConfig::builder().permute_extensions(true))
};
(4) => {
tls_options!(@build ChromeTlsConfig::builder()
.permute_extensions(true)
.enable_ech_grease(true))
};
(5) => {
tls_options!(@build ChromeTlsConfig::builder()
.permute_extensions(true)
.enable_ech_grease(true)
.pre_shared_key(true))
};
(6, $curves:expr) => {
tls_options!(@build ChromeTlsConfig::builder()
.permute_extensions(true)
.enable_ech_grease(true)
.pre_shared_key(true)
.curves($curves))
};
(7, $curves:expr) => {
tls_options!(@build ChromeTlsConfig::builder()
.permute_extensions(true)
.enable_ech_grease(true)
.pre_shared_key(true)
.curves($curves)
.alps_use_new_codepoint(true))
};
}
pub const CURVES_1: &str = join!(":", "X25519", "P-256", "P-384");
pub const CURVES_2: &str = join!(":", "X25519Kyber768Draft00", "X25519", "P-256", "P-384");
pub const CURVES_3: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384");
pub const CIPHER_LIST: &str = join!(
":",
"TLS_AES_128_GCM_SHA256",
"TLS_AES_256_GCM_SHA384",
"TLS_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
"TLS_RSA_WITH_AES_128_GCM_SHA256",
"TLS_RSA_WITH_AES_256_GCM_SHA384",
"TLS_RSA_WITH_AES_128_CBC_SHA",
"TLS_RSA_WITH_AES_256_CBC_SHA"
);
pub const SIGALGS_LIST: &str = join!(
":",
"ecdsa_secp256r1_sha256",
"rsa_pss_rsae_sha256",
"rsa_pkcs1_sha256",
"ecdsa_secp384r1_sha384",
"rsa_pss_rsae_sha384",
"rsa_pkcs1_sha384",
"rsa_pss_rsae_sha512",
"rsa_pkcs1_sha512"
);
pub const CERT_COMPRESSION_ALGORITHM: &[CertificateCompressionAlgorithm] =
&[CertificateCompressionAlgorithm::BROTLI];
#[derive(TypedBuilder)]
pub struct ChromeTlsConfig {
#[builder(default = CURVES_1)]
curves: &'static str,
#[builder(default = SIGALGS_LIST)]
sigalgs_list: &'static str,
#[builder(default = CIPHER_LIST)]
cipher_list: &'static str,
#[builder(default = AlpsProtocol::HTTP2, setter(into))]
alps_protos: AlpsProtocol,
#[builder(default = false)]
alps_use_new_codepoint: bool,
#[builder(default = false, setter(into))]
enable_ech_grease: bool,
#[builder(default = false, setter(into))]
permute_extensions: bool,
#[builder(default = false, setter(into))]
pre_shared_key: bool,
}
impl From<ChromeTlsConfig> for TlsOptions {
fn from(val: ChromeTlsConfig) -> Self {
TlsOptions::builder()
.grease_enabled(true)
.enable_ocsp_stapling(true)
.enable_signed_cert_timestamps(true)
.curves_list(val.curves)
.sigalgs_list(val.sigalgs_list)
.cipher_list(val.cipher_list)
.min_tls_version(TlsVersion::TLS_1_2)
.max_tls_version(TlsVersion::TLS_1_3)
.permute_extensions(val.permute_extensions)
.pre_shared_key(val.pre_shared_key)
.enable_ech_grease(val.enable_ech_grease)
.alps_protocols([val.alps_protos])
.alps_use_new_codepoint(val.alps_use_new_codepoint)
.aes_hw_override(true)
.certificate_compression_algorithms(CERT_COMPRESSION_ALGORITHM)
.build()
}
}