mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-20 04:37:26 -05:00
DMR: Correct KS Offset Application on Chained P_Head;
This commit is contained in:
@@ -378,7 +378,7 @@ void dmr_dheader (dsd_opts * opts, dsd_state * state, uint8_t dheader[], uint8_t
|
|||||||
//a second extended header, and the keystream on that starts after the sap/dpf and mfid value
|
//a second extended header, and the keystream on that starts after the sap/dpf and mfid value
|
||||||
//this is the only time starting the keystream at an offset value will be required
|
//this is the only time starting the keystream at an offset value will be required
|
||||||
|
|
||||||
//set ks start value to 3 (testing based on only example I have, need more samples)
|
//set ks start value to 3 (confirmed on several samples of various enc ciphers)
|
||||||
state->data_ks_start[slot] = 3;
|
state->data_ks_start[slot] = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,8 +892,8 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte
|
|||||||
{
|
{
|
||||||
// decrypted_pdu = 0; //hasn't been decrypted yet
|
// decrypted_pdu = 0; //hasn't been decrypted yet
|
||||||
int poc = (int)state->data_block_poc[slot]; //say that three times real fast
|
int poc = (int)state->data_block_poc[slot]; //say that three times real fast
|
||||||
int end = ((blocks+1)*block_len)-4-poc;
|
|
||||||
int start = (int)state->data_ks_start[slot];
|
int start = (int)state->data_ks_start[slot];
|
||||||
|
int end = ((blocks+1)*block_len)-4-poc-start;
|
||||||
//sanity check on end, has to be a positive value
|
//sanity check on end, has to be a positive value
|
||||||
if (end < 0) end = 3096; //its a signed interger, so should reflect negative values here and not rollover
|
if (end < 0) end = 3096; //its a signed interger, so should reflect negative values here and not rollover
|
||||||
int alg = 0;
|
int alg = 0;
|
||||||
@@ -957,8 +957,8 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte
|
|||||||
//will want to rework output_blocks to be a pointer instead of a fixed size (done)
|
//will want to rework output_blocks to be a pointer instead of a fixed size (done)
|
||||||
if (alg == 1 && R != 0)
|
if (alg == 1 && R != 0)
|
||||||
{
|
{
|
||||||
for (i = start; i < end; i++)
|
for (i = 0; i < end; i++)
|
||||||
state->dmr_pdu_sf[slot][i] ^= ob[i%3096];
|
state->dmr_pdu_sf[slot][i+start] ^= ob[i%3096];
|
||||||
}
|
}
|
||||||
//BP key application
|
//BP key application
|
||||||
else if (alg == 0) //&& state->K != 0
|
else if (alg == 0) //&& state->K != 0
|
||||||
@@ -980,7 +980,7 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte
|
|||||||
|
|
||||||
if (bp_key != 0)
|
if (bp_key != 0)
|
||||||
{
|
{
|
||||||
for (i = start; i < end; i++)
|
for (i = start; i < (end-start); i++)
|
||||||
state->dmr_pdu_sf[slot][i] ^= ob[i%2]; //modulus 2 here, just rinse and repeat
|
state->dmr_pdu_sf[slot][i] ^= ob[i%2]; //modulus 2 here, just rinse and repeat
|
||||||
|
|
||||||
decrypted_pdu = 1;
|
decrypted_pdu = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user