Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rc2-dvm/PeerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ private static void Peer_PeerConnected(object sender, PeerConnectedEvent e)

protected override void KeyResponse(object sender, KeyResponseEvent e)
{
// Stub
// Distribute keys to virtual channels
base.KeyResponse(sender, e);
}

/// <summary>
Expand Down
17 changes: 17 additions & 0 deletions rc2-dvm/VirtualChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ public void Start()
{
// Start radio
dvmRadio.Start();

// Load encryption key for home channel if needed
if (CurrentTalkgroup.KeyId != 0 && !loadedKeys.ContainsKey(CurrentTalkgroup.KeyId))
{
KeyItem key = keyContainer.GetKeyById(CurrentTalkgroup.KeyId);
if (key != null)
loadedKeys[key.KeyId] = key;
else
RC2DVM.fneSystem.peer.SendMasterKeyRequest(CurrentTalkgroup.AlgId, CurrentTalkgroup.KeyId);
}
}

/// <summary>
Expand Down Expand Up @@ -751,6 +761,13 @@ public bool StartTransmit()
// Setup Crypto
if (txTalkgroup.KeyId != 0 && (Secure || txTalkgroup.Strapped))
{
// Ensure key is loaded
if (!loadedKeys.ContainsKey(txTalkgroup.KeyId))
{
Log.Logger.Error("({0:l}) KEYFAIL: Key ID 0x{KeyId:X4} not loaded, cannot TX encrypted", Config.Name, txTalkgroup.KeyId);
RC2DVM.fneSystem.RemoveActiveTalkgroup(txTalkgroup.DestinationId, txTalkgroup.Timeslot);
return false;
}
crypto.SetKey(txTalkgroup.KeyId, txTalkgroup.AlgId, loadedKeys[txTalkgroup.KeyId].GetKey());
Log.Logger.Information("({0:l}) Start ENC TX on TG {1} ({2})", Config.Name, txTalkgroup.Name, txTalkgroup.DestinationId);
}
Expand Down
Loading