mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
Use constant-time compare for FPGA key check
The BIP-39 backup-key confirmation flow compared the entered key against the in-memory FPGA key with `==`, which short-circuits on the first mismatching byte and leaks prefix-length information through timing. Switch to `subtle::ConstantTimeEq`. The `subtle` crate is already a direct dependency and used in the same crate's `backups.rs` for the same purpose. Signed-off-by: tunnell <tunnell@users.noreply.github.com> Assisted-by: Claude Code (Opus 4.7)
This commit is contained in:
parent
a642095c55
commit
f22f276ead
1 changed files with 2 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ use core::num::NonZeroUsize;
|
|||
|
||||
use aes::Aes256;
|
||||
use aes::cipher::{BlockDecrypt, BlockEncrypt};
|
||||
use subtle::ConstantTimeEq;
|
||||
use cipher::generic_array::GenericArray;
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
use curve25519_dalek::{EdwardsPoint, edwards::CompressedEdwardsY};
|
||||
|
|
@ -1642,7 +1643,7 @@ impl<'a> RootKeys {
|
|||
{
|
||||
Ok(verify) => {
|
||||
log::debug!("got bip39 verification: {:x?}", verify);
|
||||
if &verify == &pcache.fpga_key {
|
||||
if bool::from(verify.as_slice().ct_eq(&pcache.fpga_key)) {
|
||||
log::debug!("verify succeeded");
|
||||
modals
|
||||
.show_notification(
|
||||
|
|
|
|||
Loading…
Reference in a new issue