Skip to content

Commit

Permalink
P25-P2 Encryption Synchronization ReSync (#1792)
Browse files Browse the repository at this point in the history
* resync ess processor on PTT, END_PTT, HANGTIME, or IDLE

* Re-order of AbstractVoiceTimeslot. Voice2 should be processed first, as any accumulated ESS information applies to the following Voice slots

* Update P25 MBE recorders to include synchronized encryption information

---------

Co-authored-by: Sawyer, Caleb (US) - ISR <[email protected]>
  • Loading branch information
crsawyer and Sawyer, Caleb (US) - ISR authored Jan 12, 2024
1 parent d89ba65 commit 3c18bfd
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.decode.p25.phase1.message.P25Message;
import io.github.dsheirer.module.decode.p25.phase1.message.hdu.HDUMessage;
import io.github.dsheirer.module.decode.p25.phase1.message.hdu.HeaderData;
import io.github.dsheirer.identifier.encryption.EncryptionKeyIdentifier;
import io.github.dsheirer.module.decode.p25.phase1.message.lc.LinkControlWord;
import io.github.dsheirer.module.decode.p25.phase1.message.lc.motorola.LCMotorolaPatchGroupVoiceChannelUpdate;
import io.github.dsheirer.module.decode.p25.phase1.message.lc.motorola.LCMotorolaPatchGroupVoiceChannelUser;
Expand Down Expand Up @@ -124,6 +127,10 @@ else if(message instanceof TDUMessage)
{
flush();
}
else if (message instanceof HDUMessage)
{
process((HDUMessage)message);
}
}

private void process(TDULinkControlMessage tdulc)
Expand Down Expand Up @@ -228,4 +235,21 @@ private void process(LDU2Message ldu2Message)
mCallSequence.setEncryptionSyncParameters(parameters);
}
}

private void process(HDUMessage hduMessage)
{
if(mCallSequence == null)
{
mCallSequence = new MBECallSequence(PROTOCOL);
}

HeaderData hd = hduMessage.getHeaderData();

if (hd.isEncryptedAudio())
{
mCallSequence.setEncrypted(true);
Phase2EncryptionSyncParameters esp = new Phase2EncryptionSyncParameters((EncryptionKeyIdentifier)hd.getEncryptionKey(), hd.getMessageIndicator());
mCallSequence.setEncryptionSyncParameters(esp);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.github.dsheirer.audio.codec.mbe.MBECallSequenceRecorder;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.decode.p25.phase2.message.EncryptionSynchronizationSequence;
import io.github.dsheirer.module.decode.p25.phase2.message.P25P2Message;
import io.github.dsheirer.module.decode.p25.phase2.message.mac.MacMessage;
import io.github.dsheirer.module.decode.p25.phase2.message.mac.MacStructure;
Expand Down Expand Up @@ -153,6 +154,10 @@ else if(message instanceof MacMessage)
{
process((MacMessage)message);
}
else if (message instanceof EncryptionSynchronizationSequence)
{
processEss((EncryptionSynchronizationSequence)message);
}
}

/**
Expand Down Expand Up @@ -382,5 +387,18 @@ private void processPTT(MacStructure mac) {
mLog.warn("Expected push-to-talk structure but found: " + mac.getClass());
}
}

private void processEss(EncryptionSynchronizationSequence ess)
{
if(mCallSequence == null)
{
mCallSequence = new MBECallSequence(PROTOCOL);
}
if (ess.isEncrypted())
{
mCallSequence.setEncrypted(true);
mCallSequence.setEncryptionSyncParameters(ess);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,30 @@ public void receive(IMessage message)
mFrequencyBandMap.put(bandIdentifier.getIdentifier(), bandIdentifier);
}

switch(macMessage.getMacPduType())
{
case MAC_1_PTT:
case MAC_2_END_PTT:
case MAC_6_HANGTIME:
case MAC_3_IDLE:
if (timeslot.getTimeslot() == 0)
{
mESSProcessor0.reset();
}
else
{
mESSProcessor1.reset();
}
break;
}

mMessageListener.receive(macMessage);
}
}
else if(timeslot instanceof AbstractVoiceTimeslot)
{
mMessageListener.receive(timeslot);

if(timeslot.getTimeslot() == 0)
{
mESSProcessor0.process((AbstractVoiceTimeslot)timeslot);
Expand Down Expand Up @@ -139,8 +158,6 @@ else if(timeslot instanceof AbstractVoiceTimeslot)
}
}

mMessageListener.receive(timeslot);

}
else
{
Expand Down

0 comments on commit 3c18bfd

Please sign in to comment.