From 3718f20e0c6bb89d3fe874afbb53f8399ccdce57 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Mon, 14 Apr 2025 20:03:47 -0400 Subject: [PATCH] ensure the P25 algId and kId are set to sane defaults (unencrypted essentially); update alias or ID immediately; --- dvmconsole/Controls/ChannelBox.xaml.cs | 6 +++++ dvmconsole/FneSystemBase.P25.cs | 2 ++ dvmconsole/MainWindow.DMR.cs | 24 ++++++++++---------- dvmconsole/MainWindow.P25.cs | 31 ++++++++++++++------------ 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/dvmconsole/Controls/ChannelBox.xaml.cs b/dvmconsole/Controls/ChannelBox.xaml.cs index 56bffc7..de53d5d 100644 --- a/dvmconsole/Controls/ChannelBox.xaml.cs +++ b/dvmconsole/Controls/ChannelBox.xaml.cs @@ -20,6 +20,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; + +using fnecore; using fnecore.DMR; using fnecore.P25; @@ -411,6 +413,10 @@ namespace dvmconsole.Controls SystemName = $"System: {systemName}"; LastSrcId = $"Last ID: {LastSrcId}"; + algId = P25Defines.P25_ALGO_UNENCRYPT; + kId = 0; + FneUtils.Memset(mi, 0, P25Defines.P25_MI_LENGTH); + VolumeMeter.ViewModel = new VuMeterViewModel(); VolumeMeter.ViewModel.Level = 0; diff --git a/dvmconsole/FneSystemBase.P25.cs b/dvmconsole/FneSystemBase.P25.cs index e757377..5f932d7 100644 --- a/dvmconsole/FneSystemBase.P25.cs +++ b/dvmconsole/FneSystemBase.P25.cs @@ -260,6 +260,7 @@ namespace dvmconsole /// /// /// + /// private void EncodeLDU2(ref byte[] data, int offset, byte[] imbe, byte frameType, CryptoParams cryptoParams) { if (data == null) @@ -386,6 +387,7 @@ namespace dvmconsole /// /// Input LDU data array /// Output data array + /// public void CreateP25LDU2Message(in byte[] netLDU2, ref byte[] data, CryptoParams cryptoParams = null) { if (cryptoParams == null) diff --git a/dvmconsole/MainWindow.DMR.cs b/dvmconsole/MainWindow.DMR.cs index b278e73..e9c932a 100644 --- a/dvmconsole/MainWindow.DMR.cs +++ b/dvmconsole/MainWindow.DMR.cs @@ -287,21 +287,21 @@ namespace dvmconsole callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString()); callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, false); // TODO: Encrypted state - string alias = string.Empty; - - try - { - alias = AliasTools.GetAliasByRid(system.RidAlias, (int)e.SrcId); - } - catch (Exception) { } + channel.Background = ChannelBox.GREEN_GRADIENT; + } - if (string.IsNullOrEmpty(alias)) - channel.LastSrcId = "Last ID: " + e.SrcId; - else - channel.LastSrcId = "Last: " + alias; + string alias = string.Empty; - channel.Background = ChannelBox.GREEN_GRADIENT; + try + { + alias = AliasTools.GetAliasByRid(system.RidAlias, (int)e.SrcId); } + catch (Exception) { } + + if (string.IsNullOrEmpty(alias)) + channel.LastSrcId = "Last ID: " + e.SrcId; + else + channel.LastSrcId = "Last: " + alias; // if we can, use the PI LC from the PI voice header as to keep all options intact if ((e.FrameType == FrameType.DATA_SYNC) && (e.DataType == DMRDataType.VOICE_PI_HEADER)) diff --git a/dvmconsole/MainWindow.P25.cs b/dvmconsole/MainWindow.P25.cs index 6b0b05e..663b270 100644 --- a/dvmconsole/MainWindow.P25.cs +++ b/dvmconsole/MainWindow.P25.cs @@ -487,22 +487,13 @@ namespace dvmconsole FneUtils.Memset(channel.mi, 0x00, P25Defines.P25_MI_LENGTH); + // make channel enc parameters sane + if (channel.algId == 0 && channel.kId == 0) + channel.algId = P25Defines.P25_ALGO_UNENCRYPT; + callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString()); callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, encrypted); - string alias = string.Empty; - - try - { - alias = AliasTools.GetAliasByRid(system.RidAlias, (int)e.SrcId); - } - catch (Exception) { } - - if (string.IsNullOrEmpty(alias)) - channel.LastSrcId = "Last ID: " + e.SrcId; - else - channel.LastSrcId = "Last: " + alias; - if (channel.algId != P25Defines.P25_ALGO_UNENCRYPT) Log.WriteLine($"({system.Name}) P25D: Traffic *CALL ENC PARMS * PEER {e.PeerId} SRC_ID {e.SrcId} TGID {e.DstId} ALGID {channel.algId} KID {channel.kId} [STREAM ID {e.StreamId}]"); } @@ -525,8 +516,20 @@ namespace dvmconsole else channel.Background = ChannelBox.GREEN_GRADIENT; - byte[] newMI = new byte[P25Defines.P25_MI_LENGTH]; + string alias = string.Empty; + try + { + alias = AliasTools.GetAliasByRid(system.RidAlias, (int)e.SrcId); + } + catch (Exception) { } + + if (string.IsNullOrEmpty(alias)) + channel.LastSrcId = "Last ID: " + e.SrcId; + else + channel.LastSrcId = "Last: " + alias; + + byte[] newMI = new byte[P25Defines.P25_MI_LENGTH]; int count = 0; switch (e.DUID)