Merge pull request #864 from tunnell/fix/root-keys-fpga-key-ct-eq

Use constant-time compare for FPGA key check
This commit is contained in:
bunnie 2026-05-08 03:22:01 +08:00 committed by GitHub
commit 679b709d2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ use core::num::NonZeroUsize;
use aes::Aes256; use aes::Aes256;
use aes::cipher::{BlockDecrypt, BlockEncrypt}; use aes::cipher::{BlockDecrypt, BlockEncrypt};
use subtle::ConstantTimeEq;
use cipher::generic_array::GenericArray; use cipher::generic_array::GenericArray;
use curve25519_dalek::scalar::Scalar; use curve25519_dalek::scalar::Scalar;
use curve25519_dalek::{EdwardsPoint, edwards::CompressedEdwardsY}; use curve25519_dalek::{EdwardsPoint, edwards::CompressedEdwardsY};
@ -1642,7 +1643,7 @@ impl<'a> RootKeys {
{ {
Ok(verify) => { Ok(verify) => {
log::debug!("got bip39 verification: {:x?}", 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"); log::debug!("verify succeeded");
modals modals
.show_notification( .show_notification(