http_quik/profile/mod.rs
1//! Data-only definitions for Chrome transport identities.
2//!
3//! This module defines the schemas used to configure the TLS and HTTP/2
4//! layers. No protocol logic resides here; instead, these structures act as
5//! the configuration contract that the `tls` and `http2` modules translate
6//! into specific BoringSSL and H2 builder calls.
7
8use boring::ssl::SslVersion;
9
10pub mod chrome_134;
11
12/// Alias for BoringSSL's internal version type.
13pub type TlsVersion = SslVersion;
14
15/// Supported execution environments for profile targeting.
16///
17/// Hardware and OS markers are embedded in several layers, including the
18/// TLS ClientHello (via GREASE and curves) and the HTTP User-Agent.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum Platform {
21 /// Apple Silicon (M1/M2/M3) - Targeted with specific X25519MLKEM768 support.
22 MacOsArm,
23 /// Intel-based macOS.
24 MacOsX86,
25 /// 64-bit Windows.
26 WindowsX64,
27 /// 64-bit Linux (Generic).
28 LinuxX64,
29}
30
31/// Configuration for the TLS 1.2/1.3 handshake layer.
32///
33/// This structure defines the Layer 4 identity of the client. Small changes
34/// here (such as the order of cipher suites) will change the JA3/JA4
35/// fingerprint and can lead to immediate detection.
36#[derive(Debug, Clone, Copy, PartialEq, Eq)]
37pub struct TlsProfile {
38 /// Minimum allowed TLS version (typically TLS 1.2).
39 pub min_version: TlsVersion,
40 /// Maximum allowed TLS version (typically TLS 1.3).
41 pub max_version: TlsVersion,
42 /// Colon-separated list of cipher suites in OpenSSL format.
43 ///
44 /// Precision in the order of this list is critical as it directly
45 /// impacts the JA3/JA4 fingerprint.
46 pub cipher_list: &'static str,
47 /// Numeric IDs for supported elliptic curve groups.
48 pub curves: &'static [u16],
49 /// Whether to enable TLS GREASE (RFC 8701) to simulate randomized extensions.
50 pub grease_enabled: bool,
51 /// Whether to permute (shuffle) TLS extensions per connection.
52 pub permute_extensions: bool,
53 /// Whether to send a dummy ECH (Encrypted Client Hello) extension for GREASE.
54 pub enable_ech_grease: bool,
55 /// Whether to enable ALPS (Application-Layer Protocol Settings).
56 pub alps_enabled: bool,
57 /// Whether to use the draft-01 or final ALPS codepoint.
58 pub alps_use_new_codepoint: bool,
59 /// Whether to support RFC 8879 certificate compression (Brotli).
60 pub compress_certificate: bool,
61 /// Whether to enable stateless session tickets for fast reconnection.
62 pub session_ticket_enabled: bool,
63 /// Ordered list of ALPN protocol identifiers.
64 pub alpn_protocols: &'static [&'static [u8]],
65 /// Ordered list of signature algorithm IDs (used for JA4_r).
66 pub sigalgs: &'static [u16],
67}
68
69/// Initial HTTP/2 SETTINGS frame parameters.
70///
71/// The values and the *order* in which they are sent are used by Akamai
72/// and other WAFs to identify the client implementation.
73#[derive(Debug, Clone, Copy, PartialEq, Eq)]
74pub struct SettingsFrame {
75 /// SETTINGS_HEADER_TABLE_SIZE (ID 0x1).
76 pub header_table_size: u32,
77 /// SETTINGS_ENABLE_PUSH (ID 0x2).
78 pub enable_push: bool,
79 /// SETTINGS_INITIAL_WINDOW_SIZE (ID 0x4).
80 pub initial_window_size: u32,
81 /// SETTINGS_MAX_HEADER_LIST_SIZE (ID 0x6).
82 pub max_header_list_size: u32,
83}
84
85/// Configuration for the HTTP/2 protocol layer.
86///
87/// Defines the Layer 5 identity, focusing on behavioral markers like
88/// pseudo-header ordering and stream priority.
89#[derive(Debug, Clone, Copy, PartialEq, Eq)]
90pub struct Http2Profile {
91 /// Initial SETTINGS frame values and order.
92 pub settings: SettingsFrame,
93 /// Total connection-level window size (default + delta).
94 ///
95 /// This value determines the initial `WINDOW_UPDATE` frame increment
96 /// sent immediately after the handshake. Chrome uses a specific non-standard
97 /// increment that acts as a strong identity signal.
98 pub initial_connection_window_size: u32,
99 /// Ordering of pseudo-headers (e.g., :method, :authority, :scheme, :path).
100 pub pseudo_order: [PseudoOrder; 4],
101 /// Priority parameters for the initial HEADERS frame.
102 pub headers_priority: HeadersPriority,
103}
104
105/// Stream priority parameters embedded in the HEADERS frame.
106#[derive(Debug, Clone, Copy, PartialEq, Eq)]
107pub struct HeadersPriority {
108 /// Stream ID that this request depends on (typically 0).
109 pub dep: u32,
110 /// Priority weight (0-255).
111 pub weight: u8,
112 /// Whether this dependency is exclusive.
113 pub exclusive: bool,
114}
115
116/// Canonical HTTP/2 pseudo-header identifiers.
117#[derive(Debug, Clone, Copy, PartialEq, Eq)]
118pub enum PseudoOrder {
119 /// `:method`
120 Method,
121 /// `:authority`
122 Authority,
123 /// `:scheme`
124 Scheme,
125 /// `:path`
126 Path,
127}
128
129/// Chrome-specific HTTP header values and behaviors.
130#[derive(Debug, Clone, PartialEq, Eq)]
131pub struct HeaderProfile {
132 /// Full User-Agent string.
133 pub user_agent: String,
134 /// `sec-ch-ua` Client Hint string.
135 pub sec_ch_ua: String,
136 /// `sec-ch-ua-platform` Client Hint string.
137 pub sec_ch_ua_platform: String,
138 /// Whether to include the `priority` header in the request.
139 pub include_priority_header: bool,
140 /// Whether to include `zstd` in `accept-encoding`.
141 pub zstd_encoding: bool,
142}
143
144/// A complete, multi-layer identity profile for a Chrome instance.
145#[derive(Debug, Clone, PartialEq, Eq)]
146pub struct ChromeProfile {
147 /// Major Chrome version (e.g., 134).
148 pub version: u32,
149 /// Target operating system and architecture.
150 pub platform: Platform,
151 /// Layer 4: TLS configuration.
152 pub tls: TlsProfile,
153 /// Layer 5: HTTP/2 configuration.
154 pub h2: Http2Profile,
155 /// Layer 6: HTTP header configuration.
156 pub headers: HeaderProfile,
157}