mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-17 09:01:30 +10:00
Hold cryptLock around RNG use in admin and key verification (#11096)
setPassKey drew the session passkey outside cryptLock, unlike the signing and key verification paths. Also replaces random() for the key verification nonce with the hardware RNG.
This commit is contained in:
@@ -151,7 +151,14 @@ bool KeyVerificationModule::sendInitialRequest(NodeNum remoteNode)
|
||||
return false;
|
||||
}
|
||||
updateState(true);
|
||||
currentNonce = random();
|
||||
// The nonce binds the handshake, so draw it from the hardware RNG (falling back to the CSPRNG)
|
||||
// under cryptLock, as allocReply does for the security number. random() is both predictable and
|
||||
// only 32 bits wide, leaving half of this nonce zero.
|
||||
{
|
||||
concurrency::LockGuard g(cryptLock);
|
||||
if (!HardwareRNG::fill((uint8_t *)¤tNonce, sizeof(currentNonce)))
|
||||
CryptRNG.rand((uint8_t *)¤tNonce, sizeof(currentNonce));
|
||||
}
|
||||
currentNonceTimestamp = getTime();
|
||||
currentRemoteNode = remoteNode;
|
||||
meshtastic_KeyVerification KeyVerification = meshtastic_KeyVerification_init_zero;
|
||||
|
||||
Reference in New Issue
Block a user