Merge pull request #888 from finnmglas/finn/constant-time-pw-verify

use constant-time password verification
This commit is contained in:
bunnie 2026-05-30 01:36:02 +08:00 committed by GitHub
commit b9d4b0578d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -882,28 +882,12 @@ impl<'a> RootKeys {
unsafe {
match pw_type {
PasswordType::Boot => {
if (*pcache_ptr).hashed_boot_pw_valid == 1 {
for (&src, &dst) in digest.iter().zip((*pcache_ptr).hashed_boot_pw.iter()) {
if dst != src {
return false;
}
}
true
} else {
false
}
(*pcache_ptr).hashed_boot_pw_valid == 1
&& bool::from(digest.ct_eq(&(*pcache_ptr).hashed_boot_pw))
}
PasswordType::Update => {
if (*pcache_ptr).hashed_update_pw_valid == 1 {
for (&src, &dst) in digest.iter().zip((*pcache_ptr).hashed_update_pw.iter()) {
if dst != src {
return false;
}
}
true
} else {
false
}
(*pcache_ptr).hashed_update_pw_valid == 1
&& bool::from(digest.ct_eq(&(*pcache_ptr).hashed_update_pw))
}
}
}