mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-14 01:37:25 -05:00
DMR: Enhanced Encryption PI / FLC Setup;
Fix some PI Elements for Consistency and List Known Alg Types;
This commit is contained in:
@@ -584,8 +584,8 @@ typedef struct
|
||||
int payload_keyidR;
|
||||
int payload_mfid;
|
||||
int payload_mfidR;
|
||||
int payload_mi;
|
||||
int payload_miR;
|
||||
unsigned long long int payload_mi;
|
||||
unsigned long long int payload_miR;
|
||||
unsigned long long int payload_miN;
|
||||
unsigned long long int payload_miP;
|
||||
int p25vc;
|
||||
@@ -1281,7 +1281,7 @@ uint32_t ComputeCrc32Bit(uint8_t * DMRData, uint32_t NbData);
|
||||
void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t databurst);
|
||||
void dmr_data_sync (dsd_opts * opts, dsd_state * state);
|
||||
void dmr_pi (dsd_opts * opts, dsd_state * state, uint8_t PI_BYTE[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors);
|
||||
void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors, uint8_t type);
|
||||
void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t CRCCorrect, uint32_t * IrrecoverableErrors, uint8_t type);
|
||||
void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8_t cs_pdu[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors);
|
||||
void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[]);
|
||||
uint8_t dmr_cach (dsd_opts * opts, dsd_state * state, uint8_t cach_bits[25]);
|
||||
@@ -1522,6 +1522,9 @@ void aes_cfb_bytewise_payload_crypt (uint8_t * iv, uint8_t * key, uint8_t * in,
|
||||
void aes_ctr_bytewise_payload_crypt (uint8_t * iv, uint8_t * key, uint8_t * payload, int type);
|
||||
void aes_ctr_bitwise_payload_crypt (uint8_t * iv, uint8_t * key, uint8_t * payload, int type);
|
||||
|
||||
//Hytera Enhanced
|
||||
void hytera_enhanced_enc_setup(dsd_opts * opts, dsd_state * state, unsigned long long int key_value, unsigned long long int mi_value);
|
||||
|
||||
//LFSR to expand either a DMR 32-bit or P25/NXDN 64-bit MI into a 128-bit IV for AES
|
||||
void LFSR128(dsd_state * state);
|
||||
void LFSR128n(dsd_state * state);
|
||||
|
||||
20
src/dmr_bs.c
20
src/dmr_bs.c
@@ -625,11 +625,21 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
||||
state->currentslot = 0;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
else if (state->payload_algid == 0x02)
|
||||
{
|
||||
state->currentslot = 0;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
if (state->payload_algidR >= 0x21)
|
||||
{
|
||||
state->currentslot = 1;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
else if (state->payload_algidR == 0x02)
|
||||
{
|
||||
state->currentslot = 1;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
|
||||
//failsafe to reset all data header and blocks when bad tact or emb
|
||||
dmr_reset_blocks (opts, state);
|
||||
@@ -943,11 +953,21 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
||||
state->currentslot = 0;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
else if (state->payload_algid == 0x02)
|
||||
{
|
||||
state->currentslot = 0;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
if (state->payload_algidR >= 0x21)
|
||||
{
|
||||
state->currentslot = 1;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
else if (state->payload_algid == 0x02)
|
||||
{
|
||||
state->currentslot = 1;
|
||||
dmr_alg_refresh (opts, state);
|
||||
}
|
||||
|
||||
//failsafe to reset all data header and blocks when bad tact or emb
|
||||
dmr_reset_blocks (opts, state);
|
||||
|
||||
@@ -559,9 +559,9 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
||||
if (databurst == 0x00) dmr_pi (opts, state, DMR_PDU, CRCCorrect, IrrecoverableErrors);
|
||||
|
||||
//full link control
|
||||
if (databurst == 0x01) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, IrrecoverableErrors, 1); //VLC
|
||||
if (databurst == 0x02) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, IrrecoverableErrors, 2); //TLC
|
||||
if (databurst == 0xEB) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, IrrecoverableErrors, 3); //EMB
|
||||
if (databurst == 0x01) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, &IrrecoverableErrors, 1); //VLC
|
||||
if (databurst == 0x02) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, &IrrecoverableErrors, 2); //TLC
|
||||
if (databurst == 0xEB) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, &IrrecoverableErrors, 3); //EMB
|
||||
|
||||
//dmr data header and multi block types (header, 1/2, 3/4, 1, UDT) - type 1
|
||||
if (databurst == 0x06) dmr_dheader (opts, state, DMR_PDU, DMR_PDU_bits, CRCCorrect, IrrecoverableErrors);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "dsd.h"
|
||||
|
||||
//combined flco handler (vlc, tlc, emb), minus the superfluous structs and strings
|
||||
void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors, uint8_t type)
|
||||
void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t CRCCorrect, uint32_t * IrrecoverableErrors, uint8_t type)
|
||||
{
|
||||
UNUSED(CRCCorrect);
|
||||
|
||||
@@ -57,7 +57,7 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
||||
source = (uint32_t)ConvertBitIntoBytes(&lc_bits[48], 24);
|
||||
|
||||
//read ahead a little to get this for the xpt flag
|
||||
if (IrrecoverableErrors == 0 && flco == 0x09 && fid == 0x68)
|
||||
if (*IrrecoverableErrors == 0 && flco == 0x09 && fid == 0x68)
|
||||
{
|
||||
sprintf (state->dmr_branding, "%s", " Hytera");
|
||||
sprintf (state->dmr_branding_sub, "XPT ");
|
||||
@@ -81,7 +81,7 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
||||
goto END_FLCO;
|
||||
}
|
||||
|
||||
if (IrrecoverableErrors == 0)
|
||||
if (*IrrecoverableErrors == 0)
|
||||
{
|
||||
|
||||
if (slot == 0) state->dmr_flco = flco;
|
||||
@@ -297,9 +297,69 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
||||
}
|
||||
|
||||
}
|
||||
else //Look for Hytera PI LC (this may fail the FEC, but have a secondary checksum value)
|
||||
{
|
||||
if (fid == 0x68 && flco == 0x02)
|
||||
{
|
||||
uint8_t checksum = 0;
|
||||
uint8_t alg = (uint8_t)ConvertBitIntoBytes(&lc_bits[0], 8);
|
||||
uint8_t key = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 8);
|
||||
unsigned long long int mi = (unsigned long long int)ConvertBitIntoBytes(&lc_bits[24], 40);
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " Slot %d Alg: %02X; KEY ID: %02X; MI(40): %010llX;", slot+1, alg, key, mi);
|
||||
fprintf (stderr, " Hytera Enhanced");
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
checksum += (uint8_t)ConvertBitIntoBytes(&lc_bits[i*8], 8);
|
||||
checksum &= 0xFF;
|
||||
}
|
||||
checksum = ~checksum & 0xFF;
|
||||
checksum++;
|
||||
|
||||
//debug
|
||||
// fprintf (stderr, " CHKSUM: %02X / %02X", checksum, (uint8_t)ConvertBitIntoBytes(&lc_bits[64], 8));
|
||||
|
||||
if (checksum == (uint8_t)ConvertBitIntoBytes(&lc_bits[64], 8))
|
||||
{
|
||||
if (slot == 0)
|
||||
{
|
||||
state->payload_algid = alg;
|
||||
state->payload_keyid = key;
|
||||
state->payload_mi = mi;
|
||||
// hytera_enhanced_enc_setup(opts, state, state->R, state->payload_mi); //need to redo part of this (no key loader yet)
|
||||
}
|
||||
else
|
||||
{
|
||||
state->payload_algidR = alg;
|
||||
state->payload_keyidR = key;
|
||||
state->payload_miR = mi;
|
||||
// hytera_enhanced_enc_setup(opts, state, state->RR, state->payload_miR); //need to redo part of this (no key loader yet)
|
||||
}
|
||||
|
||||
//disable late entry for DMRA (hopefully, there aren't any systems running both DMRA and Hytera Enhanced mixed together)
|
||||
opts->dmr_le = 0;
|
||||
|
||||
*IrrecoverableErrors = 0; //only set if checksum passes
|
||||
}
|
||||
|
||||
if (checksum == (uint8_t)ConvertBitIntoBytes(&lc_bits[64], 8))
|
||||
// fprintf (stderr, " (Checksum Okay);");
|
||||
{;}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s", KRED);
|
||||
fprintf (stderr, " (Checksum Err);");
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s ", KNRM);
|
||||
goto END_FLCO;
|
||||
}
|
||||
}
|
||||
|
||||
//will want to continue to observe for different flco and fid combinations to find out their meaning
|
||||
if(IrrecoverableErrors == 0 && is_alias == 0 && is_gps == 0)
|
||||
if(*IrrecoverableErrors == 0 && is_alias == 0 && is_gps == 0)
|
||||
{
|
||||
//set overarching manufacturer in use when non-standard feature id set is up
|
||||
if (fid != 0) state->dmr_mfid = fid;
|
||||
@@ -654,7 +714,7 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
}
|
||||
|
||||
if(IrrecoverableErrors != 0)
|
||||
if(*IrrecoverableErrors != 0)
|
||||
{
|
||||
if (type != 3) fprintf (stderr, "\n");
|
||||
fprintf (stderr, "%s", KRED);
|
||||
|
||||
323
src/dmr_pi.c
323
src/dmr_pi.c
@@ -14,6 +14,8 @@ void dmr_pi (dsd_opts * opts, dsd_state * state, uint8_t PI_BYTE[], uint32_t CRC
|
||||
{
|
||||
UNUSED2(opts, CRCCorrect);
|
||||
|
||||
uint8_t MFID = PI_BYTE[1];
|
||||
|
||||
if((IrrecoverableErrors == 0))
|
||||
{
|
||||
|
||||
@@ -24,121 +26,205 @@ void dmr_pi (dsd_opts * opts, dsd_state * state, uint8_t PI_BYTE[], uint32_t CRC
|
||||
state->last_cc_sync_time = time(NULL);
|
||||
}
|
||||
|
||||
if (state->currentslot == 0)
|
||||
if (MFID == 0x68) //Hytera Enhanced
|
||||
{
|
||||
state->payload_algid = PI_BYTE[0];
|
||||
state->payload_keyid = PI_BYTE[2];
|
||||
state->payload_mi = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
||||
if (state->payload_algid < 0x26)
|
||||
if (state->currentslot == 0)
|
||||
{
|
||||
fprintf (stderr, "%s ", KYEL);
|
||||
fprintf (stderr, "\n Slot 1");
|
||||
fprintf (stderr, " DMR PI H- ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algid, state->payload_keyid, state->payload_mi);
|
||||
|
||||
//Anytone RC4 Shim
|
||||
if (state->payload_algid == 0x01)
|
||||
{
|
||||
fprintf (stderr, " Anytone RC4 (0x01)");
|
||||
state->payload_algid = 0x21;
|
||||
}
|
||||
|
||||
//Anytone/Hytera AES-128 Shim
|
||||
if (state->payload_algid == 0x04)
|
||||
{
|
||||
fprintf (stderr, " Anytone/Hytera AES-128 (0x04)");
|
||||
state->payload_algid = 0x24;
|
||||
}
|
||||
|
||||
//Anytone/Hytera AES-256 Shim
|
||||
if (state->payload_algid == 0x05)
|
||||
{
|
||||
fprintf (stderr, " Anytone/Hytera AES-256 (0x05)");
|
||||
state->payload_algid = 0x25;
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s ", KNRM);
|
||||
|
||||
//expand the 32-bit MI to a 64-bit DES1 IV
|
||||
if (state->payload_algid == 0x22)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR64 (state);
|
||||
}
|
||||
|
||||
//expand the 32-bit MI to a 128-bit AES IV
|
||||
if (state->payload_algid == 0x24 || state->payload_algid == 0x25)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR128d (state);
|
||||
}
|
||||
state->payload_algid = PI_BYTE[0];
|
||||
state->payload_keyid = PI_BYTE[2];
|
||||
state->payload_mi = ((unsigned long long int)PI_BYTE[3] << 32ULL) | ((unsigned long long int)PI_BYTE[4] << 24) |
|
||||
((unsigned long long int)PI_BYTE[5] << 16) | ((unsigned long long int)PI_BYTE[6] << 8) | ((unsigned long long int)PI_BYTE[7] << 0);
|
||||
hytera_enhanced_enc_setup(opts, state, state->R, state->payload_mi); //need to redo part of this (no key loader yet)
|
||||
}
|
||||
else
|
||||
{
|
||||
state->payload_algidR = PI_BYTE[0];
|
||||
state->payload_keyidR = PI_BYTE[2];
|
||||
state->payload_miR = ((unsigned long long int)PI_BYTE[3] << 32ULL) | ((unsigned long long int)PI_BYTE[4] << 24) |
|
||||
((unsigned long long int)PI_BYTE[5] << 16) | ((unsigned long long int)PI_BYTE[6] << 8) | ((unsigned long long int)PI_BYTE[7] << 0);
|
||||
hytera_enhanced_enc_setup(opts, state, state->RR, state->payload_miR); //need to redo part of this (no key loader yet)
|
||||
}
|
||||
|
||||
if (state->payload_algid >= 0x26)
|
||||
fprintf (stderr, "%s ", KYEL);
|
||||
fprintf (stderr, "\n Slot %d", state->currentslot+1);
|
||||
fprintf (stderr, " DMR PI H- ALG ID: %02X; KEY ID: %02X; MI(40): %02X%02X%02X%02X%02X;",
|
||||
PI_BYTE[0], PI_BYTE[2], PI_BYTE[3], PI_BYTE[4], PI_BYTE[5], PI_BYTE[6], PI_BYTE[7]);
|
||||
|
||||
//PI_BYTE[8] is a checksum of the other bytes combined and should be equal to zero
|
||||
uint8_t checksum = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
state->payload_algid = 0;
|
||||
state->payload_keyid = 0;
|
||||
state->payload_mi = 0;
|
||||
checksum += PI_BYTE[i];
|
||||
checksum &= 0xFF;
|
||||
}
|
||||
checksum = ~checksum & 0xFF;
|
||||
checksum++;
|
||||
|
||||
//debug
|
||||
// fprintf (stderr, " CHK: %02X / %02X;", checksum, PI_BYTE[8]);
|
||||
|
||||
if (checksum == PI_BYTE[8])
|
||||
{
|
||||
fprintf (stderr, " Hytera Enhanced");
|
||||
if (PI_BYTE[2] == 0x02)
|
||||
fprintf (stderr, " RC4;");
|
||||
else if (PI_BYTE[2] == 0x05)
|
||||
fprintf (stderr, " AES-256;");
|
||||
|
||||
//disable late entry for DMRA (hopefully, there aren't any systems running both DMRA and Hytera Enhanced mixed together)
|
||||
opts->dmr_le = 0;
|
||||
|
||||
// fprintf (stderr, " (Checksum Okay);");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s", KRED);
|
||||
fprintf (stderr, " (Checksum Err);");
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
|
||||
}
|
||||
|
||||
if (state->currentslot == 1)
|
||||
else if (MFID == 0x10) //DMRA
|
||||
{
|
||||
|
||||
state->payload_algidR = PI_BYTE[0];
|
||||
state->payload_keyidR = PI_BYTE[2];
|
||||
state->payload_miR = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
||||
if (state->payload_algidR < 0x26)
|
||||
if (state->currentslot == 0)
|
||||
{
|
||||
fprintf (stderr, "%s ", KYEL);
|
||||
fprintf (stderr, "\n Slot 2");
|
||||
fprintf (stderr, " DMR PI H- ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algidR, state->payload_keyidR, state->payload_miR);
|
||||
|
||||
//Anytone RC4 Shim
|
||||
if (state->payload_algidR == 0x01)
|
||||
state->payload_algid = PI_BYTE[0];
|
||||
state->payload_keyid = PI_BYTE[2];
|
||||
state->payload_mi = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
||||
if (state->payload_algid < 0x26)
|
||||
{
|
||||
fprintf (stderr, " Anytone (0x01)");
|
||||
state->payload_algidR = 0x21;
|
||||
fprintf (stderr, "%s ", KYEL);
|
||||
fprintf (stderr, "\n Slot 1");
|
||||
fprintf (stderr, " DMR PI H- ALG ID: %02X; KEY ID: %02X; MI(32): %08X;", state->payload_algid, state->payload_keyid, state->payload_mi);
|
||||
|
||||
//check for any values that aren't 0x2X but just 0x0X
|
||||
//going to be very generic here to avoid any particular vendors using 0x2X and not 0x0X
|
||||
if (state->payload_algid & 0x20)
|
||||
fprintf (stderr, " DMRA");
|
||||
else fprintf (stderr, " DMRA Compatible");
|
||||
|
||||
if ((state->payload_algid & 0x07) == 0x01)
|
||||
{
|
||||
fprintf (stderr, " RC4;");
|
||||
state->payload_algid = 0x21;
|
||||
}
|
||||
|
||||
else if ((state->payload_algid & 0x07) == 0x02)
|
||||
{
|
||||
fprintf (stderr, " DES;");
|
||||
state->payload_algid = 0x21;
|
||||
}
|
||||
|
||||
else if ((state->payload_algid & 0x07) == 0x04)
|
||||
{
|
||||
fprintf (stderr, " AES-128;");
|
||||
state->payload_algid = 0x24;
|
||||
}
|
||||
|
||||
else if ((state->payload_algid & 0x07) == 0x05)
|
||||
{
|
||||
fprintf (stderr, " AES-256;");
|
||||
state->payload_algid = 0x25;
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s ", KNRM);
|
||||
|
||||
//expand the 32-bit MI to a 64-bit DES IV
|
||||
if (state->payload_algid == 0x22)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR64 (state);
|
||||
}
|
||||
|
||||
//expand the 32-bit MI to a 128-bit AES IV
|
||||
if (state->payload_algid == 0x24 || state->payload_algid == 0x25)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR128d (state);
|
||||
}
|
||||
}
|
||||
|
||||
//Anytone/Hytera AES-128 Shim
|
||||
if (state->payload_algidR == 0x04)
|
||||
if (state->payload_algid >= 0x26)
|
||||
{
|
||||
fprintf (stderr, " Anytone/Hytera AES-128 (0x04)");
|
||||
state->payload_algidR = 0x24;
|
||||
}
|
||||
|
||||
//Anytone/Hytera AES-256 Shim
|
||||
if (state->payload_algidR == 0x05)
|
||||
{
|
||||
fprintf (stderr, " Anytone/Hytera AES-256 (0x05)");
|
||||
state->payload_algidR = 0x25;
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s ", KNRM);
|
||||
|
||||
//expand the 32-bit MI to a 64-bit DES1 IV
|
||||
if (state->payload_algidR == 0x22)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR64 (state);
|
||||
}
|
||||
|
||||
//expand the 32-bit MI to a 128-bit AES IV
|
||||
if (state->payload_algidR == 0x24 || state->payload_algidR == 0x25)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR128d (state);
|
||||
state->payload_algid = 0;
|
||||
state->payload_keyid = 0;
|
||||
state->payload_mi = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (state->payload_algidR >= 0x26)
|
||||
if (state->currentslot == 1)
|
||||
{
|
||||
state->payload_algidR = 0;
|
||||
state->payload_keyidR = 0;
|
||||
state->payload_miR = 0;
|
||||
|
||||
state->payload_algidR = PI_BYTE[0];
|
||||
state->payload_keyidR = PI_BYTE[2];
|
||||
state->payload_miR = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
||||
if (state->payload_algidR < 0x26)
|
||||
{
|
||||
fprintf (stderr, "%s ", KYEL);
|
||||
fprintf (stderr, "\n Slot 2");
|
||||
fprintf (stderr, " DMR PI H- ALG ID: %02X; KEY ID: %02X; MI(32): %08X", state->payload_algidR, state->payload_keyidR, state->payload_miR);
|
||||
|
||||
//check for any values that aren't 0x2X but just 0x0X
|
||||
//going to be very generic here to avoid any particular vendors using 0x2X and not 0x0X
|
||||
if (state->payload_algidR & 0x20)
|
||||
fprintf (stderr, " DMRA");
|
||||
else fprintf (stderr, " DMRA Compatible");
|
||||
|
||||
if ((state->payload_algidR & 0x07) == 0x01)
|
||||
{
|
||||
fprintf (stderr, " RC4;");
|
||||
state->payload_algidR = 0x21;
|
||||
}
|
||||
|
||||
else if ((state->payload_algidR & 0x07) == 0x02)
|
||||
{
|
||||
fprintf (stderr, " DES;");
|
||||
state->payload_algidR = 0x21;
|
||||
}
|
||||
|
||||
else if ((state->payload_algidR & 0x07) == 0x04)
|
||||
{
|
||||
fprintf (stderr, " AES-128;");
|
||||
state->payload_algidR = 0x24;
|
||||
}
|
||||
|
||||
else if ((state->payload_algidR & 0x07) == 0x05)
|
||||
{
|
||||
fprintf (stderr, " AES-256;");
|
||||
state->payload_algidR = 0x25;
|
||||
}
|
||||
|
||||
|
||||
fprintf (stderr, "%s ", KNRM);
|
||||
|
||||
//expand the 32-bit MI to a 64-bit DES IV
|
||||
if (state->payload_algidR == 0x22)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR64 (state);
|
||||
}
|
||||
|
||||
//expand the 32-bit MI to a 128-bit AES IV
|
||||
if (state->payload_algidR == 0x24 || state->payload_algidR == 0x25)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
LFSR128d (state);
|
||||
}
|
||||
}
|
||||
|
||||
if (state->payload_algidR >= 0x26)
|
||||
{
|
||||
state->payload_algidR = 0;
|
||||
state->payload_keyidR = 0;
|
||||
state->payload_miR = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} //end DMRA
|
||||
|
||||
}
|
||||
}
|
||||
@@ -161,12 +247,15 @@ void LFSR(dsd_state * state)
|
||||
lfsr = (lfsr << 1) | (bit);
|
||||
}
|
||||
|
||||
lfsr &= 0xFFFFFFFF;
|
||||
|
||||
if (state->currentslot == 0)
|
||||
{
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " Slot 1");
|
||||
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algid, state->payload_keyid);
|
||||
fprintf(stderr, " MI(32): 0x%08X", lfsr);
|
||||
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algid, state->payload_keyid);
|
||||
fprintf (stderr, " MI(32): %08X;", lfsr);
|
||||
fprintf (stderr, " RC4;");
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
state->payload_mi = lfsr;
|
||||
}
|
||||
@@ -176,8 +265,9 @@ void LFSR(dsd_state * state)
|
||||
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " Slot 2");
|
||||
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algidR, state->payload_keyidR);
|
||||
fprintf(stderr, " MI(32): 0x%08X", lfsr);
|
||||
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algidR, state->payload_keyidR);
|
||||
fprintf(stderr, " MI(32): %08X;", lfsr);
|
||||
fprintf (stderr, " RC4;");
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
state->payload_miR = lfsr;
|
||||
}
|
||||
@@ -207,8 +297,9 @@ void LFSR64(dsd_state * state)
|
||||
{
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " Slot 1");
|
||||
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algid, state->payload_keyid);
|
||||
fprintf (stderr, " MI(64): 0x%016llX", lfsr);
|
||||
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algid, state->payload_keyid);
|
||||
fprintf (stderr, " MI(64): %016llX;", lfsr);
|
||||
fprintf (stderr, " DES;");
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
state->payload_mi = lfsr & 0xFFFFFFFF; //truncate for next repitition and le verification
|
||||
state->payload_miP = lfsr;
|
||||
@@ -219,8 +310,9 @@ void LFSR64(dsd_state * state)
|
||||
{
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " Slot 2");
|
||||
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algidR, state->payload_keyidR);
|
||||
fprintf (stderr, " MI(64): 0x%016llX", lfsr);
|
||||
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algidR, state->payload_keyidR);
|
||||
fprintf (stderr, " MI(64): %016llX;", lfsr);
|
||||
fprintf (stderr, " DES;");
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
state->payload_miR = lfsr & 0xFFFFFFFF; //truncate for next repitition and le verification
|
||||
state->payload_miN = lfsr;
|
||||
@@ -284,11 +376,15 @@ void LFSR128d(dsd_state * state)
|
||||
{
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " Slot 1");
|
||||
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X MI(128): ", state->payload_algid, state->payload_keyid);
|
||||
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X; MI(128): ", state->payload_algid, state->payload_keyid);
|
||||
for (x = 0; x < 16; x++)
|
||||
fprintf (stderr, "%02X", state->aes_iv[x]);
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
// fprintf (stderr, "\n");
|
||||
fprintf (stderr, ";");
|
||||
|
||||
if (state->payload_algid == 0x24)
|
||||
fprintf (stderr, " AES-128;");
|
||||
else fprintf (stderr, " AES-256;");
|
||||
|
||||
state->payload_mi = next_mi;
|
||||
state->DMRvcL = 0;
|
||||
@@ -299,15 +395,30 @@ void LFSR128d(dsd_state * state)
|
||||
{
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " Slot 2");
|
||||
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X MI(128): ", state->payload_algidR, state->payload_keyidR);
|
||||
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X; MI(128): ", state->payload_algidR, state->payload_keyidR);
|
||||
for (x = 0; x < 16; x++)
|
||||
fprintf (stderr, "%02X", state->aes_ivR[x]);
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
// fprintf (stderr, "\n");
|
||||
fprintf (stderr, ";");
|
||||
|
||||
if (state->payload_algidR == 0x24)
|
||||
fprintf (stderr, " AES-128;");
|
||||
else fprintf (stderr, " AES-256;");
|
||||
|
||||
state->payload_miR = next_mi;
|
||||
state->DMRvcR = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void hytera_enhanced_enc_setup(dsd_opts * opts, dsd_state * state, unsigned long long int key_value, unsigned long long int mi_value)
|
||||
{
|
||||
|
||||
UNUSED(opts);
|
||||
UNUSED(state);
|
||||
UNUSED(key_value);
|
||||
UNUSED(mi_value);
|
||||
|
||||
|
||||
}
|
||||
@@ -1072,7 +1072,7 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
|
||||
encL = 0;
|
||||
}
|
||||
}
|
||||
else if (state->payload_algid == 0x21 || state->payload_algid == 0x22)
|
||||
else if (state->payload_algid == 0x02 || state->payload_algid == 0x21 || state->payload_algid == 0x22)
|
||||
{
|
||||
if (state->R != 0)
|
||||
{
|
||||
@@ -1098,7 +1098,7 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
|
||||
encR = 0;
|
||||
}
|
||||
}
|
||||
else if (state->payload_algidR == 0x21 || state->payload_algidR == 0x22)
|
||||
else if (state->payload_algid == 0x02 ||state->payload_algidR == 0x21 || state->payload_algidR == 0x22)
|
||||
{
|
||||
if (state->RR != 0)
|
||||
{
|
||||
|
||||
@@ -3446,7 +3446,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
if (state->payload_algid == 0x02)
|
||||
{
|
||||
attron(COLOR_PAIR(1));
|
||||
printw("Hytera Full Encrypt");
|
||||
printw("Hytera Enhanced");
|
||||
// if (state->R != 0)
|
||||
// printw(" Key: %010X", state->R);
|
||||
attron(COLOR_PAIR(3));
|
||||
}
|
||||
|
||||
@@ -3653,7 +3655,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
if (state->payload_algidR == 0x02)
|
||||
{
|
||||
attron(COLOR_PAIR(1));
|
||||
printw("Hytera Full Encrypt");
|
||||
printw("Hytera Enhanced");
|
||||
// if (state->RR != 0)
|
||||
// printw(" Key: %010X", state->RR);
|
||||
attron(COLOR_PAIR(3));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user