Skip to content

Conversation

benma
Copy link
Collaborator

@benma benma commented Oct 2, 2025

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

@benma benma requested a review from NickeZ October 2, 2025 08:01
@benma benma force-pushed the sc-events branch 2 times, most recently from 8e21085 to e741db0 Compare October 2, 2025 08:10
benma added 4 commits October 2, 2025 12:00
`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.
Copy link
Collaborator

@NickeZ NickeZ left a 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.");
}
};
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

rentention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants