TLS-F: Emu fixes

This commit is contained in:
Alexey 2026-02-20 14:32:09 +03:00
parent 79eebeb9ef
commit 4d72cb1680
No known key found for this signature in database
1 changed files with 11 additions and 7 deletions

View File

@ -44,8 +44,12 @@ pub fn build_emulated_server_hello(
message.extend_from_slice(&[0u8; 32]); // random placeholder message.extend_from_slice(&[0u8; 32]); // random placeholder
message.push(session_id.len() as u8); message.push(session_id.len() as u8);
message.extend_from_slice(session_id); message.extend_from_slice(session_id);
// Always use TLS_AES_128_GCM_SHA256 (0x1301) to match Telegram client's offer set. let cipher = if cached.server_hello_template.cipher_suite == [0, 0] {
message.extend_from_slice(&[0x13, 0x01]); [0x13, 0x01]
} else {
cached.server_hello_template.cipher_suite
};
message.extend_from_slice(&cipher);
message.push(cached.server_hello_template.compression); message.push(cached.server_hello_template.compression);
message.extend_from_slice(&extensions_len.to_be_bytes()); message.extend_from_slice(&extensions_len.to_be_bytes());
message.extend_from_slice(&extensions); message.extend_from_slice(&extensions);
@ -67,11 +71,11 @@ pub fn build_emulated_server_hello(
]; ];
// --- ApplicationData (fake encrypted records) --- // --- ApplicationData (fake encrypted records) ---
let sizes = if cached.app_data_records_sizes.is_empty() { // Use the same number and sizes of ApplicationData records as the cached server.
vec![cached.total_app_data_len.max(1024)] let mut sizes = cached.app_data_records_sizes.clone();
} else { if sizes.is_empty() {
cached.app_data_records_sizes.clone() sizes.push(cached.total_app_data_len.max(1024));
}; }
let mut app_data = Vec::new(); let mut app_data = Vec::new();
for size in sizes { for size in sizes {