mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 02:02:23 +00:00
Don't use channel index for encrypted packet (#5509)
* Don't use channel index for encrypted packet * Remove assert in `getKey`, set invalid key length So encrypting will fail without reboot * Reset channel to 0 when unable to encrypt Such that the NAK doesn't use the failing channel hash
This commit is contained in:
@@ -178,12 +178,11 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
|
||||
{
|
||||
meshtastic_Channel &ch = getByIndex(chIndex);
|
||||
const meshtastic_ChannelSettings &channelSettings = ch.settings;
|
||||
assert(ch.has_settings);
|
||||
|
||||
CryptoKey k;
|
||||
memset(k.bytes, 0, sizeof(k.bytes)); // In case the user provided a short key, we want to pad the rest with zeros
|
||||
|
||||
if (ch.role == meshtastic_Channel_Role_DISABLED) {
|
||||
if (!ch.has_settings || ch.role == meshtastic_Channel_Role_DISABLED) {
|
||||
k.length = -1; // invalid
|
||||
} else {
|
||||
memcpy(k.bytes, channelSettings.psk.bytes, channelSettings.psk.size);
|
||||
|
||||
Reference in New Issue
Block a user