-
Notifications
You must be signed in to change notification settings - Fork 112
keystore: fewer securechip calls when checking password #1619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
8e21085
to
e741db0
Compare
`show_and_confirm_mnemonic(hal: ...)` did not use the HAL for all UI: show_mnemonic and confirm_mnemonic directly used the BitBox02 menu workflow without going through HAL. Can't use `hal().ui().menu(...)`, becaus: - these functions bolt a cancel prompt on top - show_mnemonic is not a normal menu where one can pick an entry, it's just a scroll-through for displaying the mnemonic This should make it possible to mock/fake/test the mneomnic workflow functions, and provide different implementations for them in future BitBox hardware.
The default implementation is in terms of other HAL/UI functions. For unit tests (e.g. in show_mnemonic.rs or bip85.rs), it is useful to be able to skip over the implementation details, so the tests don't have to mock selecting the right words in the quiz.
This also allows us to keep track of the number of secure chip operations in all the scenarios.
The sanity check to see if the seed has changed does not need a securechip operation, it can use the retained seed hash instead, same as `unlock_bip39()`. This reduces the number of securechip operations needed to do a password check, which reduces the risk of running into the Optiga throttling security mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK, two nits
if (!_check_retained_seed(seed, seed_len)) { | ||
Abort("Seed has suddenly changed. This should never happen."); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like an extra ;
here
// copy_seed() instead to check the seed, so they end up hacing the same number of | ||
// events.crate::securechip::fake_event_counter_reset(); | ||
for _ in 0..2 { | ||
// Further calls perform a password check.The password check does not do the rentention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling
rentention
The sanity check to see if the seed has changed does not need a securechip operation, it can use the retained seed hash instead, same as
unlock_bip39()
. This reduces the number of securechip operations needed to do a password check, which reduces the risk of running into the Optiga throttling security mechanism.This is based on #1621 so the reduction can be seen in the show_mnemonic unit test too