DMR: Code Tweaks to Hytera OTA Encryption; #373

Tweak Behavior of handling OTA Encryption when Irrecoverable Errors are present causing invalid decryption of signalling;
This commit is contained in:
lwvmobile
2026-11-17 03:35:02 -05:00
parent 26641453ba
commit 9f7c189f27
4 changed files with 31 additions and 15 deletions

View File

@@ -1023,7 +1023,7 @@ void hytera_ota_unit_testing(dsd_state * state)
{
char keystr[100];
memset(keystr, 0, sizeof(keystr));
sprintf (keystr, "%s", "2:17bfe59b29a06136fb7d3811fd1a4904");
sprintf (keystr, "%s", "128:17bfe59b29a06136fb7d3811fd1a4904");
hytera_ota_keystream_setup(state, keystr);
char string[30];

View File

@@ -31,6 +31,21 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
csbk_fid = cs_pdu[1]; //feature set id
UNUSED(csbk_lb);
if (IrrecoverableErrors != 0 && state->hota_key_loaded == 1)
{
fprintf (stderr, "\n%s", KRED);
fprintf (stderr, " BPTC Irrecoverable Errors; Encrypted;");
fprintf (stderr, "%s", KNRM);
return;
}
else if (state->hota_enc_check)
{
fprintf (stderr, "\n%s", KRED);
fprintf (stderr, " Encrypted Control Signalling Block(s)");
fprintf (stderr, "%s", KNRM);
return;
}
//check, regardless of CRC err
if (IrrecoverableErrors == 0)
{

View File

@@ -285,11 +285,13 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
fprintf (stderr, " BPTC R BITS: %d %d %d", bptc_res_bits[0], bptc_res_bits[1], bptc_res_bits[2]);
#endif
//TODO: Checkdown no irrecoverable errors prior to OTA Decryption?
//Hytera OTA Encryption
if (state->hota_key_loaded && hota_enc)
if (state->hota_key_loaded && hota_enc && IrrecoverableErrors == 0)
hytera_ota_decrypt_bptc_96(state, BPTCDmrDataBit, databurst);
else if (state->hota_key_loaded && hota_enc && IrrecoverableErrors != 0)
memset(BPTCDmrDataBit, 1, sizeof(BPTCDmrDataBit));
else if (state->hota_enc_check && hota_enc && databurst != 1)
memset(BPTCDmrDataBit, 1, sizeof(BPTCDmrDataBit));
//Hytera Data Block Level Decryption
if (databurst == 0x7) //Rate 1_2 Data Only
@@ -500,14 +502,6 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
//just fill with all ones, would be garbage from FEC anyways
memset(LC_DataBit, 1, sizeof(LC_DataBit));
IrrecoverableErrors = 1;
//TODO: columns instead of rows to match application of keystream
#ifdef DEBUG_HOTA
fprintf(stderr, "\n BPTC 128: ");
for (int i = 0; i < 8; i++)
fprintf (stderr, "%04X", (uint16_t)convert_bits_into_output(BptcDataMatrix[i], 16));
fprintf (stderr, "\n");
#endif
}
else if (state->hota_enc_check == 1)
{

View File

@@ -84,9 +84,8 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
//Hytera OTA Check Enabled, Set SRC from VLC (TLC and ELC differ)
//NOTE: VLC will always be same for each radio if its a group call
//while this is not the true src, it should be unique
//TGT will also be random between calls in each VLC,
//so assign static value
//while this is not the true src, it should be unique and static
//TGT will also be random between calls in each VLC, so assign hard value
if (state->hota_enc_check)
{
uint32_t t_target = 8686868;
@@ -137,6 +136,14 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
fprintf (stderr, "%s", KNRM);
return;
}
else if (state->hota_key_loaded && *IrrecoverableErrors != 0 && type != 3)
{
fprintf (stderr, "\n%s", KRED);
fprintf (stderr, " SLOT %d", slot+1);
fprintf (stderr, " BPTC Irrecoverable Errors; Encrypted;");
fprintf (stderr, "%s", KNRM);
return;
}
//read ahead a little to get this for the xpt flag
if (*IrrecoverableErrors == 0 && flco == 0x09 && fid == 0x68)