What changed, and why it matters
This commit is a small code cleanup: it moves the logic for entering a string on the BitBox02 device from a shared helper function directly into the device's user-interface layer, and removes the now-unused helper. There is no visible security change in behavior.
No security action needed. Review as ordinary refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch inlines trinary_input_string::enter() into BitBox02Ui::enter_string(). The same mapping from CanCancel::Yes/No to true/false, the same call to bitbox02::ui::trinary_input_string, and the same conversion of any error into Error::Cancelled are preserved. The only differences are removal of an intermediate Rust wrapper and relocation of the doc comment to the trait method. No functional or security-relevant change is introduced.
Changed components
src/rust/bitbox02-rust/src/hal/bitbox02/ui.rssrc/rust/bitbox02-rust/src/hal/ui.rssrc/rust/bitbox02-rust/src/workflow/trinary_input_string.rsInspect captured patch +10 / −21
diff --git a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
index 128a80f..18eb549 100644
--- a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
@@ -55,7 +55,13 @@ impl Ui for BitBox02Ui {
can_cancel: trinary_input_string::CanCancel,
preset: &str,
) -> Result<zeroize::Zeroizing<String>, trinary_input_string::Error> {
- trinary_input_string::enter(params, can_cancel, preset).await
+ let can_cancel = match can_cancel {
+ trinary_input_string::CanCancel::Yes => true,
+ trinary_input_string::CanCancel::No => false,
+ };
+ bitbox02::ui::trinary_input_string(params, can_cancel, preset)
+ .await
+ .or(Err(trinary_input_string::Error::Cancelled))
}
#[inline(always)]
diff --git a/src/rust/bitbox02-rust/src/hal/ui.rs b/src/rust/bitbox02-rust/src/hal/ui.rs
index 1c74a1e..ea0f7d3 100644
--- a/src/rust/bitbox02-rust/src/hal/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/ui.rs
@@ -26,6 +26,9 @@ pub trait Ui {
async fn status(&mut self, title: &str, status_success: bool);
+ /// If `can_cancel` is `Yes`, the workflow can be cancelled.
+ /// If it is `No`, the result is always `Ok(())`.
+ /// If `preset` is not empty, it must be part of `params.wordlist` and will be pre-entered.
async fn enter_string(
&mut self,
params: &trinary_input_string::Params<'_>,
diff --git a/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs b/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs
index 80b1331..3643d18 100644
--- a/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs
+++ b/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs
@@ -3,28 +3,8 @@
pub use super::cancel::Error;
pub use bitbox02::ui::{TrinaryInputStringParams as Params, trinary_input_string};
-use alloc::string::String;
-
#[derive(Copy, Clone)]
pub enum CanCancel {
No,
Yes,
}
-
-/// If `can_cancel` is `Yes`, the workflow can be cancelled.
-/// If it is no, the result is always `Ok(())`.
-/// If `preset` is not empty, it must be part of `params.wordlist` and will be pre-entered.
-/// ```
-pub async fn enter(
- params: &Params<'_>,
- can_cancel: CanCancel,
- preset: &str,
-) -> Result<zeroize::Zeroizing<String>, Error> {
- let can_cancel = match can_cancel {
- CanCancel::Yes => true,
- CanCancel::No => false,
- };
- trinary_input_string(params, can_cancel, preset)
- .await
- .or(Err(Error::Cancelled))
-}
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.