From 4e1b1ac98ea2aa6928b07abee7f1bd616bf7f2c4 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Mon, 23 Jun 2025 02:37:45 -0400 Subject: [PATCH] SDRTrunk .mbe File Replay: Tweak RC4 Keystream Creation to only create second keystream when P25p1, and only make as much keystream as needed; #298 --- src/dsd_file.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/dsd_file.c b/src/dsd_file.c index 7707920..44167e3 100644 --- a/src/dsd_file.c +++ b/src/dsd_file.c @@ -1379,19 +1379,22 @@ void read_sdrtrunk_json_format (dsd_opts * opts, dsd_state * state) //load the str_buffer into the IV portion of kiv parse_raw_user_string(str_buffer, kiv+5); - rc4_block_output (rc4_db, rc4_mod, 375, kiv, ks_bytes); + rc4_block_output (rc4_db, rc4_mod, 200, kiv, ks_bytes); - unpack_byte_array_into_bit_array(ks_bytes, ks, 375); + unpack_byte_array_into_bit_array(ks_bytes, ks, 200); //reverse lfsr on IV and create keystream with that as well //due to out of order execution on P25p1 ESS sync. - reverse_lfsr_64_to_len (kiv+5, 64); + if (protocol == 1) + { + reverse_lfsr_64_to_len (kiv+5, 64); - memset(ks_bytes, 0, sizeof(ks_bytes)); + memset(ks_bytes, 0, sizeof(ks_bytes)); - rc4_block_output (rc4_db, rc4_mod, 375, kiv, ks_bytes); + rc4_block_output (rc4_db, rc4_mod, 200, kiv, ks_bytes); - unpack_byte_array_into_bit_array(ks_bytes, ks_i, 375); + unpack_byte_array_into_bit_array(ks_bytes, ks_i, 200); + } } //end test