Skip to content

Flag P25 Phase 2 calls as encrypted when the voice channel ESS says so - #1166

Open
jfgreco wants to merge 1 commit into
TrunkRecorder:masterfrom
jfgreco:fix/p25p2-ess-encrypted-flag
Open

jfgreco wants to merge 1 commit into
TrunkRecorder:masterfrom
jfgreco:fix/p25p2-ess-encrypted-flag

Conversation

@jfgreco

@jfgreco jfgreco commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Flag P25 Phase 2 calls as encrypted when the voice channel ESS says so

p25p2_tdma reports the encryption state from each superframe's ESS as an M_P25_JSON_DATA message ({"encrypted": 0|1, "algid": …, "keyid": …}). That message has no "type" field, so p25_recorder_decode::check_message_queue() drops it.

The result: when a talkgroup's grant doesn't set the encrypted service option but the voice is encrypted, the decoder mutes every frame for lack of a key, and the call is uploaded as a silent recording labelled "encrypted": 0. There's nothing in the log to tell that apart from a decoding problem.

Change

In check_message_queue(), handle the ESS message. The first time a call's ESS reports encryption, log the algid/keyid at info and set the call's encrypted flag:

<log header> Voice channel ENCRYPTED (ESS) - algid: 0x<algid> keyid: 0x<keyid>

Setting the flag mid-call only affects the call metadata (encrypted in the call JSON). The start-of-call decision to skip encrypted talkgroups in monitor_systems.cc is unchanged.

Testing

  • Built cleanly on current master.
  • Ran on a Phase 2 TDMA system (about 230 calls): unencrypted calls are unchanged and produce no new log lines.
  • The encrypted path hasn't been exercised yet: no voice-encrypted calls came up during testing.

🤖 Generated with Claude Code

The decoder reports encryption from each superframe's ESS as a JSON
message with no "type" field, which check_message_queue() ignored. A call
whose grant did not set the encrypted service option was therefore marked
unencrypted even though every voice frame was muted for lack of a key,
producing silent recordings labelled encrypted: 0. Log the algid/keyid once
per call and set the call's encrypted flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bslatyer

bslatyer commented Oct 29, 2026 •

Copy link
Copy Markdown

Hey @jfgreco,

I don't maintain this repo, but I maintain a fork, so take this as feedback, not a block.

The parsing change looks fine: it handles a message that's currently dropped, and clear calls are unaffected. One thing I think needs fixing before merge is the description. It says setting the flag mid-call "only affects the call metadata", but on current master the code does more than that.

Once d_call->set_encrypted(true) runs (p25_recorder_decode.cc ~L329 in this PR), the flag is read at conclusion (call_concluder.cc L1082: call_info.encrypted = call->get_encrypted()), and then:

  • call_concluder.cc L1245–1252: when call_info.encrypted is set, it writes the call JSON, calls remove_call_files(call_info) and returns. That's before upload_call_worker is queued (~L1273), so the audio is deleted and plugman_call_end (L992) never runs. No plugin uploads happen.
  • broadcastify_uploader.cc L276 and rdioscanner_uploader.cc L171 also return early when call_info.encrypted is set.

So the whole call is dropped, not just relabeled. That includes any clear transmissions earlier in the same call. If one unit keys up encrypted partway through a call on a normally clear talkgroup, the clear audio from everyone else in that call is discarded too.

Dropping silent ESS-encrypted calls may be the right result, but it should be deliberate and documented. Two options:

  1. Update the description, and ideally the log line, to say the call will be discarded.
  2. Limit the effect, e.g., only set the call-level flag if no clear audio has been recorded yet, so mixed calls keep their clear audio.

As the testing section notes, we haven't exercised the encrypted path yet. It would be good to see at least one real ESS-encrypted call go through before merge, to confirm the log line fires once and the call is handled as expected.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants